Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By gimbal2
  • 1 Post By KevinWorkman

Thread: little test program, any opinions or feedback?

  1. #1
    Jason8BMX is offline Member
    Join Date
    Dec 2014
    Posts
    1
    Rep Power
    0

    Default little test program, any opinions or feedback?

    Java Code:
    import java.util.Scanner;
    public class test{
    	public static void main(String[] args){
    		String username;
    		String signup;
    		String setup;
    		String email;
    		String pssword;
    		final int length = 6;
    		final int length2 = 8;
    		Scanner input = new Scanner(System.in);
    		setup = ("Welcome to Test.net");
    				System.out.println(setup);
    				signup = ("Please enter your email to get started:");
    						System.out.println(signup);
    						email = input.next();
    						while (email.length() < length2){
    							System.out.println("this is not a valid email");
    							email = input.next();
    						}
    						System.out.println("now your username");
    						username = input.next();
    						while (username.length() < length){
    							System.out.println("your username needs to be more than 6 letters");
    							username = input.next();
    						}
    						System.out.println("now your password");
    						pssword = input.next();
    						while (pssword.length() < length){
    							System.out.println("your password needs to be more than 6 letters long, please enter it again");
    							pssword = input.next();
    						}
    				System.out.println("Here are your account details:");
    				System.out.println("username: " + username);
    				System.out.println("password: " + pssword);
    				System.out.println("email: " + email);




    This is the code from one of my test projects. I am starting to program and chose to learn java. Please let me know if I can improve on anything or if this is a good program for just a few days of java. Thanks!
    Last edited by JosAH; 12-31-2014 at 07:42 AM. Reason: added [code] ... [/code] tags

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: little test program, any opinions or feedback?

    A few remarks: why are you doing this:
    Java Code:
    variable= ("a String literal value");
    instead of simply this:
    Java Code:
    variable= "a String literal value";
    Also, your indentation style is confusing.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Monte is offline Member
    Join Date
    Jan 2015
    Posts
    6
    Rep Power
    0

    Default Re: little test program, any opinions or feedback?

    if you work with passwords, you could consider using hashes, because save a password as cleartext in a string is not very secure^^ (but i should notice i have no experience with that..)

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: little test program, any opinions or feedback?

    Quote Originally Posted by Monte View Post
    if you work with passwords, you could consider using hashes, because save a password as cleartext in a string is not very secure^^ (but i should notice i have no experience with that..)
    Well then you might be interested in this awesome article:

    https://crackstation.net/hashing-security.htm
    Monte likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    15

    Default Re: little test program, any opinions or feedback?

    You haven't told us what this program is supposed to do, and you don't include any comments. This makes it harder for people who have to work with your code (namely us). You should get into the habit of either using comments, or always including an explanation of code when you post it.

    You should also use standard naming conventions- classes start with an upper-case letter, methods and variables with a lower-case letter. This also helps other people understand your code.

    Like Jos said, your indentation is confusing. Again, this makes it harder for other people to understand your code.

    You might consider creating a method that takes parameters for the different messages, maybe use an Account object to encapsulate the data.

    But really, if you're just starting out, I wouldn't worry too much about making sure your syntax is perfect. Does this program do what you want? Cool. Do you understand exactly how it works? Cool. Move on to the next thing.

    No matter how perfectly you write your code now, it's going to look like garbage to you in 6 months. This is a sign of your improvement, and will stay with you for the rest of your programming career. You're much better off spending your time trying the next thing out than trying to write perfect code.
    SurfMan likes this.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. My first Java Program Opinions, Suggestions...
    By fredlo2010 in forum New To Java
    Replies: 10
    Last Post: 01-13-2014, 04:00 PM
  2. Requesting feedback on my first Java program.
    By DLorien in forum New To Java
    Replies: 5
    Last Post: 12-10-2013, 11:33 PM
  3. Palindrome Test Program
    By Zelaine in forum New To Java
    Replies: 5
    Last Post: 08-27-2013, 03:22 AM
  4. test program
    By azaaza0909 in forum New To Java
    Replies: 9
    Last Post: 07-17-2012, 10:50 PM
  5. Need feedback for my program.
    By Pojahn_M in forum New To Java
    Replies: 3
    Last Post: 08-12-2011, 08:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •