|
| 1 | +# Java Design Patterns Project |
| 2 | + |
| 3 | +This repository demonstrates the implementation of various design patterns in **Java**, organized into three main categories: **Behavioral**, **Creational**, and **Structural**. Each pattern includes its implementation and corresponding unit tests using **JUnit**. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | + |
| 7 | +The project is organized as follows: |
| 8 | + |
| 9 | +``` |
| 10 | +java/ |
| 11 | +├── src/ # Source code |
| 12 | +│ ├── main/ # Main application code |
| 13 | +│ │ ├── behavioral/ # Behavioral design patterns |
| 14 | +│ │ ├── creational/ # Creational design patterns |
| 15 | +│ │ ├── structural/ # Structural design patterns |
| 16 | +│ ├── test/ # Unit tests |
| 17 | +│ ├── behavioral/ # Tests for behavioral patterns |
| 18 | +│ ├── creational/ # Tests for creational patterns |
| 19 | +│ ├── structural/ # Tests for structural patterns |
| 20 | +├── .gitignore # Ignored files and directories for Git |
| 21 | +├── pom.xml # Maven configuration (for dependencies and build) |
| 22 | +├── build.gradle # Gradle configuration (if using Gradle) |
| 23 | +├── README.md # Root project README |
| 24 | +``` |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Design Pattern Categories |
| 29 | + |
| 30 | +### Behavioral Patterns |
| 31 | + |
| 32 | +Behavioral patterns focus on how objects interact and communicate with each other. |
| 33 | + |
| 34 | +- [Observer](./src/main/behavioral/Observer.java) |
| 35 | +- [State](./src/main/behavioral/State.java) |
| 36 | +- [Strategy](./src/main/behavioral/Strategy.java) |
| 37 | +- [Mediator](./src/main/behavioral/Mediator.java) |
| 38 | +- [Command](./src/main/behavioral/Command.java) |
| 39 | +- [Chain of Responsibility](./src/main/behavioral/ChainOfResponsibility.java) |
| 40 | + |
| 41 | +### Creational Patterns |
| 42 | + |
| 43 | +Creational patterns deal with the process of object creation, making a system independent of how its objects are created. |
| 44 | + |
| 45 | +- [Abstract Factory](./src/main/creational/AbstractFactory.java) |
| 46 | +- [Builder](./src/main/creational/Builder.java) |
| 47 | +- [Factory](./src/main/creational/Factory.java) |
| 48 | +- [Prototype](./src/main/creational/Prototype.java) |
| 49 | +- [Singleton](./src/main/creational/Singleton.java) |
| 50 | + |
| 51 | +### Structural Patterns |
| 52 | + |
| 53 | +Structural patterns focus on composing objects and classes into larger structures while keeping them flexible and efficient. |
| 54 | + |
| 55 | +- [Adapter](./src/main/structural/Adapter.java) |
| 56 | +- [Bridge](./src/main/structural/Bridge.java) |
| 57 | +- [Composite](./src/main/structural/Composite.java) |
| 58 | +- [Decorator](./src/main/structural/Decorator.java) |
| 59 | +- [Facade](./src/main/structural/Facade.java) |
| 60 | +- [Proxy](./src/main/structural/Proxy.java) |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Testing |
| 65 | + |
| 66 | +This project uses **JUnit** for testing. Each pattern has a dedicated test file located in the `test` folder under its respective category. |
| 67 | + |
| 68 | +### Running Tests |
| 69 | + |
| 70 | +#### Using Maven |
| 71 | + |
| 72 | +To run the tests using **Maven**, execute the following command: |
| 73 | + |
| 74 | +```bash |
| 75 | +mvn test |
| 76 | +``` |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Configuration |
| 81 | + |
| 82 | +### Maven |
| 83 | + |
| 84 | +- `pom.xml`: Configures dependencies and the build system. |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## Contributing |
| 89 | + |
| 90 | +Contributions are welcome! Feel free to open an issue or submit a pull request. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +This project is licensed under the MIT License. |
0 commit comments