Code Smells when
- Rigidity The software is difficult to change. A small change causes cascade of subsequent changes.
- Fragility The software breaks in many places due to a single change.
- Immobility You can't use part of the code in other project because of involved risk and high effort.
- Viscosity of Environment Building, testing and other tasks take a long time. Therefore, these activities are not executed properly by everyone and technical debt is introduced.
- Needless Repetition Code contains lots of code duplication: exact code duplications or design duplicates(doing the same thing in a different way). Making a change to a duplicated of code is more expensive and more error-prone because the change has to be made in several places with the risk that one place is not changed accordingly.
- Opacity The code is hard to understand. Therefore, any change takes additional time to first reengineer the code and is more likely to result in defects due to not understanding the side effects.
Class Design
- Single Responsibility Principles (SRP) A class should have one, and only one, reason to change.
- Open Closed Principle(OCP) You should be able to extend a classes behaviour without modifying it.
- Liskov Substitution Principle(LSP) Derived classes must be substitutable for their base classes.
- Dependency Inversion Principle(DIP) Depends on abstraction, not on concretions.
- Interface Segregation Priciple(ISP) Make find grained interfaces that are client-specific.
- Classes should be small Smaller classes are easier to grasp. Classes should be smaller than about 100 lines of code, Otherwise, it is hard to spot how the class does its job and it probably does more than a single job.
No comments:
Post a Comment