java-design-patterns
java-design-patterns copied to clipboard
Composition root pattern
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.
Reference: http://www.amazon.com/gp/product/1935182501/