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 ...
-
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 ... ?
-
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
-
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.
Similar Threads
-
By Application Development in forum c++
Replies: 1
Last Post: 08-30-2007, 11:10 PM
-
By Application Development in forum CSharp
Replies: 1
Last Post: 08-22-2007, 06:58 AM
-
By Application Development in forum Object
Replies: 11
Last Post: 08-20-2007, 11:06 AM
-
By Application Development in forum c++
Replies: 1
Last Post: 07-31-2007, 10:28 PM
-
By Application Development in forum c++
Replies: 5
Last Post: 06-09-2007, 04:07 PM