Tip Bank

DevX - Software Development Resource

Passing unmodifiable arguments as constobjects

Passing large objects by value as function arguments is very inefficient. On the other hand, passing them by reference/address is dangerous since it enables the callee to change its arguments

DevX - Software Development Resource

Prefer References Over Pointers

Even experienced C++ programmers who have prior experience with C tend to use pointers excessively whereas references may be a better choice. Pointers may result in bugs like the following:

DevX - Software Development Resource

Copy constructor and operator= go together

If you do not define a copy constructor and operator = , the compiler will create them automatically for you. However, there are cases when you have to define them

DevX - Software Development Resource

Better alternative to #define constants

Using #define to create macro constants is not ideal. Macros are substituted by the preprocessor, so the compiler usually cannot detect anomalies such as type mismatch (see example); furthermore, most

DevX - Software Development Resource

Explicit destructor invocation

One of the good things about destructors is that they are called automatically. There are rare cases, however, when you want to invoke an object

DevX - Software Development Resource

Make the Right Comparison

Although Java’s String package is a lot more friendly than C’s string handling, you can still find yourself surprised by its behavior at times. Consider this code: import java.lang.String;public class

DevX - Software Development Resource

What are we Looking at?

To present your applet in a visually pleasing way, it’s often handy to know the size of the screen that’s available for output. Fortunately, a built-in AWT function makes determining