Best Coding Practices – Naming Conventions
There are a lot of people who say that you must follow a traditional pattern or a notation like Hungarian notation, but I feel it is rather better to establish a naming convention within your project and stick to it, of course, it should be documented somewhere as well. This way any new developers to the team will be able to read the code quickly as there is an imposed standard. In my current project we use the following naming conventions:
namespace MyNameSpace
{
public class MyClass
{
// Constructor
public MyClass()
{}
// Private members
private int _myPrivateMember = 1;
// Public & Protected Members
public int myPublicMember = 1;
protected int myProtectedMember = 1;
// Methods
public int MyMethod(int a, int b)
{
return a + b;
}
// Properties
public int MyProperty
{
get { return _myPrivateMember; }
set { _myPrivateMember = value; }
}
}
}
Internal variables within methods names are not really governed by our naming convention but the generally accepted idea is that someone who doesn’t know what it is used for, should be able to see what it is used for by the name.
While it is perfectly acceptable to use Hungarian notation, I prefer project specific conventions for naming. This allows team members to draw up their own convention, which in turn makes it more readable to the team, especially if team members need to learn a generic convention that they don’t know.
There is a downside to developing your own convention for the project. The convention could make no sense to outsiders reading the code, or it could be very lax. Developers should always get one or more developers who aren’t part of the project and definitely did not partake in the drawing up of the convention to review the conventions at some point to make sure that they are not internalising the convention, and that it is readable.
Mac or PC ?
My laptop, which is about six years old, has finally given up on life and the battery is dead. I have tried to get a new battery but as I suspected there are none available in South Africa nor do they make them any more. So I have to take the plunge and get a new laptop, even though I have a desktop at home, I just need to have a laptop when I travel and for home with email, as I use my desktop for development.
I have always been an Apple fan but just have not been able to afford them but now I might be able to. I have been looking at the MacBook Pro 13” (with 250 gig HDD, four gigs of memory), and the normal basic entry level MacBook (with 250 gig HDD, two gigs of memory), although I don’t like the white body, plus I like the option of taking the MacBook Pro with four gigs of memory instead of two.
but there are the same options in the PC laptop world, for a cheaper cost, which are big pluses for me, but those are really the only benefits I can think of, if I want better specifications then I will start looking at the same or higher prices than the MacBook and MacBook Pro. While I agree that for 16 grand, I cat get the MacBook Pro 13” with four gigs of memory and 250 gigs HDD, but for 16 grand I can get a seriously good PC laptop from Dell, Lenovo, and Toshiba.
What still brings me back to paying the price of the MacBook and MacBook Pro is that it is an apple, so it is stable, the OS manages the resources much better than any PC laptop can and ever will while running Windows, and it’s an APPLE!
So I foresee myself having to find 16 grand somewhere in the near future to get a MacBook, cause they are fantastic machines and lets be honest, they do look really nice!
