SOLID principles is great for writing testing friendly code..!!
Glad you liked it.
I will post the next chapter soon.
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.
Tabs or spaces? :)
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.
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 ;) )
Tabs of course
Does it matter :)
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.
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.
What's a best practice for ensuring that your code is easy to follow? I've seen Gists with so many helper functions and callbacks that it's hard to follow the thread of execution
I'll create a post explaining the best way to do that.
But, functions definitions should be written in top-down schema based on his level of abstraction and importance.
Looking forward to it
Great post: the code is an abstraction for people; we write code for people not for computers..
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!
Glad to hear that.
I always forgot about the "one thing" in every projects thanks for those tips!
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 ?
Excellent article! I read about functional programming not too long ago, and have dedicated my code to try this "do one thing" approach and its made my life so much easier! Good work.
Great post but by readiness you meant readability?
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.