My only addition to that would be that I've run into problems on certain handsets (I want to say older Samsungs, but I'm not 100% sure) where we had to move a lot of code out of the constructor because having it there crashed the phone due to what appeared to be internal KVM corruption. As I recall, it was the loading of all our in-game text from a text file that croaked the phone. As a result, we do as little as is practical in the constructors now.
Tom Hubina VP of Studios Mofactor, Inc. 30423 Canwood St. Suite 205 Agoura Hills, CA 91301 818 706-1573 (office) 805 551-9645 (cell) > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:eclipseme- > [EMAIL PROTECTED] On Behalf Of Hunter, Kevin > Sent: Monday, October 23, 2006 11:22 AM > To: Russel Winder; EclipseME Users > Subject: Re: [Eclipseme-users] On programming style > > There are far fewer listeners running around in J2ME than there are in > J2SE, and what listeners there are tend to be more "tightly bound" to > objects (IMHO) than is the case in J2SE. Thus, having an object act as > its own listener tends to make sense. Frankly, I've never coded a > CommandListener as a separate object, or even as an anonymous object. > As you say, it doesn't seem to make sense to create an extra object for > this, and I think it just makes the code murkier. Whether The Powers > That Be would consider that "good" or not, I do. > > As far as constructor vs. startApp for setup, that seems to me to be > largely a matter of choice. Personally, I tend to do my main object > initialization in the constructor, but do more "application-like" stuff > (i.e. figuring out what screen should be displayed first) in startApp. > That's simply a personal preference, and I could just as easily argue > for a different division of labor. In the long run, neither one should > cause "a lot more resource activity" - you're probably going to have the > same code in your app whether it's called from the constructor or from > startApp, and both functions have to run before anything happens from > the user's point of view anyway. About the only "good" argument I can > give for how one might choose to separate is to note that startApp is > actually called both when you're starting and also when you're resuming, > so you might consider putting the kind of stuff in startApp that would > be associated with both cases, and putting one-time-only stuff (needing > to be done on start, but not resume) in the constructor. > > But that's just my $0.02. > > Kevin Hunter > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Russel Winder > Sent: Monday, October 23, 2006 11:48 AM > To: EclipseME Users > Subject: [Eclipseme-users] On programming style > > I hope this isn't considered too far off topic... > > In a Java SE context, Most people try to separate out data objects and > listener objects often with anonymous classes and Mediator pattern. All > the Java ME software I have seen to date seems to put all the listener > activity in the same class, and object, as the application. > > I am guessing this is to minimize the number of classes and objects? Is > this considered good Java ME style? > > Another thing I have noticed is two definite trends with respect to > startApp and pauseApp. Some people try to maximize the amount of work > done in the constructor of an application class and minimize the work > done in the start and pause methods. Others seem to put as little as > possible in the constructor and everything in the start and pause > methods seemingly causing a lot more resource activity to start and stop > an application. > > It is probably that I haven't read enough books on Java ME (they are in > the mail), so far I have done all my Java ME stuff from the manuals, so > I probably haven't picked up the idioms. Is one of these two approaches > `The Right Way' ? (For resources that remain from creation to > destruction, of course.) > > Thanks. > > -- > Russel. > ==================================================== > Dr Russel Winder +44 20 7585 2200 > 41 Buckmaster Road +44 7770 465 077 > London SW11 1EN, UK [EMAIL PROTECTED] > > ------------------------------------------------------------------------ - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Eclipseme-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/eclipseme-users ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Eclipseme-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/eclipseme-users
