Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet160/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   156   157   158   159   160   161   162   163   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
234 
Let's assume that images are stored in separate files. In this case we can use 
the file name as the reference to the real object. The proxy also stores its 
extent

that is, its width and height. The extent lets the proxy respond to requests for 
its size from the formatter without actually instantiating the image. 
The following class diagram illustrates this example in more detail. 
The document editor accesses embedded images through the interface defined by 
the abstract Graphic class. ImageProxy is a class for images that are created 
on demand. ImageProxy maintains the file name as a reference to the image on disk. 
The file name is passed as an argument to the ImageProxy constructor. 
ImageProxy also stores the bounding box of the image and a reference to the real 
Image instance. This reference won't be valid until the proxy instantiates the 
real image. The Draw operation makes sure the image is instantiated before 
forwarding it the request. GetExtent forwards the request to the image only if 
it's instantiated; otherwise ImageProxy returns the extent it stores. 
Applicability 
Proxy is applicable whenever there is a need for a more versatile or sophisticated 
reference to an object than a simple pointer. Here are several common situations 
in which the Proxy pattern is applicable: 
1.

remote proxy
provides a local representative for an object in a different 
address space. NEXTSTEP [Add94] uses the class NXProxy for this purpose. 
Coplien [Cop92] calls this kind of proxy an "Ambassador." 


Design Patterns: Elements of Reusable Object-Oriented Software 
235 
2.

virtual proxy
creates expensive objects on demand. The ImageProxy 
described in the Motivation is an example of such a proxy. 
3.


Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   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