![]() |
This section of the portal is for supporting the Disciplined Agile Value Stream Consultant Workshop (DAVSC), currently under development. Discussions on the pages here will take place on the Disciplined Agile LinkedIn group. |
Note: This originated as a blog August 2007
A few years ago somebody came up to me in one of my classes and said, “you’re the CEO of a successful company, co-author of a successful book (Design Patterns Explained: A New Perspective on Object-Oriented Design), … you ought to have something named after yourself.” So I, of course, immediately like this guy and think – hmm, what should that be? I came up with this:
Shalloway’s Law:
“When N things need to change and N>1, Shalloway will find at most N-1 of these things.”
Hey, I didn’t say it was complimentary. It’s a law! I have to follow it. That’s the problem. BTW: They didn’t ask me about gravity either when I was born! I really would like to break that law at times too!
Eventually I came up with Shalloway’s Principle:
“Avoid situations where Shalloway’s Law applies”
Shalloway’s law applied when “N > 1″ and Shalloway has to find all of the things involved. In other words, avoid redundancy (make N=1) or make it so Shalloway doesn’t have to find the things. For example, I may have redundancy in my interfaces. But I also have a cool “to do list generator” (some people call it a compiler) that when I change a method’s interface it tells me what I need to update. Better not to have redundancy at all, but if you do, make sure Shalloway’s law does not apply.
Shalloway’s Corollaries
It later occurred to me that there is a very useful corollary to Shalloway’s law – if shalloway finds two cases, he knows he won’t fine them all. This can also be interpreted that “if Shalloway creates two cases he may need to find later, he knows he won’t find them all.” These corollaries are useful to remind Shalloway (and maybe you) to not create duplicated code.
For an in depth view of this, see Shalloway’s Law and Shalloway’s Principle from Essential Skills for the Agile Developer: A Guide to Better Programming and Design.