Everyone
Everyone

Reputation: 2376

Is OO relevant in mobile application programming using J2ME?

Given that applications for mobile devices are expected to be small and simple, often with heavy computation off-loaded to a web-service.

Upvotes: 0

Views: 227

Answers (4)

Paul Milovanov
Paul Milovanov

Reputation: 764

As Mr. Knuth said it, "premature optimization is the root of all evil".

Similarly, just because you encounter a new platform, J2ME in this case, it makes no sense to forget everything about how to write good software and go back to the global-everything-procedural-everything-orgy.

Sure, use your brain, and don't do things that you wouldn't do on the desktop (e.g. java memleaks by spawning craploads of objects and forgetting to get rid of refs to them, or, just as bad, simply spawning loads of objects indiscriminately). Factories creating factories creating factories might however not be as stupid as it sounds, especially if the reason you're doing that is because it helps you write lots of unit tests. (And yes, do write unit tests on J2ME!)

And responding to David N. Welton a few answers up, "architecture astronaut", or over-engineering, doesn't have to ever happen if you go with the good old iterative approach -- don't make things more complex until it measurably simplifies your life.

So to sum up, my feeling is that everybody is just using the "memory and space constraints" on J2ME and Blackberry to toss the good sense out the window and write crappy, un-navigable software. I assure you that if you go the iterative way and test your app every so often you will notice when the performance becomes unsatisfactory and take appropriate measures at that point. And the chances are, the performance issue will be due to you doing something stupid and not due to the abstractions.

Disclaimer: if you ARE reading this from 1999, writing for CLDC 1.0 with 1KB of mem, or for a JavaCard, disregard all of the above. If however you're running on any feature-phone of today, you're in luck!

Upvotes: 0

David N. Welton
David N. Welton

Reputation: 1865

Sure, use OO (it is Java after all), but you have to be a little bit more careful, as space and memory are limited for J2ME. A judicious uses of classes is good, but don't go overboard with those things that have classes that create factories that generate other things, etc... etc... That's actually something I like about J2ME: you can't go overboard with the "architecture astronaut" stuff.

Upvotes: 1

Woot4Moo
Woot4Moo

Reputation: 24336

Well J2ME is Java and therefore is OO. You can write code in a procedural way in OO land, but that isn't really the point now is it? If you don't want to do OO switch to Python.

Upvotes: 0

Amber
Amber

Reputation: 527538

Object Oriented programing, in and of itself, does not imply any specific overhead. It's merely a methodology. You can create programs which use an OO design methodology which are still fast and simple, just as you can create non-OO programs which are slow and kludgy.

Upvotes: 3

Related Questions