[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: [kspread] formatting design
From: John Dailey <dailey () vt ! edu>
Date: 2002-12-16 5:52:06
[Download RAW message or body]
> I agree with Norbert here. As the first step, maybe using shared object
> with factory but without necessary duplicate check is easier to code and
> debug. Later on, we can be more aggresive with respect to memory usage by
> eliminating duplicates, either at factory-level or perhaps doing it when
> the system is idle or when saving the document.
I would at least like to implement the factory interface to create the layout
objects even if we don't at first implement the duplicate checks. This will
just save time later so we don't have to hunt through the entire program to
change things. Basically I see the factory having an interface like:
class KSpreadFormatFactory
{
public:
KSpreadBackgroundFormat getBackgroundFormat(color, pattern);
KSpreadFontFormat getFontFormat(name, pointSize, color);
KSpreadTextOutputFormat getTextOutputFormat(format, precision);
...etc.
};
The Format objects themselves would have a private constructor but a public
copy constructor and they would be the 'fancy pointers' the same way you
implemented KSpreadValue. The KSpreadFormatFactory would be a friend class
to each of the Format classes so it is the only thing that can construct
them.
So instead of using
KSpreadBackgroundFormat backFormat(color, pattern);
to create the object, we use
KSpreadBackgroundFormat backFormat = factory->getBackgroundFormat(color,
pattern);
Initially the factory function is implemented:
KSpreadFormatFactory::getBackgroundFromat(color, pattern)
{ return KSpreadBackgroundFormat(color, pattern); }
and then later when we can implement the duplicate checking
KSpreadFormatFactory::getBackgroundFromat(color, pattern)
{ if (we've already created an object with(color, pattern))
return theOldOne;
else return KSpreadBackgroundFormat(color, pattern);
}
and that will require zero changes outside the class.
-John
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic