Welcome to Gaia! ::

Lanackse-Kanvae
1. Name your variables something sensible. Nothing is worse then revisiting projects and wonder what the ******** BLAHBLAH was meant to do.

2. Pay attention to the reserved words in your language to avoid accidentally naming variables as them and then wondering why your program went wrong. Reserved words are words reserved by the language for specific purposes. For example, If and Else are reserved for selection loops

I don't think I'll run into frustrating BLAHBLAH variables or reserved words on any language (as far as I know) because I name my variables as follows:

tVar = A temporary variable.
lVar = A local variable.
gVar = A global variable.

So hopefully, that should keep me away from crossing over to reserved words. Plus it would also help me determine if I intended a certain variable to be global, temporary, etc. 3nodding

Lanackse-Kanvae

3. Plan. Plan. Plan. Plan what your program will do and how it will do it. This includes any "modules" or APIs that you might be using or referring to. After you've planned out what the program will do, write it down in what is known as structured language. Sample given below for a dice roller.

Structured language sample

Create variable "rollDice"
Create variable called "modNumber"
Create a variable called "total"
Bring up a message asking the user what dice they want to roll and then refer to the rolling module to get it and bring it back here.
Bring up a message asking the user what they wish to add to the result of the rolls and put that into the variable "modNumber"
total = rollDice + modNumber
Bring up a message saying "You rolled (total) on this roll"

Ahh this is one of my weak points. You see, when I open up a code editor to start on a project (not work related) I basically just start coding and let my thoughts unfold as to what I want to code as I'm coding it. Sort of like just go where my mind takes me kind of thing. sweatdrop
Sitwon's avatar
  • 50
  • 100
  • 150
Shedo Chung-Hee Surashu
I don't think I'll run into frustrating BLAHBLAH variables or reserved words on any language (as far as I know) because I name my variables as follows:

tVar = A temporary variable.
lVar = A local variable.
gVar = A global variable.

So hopefully, that should keep me away from crossing over to reserved words. Plus it would also help me determine if I intended a certain variable to be global, temporary, etc. 3nodding
That sounds like a variation on Hungarian notation. It's generally perceived as a bad idea. Even without encoding it in the name, there should never be any confusion about what scope a particular variable has.

Also, Java doesn't have "global" variables, the closest it has are public static final variables. As with C's constants, the convention is to write those in all caps. Class names should always start with a capital letter and be CamelCase. Every other identifier should start with a lowercase letter and is typically still camelCase. You should never need to encode any other type or scope information into the variable name because it should be obvious based on the name of the variable and the context where it's used what its type and scope are.


Shedo Chung-Hee Surashu
Ahh this is one of my weak points. You see, when I open up a code editor to start on a project (not work related) I basically just start coding and let my thoughts unfold as to what I want to code as I'm coding it. Sort of like just go where my mind takes me kind of thing. sweatdrop
That's fine. You don't really need to plan everything out up front. More important than planning is having lots of short iterations.

1. Write a little bit of code.
2. Save it. (If you use a version control system, check it in.)
3. Try to compile it.
4a. If you get errors, fix them and jump back to 3.
4b. If it succeeds, test the part you just wrote to make sure it's doing what you expect.
5. Jump back to 1.

You should be doing this early and often. Start from hello world, make sure it works, then change it a little, make sure it still works, then change it a little more, make sure it still works, ... etc. What you should NEVER do is write out a lot of code according to some plan only to find out at the very end that you made some mistakes and have to go back and fix them. I've seen coders who try to write too much without iterating and they spend 1 hour writing their code and 2 hours fixing compiler errors to make it run. It's sloppy, it's slow, it's dangerous. Don't be that guy.
psychic stalker
Java is itself a virtual machine. That's how you can write a Java program and have it run "unmodified" on any computer. The virtual machine runs the program. That's simply how it works.

So, no, Java isn't "natively supported" anywhere. But the virtual machine... That is natively supported everywhere.

And NetBeans is a Java application, so it runs within that same virtual machine.

Edit: I think that unless you're on Lion, it should be already installed?
If not, I'd suggest you install the Java 6 JDK, not Java 7. There are some compatibility problems with 1.7.
Java 1.0 is supported natively by Windows XP I think. MS had their own implementation and there were problems caused by it I think.
29582351c3
psychic stalker
Java is itself a virtual machine. That's how you can write a Java program and have it run "unmodified" on any computer. The virtual machine runs the program. That's simply how it works.

So, no, Java isn't "natively supported" anywhere. But the virtual machine... That is natively supported everywhere.

And NetBeans is a Java application, so it runs within that same virtual machine.

