Created
October 2, 2013 09:22
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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