How to Write Clean Code

Hello all my fellow developers out there!

This is a short little presentation on how to write cleaner, better code.

I enjoyed it and thought you would as well.

15 Likes

Awesome, great video, and has been bookmarked for some rewatching when I get back into my coding game again. Thank you!

1 Like

No problem, glad it helped someone too! :slight_smile:

1 Like

good to know i follow most of these practices :smiley:

4 Likes

thank goodness!

1 Like

Yeah I always thought most of this was common sense until I had to review other people’s code.

4 Likes

My best tip for clean coding is to put units in variable names. Don’t just call it “length”, call it “length_mm”. This saves masses of confusion, especially when you need to maintain it in 5 years time.

7 Likes

that’s a good suggestion.

1 Like

Another good one is to use the const keyword often in C/C++.

For example, if you have a function that takes a pointer, it could update what that pointer points to. If you make it a pointer to a const it can’t change anything, and the person calling that function can clearly see that it won’t.

This can also help the compiler optimize your code.

1 Like