iluwatar / iluwatar/java-design-patterns

Composition root pattern

Open
#379 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

epic: pattern info: help wanted type: feature
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:

  1. Centralized Dependency Creation: All dependencies are instantiated in a single location, typically at the application's entry point.
  2. Dependency Injection: Dependencies are injected into classes rather than being created within those classes, supporting Inversion of Control (IoC).
  3. Separation of Concerns: Ensures that the construction of objects and their usage are separate, enhancing maintainability and testability.

References:

Acceptance Criteria:
  1. Implement the Composition Root pattern in the project, ensuring all dependencies are instantiated in a single location at the application's entry point.
  2. Demonstrate the use of dependency injection to provide these dependencies to various components of the application.
  3. Ensure that the implemented pattern adheres to the project’s contribution guidelines and includes relevant documentation and examples.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.