cleanCode
cleanCode
- bloated classes and methods makes code sloppy and difficult to grasp.
- code duplication - each time you have to make a change in a duplicate code, you
have to remember to make the change in every instance.
- code is liability - less code means, less things to manage.
Rule of Three
When you’re doing something for the first time, just get it done.
When you’re doing something similar for the second time, cringe at having to repeat
but do the same thing anyway.
When you’re doing something for the third time, start refactoring.
How to refactor
- The main objective is code should become cleaner.
- New functionality shouldn't be created during refactorying - seperate refactorin
with direct development.
- All existing test sholuld pass.
Bloaters
When the function, class has become so big it is very hard to work with.
Change Preventers
This smell means if you have to change a code in one place, you have to make many
changes in other places too.
Dispensables
Those are codes that are pointless or unneeded.
Couplers
All the smells in this group contribute to excessive coupling between classes or
show what happens if coupling is replaced by excessive delegation.