Compare commits

..

2 Commits

289 changed files with 172 additions and 7844 deletions

View File

@ -1460,78 +1460,6 @@
"contributions": [
"code"
]
},
{
"login": "zWeBrain",
"name": "zWeBrain",
"avatar_url": "https://avatars.githubusercontent.com/u/46642512?v=4",
"profile": "https://github.com/zWeBrain",
"contributions": [
"code"
]
},
{
"login": "Al-assad",
"name": "余林颖",
"avatar_url": "https://avatars.githubusercontent.com/u/22493821?v=4",
"profile": "https://al-assad.github.io/notion/",
"contributions": [
"translation"
]
},
{
"login": "STudio26",
"name": "Alain",
"avatar_url": "https://avatars.githubusercontent.com/u/6988911?v=4",
"profile": "https://github.com/STudio26",
"contributions": [
"translation"
]
},
{
"login": "DEV-VRUPER",
"name": "VR",
"avatar_url": "https://avatars.githubusercontent.com/u/30525467?v=4",
"profile": "https://github.com/DEV-VRUPER",
"contributions": [
"doc"
]
},
{
"login": "JackieNim",
"name": "JackieNim",
"avatar_url": "https://avatars.githubusercontent.com/u/4138836?v=4",
"profile": "https://github.com/JackieNim",
"contributions": [
"code"
]
},
{
"login": "EdisonE3",
"name": "EdisonE3",
"avatar_url": "https://avatars.githubusercontent.com/u/52118917?v=4",
"profile": "https://github.com/EdisonE3",
"contributions": [
"code"
]
},
{
"login": "tao-sun2",
"name": "Tao",
"avatar_url": "https://avatars.githubusercontent.com/u/66189688?v=4",
"profile": "https://github.com/tao-sun2",
"contributions": [
"code"
]
},
{
"login": "JuanManuelAbate",
"name": "Juan Manuel Abate",
"avatar_url": "https://avatars.githubusercontent.com/u/16357060?v=4",
"profile": "https://github.com/JuanManuelAbate",
"contributions": [
"translation"
]
}
],
"contributorsPerLine": 4,

View File

@ -40,26 +40,26 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@master
with:
# Disabling shallow clone for improving relevancy of SonarQube reporting
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@master
with:
java-version: 11
distribution: 'adopt'
- name: Cache SonarCloud packages
uses: actions/cache@v2
uses: actions/cache@master
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven dependencies
uses: actions/cache@v2
uses: actions/cache@master
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

View File

@ -38,16 +38,16 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@master
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@master
with:
java-version: 11
distribution: 'adopt'
- name: Cache Maven Dependecies
uses: actions/cache@v2
uses: actions/cache@master
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

View File

