• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help me to improve my code

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic