Title: ??????? (Wrapper)
1???????(Wrapper)
??????? ???????? ??? C
- http//www.devbg.org/patternscourse/
?????? ????????
stephan.zaharievatgmail.com
NearSoft Europe www.nearsoft.ch
2?????????? ??????
- ?????? ???????? ?? ????? C
- ???????? ?? ???
- ?????? ???????? ?? UML (???? ????????)
3??????????
- ???????? ?? ???????
- ???????
- ????????? ?? ???????
- ???????? ??????????
- ????????????
- ??????? ??? ????????????
- ?? ? ?????? ???????
- ??????????
4???????? ?? ???????
- ????????? ???????? ?? ?????????????? ??? ?????
????? - ???????????????? ?? ?????? ???? ??? ??????, ??
??? ?? ??????? ?? ???? - ???????? ???????????? ??????????? ?? ???????????
?? ?????????? ??? ??????????? ?? ???????????????? - ?????? ? ??? ???? ????????? (Decorator)
5???????
- ???? ?? ?? ??????? ?? ???????????
????????????????? ??????? - ????????? ?????? ?? ??? ????????, ????? ???????
????? - ?????????, ????? ??????? ????? ?????? ?? ???
?????????? ?? ???? ???????? ? ????? - ??? ?????? ?????? ????? ?????????, ?????? ??
????? ?????????? ?? ?????????? ? ????
6??? ?? ??????????? ?????????
- ????????? ???????? ???????
?? ??????? ????
7????????? ?? ???????
8???? ?? ?????????
- Component
- ????? ????, ??????????? ??? ?????????
- BorderWrapper
- ???????, ????? ????????? ?????
- ScrollWrapper
- ???????, ????? ????????? ??????????
- TextView
- ????????? ??????? ????????
9???????? ??????????
abstract class Component public abstract
void Draw() class TextView Component
public override void Draw()
Console.WriteLine("TextView.Draw()")
(???????? ??????????)
10???????? ??????????
class ScrollDecorator Component private
Component decoratedComponent public
ScrollDecorator(Component component)
decoratedComponent component
public override void Draw()
Console.WriteLine("ScrollDecorator.Draw()")
decoratedComponent.Draw()
(???????? ??????????)
11???????? ??????????
class BorderDecorator Component private
Component decoratedComponent public
BorderDecorator(Component component)
decoratedComponent component
public override void Draw()
Console.WriteLine("BorderDecorator.Draw()")
decoratedComponent.Draw()
(???????? ??????????)
12???????? ??????????
static void Main(string args) TextView
text new TextView() ScrollDecorator scroll
new ScrollDecorator(text)
BorderDecorator border new
BorderDecorator(scroll) Component component
border component.Draw() ???????? Bord
erDecorator.Draw() ScrollDecorator.Draw() TextView
.Draw()
13???????????? 1
- ?????????? ?? ??????? ??????? ? ?????????????????
???????
14??????? ??? ????????????
- ?????????? ?? ??????????? ????? ?????? ??
???????? ?? ??????????, ????? ?????????? - ??????????? ?????????? ?? ????? Component ???,
?????? ??????????? ?? ???? ????? ?????? - ??? ?????????? ?? ????? Component ? ?????,
????????? ?? ??????????? ?? ??????? ?????????
15?? ? ?????? ???????
- ??????????
- ?????????? ?????????? ?? ?????????
??????/???????? ?? ?????????? - ??????????? ?? ?????????? ? ??-??????? ??????
????????????? - ??????? ?????????????? ?? ????????? ? ????????? ?
????????? ?????????????? - ???????????
- ?? ?????? ????? ?? ???????, ????????? ? ???????
????????? ?? ?? ????????? - ??????????? ????????? ?? ??????? ??????? ???? ??
?????? ?? ????????? ????? ??????? - ?????? ???????????? ???????? ??????
- ?????????? ?????????
16??????? (Wrapper)
17??????????
- ???? ?? ??????? ??????? ????????
- ????? ? ?????? ?? ????? ?? ????????? ????????? ?
???????? - ??? ?? ???????????? ?? ??????????? ?? ???????
???????? - ?? ????? ???????? ?????? ???? ?? ?????? ???????
????????
18?????????? ??????????
- ???? ????, ?????? ????, ???? ???????, ????
????????, ??????? ?? ??????, ????????, 2005, ISBN
954-685-352-6 - ?????? ??????, UML. ??????, ????????, 2004, ISDN
954-685-306-2