Editorials

Convention over Configuration Exceptions

Personally, I have resisted Convention over Configuration as it is often implemented. In order for Convention to work there must be a close coupling or synchronization of design between different layers in order for convention to work. For example, to make tools such as Entity Framework function by convention alone the database schema and object model must be synchronized.

Usually a good object model and a normalized database will have a high level of synchronization in design. When there are those exceptions, Convention alone will not handle code implementation. At that point you must either write the code yourself, or fall back to defining the mappings through Configuration.

Tools like Fluent NHibernate and conventional NHibernate can co-exist allowing for designs meeting both requirements. When convention works it saves time for coding and maintenance. When it doesn’t you fall back to configuration taking a little more time to write and manage.

I have seen systems completely implemented by configuration. As the system grows, maintaining the mappings of an Object Relation Mapper becomes more and more complicated. Entries in the configuration may become stale or deprecated without being removed.

What is your experience with coding by Convention? Is it a superior method? Are there pitfalls or performance issues of which you need to be aware? Share your thoughts here or by email to btaylor@sswug.org.

Cheers,

Ben