Overridable Functions/Procedures

G

Guest

Hi,
I was wondering if anyone has any information on the performance impact of
using functions declared as overridable?

To Explain more fully; By default every function created in VB is NOT
declared as overridable. However 90% of the time when creating resuable
components/classes you don't care if the target programmer overrides the item
or not.

However, if you are the target programmer and wish to alter the behviour of
a class in a polymorphic manner and the creator of the class has not declared
the function/property/procedure as overridable then you are stuck with
shadowing the original code... which of course will not operate correctly
(with respect to polymorphism).

So is there any performace reasons (memory/CPU) considerations for not
declaring all of the procedures/functions in a Class as overridable?

Regards,
Myles
 
M

Marina Levit [MVP]

Making things overridable I'm sure detracts from performance. However, I
would think this performance hit is so small as to be considered completely
inconsequential to the performance of your program.

Making things overridable or not should be done more from the perspective of
software architecture. There are some things that a developer should simply
not be able to override.

Also, from the point of view of readability, it is easier to follow what is
going on in a program and what its intended structure is if only methods
that truly need to be overridable are declared as such.

I think good programming practices should be what you worry about here, and
forget about worrying as to how this will impact performance.
 
G

Guest

Hi Marina,
thanks for the input, everthing that you have pointed out makes sense,
however the core question is still what sort of performance hit is taken...
Maybe it's insignificant (and probably is given that I haven't been hit with
loads of reply's)

With regard to "Best Programming Practice" that is what we are trying to
establish for the current and future development requirements :)

From the point of view of re-usable components it would appear sensible that
procedures are declared overridable unless there is a compelling reason not
to (Security, Stability, etc.) however the question that arose was what
impact this would have on performance (memory, cpu etc.)

Again thanks,
Myles.


Regards,
Myles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top