Forums Register Login

Help me to improve my code

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 574 times.
Similar Threads
Request for comments / critique on Go code
Help me with this tcp proxy..
Fastest chess?
Help with Spring / Netbeans tutorial
Directed Graph Question(s)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:14:20.