Identifier naming conventions

Today, one of the more relaxed weekend day in these hectic – every day the time runs out – IT business, I thought about naming conventions and the ones I already use in my projects.

In the last few month I have written lots of production code in different programming languages and recognized that besides of all the conventions we use to format source code, I am missing naming conventions for identifiers.

It is not about writing the first letter in lower or uppercase, it is more about specifying a general terminology so that identifiers express more clearly what we can expect from a source code construct.

One older example for identifier method naming are the get and set prefixes to implicitly express the access encapsulation of a simple variable by using methods.

If I remember correctly, years ago, I sometimes felt that a get was not enough and so I introduced the prefix query to express either that the returned type of the method is optional (may be null for example) or that the execution time is costly in the given context (for example a database query).

Then I found that read is a good prefix for creating data from a data source (like a string). I could have used the parse prefix, but it would imply some implementation detail. read had the implied semantics, that any error detected in the process is exposed by throwing an appropriate exception.

An extension to read is the import prefix I use. import works like read, but implies the option to ignore and log non-critical errors in the data source.

One more example: I use take to take over some kind of data from one object to another. The data returned by take is always removed from the object where the take method is called. I use it mainly for retrieving and removing queued or temporary values.

Another type of identifier I am missing conventions for, are class names. I think a good source for inspiration is the terminology introduced by software design patterns.

I would like to see some kind of standard, so that every developer is capable to make some general assumptions when looking at foreign source code.

Some people may argument that a standard would restrict the freedom of a developer to choose identifier names. But in my opinion, a standardization of identifiers names is long overdue and would offer a significant improvement of code readability.

I wish you a happy weekend!