Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 28 of 28

Thread: Absolute Beginner Here, should be an easy question for anyone really.

  1. #26
    Member
    Join Date
    Jul 2012
    Posts
    56
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Re: Absolute Beginner Here, should be an easy question for anyone really.

    Quote Originally Posted by jps View Post
    So two other quick notes.
    1. Your formatting is not completely consistent, and really does not follow java convention.
    1a. Sure you dont have to follow java convention, but if you ever work as part of a team, it sure is nice if everyone speaks the same language, right? No need to be different. When I write in java, I try to stick to java convention, and when I write c++, I stick to that convention. However...
    1b. Whether or not you stick to convention, you should at least be consistent. You should always indent the same, put brackets on the line above or on their own line etc. Granted some of the formatting may have been lost from your pc to the forum...

    2. Comments. Not a single comment in the code. It is nice to see a comment at the top that describes the purpose and use of the class (program). Then once you get into the business of the code, each little body (ok not EVERY ONE) could use a little one-liner. Just a note to remember what you meant for that line to do. Sure you can read the code and figure out what it does. But what happens when it is not working, and it is not a syntax error. It is an ugly logic error. If you look at a line that says:
    total = a + b;
    It is easy to assume the total is the sum of a and b. What if in fact total was not supposed to be the sum, instead you meant to multiply. Seeing a+b may not catch your eyes as an error, so you get to share some blood with the desk for an hour while you try to get it. Throwing in a comment like //product of this and that would make a+b stand out as not what you meant to do. Ok so that very low level example is not a suggestion to comment every time you add or multiply something, but just an example of how something can look right, and be so wrong.
    I see what you mean, I'm in the Navy right now but soon I will be getting and going to school for a BA in Computer science and I want to be a programmer, so working in a team is what I want to do. Right now I'm taking courses through University of Phoenix, working on my AAGS with a concentration in programming.

    Some of the format got lost, but there are a few inconsistencies. And the no comment thing is something I will need to do, it's just I'm so excited doing all this it is hard to stop and write a note lol.

  2. #27
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Absolute Beginner Here, should be an easy question for anyone really.

    Last but not least... Your original error: java.util.InputMisMatchException
    What if a user is entering the number of employees and accidently hits 3e<enter> before realizing their fat finger hit the 3 and the e. The program crashes and leaves them there with no fun. I don't know if you have covered this topic in class yet either, but there are ways to catch such mistakes and not die from the smoke when the computer burns up. You can even go as far as recovering and asking the user for a better input than the number 3e.

  3. #28
    Member
    Join Date
    Jul 2012
    Posts
    69
    My Mood
    Relaxed
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default Re: Absolute Beginner Here, should be an easy question for anyone really.

    For the formatting, i use an ide called Eclipse, it has a really nifty build in formatter. press control shift f and everything goes where it should be. When im working together with other people we normally agree to all do that, to minimize confusion .

  4. The Following User Says Thank You to elamre For This Useful Post:

    Harrald (July 31st, 2012)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. How do I get this to work? Easy question, I'm just hopeless at it!
    By akmi5 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 1st, 2012, 01:31 PM
  2. Exception in JUnit test (easy question)
    By opium in forum Exceptions
    Replies: 1
    Last Post: February 14th, 2012, 09:09 AM
  3. Easy array question
    By surfbumb in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 3rd, 2011, 09:44 PM
  4. Quick easy Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 25th, 2011, 03:59 PM
  5. [SOLVED] Begginer Question please help ASAP! (Easy to Answer)
    By Bagzli in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2010, 10:00 PM