class design/ design pattern question

Discussion in 'C++' started by Bartholomew Simpson, Jun 12, 2007.

  1. I have a class which takes a while to instantiate (reads from shmmem,
    then connects to db etc). I call this a "heavy" class. I would like to
    use a "lightweight" version of the class - so that I can (for example),
    create consts in my code, for reuse - however, I want to be able to
    convert the lightweight object into a heavy weight counterpart, when I
    need to do some rare stuff.

    I remember coming accross a DP that allows one to do this but - and I
    can't locate it in the GoF constructional patterns ... ?
    Bartholomew Simpson, Jun 12, 2007
    #1
    1. Advertising

  2. Bartholomew Simpson wrote:
    > I have a class which takes a while to instantiate (reads from shmmem,
    > then connects to db etc). I call this a "heavy" class. I would like to
    > use a "lightweight" version of the class - so that I can (for
    > example), create consts in my code, for reuse - however, I want to be
    > able to convert the lightweight object into a heavy weight
    > counterpart, when I need to do some rare stuff.
    >
    > I remember coming accross a DP that allows one to do this but - and I
    > can't locate it in the GoF constructional patterns ... ?


    I don't think GoF book has anything like that. What you're describing
    looks like "lazy initialisation". Delayed computation is the corner
    stone of some optimizations. Don't compute what you're not going to
    use, that's generally a good idea.

    Sorry, I can't help you much, but perhaps somebody in the newsgroup
    'comp.software.patterns' can?

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jun 12, 2007
    #2
    1. Advertising

  3. Bartholomew Simpson

    Daniel T. Guest

    Bartholomew Simpson <> wrote:

    > I have a class which takes a while to instantiate (reads from shmmem,
    > then connects to db etc). I call this a "heavy" class. I would like to
    > use a "lightweight" version of the class - so that I can (for example),
    > create consts in my code, for reuse - however, I want to be able to
    > convert the lightweight object into a heavy weight counterpart, when I
    > need to do some rare stuff.
    >
    > I remember coming accross a DP that allows one to do this but - and I
    > can't locate it in the GoF constructional patterns ... ?


    The "Proxy pattern" is what you are describing.
    Daniel T., Jun 12, 2007
    #3
    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. sunny
    Replies:
    1
    Views:
    461
    Salt_Peter
    Dec 7, 2006
  2. John Goche
    Replies:
    9
    Views:
    678
    Arne Vajhøj
    Dec 3, 2011
  3. Pallav singh
    Replies:
    0
    Views:
    354
    Pallav singh
    Jan 22, 2012
  4. Pallav singh
    Replies:
    0
    Views:
    399
    Pallav singh
    Jan 22, 2012
  5. Pallav singh
    Replies:
    1
    Views:
    449
    Peter Remmers
    Jan 22, 2012
Loading...

Share This Page