Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IFoo
- {
- bool Foo(Person a, Person b);
- }
- public class KungFoo : IFoo
- {
- public bool Foo(Person a, Person b)
- {
- if (a.IsAmateur || b.IsAmateur) // common logic
- return true;
- return false;
- }
- }
- public class KongFoo : IFoo
- {
- public bool Foo(Person a, Person b)
- {
- if (a.IsAmateur || b.IsAmateur) // common logic
- return false;
- return true;
- }
- }
- public interface IFoo
- {
- bool Foo(Person a, Person b);
- }
- public abstract class FooBase : IFoo
- {
- public bool Foo(Person a, Person b)
- {
- if (a.IsAmateur || b.IsAmateur) // common logic
- return true;
- return false;
- }
- }
- public class KungFoo : IFooBase
- {
- }
- public class KongFoo : IFooBase
- {
- public override bool Foo(Person a, Person b)
- {
- // Some other logic if the common logic doesn't work for you here
- }
- }
- public interface IFoo
- {
- bool Foo(Person a, Person b);
- }
- public class KungFoo : FooImpl
- {
- public override bool Foo(Person a, Person b)
- {
- if (this.IsAmateur(a, b))
- return true;
- return false;
- }
- }
- public class KongFoo : FooImpl
- {
- public override bool Foo(Person a, Person b)
- {
- if (this.IsAmateur(a, b))
- return false;
- return true;
- }
- }
- public abstract class FooImpl : IFoo
- {
- public abstract bool Foo(Person a, Person b);
- protected readonly Func<Person, Person, bool> IsAmateur = (a, b) => a.IsAmateur || b.IsAmateur;
- }
- public class Person
- {
- public bool IsAmateur { get; set; }
- }
- public abstract class IFoo{
- bool Foo(Person a, Person b){
- if (a.IsAmateur || b.IsAmateur) // common logic
- return true;
- }
- public abstract Object otherFooMethod(Object o);
- }
- public class KungFoo : IFoo{
- //Foo already implemented
- public Object otherFooMethod(Object o){
- return o;
- }
- }
- public class KongFoo : IFoo
- {
- public bool Foo(Person a, Person b)
- {
- if (a.IsAmateur || b.IsAmateur) // common logic
- return false;
- return !base.Foo();
- }
- public Object otherFooMethod(Object o){
- return o;
- }
- }
Add Comment
Please, Sign In to add comment