Decorator模式的好处

Decorator模式,应该就是bolch书中说的composition,在解决inheritence的问题的时候确实有效果~

dynamic dispatch就不会到subClass那里去了,而是去一个field那里!

equals方法的问题也比较容易的解决了,因为调用的是统一的基础类的equals方法

在功能合成方面和优势不错!见另外一篇decorator模式的文章~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s