Need inspiration for naming classes and methods

Possible Duplicates: Anyone else find naming classes and methods one of the most difficult part in programming? What’s the best approach to naming classes?

Finding appropriate abstraction names can sometime be time-consuming, especially if your mother tongue is not english. I was wondering if there exists somewhere some sort of online glossary/dictionary describing program-related concepts. We all know about Design Patterns from GoF but I'm looking for a much more complete lexicon, including relationships between concepts.



You know that there are conventions for naming artifacts in a program?

For example, Java has come up with a pretty strong and reliable way of naming classes, methods and attributes.

Wikipedia has this to say about naming convention (not too helpful, but still interesting)

Here is a page from Central Washington University (with Java, but still helpful for other programming languages) :

Other article here :

But basically, naming a method usually start with a action, then a noun, etc.

For example:

$obj.addObservers(...);  // action, noun
$obj.setPrice();         // action, noun
$obj.getModelFromDb();   // action, noun, preposition, noun
$obj.setActive(...);     // action, noun
$obj.isActive();         // yes (true) or no (false) statement
$obj.canEdit();          // yes (true) or no (false) statement
$obj.setCanEdit();       // action, attribute
// etc.

Avoid using negative method naming, ex: $obj.cannotConnect(); which will simply confuse everyone. (This is also true when prompting, ex: "You are about to delete this file, do you want to abort?" ... choosing 'no' thinking you are going to delete a file and it was a mistake will do the opposite...)

Back to method naming;

  • your method names should be as short as possible, but avoid using acronyms, unless the method name is too long (this is a judgement call here);
  • methods should be self explanatory and self documented;
  • avoid using prefixes, unless you are working with non-OOP languages (pretty rare these days). Your prefix should be your class, or namespace, etc.
  • each method should have only one function (one purpose) if you method does more than one thing, consider splitting that method into many, and call each of them inside a method (like doActionBatch(), where 'ActionBatch' is the name of the actual action to perform; Ex: doHttpConnect()
  • etc.

A tip I may suggest is to read programs written by the community; they usual adopt best practices in naming conventions and you will get more familiar with "how methods are named"

The main thing is, be consitent with your naming conventions.

I'm a .NET developer, so I found it best to follow the design guidelines used by the .NET Framework.

Need Your Help

Programmatically scroll NSScrollView to the right

swift macos nsscrollview

Everything is in the title; I want to programmatically scroll an NSScrollView to the right so I can see the end of my document.

registering a javascript file from a master page javascript master-pages

Is there any reason why registering a javascript file from the head tags of an ASP.NET master page wouldn't work? For example, I have the following (plus many other) file referece: