Why are Black Boxes so Hard to Reuse? (OOPSLA ’94)
www2.parc.com
www2.parc.com
Black boxes are hard to reuse because the hidden implementation details impact the client e.g. GUIs don't scale to thousands of windows, LRU caching is sometimes not optimal.
The proposed solution is "meta-interfaces" that let the client control how the interface maps to an implementation. For example, a cache could represent pages with objects that participate in swapping policy. The client could subclass the page class to provide a custom policy. It's important to separate the base/meta interfaces.
Some other more exotic forms of meta-interface are mentioned involving reflection and dynamic code generation, but no real details are given. It's also acknowledged that the OO approach often results in fragmentation i.e. too many objects.
My thoughts:
The meta-interface concept is pervasive today, in the form of composable object models and dependency injection. But these models are still hard to design and suffer from the fragmentation problem.
* Few people program in Common Lisp
* AspectJ is an extension to Java * Emphasize protocols, de-emphasize hierarchies
* Support compile time meta-programming
* Support flexible verification (optional type checker /
contracts / predicate dispatch)
The talk also covers the crux of why OO inheritance is the pits - you inherit the broken implementation. Working against protocols, which may seem initially inconvenient, actually allow you to avoid a future tarpit.Actually, when you get down to it, MVC is all about making client specific mappings for the loading of data into views. The talk is not exactly startling seen from a 2011 perspective, but it's nice to see the reasoning behind so many of today's patterns so clearly expounded.
On virtually a daily basis I drop in a new compponent where I don't know the internals. I do it without thinking twice, for the most part. Half the time I don't even look at docs -- just the interface.
Fx's OTOH are a pain to learn and integrate. And once your bought in, you're kind of locked in.
http://en.wikipedia.org/wiki/Naked_objects
[Edit: upon re-reading it again: in P006 he says blackboxes are hard to reuse because they hide performance characteristics? I can think of a better reason, actually]
All this meta-interface stuff seems like it is way more complicated than it needs to be... Please show me what I am missing.
Imagine you have a block box that calculates a interest rate futures convexity adjustment. That is for an OTC forward you have one fair value and for a future you have a different fair value because the future is has margins and the function calculates the difference between the two.
Now you have some useful code that works out margin payments for various trajectories of prices for the future/forward based on some model for price movements and and another model for interest payments/reciepts on the margin calls.
Now you have a simple change where some exchange changes way they do margin calls.
One way to resolve this is that convexity adjustment function takes in a margining function as a parameter. But if it was not known that this was needed from the start maybe another part of the model was parameterized rather than this.
In practice in this case assumptions about the margining are baked into the mathematics of the black box, and handling arbitrary margining systems is not done and you write a whole new function.
definterface Light
turnOn
turnOff
powerRequirement
There is no black box here as there is no implementation. We haven't committed to any specific misconception an implementation might represent and we've left the door open for massive scale.Deleted comment