Add CRP (Composition over Inheritance) to design principles

main
simonsan 3 weeks ago committed by GitHub
parent 74d82e3772
commit 1030dd2699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -22,6 +22,14 @@
- [Dependency Inversion Principle (DIP)](https://en.wikipedia.org/wiki/Dependency_inversion_principle):
One should "depend upon abstractions, [not] concretions."
## [CRP (Composite Reuse Principle) or Composition over inheritance](https://en.wikipedia.org/wiki/Composition_over_inheritance)
“a the principle that classes should favor polymorphic behavior
and code reuse by their composition (by containing instances of
other classes that implement the desired functionality) over inheritance
from a base or parent class” - Knoernschild, Kirk (2002). Java Design -
Objects, UML, and Process
## [DRY (Dont Repeat Yourself)](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
"Every piece of knowledge must have a single, unambiguous, authoritative
@ -52,7 +60,7 @@ of direct access to some of an object's components. Encapsulation is used to
hide the values or state of a structured data object inside a class, preventing
unauthorized parties' direct access to them.
## [Command-Query-Separation(CQS)](https://en.wikipedia.org/wiki/Command%E2%80%93query_separation)
## [Command-Query-Separation (CQS)](https://en.wikipedia.org/wiki/Command%E2%80%93query_separation)
“Functions should not produce abstract side effects...only commands (procedures)
will be permitted to produce side effects.” - Bertrand Meyer: Object-Oriented

Loading…
Cancel
Save