-
Notifications
You must be signed in to change notification settings - Fork 29
What is configuration by convention
bartelink edited this page Mar 26, 2012
·
2 revisions
Configuring Ninject by explicitly defining each and every binding individually can take a long time and result in reams of duplicated configuration code; this is never a good thing. We need a better way to configure components that need identical configuration to others; this is where configuration by conventions comes into play.
Configuration by convention means that you identify groups of components that should share a common configuration and then specify that configuration in a single statement once. An example of this form of configuration might be "all services shall be configured as singletons".
Taking this approach has several advantages:
- It greatly reduces the amount of configuration code
- New Service Types that fall within an existing convention group can be enlisted to be resolvable by Ninject without having to add new registration code each time
- Conventions by definition demand consistency in the implementation code. This has both stick (if you don't adhere to the convention it doesn't work) and carrot (you could make it work by adding explicit code to deal with the fact your code doesnt align with the existing convention, but that would be more work) based effects on the consistency, cleanliness and hence maintainability of the system's code