Back to Main Page | |||||
Favorite Sites |
Computing |
Education |
News |
Jobs |
Israel |
Bussiness |
W3 Resources |
History |
Travel |
Internet |
Russia |
Entertainment |
Books |
Art |
Science |
Languages |
Spanish |
W. Kandinsky, Improvisation VI(African), 1909
Decoupling Abstraction and Implementor also eliminates compile-time dependencies on the implementation. Changing an implementation class doesn't require recompiling the Abstraction class and its clients. This property is essential when you must ensure binary compatibility between different versions of a class library.
Furthermore, this decoupling encourages layering that can lead to a better-structured system. The high-level part of a system only has to know about Abstraction and Implementor.
If Abstraction knows about all ConcreteImplementor classes, then it can instantiate one of them in its constructor; it can decide between them based on parameters passed to its constructor.
Another approach is to choose a default implementation initially and change it later according to usage.
It's also possible to delegate the decision to another object altogether(See Abstract Factory).