`

one note of Head first design patterns(Decorator pattern)

阅读更多

I read the chapter three of head first design patterns yesterday,this chapter tell us how to use

decorator pattern.here is the defination of this pattern:

       The decorator pattern attaches additional responsibilities to  an object  dynamically,   it

provide a flexible alternative to subclassing to extending functionality.

       The pattern contains  four part.here are tey,component part.the concreteComponent part,

the decorator part ,and the concreteDecorator part. To our attention ,  it is necessary to  make

the decorator and the component have the same interface.

      This pattern uses the composition and inheritance technique to work.apparentlly,the pattern

causes the high coupling for the inheritance,but actually,it just uses the inheritance to unify the

interface,and it is the composition that extend the functionnallites.

      This pattern shows up Open-closed  principle to us .here is the defination of  Open-closed

principle.classes should be open  for extension,but closed for modifcation.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics