• Post Reply Bookmark Topic Watch Topic
  • New Topic

Organizing My Code  RSS feed

 
Levi Neuxell
Ranch Hand
Posts: 41
Clojure Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it unorthodox to break up my code as such..?



Please, if you see anything else here that's unorthodox or just bad coding please tell me. (I think the main issue with my code is probably the arrays of buttons, panels, frames and labels.)
 
Daryl Cofer
Greenhorn
Posts: 19
Eclipse IDE Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Storing your GUI components in an array adds a layer of obscurity if you are accessing individual components within the array.
The obscurity could be avoided perhaps, if you used enums to reference the indices of your button and panel arrays and would ONLY be effective if they are stored in a particular order and never re-arranged (seems like a nightmare to me).

I believe that you should only use arrays for operations that you perform to each component (ex: foreach loop to clear text on all buttons in an array). Otherwise, just reference them via their name.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using a switch to decide what sort of Components to display? That looks peculiar. Also using that anonymous class with multiple ifs gets you the bad features of anonymous classes and of multiple ifs without the good features of either.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!