Edit: I think that unless you're on Lion, it should be already installed?
If not, I'd suggest you install the Java 6 JDK, not Java 7. There are some compatibility problems with 1.7.
Java 1.0 is supported natively by Windows XP I think. MS had their own implementation and there were problems caused by it I think.
I thought that was removed from XP after the Sun lawsuit.
psychic stalker
29582351c3
psychic stalker
Java is itself a virtual machine. That's how you can write a Java program and have it run "unmodified" on any computer. The virtual machine runs the program. That's simply how it works.

So, no, Java isn't "natively supported" anywhere. But the virtual machine... That is natively supported everywhere.

And NetBeans is a Java application, so it runs within that same virtual machine.

Edit: I think that unless you're on Lion, it should be already installed?
If not, I'd suggest you install the Java 6 JDK, not Java 7. There are some compatibility problems with 1.7.
Java 1.0 is supported natively by Windows XP I think. MS had their own implementation and there were problems caused by it I think.
I thought that was removed from XP after the Sun lawsuit.
So, why is it that Apple has their own virtual machine? Or are they just delivering the official JVM with their OS?
The20
psychic stalker
29582351c3
psychic stalker
Java is itself a virtual machine. That's how you can write a Java program and have it run "unmodified" on any computer. The virtual machine runs the program. That's simply how it works.

So, no, Java isn't "natively supported" anywhere. But the virtual machine... That is natively supported everywhere.

And NetBeans is a Java application, so it runs within that same virtual machine.

Edit: I think that unless you're on Lion, it should be already installed?
If not, I'd suggest you install the Java 6 JDK, not Java 7. There are some compatibility problems with 1.7.
Java 1.0 is supported natively by Windows XP I think. MS had their own implementation and there were problems caused by it I think.
I thought that was removed from XP after the Sun lawsuit.
So, why is it that Apple has their own virtual machine? Or are they just delivering the official machine with their OS?


Pre-lion they developed and supported the Apple JVM, but as of lion it's separate from the OS in the same way as in windows.
Sitwon
That sounds like a variation on Hungarian notation. It's generally perceived as a bad idea. Even without encoding it in the name, there should never be any confusion about what scope a particular variable has.

Does that mean I have to stop using it? I personally don't have any problems remembering what the intended use for a variable is. I just want to mark it so that it looks uniform. I find that it's easier for me to read code if it follows some sort of format, and unfortunately(?) that's what I've grown to get used to.

Sitwon
Also, Java doesn't have "global" variables, the closest it has are public static final variables. As with C's constants, the convention is to write those in all caps. Class names should always start with a capital letter and be CamelCase. Every other identifier should start with a lowercase letter and is typically still camelCase. You should never need to encode any other type or scope information into the variable name because it should be obvious based on the name of the variable and the context where it's used what its type and scope are.

I see. I wouldn't have known this earlier.

Thank you for all the help you been giving me as of this thread. It has taught me quite a bunch. smile
Sitwon's avatar
  • 50
  • 100
  • 150
Shedo Chung-Hee Surashu
Sitwon
That sounds like a variation on Hungarian notation. It's generally perceived as a bad idea. Even without encoding it in the name, there should never be any confusion about what scope a particular variable has.

Does that mean I have to stop using it? I personally don't have any problems remembering what the intended use for a variable is. I just want to mark it so that it looks uniform. I find that it's easier for me to read code if it follows some sort of format, and unfortunately(?) that's what I've grown to get used to.
There's no law that you have to stop doing it. As long as it's a valid identifier the compiler won't complain if your variable name is in the proper style or even if it makes any sense.

On the other hand, if you intend to share code with any other developers, or want to be consistent with the standard libraries and other libraries you start using, then you should probably follow the same rules they use.
http://www.oracle.com/technetwork/java/codeconvtoc-136057.html
psychic stalker
29582351c3
psychic stalker
Java is itself a virtual machine. That's how you can write a Java program and have it run "unmodified" on any computer. The virtual machine runs the program. That's simply how it works.

So, no, Java isn't "natively supported" anywhere. But the virtual machine... That is natively supported everywhere.

And NetBeans is a Java application, so it runs within that same virtual machine.

Edit: I think that unless you're on Lion, it should be already installed?
If not, I'd suggest you install the Java 6 JDK, not Java 7. There are some compatibility problems with 1.7.
Java 1.0 is supported natively by Windows XP I think. MS had their own implementation and there were problems caused by it I think.
I thought that was removed from XP after the Sun lawsuit.
I am fairly certain it works the same way as MSO 2007 and the XML lawsuit. If you already had it you keep it, only new distributions have it removed.

Quick Reply

Submit
Manage Your Items
Other Stuff
Get Items
Get Gaia Cash
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff