The Code Style Used in This Book
Code conventions vary, and you should stick to the convention followed by your programming team or organization. Here, we differentiate code from the regular text by using a different font style (code). We avoid Hungarian notation for variable names and instead use the Java style. For example, we use
int count;
instead of
int m_IntCount;
Method names follow Pascal casing instead of Java's camel casing. So the Java method name
getName()
would be translated as
GetName()
Loops and control flow statements follow a slanting style, where open braces appear at the end of the line and close braces appear at the beginning of the line:
for (int i = 0; i < 100; i++) {
//Code goes here
}
We have commented the code in strategic places where it is not obvious why a particular approach was taken. We feel that the code should be as self-explanatory as possible. This can be achieved by giving meaningful names to variables and methods so that the intent of the method is conveyed without additional comments. For example, the intent of the following method is obvious:
public void PrintProperties(object o)
The code listings revolve around explaining one or two concepts. We have tried to maintain the focus of the code listing while keeping it interesting. When a concept does not deserve a full-blown class, we use code snippets.
|