Add all 23 GoF design pattern implementations
This commit is contained in:
32
02-structural/bridge/README.md
Normal file
32
02-structural/bridge/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# 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 -d out/bridge
|
||||
java -cp out/bridge bridge.Main
|
||||
```
|
||||
|
||||
Requires Java 25.
|
||||
|
||||
## Post Section ↔ File Mapping
|
||||
|
||||
| Post Section | File(s) |
|
||||
|---|---|
|
||||
| Step 1 — The Implementor Interface | `Device.java` |
|
||||
| Step 2 — Concrete Implementors (TV and Radio) | `TV.java`, `Radio.java` |
|
||||
| Step 3 — The Abstraction (RemoteControl) | `RemoteControl.java` |
|
||||
| Step 4 — Refined Abstraction (AdvancedRemote) | `AdvancedRemote.java` |
|
||||
| Wiring It Together: Main Demo | `Main.java` |
|
||||
|
||||
Note: the "Class Explosion Problem — Visualised" pseudocode and the JDBC/SLF4J snippets shown in the article are illustrative only — they are not part of this repository's runnable example.
|
||||
|
||||
Article: https://ankurm.com/bridge-design-pattern-java/
|
||||
All patterns: https://ankurm.com/design-patterns-java/
|
||||
Reference in New Issue
Block a user