What’s the best way to name a css class:
bold-text? Is there any difference between MVC’s
TextBoxFor? Or between a
DetailedRowText property and
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.