I’m learning how to program in Java, and at the same time I’m tutoring students in Visual Basic. So, as I learn things, and as I help them to learn things, I plan on posting them here. I will identify the subject as Java or Visual Basic (or if it’s applicable to both equally, I won’t identify it).
The most important thing to know is that you need to make sure you find out the preferred standards for the language you are learning. Although I would like to see a standard naming convention, you won’t find a totally standard one yet. The closest thing is the Berkley style.
Some examples of needing to know how the language prefers things are listed below.
In Visual Basic:
Variable names start with a three letter prefix denoting their data type. dbl for Double, str for String, cnst for Constant (yes I know it’s four letters), int for integers. This also applies to objects and classes. For example, lbl for label, txt for textbox, cls for class, or btn for butons.
You declare variables using a DIM statement. The syntax is Dim variablename As datatype. For example, Dim intNewNumber As integer
The variables are required to be declared before the first line of code (in the declarations section).
You don’t use prefixes in your variable names. However, you still use the camelCase and make the variables descriptive.
The declaration is type variable = new type;. For example, Integer newNumber = new Integer;
The variables should (but are not required to) be declared before the first line of code. They are required to be declared before you use them the first time. It’s good practice to declare them at the top, so you don’t have them scattered throughout the application (especially if it’s a long application).
Visual Basic is typically taught as a GUI (Goo-ey) type of application. This is because it’s designed to resemble Windows applications. There are some non-GUI apps (such as asp.net webpages), and it does use behind the scenes stuff.
Java is originally a console type of application (read command prompt). It does have the GUI capability, but you don’t see that very often. The most common use for Java is “Server side” applications, which are presented in a web browser. Hopefully as more people discover the functionality of the GUI in Java, we will see more apps created for it. This is especially beneficial, since Java runs on virtually any platform—where Visual Basic mainly runs on Windows-based platforms (not withstanding mono or other attempts to port it to Linux or other platforms).
It should be noted that I use Visual Studio 2008 for Visual Basic, and Netbeans 6.7 or 6.8 for Java. You can get these from http://www.microsoft.com/visualstudio or http://www.netbeans.org respectively.
Have a great day:)