Design Patterns, OO Design, and J2ME performance

Hello- I am a J2ME newbie. I am a design patterny/OO kind of guy using J2SE. I'm trying to create a facade for the business logic on a project I'm working on which will work on both J2ME and J2SE. I have come up with an acceptable design, but I am afraid that the bytecode may end up being way too large for J2ME. For example, I used the command pattern for some functionality, which results in many small Command classes, which is nice for extensibility and functional encapsulation, but creates extra bytecode. Another example is I like to throw specific business exceptions, however, those also require a separate class for each exception. Another example is I like to use TypeSafe enumerations, again, new, unnecessary classes.
I am aware of some workarounds (create a generic business exception, just put info into the message, don't use the command pattern, use bytes for non-typesafe constants), but I find myself resisting due to my hardcore OO/best practices tendencies. I guess J2ME is a whole different programming paradigm. How are you guys dealing with these issues? The most important issues with J2ME programming are small footprint and high performance, right? I guess I could write more procedural-ish code, but I am interested in any compromises that the OO guys here have come up with. Also, what size is an acceptable library/sdk in J2ME?
thanks,
Abraham

I'm not an OO guy, but I can definitely say that you'll will have to find some comprmises in your designs (the generic business exeption is a very good example).
Since you are making business apps, you do get some leeway on two issues:
* As opposed to games, where every cycle counts, for a business app maintainability and scalability are you usually more important than performance, so OO techniques will often be a better choice than a slightly faster implementation.
* You probably have more control over the devices you will be targetting. The most common limitation for MIDlet size these days is 64KB, so a library that more than 20-30KB probably won't be any good on these phones. But if you know your apps will be run on higher end phones you can make it a lot bigger, since they can often have MIDlets that are up to several MB in size.
shmoove

Similar Messages

  • RE: design patterns involving EJBs and JDO

    Is the idea that you specify in some config file (xml?) the methods of
    your session bean, whether its stateful or stateless, the default bean
    transaction semantics, etc, then say "go" and it generates the home and
    remote interfaces and the skeletal session bean class?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:26 AM
    To: JDO-ListServ
    Subject: Re: design patterns involving EJBs and JDO
    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----
    From: Matthew <mailto:[email protected]> Adams
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated.
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric

    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----_
    From: Matthew <mailto:[email protected]> Adams_
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated._
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric_

  • Design pattern for unprotecting and reprotecting sheets with VBA?

    Many macros can't run when a worksheet is protected, so when I develop an Excel workbook that has protected worksheets, I have to unprotect worksheets when macros are called and then reprotect the worksheets once the macro has completed.
    The current design pattern I use for this is the following:
    I look at each procedure individually and consider which sheets need to be unprotected for it to run. Then in each procedure I write:
    Sub Test()
    Dim bSheet1Protected as boolean
    Dim bSheet2Protected as boolean
    bSheet1Protected = Sheet1.ProtectContents
    bSheet2Protected = Sheet1.ProtectContents
    bSheet1Protected.Unprotect
    bSheet2Protected.Unprotect
    '''The rest of my code
    if bSheet1Protected then Sheet1.Protect
    if bSheet2Protected then Sheet2.Protect
    End Sub
    But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?

    Hi JP3O,
    I think it is a good practice to unprotect the worksheet before execute some code and protect it back after the code execute finished.
    >>But I imagine that maybe there are better ways of doing this. What is your preferred design pattern for unprotecting and reprotecting sheets with VBA?<<
    I am not able to find a better way since we always need to unproect the worksheet if some code didn't not executed successful when the worksheet is proected.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Design Patterns

    Hi,
    I am new to these forums.
    I know that there are 4 types of J2EE Design Patterns.
    1. Fundamental
    2. Structural
    3. Creational
    4. Behavioral.
    Hope that's correct. Can anyone plz tell me what's the difference between them?
    Also, examples for them. ie; Under which category mentioned above, patterns like Singleton,ServiceLocator,Session facade, DAO,DTO etc fall?
    Thanks in advance.

    BigDaddyLoveHandles wrote:
    Kumaari wrote:
    Please give me some explanation in your words.
    Thanks in advance.In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.
    Not all software patterns are design patterns. Design patterns deal specifically with problems at the level of software design. Other kinds of patterns, such as architectural patterns, describe problems and solutions that have alternative scopes.
    Better?
    Brilliant. Bravo sir, bravo

  • Complex architecture - design pattern?

    I am trying to determine which architecture, or combination woudl best suite my application: 
    The core aspect is a client receiving data from a network at variable speeds - I have this working using a producer consumer loop (data) design pattern, that starts and stops by placing it inside a case structure with start button. I'd now like to combine this with an event driven user interface, which also uses the serial port to talk to external hardware every now and then. I have that working seperately with a producer consumer (event) design pattern. I'd like to combine them and include regular events (handshaking with the external hardware) to take place whilst the producer-consumer (data) reads from the network.  
    How can I mix the two design patterns?! I'm struggling to get my head 'round this.
    Thanks

    Here is an example of two Producer-Consumers in one vi.  Notice the two queues.  One is for commands to the event loops.  The other is for the serial data loops.  When certain data is received, you can send commands to the event loop (actually to Consumer loop, 2nd from top) to cause some action.  So the user can initiate some action via event structure, and received data can also initiate some action.
    This is complex and it might not do all you want.  But its a start.
    - tbob
    Inventor of the WORM Global
    Attachments:
    DoubleProducerConsumer.vi ‏29 KB

  • A start in design pattern

    Hi guys,
    I want to start learn j2ee design pattern , i browsed net but not got any significant point from where i can start. could anybody suggest me from where should i start .
    Thanks in advance

    The Design Patterns Java Companion
    Head First Design Patterns
    Huston Design Patterns
    Overview of Design Patterns
    ~

  • Design Patterns and J2mE

    Hey,
    I do wanna know if is recommendable to use a Java Design Pattern (like Singleton, Fa�ade, etc)... in a J2ME application. I mean, a colleague of mine made a j2me application using these kind of technologies, but, when he installed in his cell phone, the application occuppied much memory. So, another guy told me that due to the limited memory space we find on these devices it's better for us to use only the MVC idea. So, is it recommendable for me to use this kind of resources???
    Thanks!

    Hi,
    it is a good programming practice to use Design patterns. But too much of design patterns results in more classes which will be a problem in j2me sometimes.
    Most of the MIDP classes uses Singleton and abstract design patterns

  • J2ME framework and design patterns

    Hi everyone.
    I'm thinking of building a few J2ME applications, and was wondering if there are any frameworks for this (i.e. for building midlets)? For web applications you have frameworks like Struts (Jakarta/apache), but I've not found anything for J2ME.
    Also, any known and proven J2ME design patterns would be of great help!
    Thanks for all your help!
    Best regards,
    Arnt

    Hi
    AFAIK there r no frameworks, you dont need them - everything you code should be as simple and straightforward as possible.
    Hmmm... proven design patterns, well, as I've found standard Java DP can't be used in J2ME, cause you need to do everything with small amount of memory and processing power. Object programming is cool, but it makes big impact on speed of code and on size of generated classes.
    And believie me, sometimes those 2-3 kb make difference (eg. on Nokia 6310i, where you have 30 KB of memory, on 3510i it's about 60KB...)
    So, one patter of which I can think about is - make your code simple :)
    regards
    Leszek

  • Best architecture and design pattern to use

    I am currently designing a moderately sized LabView application and cannot decide on the best architecture/design pattern or combinations thereof to implement.
    The program basically polls an instrument connected to a serial port continuously at a 2-10Hz rate. When operator clicks a button to start a run, the polled data is then filtered, has math functions performed on the data, writes collected data to files, and produces reltime graphs and calculates point-by-point statistics. At the completion of a run, some additional data files are written. I pretty much know how to accomplish all these tasks.
    What is also required is main-vi front panel interaction by the operator to access a database (via a C# dll with .Net) to query for specifications to apply in order to determine pass/fail status. Setup conditions also need to be changed from time to time by the operator and applied to the data in real time (ie- a measurement offset). I have prototyped the database portion successfully thus far.
    For the main vi, I started off using the Top Level Application Using Events design pattern (Event structure within a while loop). Copious use of bundled clusters and shift registers keep the database data updated. I cannot figure out how to have the top level vi concurrently poll the serial device as outlined above. The Event structure is only active when defined control values change, and use of a timeout is no help since it prevent data from being collected while the user is accessing the database. All database and setup parameters must be applied to the data as it comes in from the serial port. Error trapping/recovery is a must.
    I believe what I need is two parallel processes running under my main vi (one for database and setup, the other for polling and data processing/display, but what would be the preferred choice here?
    Revert back to a polled loop in lieu of Events, use notifiers, occurrences, user-defined events, Producer-consumer loops?
    It�s been about 3 years since I have had an application on this level (which used a state machine architecture), and a lot has changed in LabView (using 7.1 Prof Devel). I am currently having a mental block while trying to digest a lot of features I have never used before.
    Suggestions Welcome!
    Thanks.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    I suggest a (3) state machine(s) architecture. The first is the user interface. Your main VI is a good start. Another state machine handles the instrument I/O (your serial polling). The third handles all data processing. The three loops run independently. Each has a wait to allow LV's scheduler to share CPU time among the loops. I like queues or functional globals for inter-loop communications.
    This allows a lot of flexibility. Each portion can be tested alone. Each can have different timing and priority.
    Spend some time thinking about what needs to be done and plan the structure carefully before you do any coding (except for little test programs to try new ideas).
    I also like Conway and Watts "A Software Engineering Approach to LabVIEW", published
    by Prentice Hall.
    Lynn

  • Dependancy of  Appliacation Performance  on Package Design Patterns ??

    Hi
    Recently one of my collegue have suggested us to change the data base package design pattern ., i.e to design the package as per the database functionality but not as per the application functionality.
    Example to say ., to integrate all the Data retrivel Sp's into a single Package , All the Update functionality into another package so on... i was totally refused to do so as i never find as such practice in my career.,
    We design the packages as per the Application functionality i.e for each module we design one or more packages so that the developer working on that particulor module can access the Packaged objects very easily and also this will improve the Application modularity & effeciancy.
    Can any one say, what will be impacts on the Appliacation Performance prospective if i design the package as per my collegue's suggestion., and which is best approch in the application development area.
    We are working on Oracle 10gR1 and the front end is .Net .,
    Regards
    Sekhar

    I don't think the performance are the biggest problem here. I do think however the code maintenance could be a problem. Especially if your app is large, then somehow logically grouping procedures/functions with similar requirements in packages and having these groups as subsystems/modules in your application is more flexible because as your app grows, you can add another subsystem/module and another package. If you create some fixed number of packages e.g retrieval, update, insert, delete, then what you'll do for a large application? Create package Retrieval1, retrieval2 etc? Seems quite illogical.
    So I doubt there are big gains/losses from pure perfomance point, but the biggest problem is maintainability of your code.
    Gints Plivna
    http://www.gplivna.eu

  • Is design patterns to much used in j2me or wireless development?

    Hey guys,
    I do wanna know if any design patterns is too much used in J2ME development and which one of them are more used?
    Thanx
    Lucas

    Well, anything that is usable can be implemented of cource. I don't see why you you can't use them.
    Thet question what is uses morst of the time is irrelevant, since pattern are alway's dependant on what you would like to do.
    You should never use a pattern just to use a pattern!

  • Business delegate and Session facade design patterns

    Does any one tell me, what is the difference between business delegate and session facade design patterns.

    1. Session Facade decouples client code from Entity beans introducing session bean as a middle layer while Business Delegate decouples client code from EJB layer ( Session beans).
    2. SF reduces network overhead while BD reduces maintenance overhead.
    3. In SF any change in Session bean would make client code change.
    While in DB client is totally separate from Session bean because BD layer insulate client from Session beans(EJB layer).
    3. In only SF scenario, Client coder has to know about EJB programming but BD pattern no EJB specialization needed.
    4.SF emphasizes on separation of Verb, Noun scenario while BD emphasizes on separation of client(presentable) and EJB layer.
    Anybody pls suggest more differences ?

  • How to create plug and play design pattern on a environment

    Hi All,
    Help me to get a best design for my problem statement.
    Problem Statement: I have to create a platform where I should be able to plug and play different components. explaining better with example
    Example:
    1. I have to create a platform for school
    2. In this school platform we have to plug in multiple components like "Student", "Teacher", "Subjects", "ClassPeriods" etc.,
    3. These components should be easily plug/unplug and play
    4. Like, the component "ClassPeriods" want to purchase from Vendor 1 and plug it to "School" platform it should work.
    5. Incase if we want to unplug the "ClassPeriod" component provided bfy Vendor 1 from "School" platform and want to plug the "ClassPeriod" from Vendor 2. then the Design should support without any extra effort.
    Suggest me the best design pattern for the problem
    This design pattern is for ASP.Net
    Thanks,
    S.Kannan

    Sounds like you're looking at 'Composition'. As a background, and possible solution, take a look at MEF;
    http://mef.codeplex.com/
    http://pauliom.wordpress.com

  • JavaBean Models, Command Bean and J2EE Design Pattern

    Hello,
    I have read the available "How To", “Using EJBs in Web Dynpro Applications” where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
    I have developed a WD App which uses EJBs to read data from the DB.
    Let's suppose I only have two tables: BOOKS and AUTHORS.
    Let’s also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
    I also have a Command Bean which I imported in my WD App.
    My questions are:
    How should I design my Command Bean?
    Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
    Or instead should I design two Command Beans, one for each call?
    In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
    Furthermore, how should I store the data in my command bean? In instance variables?
    If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
    I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
    One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
    I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
    Some guidance or tips would be highly appreciated.
    King Regards

    I have the same problem.
    Does anyone know the solution?
    Thanks
    Davide

  • XI Design Issue- BPM Usage and Performance

    Hi All
    System A is sending mutiple messages to XI and every message has a node called TEVEN which has line Items. The TEVEN is repeated and based on EId value. The receiver has to be decided, that means a single message can have multiple same Eid which has to be colleted in one set of Message and XI will keep on receiving such messages for 30 minutes and after the same grouping from all messages and their payload being done a file will be created to different Receivers (in case of Eid 1 the receiver will be System A in case of Eid 2 the receiver will be System B)
    How do I Achieve this in my BPM - the problem is to go through every message payload and then collect TEVEN header in one single message and keep on doing so for all messages received within 30 minutes and then using file adpater put those files on File Server (The receiving system desires to have only one file and will check every 30 minutes for the file)
    Any thoughts on designing this scenarion in XI are welcome. And also regarding comments on designing a BPM to handle this and the performance related with that.
    <ns0:TEVEN>
    <ns0:EText />
    <ns0:EId>0001</ns0:EId>
    </ns0:TEVEN>
    <ns0:TEVEN>
    u2026u2026.
    u2026.
    </ns0:TEVEN>
    BR / Swetank

    Hi,
    If you have collect the messages till 30 mins and then create a file then i see you have to use BPM only.
    You can use the correlation for different  Eid, or you can use the option of Enhanced Receiver Determination.
    The help for both is available on SDN.
    with regards,
    Ravi Siddam

Maybe you are looking for

  • Run-Time Engine error

    I have created an automated test and had it running as an executable on a stand alone test computer. I updated my LabView software to 8.6.1. I just made some changes to the test and recompiled it. When I tried to run it on the stand alone computer it

  • Make field read only untill value within pciklist is choosen

    Hello, I am trying to establish if it is possible to make a field read-only until a value within a pick list is chosen. Basically we have a pick list called structure and if the field value called "Aligned" is selected then I want the text field call

  • Why do some YouTube videos no longer play in stereo?

    I have uploaded over 200 music videos on YouTube (user name "texpaco"), all in HD format. Until recently ALL played in stereo. However, YouTube recently made changes that affect over half of them. They now load with a defaulted 240p playback option w

  • Hello, how to unlock the iphone 4.

    my friend have bought a iphone 4 in LA, BestBuy, when he came to UK, he switch the carrier into the Vodafone, the phone can't read it, what wrong?

  • Re: Nokia PC Suite 6.8

    Does it support Applemac?