Don't be afraid to make a name long.
A long descriptive name is better than a short enigmatic name.
A long descriptive name is better than a long descriptive comment. ✔️
Use a naming convention that allows multiple words to be easily read in the function names, and then make use of those multiple words to give the function a name that says what it does.
#CleanCode #Tip1
A long descriptive name is better than a short enigmatic name.
A long descriptive name is better than a long descriptive comment. ✔️
Use a naming convention that allows multiple words to be easily read in the function names, and then make use of those multiple words to give the function a name that says what it does.
#CleanCode #Tip1
Unit Tests ✅
Ten years ago this would have raised a lot of eyebrows ! 👁
The discipline of Test Driven Development has made a profound impact upon our industry and has become one of our most fundamentals disciplines.
Dave Thomas :
Code without tests, is not clean, No matter how elegant it is, no matter how readable and accessible, If it hath not tests, it be unclean.
#CleanCode #Tip2
Ten years ago this would have raised a lot of eyebrows ! 👁
The discipline of Test Driven Development has made a profound impact upon our industry and has become one of our most fundamentals disciplines.
Dave Thomas :
Code without tests, is not clean, No matter how elegant it is, no matter how readable and accessible, If it hath not tests, it be unclean.
#CleanCode #Tip2
Which code is better ?
or this ?
Absolutely the second one is more readable and it takes you less time to understand ! ⏰
#CleanCode #DontUseComments #Tip3
// Check to see if the employee is eligible for full benefits
if((employee.flags & HOURLY_FLAG) && (empoyee.age > 65))
or this ?
if(employee.isEligibleForFullBenefits())
Absolutely the second one is more readable and it takes you less time to understand ! ⏰
#CleanCode #DontUseComments #Tip3
How your classes should be ? 💭
Think of a well-written newspaper article, You read it vertically.
At the top you expect a headline that will tell you what the story is about and allows you to decide whether it is
something you want to read. The first paragraph gives you a synopsis of the whole story.
As you continue down-ward, the details increase until you have all the dates, names, quotes, claims, and other
minutia.
We would like a source file to be like a newspaper article. 📜
The name should be simple but explanatory.
The name, by itself, should be sufficient to tell us whether we are in the right module or not.
The topmost parts of the source file should provide the high-level concepts and algorithms.
Detail should increase as we move downward, until at the end we find the lowest level functions and details in the source file.
A newspaper is composed of many articles; most are very small, Some are a bit larger, Very few contain as much text as a page can hold.
This makes the newspaper usable. If the newspaper were just one long story containing a disorganized agglomeration of facts, dates, and names, then we simply would not read it !
#CleanCode #NewsPaper #Metaphor
Think of a well-written newspaper article, You read it vertically.
At the top you expect a headline that will tell you what the story is about and allows you to decide whether it is
something you want to read. The first paragraph gives you a synopsis of the whole story.
As you continue down-ward, the details increase until you have all the dates, names, quotes, claims, and other
minutia.
We would like a source file to be like a newspaper article. 📜
The name should be simple but explanatory.
The name, by itself, should be sufficient to tell us whether we are in the right module or not.
The topmost parts of the source file should provide the high-level concepts and algorithms.
Detail should increase as we move downward, until at the end we find the lowest level functions and details in the source file.
A newspaper is composed of many articles; most are very small, Some are a bit larger, Very few contain as much text as a page can hold.
This makes the newspaper usable. If the newspaper were just one long story containing a disorganized agglomeration of facts, dates, and names, then we simply would not read it !
#CleanCode #NewsPaper #Metaphor