I've Learned About A Few General Java/Programming Conventions
by
, January 29th, 2012 at 04:51 PM (1252 Views)
First of all, thanks to the following members for helping me out thus far. I very much appreciate your time and effort and I've decided to take everything on board.
First of all, KevinWorkman told me of the importance of implementing braces on all statements (If Statements, Switch Statements, etc) regardless of whether there's only one line's code after the condition. If you don't implement braces around these statements and you decide later that you want to add another line of code into a statement, there's a chance you're going to forget to insert your braces. Basically, we do this just to prevent bugs from appearing at compile time.
Kevin also addressed a question I had about Switch Statements. Instead of using an If/If Else Statement, we use a Switch Statement when we know exactly what one of the operands are ahead of compiling.
JavaPF then mentioned he would allow me blogging permissions so I could make this an official blog. Hopefully, I'll be moving this blog to an official blog in the near future.
Norm and Mr.777 then backed up Kevin to cement the importance of using braces always.
Norm then made two very useful observations about my programming style. First, he made aware to me the fact that classes should start with a capital letter. Instead of using class1, I should have been using Class1. I'll make sure I use proper capitalisation in the future. Norm, I presume that if the name of the class has two words, so to speak, that the first word isn't capitalised and the second is? By this I mean, startRendering. If we were to use that as a class name (for whatever reason), it would be as is instead of StartRendering? Maybe I'm getting this confused with the naming conventions for variables. I'd appreciate if you could clear that up.
Norm then pointed out that I clustered my code together too much. An example being, if(this==that). I should be spacing it out some more and implementing more white space: if(this == that). I had been under the impression that it wasn't really a big deal whether you made use of spacing or not, but I guess it only makes sense to space it out. If not for yourself, for others.
That's all for now. I'll be covering some more in-depth information on the use of multiple methods in my next post.
Thanks everyone,
JD1