5 RULES to Write Better Code

preview_player
Показать описание
In this video I go through 5 different rules I use to write code that is easy to understand and maintain. These all come from my favorite book: Clean Code by Robert C. Martin.

📄 *** DOWNLOAD MY FREE STUDY MANUAL ***
Рекомендации по теме
Комментарии
Автор

This is one of the longest and most information dense videos I've put out in quite a while so I'd love to hear your thoughts on it. Leave me a comment and let me know if the video and the examples helped you out.

AndySterkowitz
Автор

Take a look at some of Google's open source code. Some of their variables are complete sentences.

MrPDTaylor
Автор

I agree with everything except the commenting thing. Everyone who tells me that their code is "self-describing, " I usually cannot read that code. It is usually terrible. People who comment a lot, I have noticed also follow the other best practices because, they care A LOT about readability

iandrsaurri
Автор

i actually went back through some of my code and was like yep that function has a noun and not a verb as a name. lol very helpful because as a begin you don't know the correct way to do all the things until someone point it out. it like speaking or writing another language there are just some formal things that need to happen. thanks for the video

mexiangel
Автор

twentyFour as a boolean made perfect sense to me instantly, I have no idea what military time is...

kabiskac
Автор

Hey Andy, really great content! Although I‘m no beginner by any means. Watching you explain principles and you being so relatable in your videos made my day! ❤️ Maybe a video on Unit testing and common patterns would help junior devs to be more keen on this topic

Goaty
Автор

I did enjoy this set of 5 rules because they solidify how I write except w/t comments. I now understand your point of how comments can get in the way or be harmful and if the previous 4 rules are followed, then #5 is easy to understand. I learned a lot with this video and will start now getting them into my rhythm of writing.

thorntontarr
Автор

These rules are classic. With the right procedure names and variable names, your code becomes self documenting.

davidgagnon
Автор

The best thing about variables is that size of the name doesn't matter at runtime. Before you compile the code, sure, the longer name takes up space, but once compiled, the size of your variable name is irrelevant to the code.

For comments, I typically use them to break up the code visually, more of a roadmap than necessary information. For instance, I might group all of my Public Methods under one comment and Private Methods under another.

Totally spot on about descriptive functions and variables though. I remember working on a project getting my degree in graphic art/game art, and trying to help fix a program that wasn't working. Spent a half day trying to figure out what the variable "s" was used for; turned out, nothing at all relevant to anything going on. I think it was an unimplemented speed parameter, but as the guy coming in after someone else coded, I had to work that out for myself.

nyghtwyng
Автор

Some of these suggestions I've kind of picked up during my studies or intuited, but I definitely appreciated the confirmation that my thought process was on the right track! I'll renew my focus on keeping my code more readable.

joshb.
Автор

Thank you for keeping this simple and easy to understand.

ShiloRich
Автор

I agree! Name your variables properly will help. It has caused so many headaches for other people reading my code. Wished if I had this advice a few months ago😥. Thanks, Andy - keep at it this was helpful👨‍💻

Art-yk
Автор

Okay so I understand both sides of the comments vs. no comments argument. I would like to see a video of appropriate times for a comment. I also think its a ridiculous premise to fire an individual for not commenting. If you have a complicated app that you feel the dev should add comments to then instruct them to do just that. Andy I see and agree with its a more practical approach to rename variables and functions that essential tell you what they do for the app. Thank you for your efforts and instruction. I myself have just decided to reorganize my life to attempt to be a programmer after a 9 year set back.

benjaminnelson
Автор

isMilitaryTime does make even less sense to at least a non US audience, as normal time is 24h and 12h is just US time. The fact that twentyFour is a boolean made is meaning clear, though not sufficiently explicit. Apart from the example, the point is very valid.

martijnb
Автор

10:38 "mon is that for 'hey mon'?" 😂

yandhi
Автор

Clean code is a good book to read for more like this.

anlofdeath
Автор

Yes sir, going into my Junior year and I read the book Clean Code this summer. Definitely aligns well with a lot if not all of the points.

huhtj
Автор

Yes, absolutely, I am the type of person who benefits from explicit examples, so I found this format to be extremely helpful. Even though I haven't learned any JS (not yet, but soon), the code was easy to follow as a student of Python and C. Thanks for the tips!

acopperlily
Автор

This is really informative and helpful. Appreciate the examples!

daniellelindblom
Автор

Fantastic video! Thank you very much for putting in the time to make these.

aaRept