SWE : Structural Design Pattern

Part 3 of Design Pattern series.

image

1. Adapter

Pros

Cons

Example

Class with parameter x1, y1, x2, y2
Class with Incompatible parameter — x, y, width, height
Adapter
Main

Reference

2. Bridge

Pros

Cons

Example

Implementation
Abstraction by Bridge

3. Composite

Pros

Cons

Example

Component — traverse()
Composite — add() & traverse()
Main
Output

Reference

4. Decorator

Pros

Cons

Example

Base
Decorator
Main
Output

Reference

5. Facade

Pros

Cons

6. Flyweight

Pros

Cons

7. Private Class Data

Example

getter & setter —getName & setName
Main

Reference

8. Proxy

Pros

Cons

Example

Interface shared between Proxy and Base Class
Base Class
Proxy
Main
Output

Reference

A Software Engineer in Machine Learning world 🤖

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store