class design/ design pattern question - c++

This is a discussion on class design/ design pattern question - c++ ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

class design/ design pattern question

  1. Default class design/ design pattern question

    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 ... ?

  2. Default Re: class design/ design pattern question

    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



  3. Default Re: class design/ design pattern question

    Bartholomew Simpson <123evergreen@terrace.com> 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.

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 08-30-2007, 11:10 PM
  2. Replies: 1
    Last Post: 08-22-2007, 06:58 AM
  3. Design Pattern Question
    By Application Development in forum Object
    Replies: 11
    Last Post: 08-20-2007, 11:06 AM
  4. Any design pattern for a transformation class?
    By Application Development in forum c++
    Replies: 1
    Last Post: 07-31-2007, 10:28 PM
  5. Design pattern question
    By Application Development in forum c++
    Replies: 5
    Last Post: 06-09-2007, 04:07 PM