I ponder upon a pile of codes, and wondered what was going on. Why were so many smart decision makers in the lower-level business objects, and why they were making decisions or reversing decisions just made in higher-level layer?
Ok, they were making the decisions based on a parameter passed from higher-level business layer. This parameter was in such higher-level business layer that it had a huge influence on many lower-level business objects.
It dawned on me that this violated the Single Responsibility Principle (SRP), and overloaded one variable with two or more meanings. It, therefore, forced lower-level business objects to figure out the actual meaning in that particular context using adjustments of all kinds of assumptions and guessing.
I usually think about SRP in the context of classes (or objects), and don’t realized it applies to anywhere in our implementation even to a single variable. So we can use SRP to solve the problem here.
For reference to SRP, as quoted “The single responsibility principle is a computer programming principle that states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility. Robert C. Martin expresses the principle as, “A class should have only one reason to change.”