Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Style for ActionListener  RSS feed

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
Which style is better

OR

In First case you have lots of if statements and in second case you have lots of inner class.
So which style is better and why?
Thank you
Garandi
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer the second because it is more readable, the result of the button press appears close in the code to the button. The only drawback is that there is a small bit of overhead because more classes have to be loaded. This is really pretty negligible amount, though.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nate,
I have been enjoing your comments in Javaranch.
Thank you
Garandi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!