On Tue, 21 Aug 2007 13:39:36 +0200
Eike Rathke <[EMAIL PROTECTED]> wrote:

> Hi Takashi,
> 
> On Tuesday, 2007-08-21 13:34:18 +0900, Takashi Nakamoto wrote:
> 
> > > > Switching routine that choose one class from the four
> > > > classes for creating an instance of a cell would be complex.
> > > 
> > > I don't think so. You need to distinguish anyway, and subclassing may
> > > actually ease things because switching can be done internally using
> > > factory patterns and RTTI.
> > 
> > I've considered this point. However, I couldn't find any factory patterns
> > in ongoing source codes related to cells. Instead, I found many
> > statements like "new ScStringCell ()".
> 
> > This means we need to revise
> > many lines related to the instantiation of Sc*Cell if we add
> > ScRubyStringCell. Such revise results in complex code.
> 
> No, it results in complex code analysis. You will have to find the
> places anyway where you want to add ruby to string cells. Once changed
> to a factory pattern the resulting code will be not more complex than
> changing calls of
> 
>     ScStringCell* pCell = new ScStringCell(someText);
> 
> to calls of
> 
>     ScStringCell* pCell = ScStringCell::createInstance(someText,maybeRuby);
> 
> that returns a new'd ScRubyStringCell if maybeRuby is not empty, and
> ScStringCell otherwise. A ScRubyStringCell should still have the
> eCellType member variable set to CELLTYPE_STRING so you wouldn't need to
> adapt the zillion places where that is used, but should be
> distinguishable by means of RTTI where needed.
> 
> 
> > If Sc*Cell class group was designed to be added a new cell type to
> > from the start, subclassing would be the most attractive and cleanest
> > solution for this problem.
> 
> All cell types are derived from ScBaseCell so that shouldn't be a big
> problem. We have CellType that so far was sufficient and efficient.
> A real RTTI interface isn't available yet because most compilers didn't
> know about RTTI back those days, which actually is the reason why the
> ugly tools/rtti.hxx macros came to existence. We should strive for the
> cleanest possible solution anyway, and if something is missing add the
> missing pieces instead of fearing complex changes.

I just expected a factory pattern and RTTI are already used.
I agree about that shifting to a factory pattern and using RTTI
interface is the cleanest solution.

--
 Japanese Native-Language project
 Good-Day Inc.
 Takashi Nakamoto

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to