java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

Composition root pattern

Open npathai opened this issue 10 years ago • 2 comments

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.

npathai avatar Feb 12 '16 11:02 npathai

Reference: http://www.amazon.com/gp/product/1935182501/

npathai avatar Feb 12 '16 11:02 npathai