Convention over configuration… even without convention

When it comes to web frameworks, I am a firm believer in convention over configuration. It’s a beautifully simple idea that we ought to configure the exceptions to our code rather than the rules. It works well because, by definition, rules are more frequent than exceptions. So, why waste your time configuring most of the application when you can configure less of it?

Now, it’s also sometimes hard to assess whether there really is a convention in something. Content management systems are a great example. They are full of concepts with general conventions (I mention some of them here)
but they are also full of concepts without much convention.

For instance, what is the convention for the display of items in a dropdown, table, or data grid? If we have a listing of companies, we probably want to display something like [CompanyName]. If we have a listing of people, it may look like [LastName], [FirstName]. Let’s say these people are all baseball players. Maybe each player in the dropdown will display [LastName], [FirstName] – [TeamName] – [PositionType].

Suffices to say, there is no convention. In my current project, generating CMS tools from a data model, I’m allowing a meta data file (aka configuration file) to control these areas that don’t have convention. The file allows you to specify how each object should look like in a display drop down, among many other things (e.g. The order of form elements on an add/edit screen, etc.).

However, I still like to employ convention over configuration here, even without convention. My current plan is, on the first run of the CMS generator, the generator will also create this configuration file for you. Since there is no convention for how objects display in a dropdown, I’ll just decide the convention will be to display every attribute. That way, when I go about configuring, it’s a matter of deleting most of the configuration contexts, and in some instances, parsing things together (e.g. [LastName], [FirstName]).

So, even when there is no convention, I think there’s benefit in coming up with something…preferably something that is overtly more than what might be the end configuration. That way, most of my configuration experience is about taking away what’s there rather than writing out stuff that’s not there yet. Undoing over doing, perhaps?