Tip Bank

DevX - Software Development Resource

Introspection of classes

Question: In Java using the java.lang.reflect classes, one can find out the name, class, and methods of an object simply by having a reference to that object. Is there a

DevX - Software Development Resource

Passing a unction as an argument

Question: How do I pass a function as a parameter? Answer: First, let’s distinguish between a parameter and an argument. The parameter is the type of the object passed. An

DevX - Software Development Resource

Strong Types

Question: How do you make the compiler generate an error when a variable is set to a value outide the range of the constrained type? For example; strong x; //strong

DevX - Software Development Resource

Extract null-delimited strings

Most API function that return a string require that you pass a buffer where they can place the result as a null-terminated ANSI string (a.k.a. ASCIIZ string). The calling code

DevX - Software Development Resource

Count substrings with the Replace function

You can often use the Replace function in a smewhat unorthodox ways to simplify (and sometimes optimize) your code. For example, in order to count the number of occurrences of

DevX - Software Development Resource

Avoid append operations with the Replace function

I find the Replace function very useful when I want to avoid too many append operations just to insert non-printable characters. For example, the following statement: MsgBox “Disk not ready.”