Phantom (Menace) Dependencies 5
We’ve been working on new course materials lately. The other day we were discussing the bad dependencies in code that can occur when the Interface Segregation Principle (ISP) is violated.
We started calling these dependencies phantom dependencies. Here’s why…
In the simplest example of an ISP problem, several client components depend on a “server” component, but each uses completely independent facilities provided by that component. There are no direct or indirect connections between clients. So, none of the clients knows anything about the other clients, nor cares to, yet each client has an implicit dependency on the other clients.
Why? Because if a change in one client forces a change in the server component, the other clients are affected. At the very least, a rebuild may be required.
The solution is to hide the server component behind segregated interfaces, one tailored for each client, and have the server component implement those interfaces. Even better, if the features really are independent, then segregate the server component, too!
Anyway, we sometimes use the term back-channel dependency for this situation. However, while thinking about it, I remembered an article that I had read a few days before on the phantom pain phenomenon that amputees sometimes experience, where they feel pain in limbs that are no longer there. The ISP case is analogous; there is no traversable (“real”) connections from one client component to another, yet each “feels” the presence of the others. Hence, the term phantom dependency.
Nice to see someone thinking about those, “Phantom dependencies.” I’ve never seen any solution suggestions: it seems to be an unsolvable problem in OO, or perhaps programming in general.
I suppose it would be heresy to suggest that re-use is itself the problem.
It might be solvable to a run-time software configuration management tool, whereby, given clients A and B of interface C which encapsulates implementation D, B could, at run-time, use a newer implementation than A because that new implementation is available in the run-time configuration repository. Of course, the code would then be duplicated, but it would be anyway with multiple versions of products alive out there.
I wonder if any language has such a property.
Loads of down-sides, of course.
This article is very usefull for me! I can see that you are putting a lots of efforts into your blog. I will keep watching in your blog, thanks.
Of course, the code would then be duplicated, but it would be anyway with multiple versions of products alive out there.
very useful informative paragraph…Thanks
Dünyan?n en büyük online okey oyunu bu sitede sizleri bekliyor. Gerçek ki?ilerle sohbet ederek Okey Oyunu Oyna ve internette online oyun oynaman?n zevkini ç?kar
well. you guys really give us the sample of C++ programing skill. So. why not try this method and do a better code. next time. have another try.