The Book Every Programmer Should Read
Writing code that any programmer who read can understand is a must-have skill for software developers. The fact is: only 20% of the programmers have the ability.
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” — Martin Fowler
When I started caring about code readability I noticed that my code started to be:
- easier to maintain
- easier to refactor
- reusable
- consistent
The Book
Robert "Uncle Bob" Martin's "Clean Code: A Handbook of Agile Software Craftsmanship" is the clean coder programmer bible. This book talks about code, behaviour, automated tests and so on.
Let's get practical! Writing meaningful names.
One of Clean Code chapters talks about meaningful naming. In this story, you are going to be the code reader. Take a look at this function:
def calc(n1, n2)
return n1 / n2
end
Do you think "calc" is a good name for this function? Uncle Bob would say: no! Why?
- “calc” is an abbreviation : don't!
- Functions do something. It must be named with a verb.
- Even I rename "calc" to "calculate", it still be vague. We need to improve the semantics by giving the function name more meaning.
This function divides two numbers. "divide" is a good name for it.
def divide(n1, n2)
return n1 / n2
end
result = divide(1, 2)
We still have problems with it. "n1" and "n2", the parameters, are not semantic. What if we call them "dividend" and "divisor"? The same thing to the "result" variable. It should be called something like "quotient".
def divide(dividend, divisor)
return dividend / divisor
end
quotient = divide(1, 2)
Much more semantic!
Thank you for reading! Don't forget to follow me on Medium, Instagram and LinkedIn.
Drift Boss is an addictive driving game that challenges players to drift through turns without falling down.
I appreciate the tutorials, it’s an excellent resource. Recently, I’ve been researching numerology, and the materials I found were quite helpful. Currently, I’m juggling both a course project and contemplating ordering an essay on 99papers. Personally, I find multitasking diminishes efficiency and quality, so seeking assistance seems like the most suitable option for me.
Choosing the Programmer’s Book and Essay service was a game-changer for me. Their ability to ‘write my essay for me’ exceeded all expectations. The content was not only impeccably written but also showcased a deep understanding of the subject matter. The service "professional writer https://www.customwritings.com " provided a seamless experience, from prompt communication to on-time delivery. I’m grateful for their expertise and highly recommend them to anyone in need of top-notch writing assistance!