I recently read this blog entry by Hadi Hariri: That dreaded M in ASP.NET MVC. Hadi surveyed fellow ASP.NET MVC developers about the types of models they use in the applications. One of his survey questions read:
If you bind to Domain Model, how do you deal with extra data such as country list?
And one person wrote select Other and wrote in: “conventions.” Following that, Hadi wrote:
I’ve actually found another way to solve this problem, partially based on conventions.
And then later says:
Maybe we should take the concept of conventions more seriously than just what folders our Views, Controllers and Models reside in. Maybe we should push conventions to the limit and see if we actually reduce this friction.
What does he mean by using “conventions” to solve this problem? I’m not familiar with the term in this context.
Thanks
Convention in this context could mean many things. Loosely it is just a solution to the problem that is not built in but looked up using names.
An example of this already in MVC is that a route to a controller named “Home” is mapped to a class named “HomeController”. Extending this idea to the selected country and country list problem you can think of many solutions.
One example would be given a model:
We may define options for this model via a convention on the naming where it looks for a model with the word “Options” after its name and then matches the property on the model with a like named property on the options model.
This may not be a great convention but is an acceptable example of what the author may be talking about.