[Gambas-user] OO design problem?

adamnt42 at ...626... adamnt42 at ...626...
Wed Aug 31 01:13:02 CEST 2016


On Mon, 29 Aug 2016 01:13:01 +0300
Jussi Lahtinen <jussi.lahtinen at ...626...> wrote:

> > It's not unnecessary in fact. Imagine if a children not implement the
> > property... then it's the property in the parent that is readed.
> >
> 
> Yes I know, but in my case it is unnecessary.
> 
But if I understand you correctly then you should be implementing an Error.Raise in those empty methods to trap where a child class has not re-implemented the property!
> 
> 
> > Another way is to not declare the property in the parent and use an
> > object type to walk the children.
> >
> >
> > Dosometing(hChild as Myclass)
> >
> > dim hObj as Object = hChild
> >
> > try hObj.DoSomethingElse()
> >
> > end
> >
> 
> Thanks for the suggestion. Though, I hope something more elegant...
> 
> 
> 
> Jussi
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user


And another use we have here for those "empty" methods is to implement a (hackish) trap to enforce a sort of protection i.e. the implementing child must be a particular object type. in other words to prevent say a client program calling the root method class directly.

-- 
B Bruen <adamnt42 at ...3379... (sort of)>




More information about the User mailing list