Add all 23 GoF design pattern implementations (2026-06-13)
This commit is contained in:
30
02-structural/bridge/README.md
Normal file
30
02-structural/bridge/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Bridge Design Pattern — Java Example
|
||||
|
||||
**Pattern:** Structural → Bridge
|
||||
**Article:** https://ankurm.com/bridge-design-pattern-java/
|
||||
|
||||
## What this example shows
|
||||
|
||||
Decouples remote controls (Abstraction) from devices (Implementation). A basic remote and an advanced remote each work with any device (TV, Radio) without creating N×M subclasses.
|
||||
|
||||
## How to run
|
||||
|
||||
```bash
|
||||
javac bridge/*.java
|
||||
java bridge.Main
|
||||
```
|
||||
|
||||
Requires Java 11+.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Role |
|
||||
|---|---|
|
||||
| `Device.java` | Implementor interface |
|
||||
| `TV.java` / `Radio.java` | Concrete Implementors |
|
||||
| `RemoteControl.java` | Abstraction (holds Device bridge) |
|
||||
| `AdvancedRemote.java` | Refined Abstraction |
|
||||
| `Main.java` | Demo entry point |
|
||||
|
||||
Article: https://ankurm.com/bridge-design-pattern-java/
|
||||
All patterns: https://ankurm.com/design-patterns-java/
|
||||
Reference in New Issue
Block a user