https://github.com/dizzydroid/designpatternsnutshell
Example code used in my handbook, Design Patterns in a Nutshell
https://github.com/dizzydroid/designpatternsnutshell
design-patterns design-patterns-implemented-in-java example-code handbook java reference software-engineering
Last synced: 8 days ago
JSON representation
Example code used in my handbook, Design Patterns in a Nutshell
- Host: GitHub
- URL: https://github.com/dizzydroid/designpatternsnutshell
- Owner: dizzydroid
- License: mit
- Created: 2024-11-03T22:59:18.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-01-10T00:26:28.000Z (3 months ago)
- Last Synced: 2025-03-27T12:52:38.559Z (25 days ago)
- Topics: design-patterns, design-patterns-implemented-in-java, example-code, handbook, java, reference, software-engineering
- Language: Java
- Homepage:
- Size: 2.35 MB
- Stars: 24
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Welcome to the **Design Patterns in a Nutshell** repository! This repository is a companion to the handbook _Design Patterns in a Nutshell_ and is designed to provide practical, runnable examples for each pattern discussed. Whether you're a beginner or a seasoned developer, you'll find this resource invaluable for mastering design patterns.
## π What are Design Patterns?
**Someone has already solved your problems**,
*βA design pattern is a well-known approach to solve a well-known problem that a (probably) well-known someone has faced.β*Patterns are not a specific piece of code that youβd take in an off-the-shelf fashion, but rather a concept or a blueprint that you can apply and adapt into your software. They are a set of best practices that can be used to solve common problems in software design.
Think of design patterns as a set of tools in your toolbox. Just like a carpenter uses a hammer to drive nails, you can use design patterns to solve common problems in software development. They provide a common language for developers to communicate and share solutions to recurring problems.
## π Pre-requisites
The handbook generally assumes a basic understanding of object-oriented programming concepts. The examples in this repo are particularly written in Java, but if you're familiar with other languages, you should be able to follow along.If you're new to Object-Oriented Programming, consider learning the basics before diving into design patterns. Here are some great resources that I personally recommend:
- [**Head First Java** by Kathy Sierra, Bert Bates, Trisha Gee](https://www.oreilly.com/library/view/head-first-java/9781492091646/)
- [**Bro Code's full Java Course**](https://www.youtube.com/watch?v=xk4_1vDrzzo)
- [**learnjavaonline.org**](https://www.learnjavaonline.org/)The resources above (ordered by personal preference) will help you get started with Java and Object-Oriented Programming.
The handbook is designed to be beginner-friendly, so don't worry if you're new to design patterns. You'll find the examples and explanations easy to follow.
---
## π Repository Structure
The repository is neatly organized into three main folders, corresponding to the **three families** of design patterns. Each pattern links directly to its folder and example:
### **1. Creational Patterns** [(`/Creational Patterns`)](./Creational%20Patterns)
Focus on object creation mechanisms, increasing flexibility and reuse:
- [**Singleton**](./Creational%20Patterns/singleton)
- [**Factory Method**](./Creational%20Patterns/factory-method)
- [**Abstract Factory**](./Creational%20Patterns/abstract-factory)
- [**Builder**](./Creational%20Patterns/builder)
- [**Prototype**](./Creational%20Patterns/prototype)
- [**Object Pool**](./Creational%20Patterns/object-pool)### **2. Structural Patterns** [(`/Structural Patterns`)](./Structural%20Patterns)
Deal with the composition of classes and objects to form larger structures:
- [**Adapter**](./Structural%20Patterns/adapter)
- [**Proxy**](./Structural%20Patterns/proxy)
- [**Decorator**](./Structural%20Patterns/decorator)
- [**Flyweight**](./Structural%20Patterns/flyweight)
- [**Composite**](./Structural%20Patterns/composite)
- [**Bridge**](./Structural%20Patterns/bridge)
- [**FaΓ§ade**](./Structural%20Patterns/facade)### **3. Behavioral Patterns** [(`/Behavioral Patterns`)](./Behavioral%20Patterns)
Concerned with algorithms and object interaction:
- [**Template Method**](./Behavioral%20Patterns/template-method)
- [**Observer**](./Behavioral%20Patterns/observer)
- [**State**](./Behavioral%20Patterns/state)
- [**Command**](./Behavioral%20Patterns/command)
- [**Mediator**](./Behavioral%20Patterns/mediator)
- [**Visitor**](./Behavioral%20Patterns/visitor)
- [**Strategy**](./Behavioral%20Patterns/strategy)
- [**Chain of Responsibility**](./Behavioral%20Patterns/chain-of-responsibility)
- [**Iterator**](./Behavioral%20Patterns/iterator)---
## β¨ Highlights
- **Practical Examples:** Fully runnable code for every pattern.
- **Embedded UML Diagrams:** Each pattern's markdown file includes a clear UML diagram for easy visualization.
- **Beginner-Friendly:** Simple explanations and real-world use cases.---
## π― Goals of the Repository
- Serve as a **reference** for understanding and implementing design patterns.
- Provide a **hands-on approach** to supplement theoretical learning.
- Offer **quick access** to runnable examples and diagrams for every pattern.---
## π Get the Handbook
This repository is a companion to the [Design Patterns in a Nutshell](https://drive.google.com/file/d/19qE0GULc0QBZ7pHO0XIFj_GkTRuBpd5v/view) handbook.---
## π Acknowledgements
This handbook and repository are largely inspired by the incredible work by the authors of the book, [**Head First Design Patterns**](https://www.oreilly.com/library/view/head-first-design/9781492077992/). The book is a must-read for anyone interested in design patterns and I can't recommend it enough.Pattern definitions, and some diagrams are inspired directly by the ones that started it all, the Gang of Four (GoF) book, [**Design Patterns: Elements of Reusable Object-Oriented Software**](https://www.oreilly.com/library/view/design-patterns-elements/0201633612/).
Some examples and analogies were influenced by the amazing content on [**Refactoring Guru**](https://refactoring.guru/).
This repository and the handbook would not have been possible without the amazing resources above. I am grateful for the knowledge they have shared with the world.
---
## π License
This repository is owned by **Shehab Mahmoud**. All content is protected under the terms of intellectual property. Refer to the [`LICENSE`](./LICENSE) file for additional details.
---
## β Disclaimer
This handbook includes content from third-party sources, including images and text excerpts.
Such content remains the property of their respective owners and is included here under
applicable licenses or fair use. If you are the owner of any content and believe it has been
used without proper permission, please contact us to resolve the issue.---
## π€ Contributions
Contributions are welcome! If youβd like to suggest improvements, add examples, or fix bugs:
- Open an issue or submit a pull request.
- Refer to the [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.---
Happy learning and coding! π