Block structure can sometimes be used as an alternative to multiple inheritance. In
Window
WindowWithTitle WindowWithBorde
WindowWithTitleAndBorder
This window hierarchy may be described using nested patterns:
Window:
(# Title: (# ... #);
Border: (# ... #);
...
#);
aWindow: @ Window(# T: @Title; B: @Border #)
The descriptions for title and border are made using nested patterns. For a given window,
like aWindow, a title object and a border object may be instantiated. For example if two
titles are needed, two instances of Title are made.
Do'stlaringiz bilan baham: