Coding Best Practices, Chapter One: Functions.

Levi Velázquez on May 22, 2019

My purpose IS NOT to say what is the best way to write code, some programmers have their ways and they are just fine. I just want to share with oth... [Read Full]
markdown guide
 

If there is one rule that gets broken more than most it has to be the 'do one thing', been there and guilty of that. Then when you suffer at the hands of you're own code, you suddenly realize why it's a thing.

 

SOLID principles is great for writing testing friendly code..!!
Great post.
following_for_more_post()

 

Glad you liked it.

I will post the next chapter soon.

 

Good job! For me, the code legibility is the principal skill to great developers.

 

Glad you liked it. Yep, that is the most valuable skill for sure.

 
 

Sometimes depends on the language being used, sometimes depends on the person. I can't say that there is a Real/Definitive answer but my preference is spaces.

I always map my tab key to spaces. Why? I use python mostly and tabs may vary depending on the system, this could lead to an enormous amount of issues, a space is just one column. Of course, you need to learn how to navigate through the code independently of the selected method to avoid using right/left arrows.

If you use Javascript, this guide made by Airbnb suggest two spaces instead of hard tabs. I consider this a good style guide for ES6 (javascript).

Python == Spaces and so on.

If you share code with other developers, you must agree on a standard no matter your choice.

If you want to use tabs and you are comfortable with it, it's just ok. But, I'm an astronaut(space person ;) )

 
 
 

Very good advices, I have seen implementing this guideline helped me solve like most of my mutations in my code, so really useful and worth the time spent!

 
 

I always forgot about the "one thing" in every projects thanks for those tips!

 

Do you separate scope of function definition somehow, e.g. defining sub-functions in the main function closure or moving them into separate module?

Pythons catch is except btw :)

 

this depends on what framework, structure, etc, you are using. If I need to implement a concept with multiples features and it is quite complex, I create a module for him.

 

Being verbose is hard when you know that doing so is not the fastest way to code. Knowing in advance that you'll take twice as long is a really good way to never get started at all.

 

Hi, thx for your comment.

I disagree with you, this only should applies in programming contests where you have 3 hours to solve puzzles.

In my case and experience, beign verbose never going to take twice the time. In fact, you’ll need to review the code again, so, do you prefer spending time trying to understand your code because you used variables as: i, j, k, a, ? And if you are working with a team, imagine how painful could be. Of course this is not just easy, it requires practice but this is part of having good practices. Who doesn’t want to improve ?

code of conduct - report abuse