I've just updated the documentation part about the SOLID Design
Principles.
The former blog article
(almost 4 years old!) sounds like a bit deprecated now...
This is why I would extract here an updated version of this material.
Ensure you checked the
corresponding part of the mORMot documentation, which is the updated
reference, and probably the easiest to read - including links to all the other
documentation.
The acronym SOLID is derived from the following OOP principles (quoted from
the corresponding Wikipedia article):
- Single responsibility principle: the notion that an object should
have only a single responsibility;
- Open/closed principle: the notion that "software entities ...
should be open for extension, but closed for modification";
- Liskov substitution principle: the notion that "objects in a
program should be replaceable with instances of their subtypes without altering
the correctness of that program” - also named as "design by
contract";
- Interface segregation principle: the notion that "many client
specific interfaces are better than one general purpose interface.";
- Dependency inversion principle: the notion that one should "Depend
upon Abstractions. Do not depend upon concretions.". Dependency
injection is one method of following this principle, which is also called
Inversion Of Control (aka IoC).
If you have some programming skills, those principles are general statements
you may already found out by yourself. If you start doing serious
object-oriented coding, those principles are best-practice guidelines you would
gain following.
They certainly help to fight the three main code weaknesses:
- Rigidity: Hard to change something because every change affects
too many other parts of the system;
- Fragility: When you make a change, unexpected parts of the system
break;
- Immobility: Hard to reuse in another application because it cannot
be disentangled from the current application.