This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Feedback.

 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just finished this program, just looking for some opinions, is there any way i can improve this? is the coding messy? could i add more comments?

 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well at least you didn't put that pointless for loop the other person doing this same homework did. He did have the same code when n = 1 or n = 2 and you do two different things.

if (n ==1) { line2 = line5; line3 = line4;} // When there is no bytes left, changes lines.
if (n ==2) { line3 = line4; line2 = line6;} // When there is no bytes left, changes lines.

I think he made line2=line5 on both cases, might want to check your code or tell him about his error.

Besides that you can put all those strings as constants public static final declares in the class.

Public Static Final LINE_1 = " bytes of bits on the bus ";... etc instead of
String line2 = (" bytes of bits \nTake two down, \nshort them to ground. ");...

You can do away with the parenthesis.

What if caps locks is set?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic