O
ORi
Hi all !
There's a question I've been bothering for a while:
I'm actually developing architectural frameworks for application
developing and I think virtual methods, although needed because of the
flexibility they introduce (flexibility really needed in framework
developing), are often a nuisance for final developers. They don't
like them because they never know if base class must be called and
where should they place the call if needed, so we have mostly two
different situations:
1) Base method should always be called !! : We've solved this issue by
using Template Methods, this way it doesn't matter if the class calls
base method or not.
2) Method can be overriten if needed but if it is, base method should
NOT be called. A silly example might be the following:
public class A
{
private int _att;
public virtual void foo()
{
_att = 5;
}
}
public class B:A
{
public override void foo()
{
//here they might need to alter _att's value so base.foo() should
//never be called after their code.
_att = 6;
}
}
This is specially a problem since we've changed to VS.Net 2003 and the
IDE automatically creates override sentences and inserts the base
method call which is what I want to avoid.
I can't find a way to achieve this, and any help would be appreciated
!!
thx in advance
ori
There's a question I've been bothering for a while:
I'm actually developing architectural frameworks for application
developing and I think virtual methods, although needed because of the
flexibility they introduce (flexibility really needed in framework
developing), are often a nuisance for final developers. They don't
like them because they never know if base class must be called and
where should they place the call if needed, so we have mostly two
different situations:
1) Base method should always be called !! : We've solved this issue by
using Template Methods, this way it doesn't matter if the class calls
base method or not.
2) Method can be overriten if needed but if it is, base method should
NOT be called. A silly example might be the following:
public class A
{
private int _att;
public virtual void foo()
{
_att = 5;
}
}
public class B:A
{
public override void foo()
{
//here they might need to alter _att's value so base.foo() should
//never be called after their code.
_att = 6;
}
}
This is specially a problem since we've changed to VS.Net 2003 and the
IDE automatically creates override sentences and inserts the base
method call which is what I want to avoid.
I can't find a way to achieve this, and any help would be appreciated
!!
thx in advance
ori