Component Engineering - Adapter Proxy
Component Engineering - Adapter Proxy
Santanu Sinha
We have a custom container interface present in the library The container provides methods to add/remove objects from the beginning and end It also provides lots of other functionality such as efficient searching, insertion in the middle etc. We want customer to have a queue
Santanu Sinha
We have a custom container interface present in the library The interface has been sub-classed into different implementations One of these implementations are selected by the library depending on some parameters We want customer to have a queue
Santanu Sinha
Adapter / Wrapper
Santanu Sinha
Object Adapter
Santanu Sinha
Adapter: Consequences
Class Adapter:
Commits to adapt a particular class Can override functionality of adaptee No pointer redirection required Cannot adapt subclasses of a class Can adapt many classes at once Cannot override adaptee functionality Pointer dereferencing required
Santanu Sinha
Object Adapter
Example
Santanu Sinha
Generic Adapters
Santanu Sinha
Santanu Sinha
Santanu Sinha
Problem 3: Logging
Remote logging is required For production use, logging is required only in error case Log object initialization will take some time We want to defer creation of this object as long as possible
Santanu Sinha
Proxy / Surrogate
Santanu Sinha
Proxy: Consequences
A proxy for remote object can be efficient On demand object creation may be possible Can be used to perform house-keeping tasks
Santanu Sinha
Example
Santanu Sinha
Create pointer type with overloaded operator -> and operator * Proxy can be improvised to point to any class in an inheritance hierarchy
Santanu Sinha
Conclusion
Questions?
Santanu Sinha