Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RefactoringGuru/design-patterns-java
Design Pattern Examples in Java
https://github.com/RefactoringGuru/design-patterns-java
design-patterns java
Last synced: 3 days ago
JSON representation
Design Pattern Examples in Java
- Host: GitHub
- URL: https://github.com/RefactoringGuru/design-patterns-java
- Owner: RefactoringGuru
- License: other
- Created: 2017-09-15T12:26:36.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-05-29T15:32:09.000Z (6 months ago)
- Last Synced: 2024-05-30T05:34:14.097Z (5 months ago)
- Topics: design-patterns, java
- Language: Java
- Homepage: https://refactoring.guru/design-patterns/java
- Size: 272 KB
- Stars: 877
- Watchers: 37
- Forks: 258
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- my-awesome - RefactoringGuru/design-patterns-java - patterns,java pushed_at:2024-05 star:0.9k fork:0.3k Design Pattern Examples in Java (Java)
README
# Design Patterns in Java
This repository is part of the [Refactoring.Guru](https://refactoring.guru/design-patterns) project.
It contains Java examples for all classic GoF design patterns.
## Requirements
The examples were written in Java 8, but also tested in Java 9.
For the best experience, we recommend working with examples in IntelliJ IDEA. The Community Edition of IDE is available for free (https://www.jetbrains.com/idea/download/).
After downloading or cloning this repository to your computer, import its root directory into a New project:
- Either through start dialog: Select "Import Project" option and skip through the rest of the steps.
- Or via the main menu: File > New > Project from Existing Sources...
After importing the project, you will be able to run examples by right-clicking "Demo" files inside every example and selecting the "Run" command from the context menu.
## Roadmap
- [ ] Add detailed comments all classes.
- [ ] Add structure-only examples.## Contributor's Guide
We appreciate any help, whether it's a simple fix of a typo or a whole new example. Just [make a fork](https://help.github.com/articles/fork-a-repo/), do your change and submit a [pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
Here's a style guide which might help you to keep your changes consistent with our code:
1. All code should meet the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
2. Try to hard wrap the code at 80th's character. It helps to list the code on the website without scrollbars.
3. Examples should match following package convention: refactoring_guru.{pattern}.{example_name}. Example:
```java
package refactoring_guru.factory_method.ui_example.buttons;class Button {
...
```4. Places classes into separate files.
5. Group classes into sub-packages. It helps people to understand dependencies of a class by glancing over its imports. Example:
```java
package refactoring_guru.factory_method.example.buttons;class Button {
...
``````java
package refactoring_guru.factory_method.example.factories;import Button;
class Factory {
...
```6. Comments may or may not have language tags in them, such as this:
```java
/**
* EN: All products families have the same varieties (MacOS/Windows).
*
* This is a MacOS variant of a button.
*
* RU: Все семейства продуктов имеют одни и те же вариации (MacOS/Windows).
*
* Это вариант кнопки под MacOS.
*/
```Don't be scared and ignore the non-English part of such comments. If you want to change something in a comment like this, then do it. Even if you do it wrong, we'll tell you how to fix it during the Pull Request.
## License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
## Credits
Authors: Bohdan Herashchenko ([@b1ger](https://github.com/b1ger)) and Alexander Shvets ([@neochief](https://github.com/neochief))