Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > class design/ design pattern question

Reply
Thread Tools

class design/ design pattern question

 
 
Bartholomew Simpson
Guest
Posts: n/a
 
      06-12-2007
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 ... ?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-12-2007
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


 
Reply With Quote
 
 
 
 
Daniel T.
Guest
Posts: n/a
 
      06-12-2007
Bartholomew Simpson <(E-Mail Removed)> 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 With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 1 01-22-2012 10:48 PM
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 0 01-22-2012 10:26 PM
C++ and design Pattern (Composite design Pattern ) Pallav singh C++ 0 01-22-2012 10:25 PM
May I have a example of design pattern of "composite", I still feel fuzzy after reading book of Addison-Wesley's"design pattern " jones9413@yahoo.com C++ 1 08-31-2007 04:09 AM
Class design/design pattern resources TomTom MCSD 2 10-09-2004 07:38 AM



Advertisments