From the course: Java EE: Design Patterns and Architecture
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The Decorator design pattern
From the course: Java EE: Design Patterns and Architecture
The Decorator design pattern
- [Instructor] The Decorator Pattern is one of the structural patterns described in the Gang of Four design pattern book. It's purpose is to wrap a target object, so that you can dynamically add new responsibilities at runtime. Each decorator can wrap another one, which allows for a theoretically unlimited number of decorating of target objects. The Decorator Pattern is often use dynamically to add behavior to objects at runtime, or when it is not possible, or advisable, to use sub classing. A good example are data streams. They are often decorated in this way. The java.io.BufferedInputStream is an example of a decorator wrapping a lower level API and adding functionality to buffer and input stream. Although this runtime behavior is much more flexible than inheritance by sub classing, it introduces a level of complexity to concrete sub classing as it makes it more difficult to determine the types and behaviors of objects prior to executing the application. The decorator implementation…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Classic design patterns revisited1m 51s
-
(Locked)
The Singleton design pattern2m 6s
-
(Locked)
Implement a Singleton pool manager5m 58s
-
(Locked)
Advanced Singleton pattern3m 58s
-
(Locked)
Singleton pattern concurrency5m 4s
-
(Locked)
The Facade design pattern2m 10s
-
(Locked)
Implement the Facade pattern4m 54s
-
(Locked)
Advanced Facade services4m 59s
-
(Locked)
The Observer design pattern3m 14s
-
(Locked)
Implement Observer pattern8m 3s
-
(Locked)
Observer priority and qualifiers7m 28s
-
(Locked)
Asynchronous observer3m 54s
-
(Locked)
The Decorator design pattern2m 16s
-
(Locked)
Implement the Decorator pattern8m 39s
-
-
-
-
-
-
-
-
-