11.6. Paradigm Mismatch

 <  Day Day Up  >  

Sometimes the paradigm of the underlying implementation does not match the paradigm of the interface you have created. Usually you can create an adapter that hides this difference. A dictionary holds pairs of keys with associated values. If you add a key that already exists, the value for the previous entry in the dictionary is overwritten silently. In other implementations , the duplication generates an error.

You might have created an interface that works one way. An implementation might work the other way. You can add logic to make that implementation work the other way. For example, if your interface assumed silent overwriting, the logic can check for the existence of the key and delete the current key before adding the new one.

You cannot adapt some paradigm mismatches in this manner. You might not be able to find an implementation that works in the paradigm of the interface you designed. In that case, you will have to rewrite the interface and redo the methods that depend upon it. [*]

[*] Eric M. Burke, a reviewer, noted that if you develop an interface without creating an implementation, you might create an interface that is impossible to implement in reality. Do not cast an interface in stone until you have developed and tested an implementation.

 <  Day Day Up  >  


Prefactoring
Prefactoring: Extreme Abstraction, Extreme Separation, Extreme Readability
ISBN: 0596008740
EAN: 2147483647
Year: 2005
Pages: 175
Authors: Ken Pugh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net