which design is better??? in term of memory used, speed...etc????

Discussion in 'Java' started by sayoyo, Jul 7, 2003.

  1. sayoyo

    sayoyo Guest

    Hi Guys,

    I have to implement a design in Java which is a collection class
    gathers several units of the same class.

    I was thinking about two ways to implement it. the first is to create
    two class: the collection class and the unit class. The second one is
    to create only one unit class but, the all units(whole collection) are
    stored into the class variable (static) of the unit class.

    And I have no idea which design is better in term of memory used,
    speed, etc...

    If someone has an idea????? Thanks you very much!!!!!!


    Sayoyo


    class unitSet{
    private HashMap setOfUnit = null;
    unitSet(){
    setOfUnit = new HAshMap(20);
    }
    addUnit()....
    removeUnit()....
    setUnit().....
    }


    class unit{
    unit(){
    }
    }

    ******** OR ***********

    class unit{

    static private HashMap setOfUnit = nll;
    static{
    setOfUnit = new HAshMap(20);
    }
    static addUnit()...
    static removeUnit()...
    static setUnit()...

    unit(){
    }
    }
     
    sayoyo, Jul 7, 2003
    #1
    1. Advertising

  2. sayoyo

    Jacob Guest

    sayoyo wrote:
    > And I have no idea which design is better in term of memory used,
    > speed, etc...


    Don't care about this. Memory and performance is not
    at stake for the classes mentioned.

    In general: Select the design that is closest to the
    domain objects you are trying to model. In this case
    your first example seems fine.
     
    Jacob, Jul 7, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Slade

    [OT] - Definition of Usenet term used here a lot

    Andrew Slade, Jan 2, 2004, in forum: C Programming
    Replies:
    10
    Views:
    564
    Andrew Slade
    Jan 3, 2004
  2. Replies:
    0
    Views:
    735
  3. Replies:
    9
    Views:
    360
    Jerry Coffin
    Jul 28, 2006
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    459
    Fredrik Lundh
    Aug 13, 2008
  5. Ross
    Replies:
    6
    Views:
    255
    Arne Vajhøj
    Oct 4, 2009
Loading...

Share This Page