I’m Portuguese and most of the software I design and develop is about concepts in Portuguese. How should I name stuff?

If I’m talking about Conta or Cliente it’s easy: Account and Customer. And what about concepts that aren’t in English or for which a translation would be unrecognizable?

When I name stuff I try to make things easily recognizable for those who read it, and this brings us to a combination of both Portuguese and English.

When someone finds in the code or documentation ContaInválidaException (names are in Unicode, it’s time to let go archaic prejudice – “conta invalida” means that the account is making something invalida and “conta inválida” means that the account is invalid) identifies immediately what it is. For a business person it’s obvious that it’s something about an invalid account and for a technology person it’s obvious that it’s some kind of exception.

Before you get too excited, according to Tom Hollander, this is really just a maintenance release addressing a small number of issues discovered since the release of 3.0. Here is a summary of the main changes:

Policy Injection Application Block

The default Remoting Policy Injector can now be replaced with alternative interception mechanisms via configuration without modifying the application block code

Call Handler attributes are now honored correctly when placed on interface methods

Fixed an issue that could cause duplicate handlers where matching rules matched both a class and its interface

Classes implementing COM interfaces (including those deriving from System.Windows.Forms.Form) can now be intercepted

TraceLogEntry class is now serializable, allowing it to be used with the MSMQ Trace Listener

Validation Application Block

Fixed an issue that prevented the PropertyComparisonValidator from working with the Windows Forms integration adapter

The message template for the PropertyComparisonValidator can now be saved using the configuration tools.

Data Access Application Block

Connection strings for OLEDB and ODBC connections can now be edited using custom dialog boxes from the configuration tools

Software factories [^] [^] [^] and other code generation tools have been taking care of writing the tedious (and, sometimes, ugly) code but, at some point, some code must be written and read by human developers. That’s why (in my opinion) the way the code is written is as much important as the language it is written in.

There are several resources about coding conventions for the .NET framework:

I have to disagree with Microsoft’s position about naming conventions of private members. In an enterprise as big as Microsoft projects start and end, people move between teams and every time someone changes team he/she is faced with the possibility of having to learn and adapt to a new set of naming conventions for private members.

IDesign goes one step further on defining naming conventions for private members. I just don’t like the convention they used. What’s the point of prefixing private member fields (not variables as in their document) with m_? What does it mean? Member? If it’s not a local method variable or a method parameter it’s a member.

Some just prefix with _. Once again, why? What does that mean?

The only reason I can find for this prefixing practice is lost in the old days of colorless IDEs, printers and books. With colorful IDEs like Visual Studio 2005 you just need to qualify instance member fields with the this (Me for Visual Basic) keyword and static (Shared in Visual Basic) member fields with (lacking of a better solution) the class name.

Lets pretend for a moment that I’m one of the prefixes. How would I do it?

i_camelCase for private instance members.

s_camelCase for private static members.

c_camelCase for private constants.

Why stop there? Let’s also prefix method variables:

v_camelCase for method variables.

Now I’m on a roll. Let’s prefix method parameters:

i_camelCase for input parameters.

o_camelCase for output parameters.

r_camelCase for by reference parameters.

The next step would be to go Hungarian and add type information to the names, right? No. Let’s stop here and get in the right track.

My Naming Conventions for C#

I Find that keeping naming conventions as simple as possible is the best way use and validate them.

Generic Reflective API

TypeMocks™ was the same tool for both the .NET 1.1 and the .NET 2.0 runtimes and they were avoiding the need to have two tools. But we already need two runtimes and two IDEs, so two versions of TypeMocks™ isn’t such an hassle. I’m glad they came to their senses about this.

I would be very happy with this last solution. But both these two solutions have have too much mocking infrastruture coded in the test code and, because the people at TypeMocks™ aren’t in the market of just making me happy, they came up with a better solution (available on Professional and Enterprise Editions only):

Generic Test Decorator

TypeMocks™ is more than just a mocking framework, and it now enables writing custom test decorators. These are test framework agnostic and it is simple to add more features to your tests. Now you can write your own version of VerifyMocksAttribute and ClearMocksAttribute (available on Enterprise Edidion only).