Adapter Pattern

The Adapter pattern is used to convert the interface of one class into a more useful interface that a using class expects. We have a bit of a difference between the way the TextBox works and the way our TextModel and Form want to work. Adapter might help us sort that out.

We sort of have Adapter in place now. Note the call to PutText on the TextBox in the code just shown. Thats not a native method of TextBox class but a method of our specialized subclass of TextBox, TestableTextBox. This is called the class adapter approach. We could also build a separate object to handle the situation, containing a TextBox for which it does translation. That would be called object adapter.

Ive been complaining about the relationship between TextModel and the TextBox for a long time now, and maybe this is a good approach.

Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291 © 2008-2017.
If you may any questions please contact us: