Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this backwards naming convention a bad idea (ie. contrary to industry standards)?

I've always reversed names so that they naturally group in intellisense. I am wondering if this is a bad idea.

For example, I run a pet store and I have invoicing pages add, edit, delete, and store pages display, preview, edit. To get the URL for these, I would call the methods (in a suitable class like GlobalUrls.cs

InvoicingAddUrl()
InvoicingEditUrl()
InvoicingDeleteUrl()

StoreDisplayUrl()
StorePreviewUrl()
StoreEditUrl()

This groups them nicely in intellisense. More logical naming would be:

AddInvoiceUrl()
EditInvoiceUrl()
DeleteInvoiceUrl()

DisplayStoreUrl()
PreviewStoreUrl()
EditStoreUrl()

Is it better (better being, more of an industry standard way) to group them for intellisense, or logically?

like image 553
NibblyPig Avatar asked Jan 13 '11 16:01

NibblyPig


2 Answers

Grouping in Intellisense is just one factor in creating a naming scheme, but logically grouping by category rather than function is a common practice as well.

Most naming "conventions" dictate usage of characters, casing, underscores, etc. I think it is a matter of personal preference (company, team or otherwise) as to whether you use NounVerb or VerbNoun formatting for your method names.

Here are some resources:

  • Microsoft - General Naming Conventions
  • Wikibooks C# Programming/Naming
  • Akadia .NET Naming Conventions

Related questions:

  • Naming Conventions - Guidelines for Verbs, Nouns and English Grammar Usage
  • Do vs. Run vs. Execute vs. Perform verbs
  • Events - naming convention and style
like image 178
JYelton Avatar answered Sep 18 '22 13:09

JYelton


Check out how the military names things. For example, MREs are Meals, Ready to Eat. They do this because of sort order, efficiency and not making mistakes. They are ready to ignore the standard naming conventions of the language (i.e., English) used outside of their organization because they are not impressed with the quality of operations outside of their organization. In the military, the quality of operations is literally a matter of life and death. Also, by doing things their own way they have a way of identifying who is inside and who is outside of the organization. Anyone unable or unwilling to learn the military way, which is different but not impossibly difficult, is not their first choice for recruitment or promotion.

So, if you are impressed with the standard quality of software out there, then by all means keep doing what everyone else is doing. But, if you wish to do better than you have in the past, or better than your competitor, then I suggest looking at other fields for lessons learned the hard way, such as the military. Then make some choices for your organization, that are not impossible but are for you and your competitiveness. You can choose big-endian names (most significant information comes last) or the military-style little-endian names (most significant information comes first), or you can use the dominant style your competitors probably use, which is doing whatever you feel like whenever you feel like it.

Personally, I prefer little-endian Hungarian (Apps) naming, which was widely seen as superior when it first came out, but then lost favor because Hungarian (Sys) naming destroyed the advantage due to a mistranslation of the basic idea, and because of rampant abbreviations. The original intent was to start a name with what kind of a thing it is, then become increasingly specific until you end with a unique qualification. This is also the order that most array dimensions and object qualifiers are in, so in most languages little-endian naming flows into the larger scheme of the language.

You are on to something. Forward, march.

like image 43
DaveWalley Avatar answered Sep 19 '22 13:09

DaveWalley