[Klug-general] c++ design pattern question

MacGyveR macgyver at thedumbterminal.co.uk
Wed Oct 16 20:11:01 UTC 2013


On 10/14/2013 12:22 PM, James Morris wrote:
>
> i've created an abstract base class to store object representations 
> for the ui.
>
> each object consists of any number of elements of which there are 
> three classes of.
>
> so I have created three ui element classes derived from the common 
> abstract class.
>
> however the three classes don't have so much in common when it comes 
> to methods, return types, arguments, data, to make virtual methods 
> seem quite the right way to go.
>
> so I store the element type in the base class and do a switch on that 
> and then perform a static_cast to obtain the correct object type to 
> access its methods. but i'm not really convinced about this either.
>
> I could go with the virtual methods and they could return error codes 
> when called on the wrong ui element type.
>
> just wondering if anyone knows the name of the design pattern that 
> solves this one so I can go read up on it?
>
>
>
> _______________________________________________
> Kent mailing list
> Kent at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/kent
you could use three decorator classes which are instantiated via a 
factory when given an object instance?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/kent/attachments/20131016/5149fb9a/attachment.html>


More information about the Kent mailing list