Design Patterns : Elements of Reusable Object-Oriented Software


Abstracting Object Creation



Download 4,06 Mb.
Pdf ko'rish
bet49/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   45   46   47   48   49   50   51   52   ...   288
Bog'liq
GOF Design Patterns

Abstracting Object Creation 
Everything we see and interact with in Lexi's user interface is aglyph composed 
in other, invisible glyphs like Row and Column. Theinvisible glyphs compose visible 
ones like Button and Character and laythem out properly. Style guides have much 
to say about the look andfeel of so-called "widgets," another term for visible 
glyphs likebuttons, scroll bars, and menus that act as controlling elements in 
auser interface. Widgets might use simpler glyphs such as characters,circles, 
rectangles, and polygons to present data. 
We'll assume we have two sets of widget glyph classes with which toimplement 
multiple look-and-feel standards: 
1.
A set of abstract Glyph subclasses for each category of widgetglyph. For 
example, an abstract class ScrollBar will augment the basicglyph interface 


Design Patterns: Elements of Reusable Object-Oriented Software 
61 
to add general scrolling operations; Button is anabstract class that adds 
button-oriented operations; and so on. 
2.
A set of concrete subclasses for each abstract subclass thatimplement 
different look-and-feel standards. For example, ScrollBarmight have 
MotifScrollBar and PMScrollBar subclasses that implementMotif and 
Presentation Manager-style scroll bars, respectively. 
Lexi must distinguish between widget glyphs for different look-and-feelstyles. 
For example, when Lexi needs to put a button in its interface,it must instantiate 
a Glyph subclass for the right style of button(MotifButton, PMButton, MacButton, 
etc.). 
It's clear that Lexi's implementation can't do this directly, say,using a 
constructor call in C++. That would hard-code the button of aparticular style, 
making it impossible to select the style atrun-time. We'd also have to track down 
and change every suchconstructor call to port Lexi to another platform. And buttons 
areonly one of a variety of widgets in Lexi's user interface.Littering our code 
with constructor calls to specific look-and-feelclasses yields a maintenance 
nightmare

miss just one, and you couldend up with a Motif menu in the middle of 
your Mac application. 
Lexi needs a way to determine the look-and-feel standard that's beingtargeted 
in order to create the appropriate widgets. Not only must weavoid making explicit 
constructor calls; we must also be able toreplace an entire widget set easily. 
We can achieve both by 
abstracting the process of object creation
. An example 
willillustrate what we mean. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   45   46   47   48   49   50   51   52   ...   288




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish