Skip to content

Instantly share code, notes, and snippets.

@rofr
Created October 2, 2013 09:22
Show Gist options
  • Save rofr/6791163 to your computer and use it in GitHub Desktop.
Save rofr/6791163 to your computer and use it in GitHub Desktop.
Which design is prefereble? Derive from a subclass and override an abstract method or derive from same class and overload exactly one of 2 possible virtual methods?
public abstract class Command<M> where M : Model
{
public virtual void Execute(M modelIn, out M modelOut)
{
modelOut = null;
throw new NotImplementedException();
}
public virtual void Execute(M Model)
{
throw new NotImplementedException();
}
}
public abstract class Command<M,R> where M : Model
{
public virtual R Execute(M modelIn, out M modelOut)
{
modelOut = null;
throw new NotImplementedException();
}
public virtual R Execute(M Model)
{
throw new NotImplementedException();
}
}
public abstract class ImmutabilityCommand<M,R> : Command<M,R> where M:Model
{
public abstract R Execute(M model, out M modelNext);
}
public abstract class ImmutabilityCommand<M> : Command<M> where M:Model
{
public abstract void Execute(M model, out M nextModel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment