abstract method signature, inheritance, and "Do" naming convention

Posted by T. Webster on Stack Overflow See other posts from Stack Overflow or by T. Webster
Published on 2010-03-18T21:23:05Z Indexed on 2010/03/18 21:31 UTC
Read the original article Hit count: 271

I'm learning about design patterns and in examples of code I've seen a convention where the abstract class declares a method, for example:

public abstract class ServiceBase {
... 

public virtual object GetSomething();

and then

protected abstract object DoGetSomething();

My question is on why these two methods exist, since they appear to serve the same purpose. Is this so that the base class GetSomething() method logic cannot be overridden by inherited classes? But then again, the method is marked virtual, so it can be overridden anyway. What is the usefulness here in requiring derived class implementers to implement the abstract method when the virtual method can be called anyway?

© Stack Overflow or respective owner

Related posts about c#

Related posts about design