1: Decorative mode: Decorative mode expands the functionality of the object in a transparent manner to the client, and is an alternative to the inheritance relationship, providing more flexibility than inheritance. Dynamically adds functionality to an object that can be undone on the fly. Adds a very large amount of functionality resulting from the combination of some basic functions. is the ability to dynamically extend an object without having to change the original class file and not use inheritance . It is by creating a wrapper object, that is, decorating to wrap the real object
Fun explanation: DECORATOR-mary to sarly birthday, or do not call her own pick, otherwise this month food is sure to finish, take out my last year in China on the top of the photo, write on the back "the best gift, is Love your Fita", And then to the street gift shop to buy a box (selling gifts mm is also very beautiful OH), and then find the next door to make art design Mike designed a beautiful box installed up ..., we are all decorator, and finally all in the decoration of my this person ah, how, understand? Interesting explanations See also: http://blog.jobbole.com/20496/
Implemented in Java code:
Decorator mode of java--23 design pattern