Code readability

+1 Jake Scaife · March 4, 2015
Hi all,

I seem to be having some major issues with readability when I'm writing code in Java, using the Eclipse IDE.
So i'm just wondering if I could get some quick feedback, on ways to improve my code readability.

I've made a quick, simple grading program with a few different features - case, if, try, etc.. Any feedback on how to make my code look "better" would be greatly appreciated. ( Such as whitespace, bracket placement - etc)

/images/forum/upload/2015-03-04/5e9093f7e733373faae7247e2ddfaafb.PNG

Post a Reply

Replies

Oldest  Newest  Rating
+1 Jake Scaife · March 5, 2015
Thanks for the feedback @Arjun, I will implement those techniques from now on!
+1 Jake Scaife · March 5, 2015
@Abdullah I find that using the code tags often ignores my code indentation, which was exactly what I was focusing on in this post. Just laziness on my part, apologies!
+1 Dol Lod · March 4, 2015
Always have brace started on new lines. ie.e. Tab every time you apply braces for loops. 

while(true)
{
    System.out.println(1);
}

Align, try, catch and finailly. 

If you see that you've got huge blocks of code ex. 50 lines Try and see if you can delegate the work to a function instead. 

Wrap if things look like they are getting way too long for things like parameters, funciton calls, and initiliazing array elements through braces. 
0 Abdullah Nauman · March 5, 2015
Please the code tags. That screen shot hides a lot of your text. Especially on mobile devices.
0 Jake Scaife · March 5, 2015
I'm guessing you don't approve of my generic exception catching? :'(
  • 1

Java / Android Development

107,299 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator