iluwatar / iluwatar/java-design-patterns
Composition root pattern
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 94.7k
- Forks
- 27.4k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 10
Description
Description:
The Composition Root design pattern is a method of organizing code to ensure that all dependencies are created in a single location within an application. This helps manage dependencies more effectively, improve testability, and promote a clear separation of concerns. By centralizing the creation of dependencies, the Composition Root pattern ensures that an application's object graph is constructed in a consistent manner.
Main elements of the pattern:
- Centralized Dependency Creation: All dependencies are instantiated in a single location, typically at the application's entry point.
- Dependency Injection: Dependencies are injected into classes rather than being created within those classes, supporting Inversion of Control (IoC).
- Separation of Concerns: Ensures that the construction of objects and their usage are separate, enhancing maintainability and testability.
References:
- Composition Root - Mark Seemann
- Dependency Injection Principles, Practices, and Patterns by Mark Seemann and Steven van Deursen
- Project Contribution Guidelines
Acceptance Criteria:
- Implement the Composition Root pattern in the project, ensuring all dependencies are instantiated in a single location at the application's entry point.
- Demonstrate the use of dependency injection to provide these dependencies to various components of the application.
- Ensure that the implemented pattern adheres to the project’s contribution guidelines and includes relevant documentation and examples.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the project contribution guidelines and existing Java design-pattern examples, then identify the application's entry point and the dependencies that would belong in a composition root. Done means dependencies are created in one location, injected into components, and accompanied by relevant documentation and examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100