Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet56/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   52   53   54   55   56   57   58   59   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
70 
// report error 
} else { 
GpiStrokePath(_hps, 1L, 0L); 


Why is this so different from the X version? Well, PM doesn't have anoperation 
for drawing rectangles explicitly as X does. Instead, PM has amore general 
interface for specifying vertices of multisegment shapes(called a 
path
) and for 
outlining or filling the area theyenclose. 
PM's implementation of DeviceRect is obviously quitedifferent from X's, but that 
doesn't matter. WindowImp hidesvariations in window system interfaces behind a 
potentially large butstable interface. That lets Window subclass writers focus 
on the windowabstraction and not on window system details. It also lets us 
addsupport for new window systems without disturbing the Window classes. 
Configuring Windows with WindowImps 
A key issue we haven't addressed is how a window gets configured withthe proper 
WindowImp subclass in the first place. Stated another way,when does _imp get 
initialized, and who knows what windowsystem (and consequently which WindowImp 
subclass) is in use? Thewindow will need some kind of WindowImp before it can 
do anythinginteresting. 
There are several possibilities, but we'll focus on one that uses theAbstract 
Factory (99) pattern. We can definean abstract factory class WindowSystemFactory 
that provides aninterface for creating different kinds of window 
system-dependentimplementation objects: 
class WindowSystemFactory { 
public: 
virtual WindowImp* CreateWindowImp() = 0; 
virtual ColorImp* CreateColorImp() = 0; 
virtual FontImp* CreateFontImp() = 0; 
// a "Create..." operation for all window system resources 
}; 
Now we can define a concrete factory for each window system: 
class PMWindowSystemFactory : public WindowSystemFactory { 
virtual WindowImp* CreateWindowImp() 
{ return new PMWindowImp; } 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   52   53   54   55   56   57   58   59   ...   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