06-05-2012 11:04 AM - edited 06-05-2012 11:20 AM
If I can just chip in here.
There is always this sort of debate regarding best practice verses efficient coding, and I would throw in ease of understanding and ease of development into the mix. To answer questions on this forum, I focus on the later, as the majority of people here are struggling to understand BlackBerry without this being complicated by other factors, such as design patterns or Permissions requirements. Not a great justification I know.
And I have had to deal with code that was coded with all the best practices, including MVC and asynchronous messaging, which was failing and extremely difficult to debug because the implementation was done badly. So I am very cautious about attempting to explain this sort of concept in a forum. Even people who think they know how to do this, and have studied it at University, will get it wrong.
And just to clarify, in a post above, I mentioned that you can use the UiApplication as a hub. I believe this is the comment that prompted the debate. Note that the OP was intending to use this Object as a state machine anyway, so it seemed logical to suggest that they could send the messages directly to it. Global Events end up there (or in a class that you obtain from the UiApplication Object) anyway. They could replace the postGlobalEvent(), with a method that obtained the UiApplication, obtained the GlobalEventListener from it, and then invoked eventOccurred() directly (or on a separate Thread). I suspect this has has as much abstraction/modularity/separation as the Global Event implementation, without the 'overhead' of being shipped to all Applications.
Other peole have chipped in while I was pondering. One last comment
To SImon's comment "J2me is over a century old,". I think you mean "so last century......."
"Peter and I are by no means perfect developers."
Simon is much better than me!
"let’s not get into a flame war over it" Agree, let me also add I think the comments are perfectly justified and useful. Thank you for making them.