@ -6,16 +6,16 @@
![Java CI](https://github.com/iluwatar/java-design-patterns/workflows/Java%20CI/badge.svg)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=ncloc)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=ncloc)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-168-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-160-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<br/>
Read in different language : [**zh**](/localization/zh/README.md), [**ko**](/localization/ko/README.md), [**fr**](/localization/fr/README.md), [**tr**](/localization/tr/README.md), [**ar**](/localization/ar/README.md), [**es**](/localization/es/README.md)
Read in different language : [![CN](/assets/flags/CN.png)**CN**](/zh/README.md), [![KR](/assets/flags/KR.png)**KR**](/ko/README.md), [![FR](/assets/flags/FR.png)**FR**](/fr/README.md), [![TR](/assets/flags/TR.png)**TR**](/tr/README.md), [![AR](/assets/flags/AR.png)**AR**](/ar/README.md)
<br/>
@ -34,7 +34,7 @@ are familiar with the patterns.
# Getting started
This site showcases Java Design Patterns. The solutions have been developed by
experienced programmers and architects from the open source community. The
experienced programmers and architects from the open source community. The
patterns can be browsed by their high level descriptions or by looking at their
source code. The source code examples are well commented and can be thought as
programming tutorials on how to implement a specific pattern. We use the most
@ -49,7 +49,7 @@ patterns should only be introduced when they are needed for practical
extensibility.
Once you are familiar with these concepts you can start drilling down into the
[available design patterns](https://java-design-patterns.com/patterns/) by any
[available design patterns](https://java-design-patterns.com/patterns/) by any
of the following approaches
- Search for a specific pattern by name. Can't find one? Please report a new pattern [here](https://github.com/iluwatar/java-design-patterns/issues).
@ -61,8 +61,8 @@ in your architectures and have as much fun learning them as we had developing th
# How to contribute
If you are willing to contribute to the project you will find the relevant information in
our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help
If you are willing to contribute to the project you will find the relevant information in
our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help
you and answer your questions in the [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).
# License
@ -315,18 +315,6 @@ This project is licensed under the terms of the MIT license.
<td align="center"><a href="https://www.linkedin.com/in/jinisha-vora"><img src="https://avatars.githubusercontent.com/u/40777762?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jinishavora</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3Ajinishavora" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=jinishavora" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/eas5"><img src="https://avatars.githubusercontent.com/u/50836521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elvys Soares</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=eas5" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/zWeBrain"><img src="https://avatars.githubusercontent.com/u/46642512?v=4?s=100" width="100px;" alt=""/><br /><sub><b>zWeBrain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=zWeBrain" title="Code">💻</a></td>
<td align="center"><a href="https://al-assad.github.io/notion/"><img src="https://avatars.githubusercontent.com/u/22493821?v=4?s=100" width="100px;" alt=""/><br /><sub><b>余林颖</b></sub></a><br /><a href="#translation-Al-assad" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/STudio26"><img src="https://avatars.githubusercontent.com/u/6988911?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alain</b></sub></a><br /><a href="#translation-STudio26" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/DEV-VRUPER"><img src="https://avatars.githubusercontent.com/u/30525467?v=4?s=100" width="100px;" alt=""/><br /><sub><b>VR</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=DEV-VRUPER" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/JackieNim"><img src="https://avatars.githubusercontent.com/u/4138836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JackieNim</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=JackieNim" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/EdisonE3"><img src="https://avatars.githubusercontent.com/u/52118917?v=4?s=100" width="100px;" alt=""/><br /><sub><b>EdisonE3</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=EdisonE3" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tao-sun2"><img src="https://avatars.githubusercontent.com/u/66189688?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tao</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=tao-sun2" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/JuanManuelAbate"><img src="https://avatars.githubusercontent.com/u/16357060?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan Manuel Abate</b></sub></a><br /><a href="#translation-JuanManuelAbate" title="Translation">🌍</a></td>
</tr>
</table>
<!-- markdownlint-restore -->

View File

@ -4,7 +4,6 @@ title: Abstract Document
folder: abstract-document
permalink: /patterns/abstract-document/
categories: Structural
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Abstract Factory
folder: abstract-factory
permalink: /patterns/abstract-factory/
categories: Creational
language: en
tags:
- Gang of Four
---
@ -20,9 +19,9 @@ objects without specifying their concrete classes.
## Explanation
Real-world example
Real world example
> To create a kingdom we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency between the objects in the kingdom.
> To create a kingdom we need objects with a common theme. Elven kingdom needs an Elven king, Elven castle and Elven army whereas Orcish kingdom needs an Orcish king, Orcish castle and Orcish army. There is a dependency between the objects in the kingdom.
In plain words
@ -34,7 +33,7 @@ Wikipedia says
**Programmatic Example**
Translating the kingdom example above. First of all, we have some interfaces and implementation for the objects in the
Translating the kingdom example above. First of all we have some interfaces and implementation for the objects in the
kingdom.
```java
@ -52,21 +51,21 @@ public interface Army {
// Elven implementations ->
public class ElfCastle implements Castle {
static final String DESCRIPTION = "This is the elven castle!";
static final String DESCRIPTION = "This is the Elven castle!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
public class ElfKing implements King {
static final String DESCRIPTION = "This is the elven king!";
static final String DESCRIPTION = "This is the Elven king!";
@Override
public String getDescription() {
return DESCRIPTION;
}
}
public class ElfArmy implements Army {
static final String DESCRIPTION = "This is the elven Army!";
static final String DESCRIPTION = "This is the Elven Army!";
@Override
public String getDescription() {
return DESCRIPTION;
@ -77,7 +76,7 @@ public class ElfArmy implements Army {
```
Then we have the abstraction and implementations for the kingdom factory.
Then we have the abstraction and implementations for the kingdom factory
```java
public interface KingdomFactory {
@ -111,7 +110,7 @@ public class OrcKingdomFactory implements KingdomFactory {
}
```
Now we have the abstract factory that lets us make a family of related objects i.e. elven kingdom factory creates elven castle, king and army, etc.
Now we have our abstract factory that lets us make family of related objects i.e. Elven kingdom factory creates Elven castle, king and army etc.
```java
var factory = new ElfKingdomFactory();
@ -127,13 +126,13 @@ army.getDescription();
Program output:
```java
This is the elven castle!
This is the elven king!
This is the elven Army!
This is the Elven castle!
This is the Elven king!
This is the Elven Army!
```
Now, we can design a factory for our different kingdom factories. In this example, we created `FactoryMaker`, responsible for returning an instance of either `ElfKingdomFactory` or `OrcKingdomFactory`.
The client can use `FactoryMaker` to create the desired concrete factory which, in turn, will produce different concrete objects (derived from `Army`, `King`, `Castle`).
Now, we can design a factory for our different kingdom factories. In this example, we created FactoryMaker, responsible for returning an instance of either ElfKingdomFactory or OrcKingdomFactory.
The client can use FactoryMaker to create the desired concrete factory which, in turn, will produce different concrete objects (Army, King, Castle).
In this example, we also used an enum to parameterize which type of kingdom factory the client will ask for.
```java
@ -179,8 +178,8 @@ public static void main(String[] args) {
Use the Abstract Factory pattern when
* The system should be independent of how its products are created, composed, and represented
* The system should be configured with one of the multiple families of products
* The system should be independent of how its products are created, composed and represented
* The system should be configured with one of multiple families of products
* The family of related product objects is designed to be used together, and you need to enforce this constraint
* You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
@ -200,7 +199,7 @@ Example use cases
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
* While the pattern is great when creating predefined objects, adding the new ones might be challenging.
* The code becomes more complicated than it should be since a lot of new interfaces and classes are introduced along with the pattern.
* The code becomes more complicated than it should be, since a lot of new interfaces and classes are introduced along with the pattern.
## Tutorial

View File

@ -37,7 +37,7 @@ import lombok.extern.slf4j.Slf4j;
*
* <p>The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory})
* and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses
* both concrete implementations to create a king, a castle, and an army.
* both concrete implementations to create a king, a castle and an army.
*/
@Slf4j
public class App implements Runnable {
@ -60,13 +60,13 @@ public class App implements Runnable {
@Override
public void run() {
LOGGER.info("elf kingdom");
LOGGER.info("Elf Kingdom");
createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
LOGGER.info(kingdom.getArmy().getDescription());
LOGGER.info(kingdom.getCastle().getDescription());
LOGGER.info(kingdom.getKing().getDescription());
LOGGER.info("orc kingdom");
LOGGER.info("Orc Kingdom");
createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
LOGGER.info(kingdom.getArmy().getDescription());
LOGGER.info(kingdom.getCastle().getDescription());

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfArmy implements Army {
static final String DESCRIPTION = "This is the elven army!";
static final String DESCRIPTION = "This is the Elven Army!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfCastle implements Castle {
static final String DESCRIPTION = "This is the elven castle!";
static final String DESCRIPTION = "This is the Elven castle!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class ElfKing implements King {
static final String DESCRIPTION = "This is the elven king!";
static final String DESCRIPTION = "This is the Elven king!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcArmy implements Army {
static final String DESCRIPTION = "This is the orc army!";
static final String DESCRIPTION = "This is the Orc Army!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcCastle implements Castle {
static final String DESCRIPTION = "This is the orc castle!";
static final String DESCRIPTION = "This is the Orc castle!";
@Override
public String getDescription() {

View File

@ -28,7 +28,7 @@ package com.iluwatar.abstractfactory;
*/
public class OrcKing implements King {
static final String DESCRIPTION = "This is the orc king!";
static final String DESCRIPTION = "This is the Orc king!";
@Override
public String getDescription() {

View File

@ -29,14 +29,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for abstract factory.
* Test for abstract factory.
*/
class AbstractFactoryTest {
private final App app = new App();
@Test
void verifyKingCreation() {
void king() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -51,7 +51,7 @@ class AbstractFactoryTest {
}
@Test
void verifyCastleCreation() {
void castle() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -66,7 +66,7 @@ class AbstractFactoryTest {
}
@Test
void verifyArmyCreation() {
void army() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -81,7 +81,7 @@ class AbstractFactoryTest {
}
@Test
void verifyElfKingdomCreation() {
void createElfKingdom() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
final var kingdom = app.getKingdom();
@ -97,7 +97,7 @@ class AbstractFactoryTest {
}
@Test
void verifyOrcKingdomCreation() {
void createOrcKingdom() {
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
final var kingdom = app.getKingdom();

View File

@ -28,7 +28,10 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Check whether the execution of the main method in {@link App} throws an exception.
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App}
* throws an exception.
*/
class AppTest {

View File

@ -4,7 +4,6 @@ title: Active Object
folder: active-object
permalink: /patterns/active-object/
categories: Concurrency
language: en
tags:
- Performance
---

View File

@ -4,7 +4,6 @@ title: Acyclic Visitor
folder: acyclic-visitor
permalink: /patterns/acyclic-visitor/
categories: Behavioral
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Adapter
folder: adapter
permalink: /patterns/adapter/
categories: Structural
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Aggregator Microservices
folder: aggregator-microservices
permalink: /patterns/aggregator-microservices/
categories: Architectural
language: en
tags:
- Cloud distributed
- Decoupling

View File

@ -4,7 +4,6 @@ title: Ambassador
folder: ambassador
permalink: /patterns/ambassador/
categories: Structural
language: en
tags:
- Decoupling
- Cloud distributed

View File

@ -4,7 +4,6 @@ title: API Gateway
folder: api-gateway
permalink: /patterns/api-gateway/
categories: Architectural
language: en
tags:
- Cloud distributed
- Decoupling

View File

@ -4,7 +4,6 @@ title: Arrange/Act/Assert
folder: arrange-act-assert
permalink: /patterns/arrange-act-assert/
categories: Idiom
language: en
tags:
- Testing
---

BIN
assets/flags/AR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

BIN
assets/flags/CN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
assets/flags/FR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

BIN
assets/flags/KR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

BIN
assets/flags/TR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

View File

@ -4,7 +4,6 @@ title: Async Method Invocation
folder: async-method-invocation
permalink: /patterns/async-method-invocation/
categories: Concurrency
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Balking
folder: balking
permalink: /patterns/balking/
categories: Concurrency
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Bridge
folder: bridge
permalink: /patterns/bridge/
categories: Structural
language: en
tags:
- Gang of Four
---

View File

@ -43,7 +43,7 @@ public class Hammer implements Weapon {
@Override
public void swing() {
LOGGER.info("The hammer is swung.");
LOGGER.info("The hammer is swinged.");
enchantment.apply();
}

View File

@ -43,7 +43,7 @@ public class Sword implements Weapon {
@Override
public void swing() {
LOGGER.info("The sword is swung.");
LOGGER.info("The sword is swinged.");
enchantment.apply();
}

View File

@ -4,7 +4,6 @@ title: Builder
folder: builder
permalink: /patterns/builder/
categories: Creational
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Business Delegate
folder: business-delegate
permalink: /patterns/business-delegate/
categories: Structural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Bytecode
folder: bytecode
permalink: /patterns/bytecode/
categories: Behavioral
language: en
tags:
- Game programming
---

View File

@ -4,7 +4,6 @@ title: Caching
folder: caching
permalink: /patterns/caching/
categories: Behavioral
language: en
tags:
- Performance
- Cloud distributed

View File

@ -4,7 +4,6 @@ title: Callback
folder: callback
permalink: /patterns/callback/
categories: Idiom
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Chain of responsibility
folder: chain
permalink: /patterns/chain/
categories: Behavioral
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Circuit Breaker
folder: circuit-breaker
permalink: /patterns/circuit-breaker/
categories: Behavioral
language: en
tags:
- Performance
- Decoupling

View File

@ -4,7 +4,6 @@ title: Static Content Hosting
folder: cloud-static-content-hosting
permalink: /patterns/cloud-static-content-hosting/
categories: Cloud
language: en
tags:
- Cloud distributed
---

View File

@ -4,7 +4,6 @@ title: Collection Pipeline
folder: collection-pipeline
permalink: /patterns/collection-pipeline/
categories: Functional
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Combinator
folder: combinator
permalink: /patterns/combinator/
categories: Idiom
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Command
folder: command
permalink: /patterns/command/
categories: Behavioral
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Commander
folder: commander
permalink: /patterns/commander/
categories: Concurrency
language: en
tags:
- Cloud distributed
---

View File

@ -1,123 +0,0 @@
---
layout: pattern
title: Composite Entity
folder: composite-entity
permalink: /patterns/composite-entity/
categories: Structural
language: en
tags:
- Enterprise Integration Pattern
---
## Intent
It is used to model, represent, and manage a set of persistent objects that are interrelated, rather than representing them as individual fine-grained entities.
## Explanation
Real world example
> For a console, there may be many interfaces that need to be managed and controlled. Using the composite entity pattern, dependent objects such as messages and signals can be combined together and controlled using a single object.
In plain words
> Composite entity pattern allows a set of related objects to be represented and managed by a unified object.
**Programmatic Example**
We need a generic solution for the problem. To achieve this, let's introduce a generic
Composite Entity Pattern.
```java
public abstract class DependentObject<T> {
T data;
public void setData(T message) {
this.data = message;
}
public T getData() {
return data;
}
}
public abstract class CoarseGrainedObject<T> {
DependentObject<T>[] dependentObjects;
public void setData(T... data) {
IntStream.range(0, data.length).forEach(i -> dependentObjects[i].setData(data[i]));
}
public T[] getData() {
return (T[]) Arrays.stream(dependentObjects).map(DependentObject::getData).toArray();
}
}
```
The specialized composite entity `console` inherit from this base class as follows.
```java
public class MessageDependentObject extends DependentObject<String> {
}
public class SignalDependentObject extends DependentObject<String> {
}
public class ConsoleCoarseGrainedObject extends CoarseGrainedObject<String> {
@Override
public String[] getData() {
super.getData();
return new String[]{
dependentObjects[0].getData(), dependentObjects[1].getData()
};
}
public void init() {
dependentObjects = new DependentObject[]{
new MessageDependentObject(), new SignalDependentObject()};
}
}
public class CompositeEntity {
private final ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
public void setData(String message, String signal) {
console.setData(message, signal);
}
public String[] getData() {
return console.getData();
}
}
```
Now managing the assignment of message and signal objects with the composite entity `console`.
```java
var console = new CompositeEntity();
console.init();
console.setData("No Danger", "Green Light");
Arrays.stream(console.getData()).forEach(LOGGER::info);
console.setData("Danger", "Red Light");
Arrays.stream(console.getData()).forEach(LOGGER::info);
```
## Class diagram
![alt text](./etc/composite_entity.urm.png "Composite Entity Pattern")
## Applicability
Use the Composite Entity Pattern in the following situation:
* You want to manage multiple dependency objects through one object to adjust the degree of granularity between objects. At the same time, the lifetime of dependency objects depends on a coarse-grained object.
## Credits
* [Composite Entity Pattern in wikipedia](https://en.wikipedia.org/wiki/Composite_entity_pattern)

View File

@ -1,45 +0,0 @@
@startuml
package com.iluwatar.compositeentity {
class App {
+ App(message: String, signal: String)
+ main(args : String[]) {static}
}
class CompositeEntity{
- console : ConsoleCoarseGrainedObject
+ CompositeEntity()
+ setData(message: String, signal: String)
+ getData()
+ init()
}
abstract CoarseGrainedObject{
- dependentObjects : DependentObject[]
+ CoarseGrainedObject()
+ setData(data: T[])
+ getData()
}
abstract DependentObject{
- data : T
+ DependentObject()
+ setData(data: T)
+ getData()
}
class ConsoleCoarseGrainedObject{
+ ConsoleCoarseGrainedObject()
+ getData()
+ init()
}
class MessageDependentObject{
+ MessageDependentObject()
}
class SignalDependentObject{
+ SignalDependentObject()
}
MessageDependentObject --|> DependentObject
SignalDependentObject --|> DependentObject
ConsoleCoarseGrainedObject --|> CoarseGrainedObject
CompositeEntity -right-> ConsoleCoarseGrainedObject
CoarseGrainedObject "1" o--> "0.." DependentObject
App .right.> CompositeEntity
}
@enduml

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

View File

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright © 2014-2021 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.25.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>composite-entity</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<archive>
<manifest>
<mainClass>com.iluwatar.composite-entity.com.iluwatar.compositeentity.App</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,61 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
/**
* Composite entity is a Java EE Software design pattern and it is used to model, represent, and
* manage a set of interrelated persistent objects rather than representing them as individual
* fine-grained entity beans, and also a composite entity bean represents a graph of objects.
*/
@Slf4j
public class App {
/**
* An instance that a console manages two related objects.
*/
public App(String message, String signal) {
var console = new CompositeEntity();
console.init();
console.setData(message, signal);
Arrays.stream(console.getData()).forEach(LOGGER::info);
console.setData("Danger", "Red Light");
Arrays.stream(console.getData()).forEach(LOGGER::info);
}
/**
* Program entry point.
*
* @param args command line args
*/
public static void main(String[] args) {
new App("No Danger", "Green Light");
}
}

View File

@ -1,46 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
import java.util.Arrays;
import java.util.stream.IntStream;
/**
* A coarse-grained object is an object with its own life cycle manages its own relationships to
* other objects. It can be an object contained in the composite entity, or, composite entity itself
* can be the coarse-grained object which holds dependent objects.
*/
public abstract class CoarseGrainedObject<T> {
DependentObject<T>[] dependentObjects;
public void setData(T... data) {
IntStream.range(0, data.length).forEach(i -> dependentObjects[i].setData(data[i]));
}
public T[] getData() {
return (T[]) Arrays.stream(dependentObjects).map(DependentObject::getData).toArray();
}
}

View File

@ -1,46 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
/**
* Composite entity is the coarse-grained entity bean which may be the coarse-grained object, or may
* contain a reference to the coarse-grained object.
*/
public class CompositeEntity {
private final ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
public void setData(String message, String signal) {
console.setData(message, signal);
}
public String[] getData() {
return console.getData();
}
public void init() {
console.init();
}
}

View File

@ -1,43 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
/**
* A specific CoarseGrainedObject to implement a console.
*/
public class ConsoleCoarseGrainedObject extends CoarseGrainedObject<String> {
@Override
public String[] getData() {
return new String[]{
dependentObjects[0].getData(), dependentObjects[1].getData()
};
}
public void init() {
dependentObjects = new DependentObject[]{
new MessageDependentObject(), new SignalDependentObject()};
}
}

View File

@ -1,43 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
/**
* It is an object, which can contain other dependent objects (there may be a tree of objects within
* the composite entity), that depends on the coarse-grained object and has its life cycle managed
* by the coarse-grained object.
*/
public abstract class DependentObject<T> {
T data;
public void setData(T message) {
this.data = message;
}
public T getData() {
return data;
}
}

View File

@ -1,32 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
/**
* The first DependentObject to show message.
*/
public class MessageDependentObject extends DependentObject<String> {
}

View File

@ -1,32 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
/**
* The second DependentObject to show message.
*/
public class SignalDependentObject extends DependentObject<String> {
}

View File

@ -1,48 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
/**
* com.iluwatar.compositeentity.App running test
*/
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
* <p>
* Solution: Inserted assertion to check whether the execution of the main method in {@link
* App#main(String[])} throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}

View File

@ -1,55 +0,0 @@
/*
* The MIT License
* Copyright © 2014-2021 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.compositeentity;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PersistenceTest {
final static ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
@Test
void dependentObjectChangedForPersistenceTest() {
MessageDependentObject dependentObject = new MessageDependentObject();
console.init();
console.dependentObjects[0] = dependentObject;
String message = "Danger";
assertNull(console.dependentObjects[0].getData());
dependentObject.setData(message);
assertEquals(message, console.dependentObjects[0].getData());
}
@Test
void coarseGrainedObjectChangedForPersistenceTest() {
MessageDependentObject dependentObject = new MessageDependentObject();
console.init();
console.dependentObjects[0] = dependentObject;
String message = "Danger";
assertNull(console.dependentObjects[0].getData());
console.setData(message);
assertEquals(message, dependentObject.getData());
}
}

View File

@ -4,7 +4,6 @@ title: Composite
folder: composite
permalink: /patterns/composite/
categories: Structural
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Converter
folder: converter
permalink: /patterns/converter/
categories: Creational
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: CQRS
folder: cqrs
permalink: /patterns/cqrs/
categories: Architectural
language: en
tags:
- Performance
- Cloud distributed

View File

@ -4,7 +4,6 @@ title: Data Access Object
folder: dao
permalink: /patterns/dao/
categories: Architectural
language: en
tags:
- Data access
---

View File

@ -5,7 +5,6 @@ folder: data-bus
permalink: /patterns/data-bus/
categories: Architectural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Data Locality
folder: data-locality
permalink: /patterns/data-locality/
categories: Behavioral
language: en
tags:
- Game programming
- Performance

View File

@ -4,7 +4,6 @@ title: Data Mapper
folder: data-mapper
permalink: /patterns/data-mapper/
categories: Architectural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Data Transfer Object
folder: data-transfer-object
permalink: /patterns/data-transfer-object/
categories: Architectural
language: en
tags:
- Performance
---

View File

@ -4,7 +4,6 @@ title: Decorator
folder: decorator
permalink: /patterns/decorator/
categories: Structural
language: en
tags:
- Gang Of Four
- Extensibility

View File

@ -4,7 +4,6 @@ title: Delegation
folder: delegation
permalink: /patterns/delegation/
categories: Structural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Dependency Injection
folder: dependency-injection
permalink: /patterns/dependency-injection/
categories: Creational
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Dirty Flag
folder: dirty-flag
permalink: /patterns/dirty-flag/
categories: Behavioral
language: en
tags:
- Game programming
- Performance

View File

@ -4,7 +4,6 @@ title: Double Buffer
folder: double-buffer
permalink: /patterns/double-buffer/
categories: Behavioral
language: en
tags:
- Performance
- Game programming
@ -26,4 +25,4 @@ This pattern is one of those ones where youll know when you need it. If you h
## Credits
* [Game Programming Patterns - Double Buffer](http://gameprogrammingpatterns.com/double-buffer.html)
* [Game Programming Patterns - Double Buffer]([http://gameprogrammingpatterns.com/double-buffer.html](http://gameprogrammingpatterns.com/double-buffer.html))

View File

@ -4,7 +4,6 @@ title: Double Checked Locking
folder: double-checked-locking
permalink: /patterns/double-checked-locking/
categories: Idiom
language: en
tags:
- Performance
---

View File

@ -4,7 +4,6 @@ title: Double Dispatch
folder: double-dispatch
permalink: /patterns/double-dispatch/
categories: Idiom
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: EIP Aggregator
folder: eip-aggregator
permalink: /patterns/eip-aggregator/
categories: Integration
language: en
tags:
- Enterprise Integration Pattern
---

View File

@ -4,7 +4,6 @@ title: EIP Message Channel
folder: eip-message-channel
permalink: /patterns/eip-message-channel/
categories: Integration
language: en
tags:
- Enterprise Integration Pattern
---

View File

@ -4,7 +4,6 @@ title: EIP Publish Subscribe
folder: eip-publish-subscribe
permalink: /patterns/eip-publish-subscribe/
categories: Integration
language: en
tags:
- Enterprise Integration Pattern
---

View File

@ -4,7 +4,6 @@ title: EIP Splitter
folder: eip-splitter
permalink: /patterns/eip-splitter/
categories: Integration
language: en
tags:
- Enterprise Integration Pattern
---

View File

@ -4,7 +4,6 @@ title: EIP Wire Tap
folder: eip-wire-tap
permalink: /patterns/eip-wire-tap/
categories: Integration
language: en
tags:
- Enterprise Integration Pattern
---

View File

@ -4,7 +4,6 @@ title: Event Aggregator
folder: event-aggregator
permalink: /patterns/event-aggregator/
categories: Structural
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Event-based Asynchronous
folder: event-asynchronous
permalink: /patterns/event-asynchronous/
categories: Concurrency
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Event Driven Architecture
folder: event-driven-architecture
permalink: /patterns/event-driven-architecture/
categories: Architectural
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Event Queue
folder: event-queue
permalink: /patterns/event-queue/
categories: Concurrency
language: en
tags:
- Game programming
---

View File

@ -4,7 +4,6 @@ title: Event Sourcing
folder: event-sourcing
permalink: /patterns/event-sourcing/
categories: Architectural
language: en
tags:
- Performance
- Cloud distributed

View File

@ -4,7 +4,6 @@ title: Execute Around
folder: execute-around
permalink: /patterns/execute-around/
categories: Idiom
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Extension objects
folder: extension-objects
permalink: /patterns/extension-objects/
categories: Behavioral
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Facade
folder: facade
permalink: /patterns/facade/
categories: Structural
language: en
tags:
- Gang Of Four
- Decoupling

View File

@ -4,7 +4,6 @@ title: Factory Kit
folder: factory-kit
permalink: /patterns/factory-kit/
categories: Creational
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Factory Method
folder: factory-method
permalink: /patterns/factory-method/
categories: Creational
language: en
tags:
- Extensibility
- Gang Of Four

View File

@ -4,7 +4,6 @@ title: Factory
folder: factory
permalink: /patterns/factory/
categories: Creational
language: en
tags:
- Gang of Four
---

View File

@ -4,7 +4,6 @@ title: Feature Toggle
folder: feature-toggle
permalink: /patterns/feature-toggle/
categories: Behavioral
language: en
tags:
- Extensibility
---

View File

@ -4,7 +4,6 @@ title: Filterer
folder: filterer
permalink: /patterns/filterer/
description: Design pattern that helps container-like objects to return filtered version of themselves.# short meta description that shows in Google search results
language: en
categories:
- Functional
tags:

View File

@ -4,7 +4,6 @@ title: Fluent Interface
folder: fluentinterface
permalink: /patterns/fluentinterface/
categories: Functional
language: en
tags:
- Reactive
---

View File

@ -4,7 +4,6 @@ title: Flux
folder: flux
permalink: /patterns/flux/
categories: Structural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Flyweight
folder: flyweight
permalink: /patterns/flyweight/
categories: Structural
language: en
tags:
- Gang Of Four
- Performance

60
fr/README.md Normal file
View File

@ -0,0 +1,60 @@
<!-- Cette ligne doit restée vide pour des raisons de formatage
afin qu'on puisse avoir un affichage agréable comme sur un
site web par exemple -->
# Les patrons de conception implémentés en Java
![Java CI with Maven](https://github.com/iluwatar/java-design-patterns/workflows/Java%20CI%20with%20Maven/badge.svg)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=ncloc)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-148-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
# Introduction
Le patron de conception est la meilleure formatalisation qu'un programmeur
peut utiliser pour résoudre un problème lors d'une conception d'une application/system.
Le patron de conception (design pattern) est là pour accélérer le processus de
développement en fournissant des paradigmes éprouvés.
La réutilisation de patron de conception aide à prévenir des problèmes subtiles mais
qui sont à l'origine de problèmes majeures, comme cette pratique augmente la lisibilitée
du code par les développeurs/architectes familiers avec l'utilisation de ces concepts.
# Commencer
Ce site présente des modèles de conception Java. Les solutions ont été développées par des
développeurs et architectes expérimentés de la communauté open source. Les modèles peuvent être parcourus par leurs descriptions de haut niveau ou en regardant leur code source. Les exemples de code source sont bien commentés et peuvent être considérés comme tutoriels de programmation sur la façon d'implémenter un modèle spécifique. Nous utilisons le plus technologies Java open source éprouvées au combat.
Avant de plonger dans le matériau, vous devez vous familiariser avec divers
[Principes de conception de logiciels](https://java-design-patterns.com/principles/).
Toutes les conceptions doivent être aussi simples que possible. Vous devriez commencer par KISS, YAGNI,
et faire la chose la plus simple qui pourrait éventuellement fonctionner principes. Complexité et
les modèles ne devraient être introduits que lorsqu'ils sont nécessaires pour
extensibilité.
Une fois que vous êtes familiarisé avec ces concepts, vous pouvez commencer à explorer
[modèles de conception disponibles](https://java-design-patterns.com/patterns/) par tout
des approches suivantes
- Recherchez un modèle spécifique par son nom. Vous n'en trouvez pas? Veuillez signaler un nouveau modèle [ici](https://github.com/iluwatar/java-design-patterns/issues).
- Utilisation de balises telles que `Performance`, `Gang of Four` ou `Data access`.
- Utilisation des catégories de modèles, `Créatif`, `Comportemental` et autres.
J'espère que les solutions orientées objet présentées sur ce site vous seront utiles
dans vos architectures et ayez autant de plaisir à les apprendre que nous en avons eu à les développer.
# Comment contribuer
Si vous souhaitez contribuer au projet, vous trouverez les informations pertinentes dans
notre [wiki développeur](https://github.com/iluwatar/java-design-patterns/wiki). Nous aiderons
vous et répondez à vos questions dans le [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).
# Licence
Ce projet est concédé sous les termes de la licence MIT.

View File

@ -4,7 +4,6 @@ title: Front Controller
folder: front-controller
permalink: /patterns/front-controller/
categories: Structural
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Game Loop
folder: game-loop
permalink: /patterns/game-loop/
categories: Behavioral
language: en
tags:
- Game programming
---

View File

@ -4,7 +4,6 @@ title: Guarded Suspension
folder: guarded-suspension
permalink: /patterns/guarded-suspension/
categories: Concurrency
language: en
tags:
- Decoupling
---

View File

@ -4,7 +4,6 @@ title: Half-Sync/Half-Async
folder: half-sync-half-async
permalink: /patterns/half-sync-half-async/
categories: Concurrency
language: en
tags:
- Performance
---

View File

@ -5,7 +5,6 @@ folder: hexagonal
permalink: /patterns/hexagonal/
pumlformat: svg
categories: Architectural
language: en
tags:
- Decoupling
---

Some files were not shown because too many files have changed in this diff Show More