NotOverridable = still overloadable?

  • Thread starter Thread starter Rick Mogstad
  • Start date Start date
R

Rick Mogstad

Is there any way to make a sub/function that you can neither override nor
overload? I cant seem to find any information on blocking the ability to
overload a function in a derived class..

Any help is appreciated,

Rick
 
Rick,
| Is there any way to make a sub/function that you can neither override nor
| overload?
As you know, you can use NotOverridable to prevent a method from being
overridden, however you cannot prevent overloading.

Just out of curiosity, what do you think not overloading is going to buy
you?

Hope this helps
Jay

| Is there any way to make a sub/function that you can neither override nor
| overload? I cant seem to find any information on blocking the ability to
| overload a function in a derived class..
|
| Any help is appreciated,
|
| Rick
|
|
 
Jay B. Harlow said:
Rick,
| Is there any way to make a sub/function that you can neither override
nor
| overload?
As you know, you can use NotOverridable to prevent a method from being
overridden, however you cannot prevent overloading.

Just out of curiosity, what do you think not overloading is going to buy
you?

Its really to prevent another developer from overloading the function and
then complaining when it doesnt do what its supposed to. And its not really
my question, it was asked of me, and I didnt know the answer. So i guess I
dont know the whole reason, but I know that its more to prevent it so that
it will not confuse rather than that it will cause any actual harm.
 
Rick,
If "preventing" overloading was important, as you indicate they can be
"confusing" for some developers. You could always use or create a tool such
as FxCop with a rule that indicates that overloaded functions are bad. Then
use the tool as part of your code reviews.

I personal find overloading to be a very powerful & useful tool when writing
programss.

Hope this helps
Jay

|
| | > Rick,
| > | Is there any way to make a sub/function that you can neither override
| > nor
| > | overload?
| > As you know, you can use NotOverridable to prevent a method from being
| > overridden, however you cannot prevent overloading.
| >
| > Just out of curiosity, what do you think not overloading is going to buy
| > you?
| >
|
| Its really to prevent another developer from overloading the function and
| then complaining when it doesnt do what its supposed to. And its not
really
| my question, it was asked of me, and I didnt know the answer. So i guess
I
| dont know the whole reason, but I know that its more to prevent it so that
| it will not confuse rather than that it will cause any actual harm.
|
|
|
 
Jay B. Harlow said:
Rick,
If "preventing" overloading was important, as you indicate they can be
"confusing" for some developers. You could always use or create a tool
such
as FxCop with a rule that indicates that overloaded functions are bad.
Then
use the tool as part of your code reviews.

I personal find overloading to be a very powerful & useful tool when
writing
programss.

Hope this helps
Jay


We use overloading heavily, we just want to prevent a derived class from
overloading a method that is not overridable in the base class.
 

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

Back
Top