Documentation
Documentation copied to clipboard
Add 'best practices' page to documentation
Many of the best practices are scattered throughout the documentation and articles across the internet. These best practices should be summarized in one wiki page, while linking to the complete articles when needed.
Here's a starting point for some best practices:
- DO Configure your container in one place: The Compostion Root
- DO NOT let application code depend on the container
- PREFER constructor injection over any other form
- DO let components have only one public constructor
- DO NOT use optional constructor arguments
- DO NOT use Ambient Contexts
-
DO NOT work with runtime data using object construction
- DO NOT inject runtime data into constructors of application components
- DO NOT inject components based on runtime data.
- AVOID the use of factories to create application components.
- AVOID cyclic dependencies
- AVOID constructor over-injection
- DO let injection constructors be simple and fast
- DO make attributes passive; behaviorless
- What objects should be registered in the container and what not.