Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commands

 
Danish Shaukat
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

Suppose I have three or four screens in my midlet that use the same type of command, say OkCommand.

Do you think it is a good idea to create a single okCommand object and use it with different screens. Or is it better to create separate okCommand object for each screen.

Danish
 
arnel nicolas
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me i use the same command button if it is applicable to my screen. Then i try to validate which screen currently that command was attached, in that way i can process the command action depending on the current screen.

On the other hand, you can consrve much resources by not creating too much object in the heap.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would create a single OK command and delegate the event handler to a single utility method in the MIDlet class. Or, alternatively, use a centralized CommandListener for all screens in the app.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic