This document discusses principles for writing solid code, including the SOLID principles and Kent Beck's four simple design rules. The SOLID principles are: single responsibility principle, open/closed principle, Liskov substitution principle, interface segregation principle, and dependency inversion principle. Applying these principles helps reduce coupling between classes and modules, increase cohesion and reuse, prevent dependency hell, and make code more maintainable and flexible over time. Kent Beck's design rules are that code should pass all tests, reveal intention, have no duplication, and have the fewest elements. Following these best practices helps write code that is understandable, extensible and resistant to rotting over time.
13. DEPENDENCY MANAGEMENT
• Controlling interdependencies among various software
entities
• As interdependencies increase, Reusability, Flexibility
and Maintainability of your applications decrease
• Unmanaged dependencies lead to “Dependency Hell”
13
23. RIGIDITY
• Difficult to change
• Cascading of Changes in Dependent Modules
• Impact of change cannot be predicted
• Thus, It can’t be estimated
• Time and Cost can’t be quantified
23
26. FRAGILITY
• Break many places when changed
• Errors appear in areas unrelated to changed areas
• Quality is unpredictable
• Development Team Credibility Loss
• Sometimes breakage increases with time
26
29. IMMOBILITY
• Inability to reuse Software Components
• Lack of reusable modules
• Desirable parts of the system dependent on
undesirable parts
• Work and risk of extracting greater than cost of
writing it from scratch
29
33. VISCOSITY OF DESIGN
• Design Preserving methods are harder than Hacks
• Easy to do Wrong thing but harder to do right thing
• As time progresses, it will become increasingly difficult to
continue developing the application
33
34. VISCOSITY OF ENVIRONMENT
• Development Environment is slow and inefficient
• Slower feedback
Ex: Longer compile times, Slower builds, Long running tests
34
43. Why is it important to separate these two
responsibilities into separate classes ?
• Each responsibility is an axis of change
• Changes in one responsibility may affect another
• Coupling among classes leads to Fragile Design
43
56. DESIGN BY CONTRACT
56
• Methods of class define pre-conditions and
post-conditions
• The preconditions must be met for method
to execute
• Upon completion, method guarantees that
the post conditions are met
78. DIP
78
• High Level Modules should not depend on low
level modules, Both should depend on
Abstractions
• Abstractions should not depend on details.
Details should depend on abstractions.
99. WRAPPING UP
99
● SRP - One responsibility per class
● OCP - Extend not modify
● LSP - Derived substitutable for base
● ISP - Split into Focussed interfaces
● DIP - Depend on Abstractions
100. REFERENCES
100
● Design Principles and Patterns (http://
www.objectmentor.com/resources/articles/
Principles_and_Patterns.pdf)
● Design By Contract - Eiffel (https://www.eiffel.com/values/
design-by-contract/)
● Code from the talk - Java: https://github.com/rShetty/
S.O.L.I.D-Java
● Code from the talk - Ruby: https://github.com/rshetty/
S.O.L.I.D