• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me to improve my code  RSS feed

 
James Taunt
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been programming in Java for quite awhile, and would like to enhance my Java skills. Could anyone check my repository and see any area of improvements and what should I try to learn?
https://github.com/hahajoker181/Java-Text-Base-Game/blob/master/src/textbase/hk/hahajoker181/Main.java
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Style-wise:
1. Indentations are too big. Java code usually uses four spaces for each indentation level.
2. Variables are using underscores. Standard convention is to use camel case and start with lowercase, no underscores. I have to admit that I find underscores more readable but I follow convention first. Did you program in Python before?

Structure-wise:
1. Everything is in main() -- not good. Would use methods to break things down into smaller chunks of functionality. Have you learned about methods yet?

Otherwise, it's relatively clean and appears to be something that can easily be refactored.
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello James, welcome to the Ranch!

You will probably get a lot more out of a site like this by asking specific questions about a problem you are having or if there is a particular area of your code that you think could be improved. In those cases I encourage you to post your code here for us to see, along with whatever question you have about it.

Asking us to go looking around your github account for a general code review is unlikely to get the response you would want.

Edit: I stand corrected.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:Edit: I stand corrected.

Sorry, Tim - I'm in some kind of funk and been feeling the need to review code, any code, lately. I did just give the code a cursory look.
 
James Taunt
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:Style-wise:
1. Indentations are too big. Java code usually uses four spaces for each indentation level.
2. Variables are using underscores. Standard convention is to use camel case and start with lowercase, no underscores. I have to admit that I find underscores more readable but I follow convention first. Did you program in Python before?

Structure-wise:
1. Everything is in main() -- not good. Would use methods to break things down into smaller chunks of functionality. Have you learned about methods yet?

Otherwise, it's relatively clean and appears to be something that can easily be refactored.


I did Python before, and I guess, I could create a new class and just put all the methods in that class, since most of space is being taken by the user input.


Tim Cooke wrote:Style-wise:
Hello James, welcome to the Ranch!

You will probably get a lot more out of a site like this by asking specific questions about a problem you are having or if there is a particular area of your code that you think could be improved. In those cases I encourage you to post your code here for us to see, along with whatever question you have about it.

Asking us to go looking around your github account for a general code review is unlikely to get the response you would want.

Edit: I stand corrected.


Thanks, I guess next time I use for questions.


James Taunt
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!