|
From: Frank V. C. <fr...@co...> - 2000-01-13 17:33:26
|
Typo comment added to the end of this reply
"Frank V. Castellucci" wrote:
>
> In light of the recent exchange here in regards to genericity in
> collections, it brought up an interesting conversation I had with Tom
> Maguire (a team member both here and on the job I have so my kids can
> milk me for every dime I have..., sorry), about the Bridge
> implementation.
>
> As you all know, or maybe don't, I implemented the Bridge pattern where
> the base abstraction has the data member for the implementation:
>
> class Bridge : public CoreLinuxObject
> {
> ...
>
> protected:
>
> CoreLinuxObjectPtr getImplementation( void );
>
> private:
>
> CoreLinuxObjectPtr theImplementation;
> };
>
> This means that when a derivation is using the protected accessor, in
> order to perform the operation the bridge was called up to do, it would
> have to cast the implementation to the type that the derivation
> expected. In the example code, EngineBridge worked with Engine
> implementations.
>
> Now, with Tom I mentioned his comment "Typically this is really ugly
> type checking code that is the hallmark of poor or shortsighted
> analysis." in regards to the Java hashtable thread. I pointed out that
> Bridge requires the derivation to do exactley that!!!
>
> So I am wondering, should we be offering a choice of implementation
> where possible? In the bridge case a possible scenario would be:
>
> --------- In libcorelinux++ source -----------
>
> // We keep the same Bridge we already have AND ADD
>
> template < class Implementation >
> class BridgeTemplate : public Bridge
> {
> ...
>
> protected:
>
> Implementation * getImplementation( void )
> {
> return dynamic_cast<Implementation *>
> (Bridge::getImplementation());
> }
>
> private:
>
> };
>
> // OR We keep the same Bridge we already have AND ADD
>
> template < class Implementation >
> class BridgeTemplate : public CoreLinuxObject
> {
> ...
>
> protected:
>
> Implementation * getImplementation( void )
> {
> return theImplementation;
> }
>
> private:
>
> Implementation * theImplementation;
> };
>
> ------------------------------------------------------
The above is wrong as I did not clarify that we would LOOSE the data
member in the base Bridge abstraction. Sorry.
|