Design Pattern Slide 04dadadfadadfads.pptx

nrezaeeof 0 views 10 slides Oct 12, 2025
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

about design pattern


Slide Content

Design Pattern Decorator design pattern   Computer Science Faculty Network Engineering Department Slide:- 04 Year:- 2024

Contents Structural Design Patterns Types of Structural Design Patterns Decorator design pattern  Procedure

Structural Design Patterns Structural Design Patterns are concerned with how classes and objects are composed to form larger structures. Structural class patterns use inheritance to compose interfaces or implementations.

Types of Structural Design Patterns Adapter Method Design Patterns Bridge Method Design Patterns Composite Method Design Patterns Decorator Method Design Patterns Facade Method Design Patterns Flyweight Method Design Patterns Proxy Method Design Patterns

Decorator design pattern   allows us to dynamically add functionality and behavior to an object without affecting the behavior of other existing objects within the same class. We use inheritance to extend the behavior of the class. This takes place at compile-time, and all the instances of that class get the extended behavior.

Continue… Decorator patterns allow a user to add new functionality to an existing object without altering its structure. So, there is no change to the original class. The decorator design pattern is a structural pattern, which provides a wrapper to the existing class. The decorator design pattern uses abstract classes or interfaces with the composition to implement the wrapper.

 Real-World Analogy

Continue… Decorator design patterns create decorator classes, which wrap the original class and supply additional functionality by keeping the class methods’ signature unchanged. Decorator design patterns are most frequently used for applying single responsibility principles since we divide the functionality into classes with unique areas of concern. The decorator design pattern is structurally almost like the chain of responsibility pattern.

Usage Decorator design pattern is useful in providing runtime modification abilities and hence more flexible. Its easy to maintain and extend when the amount of choices are more. The disadvantage of decorator design pattern is that it uses plenty of similar kind of objects (decorators) Decorator pattern is used a lot in  Java IO classes , like  FileReader ,  BufferedReader ,   etc.

Procedure Create an interface. Create concrete classes implementing the same interface. Create an abstract decorator class implementing the above same interface. Create a concrete decorator class extending the above abstract decorator class. Now use the concrete decorator class created above to decorate interface objects. Lastly, verify the output
Tags