Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet131/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   127   128   129   130   131   132   133   134   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
184 
It also declares operations that all composite objects share, such as operations 
for accessing and managing its children. 
The subclasses Line, Rectangle, and Text (see preceding class diagram) define 
primitive graphical objects. These classes implement Draw to draw lines, 
rectangles, and text, respectively. Since primitive graphics have no child 
graphics, none of these subclasses implements child-related operations. 
The Picture class defines an aggregate of Graphic objects. Picture implements 
Draw to call Draw on its children, and it implements child-related operations 
accordingly. Because the Picture interface conforms to the Graphic interface, 
Picture objects can compose other Pictures recursively. 
The following diagram shows a typical composite object structure of recursively 
composed Graphic objects: 
Applicability 
Use the Composite pattern when 

you want to represent part-whole hierarchies of objects.

you want clients to be able to ignore the difference between compositions 
of objects and individual objects. Clients will treat all objects in the 
composite structure uniformly.


Design Patterns: Elements of Reusable Object-Oriented Software 
185 
Structure 
A typical Composite object structure might look like this: 
Participants 

Component
(Graphic)
o
declares the interface for objects in the composition. 
o
implements default behavior for the interface common to all classes, 
as appropriate. 
o
declares an interface for accessing and managing its child 
components. 
o
(optional) defines an interface for accessing a component's parent 
in the recursive structure, and implements it if that's appropriate. 

Leaf
(Rectangle, Line, Text, etc.)
o
represents leaf objects in the composition. A leaf has no children. 
o
defines behavior for primitive objects in the composition. 

Composite
(Picture)



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   127   128   129   130   131   132   133   134   ...   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