What’s the best way to name a css class: form-field-label or bold-text? Is there any difference between MVC’s EditorFor and TextBoxFor? Or between a DetailedRowText property and ArticleDescription?
For all the cases, there is a difference. The first one is naming by purpose and the other naming by effect, or what it actually does. Even though the methods/properties do exactly the same thing, there’s a huge difference in the coupling they imply. When named by effect, the name is a promise to the caller on exactly what will be done. It is safe to use it in different circumstances, trusting that it will always do what the name implies. When a method is named by purpose there’s no guarantee on exactly what it will do, there’s instead a promise that it will adopt it’s behaviour as needed.
Both naming by purpose and naming by effect have their uses, but they shouldn’t be confused. The choice between them should always be deliberate and not accidental.
This post is written by guest blogger Albin Sunnanbo. He’s a great friend and source of inspiration and also one of the best developers I know. It was Albin that first introduced me to LINQ, EF Migrations and jQuery that I now use daily.
We had recently built a new version of Twitter Bootstrap from less files with Chirpy instead of using the official CSS files and suddenly the whole layout broke down in IE7. All other browsers looked OK, including IE9. At first sight It looked like the CSS files had not loaded at all in IE7.
I started debugging in IE9 by opening the debug tools and switched Document Mode to IE7.
Now the error occured in IE9 too. When inspecting HTML elements I saw that the elements had some styles from bootstrap.css in IE7 mode, but not all the styles they had in IE9 mode.