By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,039 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,039 IT Pros & Developers. It's quick & easy.

class design/ design pattern question

P: n/a
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 ... ?
Jun 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jun 12 '07 #2

P: n/a
Bartholomew Simpson <12**********@terrace.comwrote:
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.
Jun 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.