Results 1 to 5 of 5
- 12-31-2014, 05:31 AM #1
Member
- Join Date
- Dec 2014
- Posts
- 1
- Rep Power
- 0
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 08:42 AM. Reason: added [code] ... [/code] tags
- 12-31-2014, 08:45 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Re: little test program, any opinions or feedback?
A few remarks: why are you doing this:
Java Code:variable= ("a String literal value");
Java Code:variable= "a String literal value";
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 01-05-2015, 11:01 AM #3
Member
- Join Date
- Jan 2015
- Posts
- 6
- Rep Power
- 0
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..)
- 01-05-2015, 11:04 AM #4
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: little test program, any opinions or feedback?
Well then you might be interested in this awesome article:
https://crackstation.net/hashing-security.htm"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 01-05-2015, 04:36 PM #5
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.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
-
My first Java Program Opinions, Suggestions...
By fredlo2010 in forum New To JavaReplies: 10Last Post: 01-13-2014, 05:00 PM -
Requesting feedback on my first Java program.
By DLorien in forum New To JavaReplies: 5Last Post: 12-11-2013, 12:33 AM -
Palindrome Test Program
By Zelaine in forum New To JavaReplies: 5Last Post: 08-27-2013, 04:22 AM -
test program
By azaaza0909 in forum New To JavaReplies: 9Last Post: 07-17-2012, 11:50 PM -
Need feedback for my program.
By Pojahn_M in forum New To JavaReplies: 3Last Post: 08-12-2011, 09:12 PM
Bookmarks