"Client" concept in OOP Design Patterns? -
i read many topics oop design patterns of gof, not sure "client" concept. it? how can realize in our application. thank!
in gof book, client code or class using classes in pattern.
for example, abstract factory pattern under motivation:

consider user interface toolkit supports multiple look-and-feel standards, such motif , presentation manager. different look-and-feels define different appearances , behaviors user interface "widgets" scroll bars, windows, , buttons. portable across look-and-feel standards, application should not hard-code widgets particular , feel. instantiating look-and-feel-specific classes of widgets throughout application makes hard change , feel later.
we can solve problem defining abstract widgetfactory class declares interface creating each basic kind of widget. there's abstract class each kind of widget, , concrete subclasses implement widgets specific look-and-feel standards. widgetfactory's interface has operation returns new widget object each abstract widget class. clients call these operations obtain widget instances, clients aren't aware of concrete classes they're using. clients stay independent of prevailing , feel.
there concrete subclass of widgetfactory each look-and-feel standard. each subclass implements operations create appropriate widget , feel. example, createscrollbar operation on motifwidgetfactory instantiates , returns motif scroll bar, while corresponding operation on pmwidgetfactory returns scroll bar presentation manager. clients create widgets solely through widgetfactory interface , have no knowledge of classes implement widgets particular , feel. in other words, clients have commit interface defined abstract class, not particular concrete class.
a widgetfactory enforces dependencies between concrete widget classes. motif scroll bar should used motif button , motif text editor, , constraint enforced automatically consequence of using motifwidgetfactory.
Comments
Post a Comment