Why you should delete your comments to write better code

preview_player
Показать описание
I think the easiest way to write better code is to remove code comments. It forces you to write clearer and more understandable code, rather that letting the comments explain the code for you.

👨‍👨‍👦‍👦 Social
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Рекомендации по теме
Комментарии
Автор

2:20 I’m one of the “long methods are a smell” folks. I find it much easier to grok a process by being able to read the high level method names, and then can quickly dig into the method(s) that are applicable to whatever I’m trying to fix/extend. IDEs and editors have really great tools for navigating around symbols, so I’ve never found jumping around to be all that difficult. And this eliminates the need for comments to delineate blocks in the method. As a bonus, if there are reuse opportunities, the methods have already been broken out and are basically ready for that reuse to happen.

briandadams
Автор

It's funny how much has changed over time. In the 80's/90s they taught to comment EVERYTHING even when it was obvious and simple. You basically wrote a novel of how the program worked around the code itself.

fictitiousnightmares
Автор

This is 100% my take on comments. Love it

doce
Автор

I very rarely write comments. I'm just developing CRUD applications, not doing rocket science, so the code can almost always be self-explanatory with good naming and structuring.

EdmondDantèsDE
Автор

2:47 I wholeheartedly agree with keeping procedural code in a long method. I absolutely hate jumping around function from function.

captainlennysub
Автор

Variable names, function names, and even enumerated types are, in a way, specialized forms of comments. Sometimes they're better, sometimes not.

I find comments are best when you need to explain *why* the code does something a certain way. I'm not going to name a function ConvertAscii2EbcdicBecauseLibFubarUsesEbcdicForSomeReason, I'm going to name it Ascii2Ebcdic and put the rest in a comment.

The other case is regexes (regexen? regeex? registeel?) because those are unreadable no matter what you do. With a comment the next person knows what it's trying to do, they still have to verify it was written correctly but at least they can skip the detective work.

AlexanderVulpes
Автор

Dude this content is incredible. This is the kind of stuff that has me waiting for the next video 👏

moddell
Автор

Great suggestion! I like the record result idea!

williamliu
Автор

Im terribly guily of leaving comments... I agree but there are always these crazy edge cases you have to deal with & days, week, months after, you just wonder why was this code here...

Kayotesden
Автор

2:27 you fall into the locality of behavior camp like htmx grug brain and Primeagean. I like that way too

Jabberwockybird
Автор

Please do a lot more videos the entity framework is by far my favorite

Funkfreed
Автор

lmao as a dev, please don't delete your comments. Yes I can read the code, but also a simple "I did this because x and y" goes a long way.

brucecrusty
Автор

Nice vids but If u write smaller methods then unit tests and self documenting code is much better than comments that don’t get updated.

whosgotrythm
Автор

imo BS; comments are hella useful, especially when whole function is quite large or in fact just complicated, then even prettiest code won't explain shit what's happening lmao

lilsos