Naming by Purpose or by Effect

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.

Let’s look closer at the examples listed above.

Using a Bit of Luck to Track Down CSS Parse Errors in IE7

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.

Recently I had trouble with Twitter Bootstrap in IE7.

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.

Toggle mode

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.

Software Development is a Job – Coding is a Passion

I'm Anders Abel, a systems architect and developer working for Kentor in Stockholm, Sweden.

profile for Anders Abel at Stack Overflow, Q&A for professional and enthusiast programmers

The complete code for all posts is available on GitHub.

Popular Posts

Archives

Series

Powered by WordPress with the Passion for Coding theme.