Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Hi friends,

    This is a question about something that came to mind to try to improve the performance of a midlet.

    In your opinion which is the best approach:

    1) Use System.getProperty("microedition.platform") each time i need that information

    OR

    2) Save the value in a global variable and retrieve it each time needed

    I think that the 1st one use less memory and the 2nd one executes faster...

    Any other comments guys ? I think that i would go for the 2nd approach because it's much cleaner code and it executes faster. But i would appreciate if maybe there are some of you who have some other ideas about these different approaches...

  2. #2
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    Option (2) will be significantly faster. It will cost you four bytes.

    Better still, don't save the value, but save some useful piece of information based on that value.

    Graham.

  3. #3
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Mmm i thought so but i said i should check what people with more experience think heh

  4. #4
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    Remember that you're not making a copy of the string, just a copy of the object reference (four bytes). So the memory cost is negligable.

  5. #5
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Mmm thats an interesting fact, because to say the truth i never knew that an object reference is just 4 bytes...

    Btw just to be safe, can: System.getProperty("microedition.platform") ever be null ?? On any phone in the world !!

  6. #6
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    The only rule about the value for microedition.platform is in JSR-248 (MSA), which specifies a format for the string - manufacturer name followed by model with no separator between (like "Nokia7210"), optionally followed by a "/" and additional information.

    Other devices could potentially return null, though I can't think of any off hand. Many devices do just return "j2me".

  7. #7
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Quote Originally Posted by grahamhughes View Post
    The only rule about the value for microedition.platform is in JSR-248 (MSA), which specifies a format for the string - manufacturer name followed by model with no separator between (like "Nokia7210"), optionally followed by a "/" and additional information.
    I wish there was an international standard for all phones, to return a standard formatted string like "make_model_etc..." :-/

  8. #8
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    There is: JSR-248. Unfortunately, the original CLDC spec doesn't specify a format. Believe me, that omission is the least of J2ME's problems...

  9. #9
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Quote Originally Posted by grahamhughes View Post
    There is: JSR-248.
    So howcome some phones return J2ME and others return null ? If there's a standard...

  10. #10
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    It's a new standard. It was never in the original CLDC specification. There's also no rule that says phone must comply with any given standard.

  11. #11
    Regular Contributor kurteknikk's Avatar
    Join Date
    May 2009
    Posts
    95
    Sure there's not rule but i don't find a single reason why not to comply with such a standard. I mean certain type of software, like the one that i'm working on, isn't able to be 100% dynamic depending on the phone make...

    And i believe that for certain other type of software such information can be vital for certain known issues of certain phone makes / models...

  12. #12
    Nokia Developer Champion Tiger79's Avatar
    Join Date
    Apr 2007
    Posts
    2,697
    yeah you might think the same about getting IMEI (might be vital to uniquely identify a device), guess what ? Thats no standard either.. SOme people find it vital to get the devices phine number.. again no standard...
    The CLDC/MIDP standards themselves are used on Java Devices, but those weren't specifically written for Java mobile phones, just "small devices"...
    So just take into account you will encounter more of those "illogical" missing information-retrieveing methods/api's...

Similar Threads

  1. question about global var's performance in dll?
    By ptclin_2007 in forum Symbian C++
    Replies: 0
    Last Post: 2008-04-11, 10:48
  2. N81 BUG: Web Services Parser an question marks???
    By masterchief2004 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-03-07, 17:59
  3. Performance investigator question
    By riussi in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-01-28, 09:15
  4. Replies: 0
    Last Post: 2003-04-07, 09:52
  5. Question on support of dll's
    By sanju_v in forum Symbian C++
    Replies: 1
    Last Post: 2003-03-05, 13:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved