I'm studying the SOLID principles and I'm having some troubles dealing with the Specification Pattern and the open/closed principle.
The fact is that the Specification pattern introduced by Eric Evans and Martin Fowlers creates some abstraction and a really open way to manage business rules.
But I was wondering if it was really based on Open/closed principle.
The fact is that, when we need a new rule, we can extend it from our parent specification class. So, it's open in extension, that is a good point from a SOLID point of view.
On the other hand, specification pattern is based on rules combination, so we have to modify the rules code, or at least, the parent rule code. This way, we're open in modification in a class that, in my mind, should not be modified.
I'm probably missunderstanding something in this process.
Can anybody explain me:
- How does (if it's the case) the specification pattern respect the OC principle ?
- Does it exist an alternative to this pattern ?