[Mono-list] Overridden method calling base method (anddoing nothing else)

cafeaunet cafeaunet at gmail.com
Fri Dec 14 16:08:27 EST 2007


Harper's explanation makes perfect sense.

Am I right then in saying the following? If an overridden method that simply
calls the base method has the same attributes as its base method, it is
OK--probably better--to not define the overridden method. For example, see
the method AppendChild in the class System.Xml.XmlAttribute (and several
such methods in the System.Xml package).

I have not experimentally verified this, but it seems like unnecessarily
overriding a method can potentially increase runtime, because the time
needed to dispatch a method increases with each overriding of a virtual
method. This would be in addition to the overhead of calling the base
method. The latter expense might not be an issue if the runtime cleverly
inlines the call to the base method, but overridden virtual methods are
known to make such optimizations difficult.


Café.

-----Original Message-----
From: mono-list-bounces at lists.ximian.com
[mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Jackson Harper
Sent: Tuesday, December 11, 2007 8:51 PM
To: mono-list at lists.ximian.com
Subject: Re: [Mono-list] Overridden method calling base method (anddoing
nothing else)



Often the methods are overridden in MS classes because they have different
attributes on them then the base class, a lot of times it is just design
time attributes.

On Tue, 2007-12-11 at 21:46 -0500, shawn vose wrote:
> Not trying to fire anyone up just curious and ignorant.
> 
> The unanswered part of cafe's post of "Wouldn't such methods just slow 
> down execution?" to me is the most important. Is mono restricted from 
> making an improvement on a standard?

In this case it wouldn't be worth it.  Almost no performance benefit vs.
forcing people to recompile their apps to run on mono.

Jackson



> 
> 
> On Dec 11, 2007 6:15 PM, Robert Jordan <robertj at gmx.net> wrote:
>         cafeaunet wrote:
>         > Hello,
>         >
>         > I notice that some methods in Mono (1.2.5.1) override a base
>         method, and
>         > just call the base method inside the overridden method. For
>         example, the 
>         > method AppendChild in the class System.Xml.XmlAttribute
>         simply calls
>         > base.AppendChild (and does nothing else). I notice this
>         behavior especially
>         > in .NET 2.0 methods.
>         >
>         > What is the rationale for such methods? It seems like these
>         overridden 
>         > methods are simply not needed. Wouldn't such methods just
>         slow down
>         > execution?
>         
>         
>         They are for API compatibility. If MS overrides a method,
>         we have to do it as well, even if our implementation details 
>         do not need the overridden method.
>         
>         Robert
>         
>         
>         _______________________________________________
>         Mono-list maillist  -  Mono-list at lists.ximian.com
>         http://lists.ximian.com/mailman/listinfo/mono-list
>         
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com 
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
Jackson Harper
jackson at ximian.com


_______________________________________________
Mono-list maillist  -  Mono-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list



More information about the Mono-list mailing list