Member-only story
Must Know Clean Code Principles for Senior Devs
Code Review Smells and Heuristics
Nowadays, one of the most important skills that companies demand from Software Engineers (mainly from Senior level…) is to deliver high quality code reviews on iterative and incremental manner. That means with each PR Review Developers are asked to improve quality of the to-be-merged code again and again. In this post I will try to point out the basic principles that each Developer should have in mind when doing refactoring or review. If you want to see practical implementation of these points on code piece, check my this other blog:
Ultimate Guide to Clean Code with over 30 Java Refactoring Examples
Let us have a look at these points topic by topic:
1.Meaningful Names
Use intention revealing names: the method or variable names should explain itself what its intention is before even looking at code implementation.
Class names should be noun or noun phrase.
Method names should be verb.
Pick one word for each concept: get, retrieve, fetch are interchangeable, choose one and use only it for all same actions.
Use Computer Science terms: AccountAdapter would mean adapter pattern for programmer, if there is not relevant computer science name use problem oriented name.
Use pronounceable names/searchable names: Searching specific phrase in IDE will be easier.
2.Functions
Functions should be small: the bigger function is, the more difficult it is gonna be to debug it.
Blocks and Intends should be tidy: this point is not actual because nowadays IDEs doing this kind of formatting by default.
Do one thing: one function means one task.
One level of abstraction per function: functions should be small enough to be implemented in the scope of one abstraction level.
Reading code from top to bottom: step-down rule should be applied. Nested functions should come after mother function, so as to have a nice book like reading feeling.