Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Last active December 12, 2015 10:09
Show Gist options
  • Save PetersonDave/4756980 to your computer and use it in GitHub Desktop.
Save PetersonDave/4756980 to your computer and use it in GitHub Desktop.
How to handle scenario where we want to use related interfaces, but have a common interface within an abstract class?
Public Interface IBrewCoffeee
{
void DoSomething;
}
Public Interface IStarbucksBrewsCoffee
{
void DoSomething;
void DoSomething1;
void DoSomething2;
}
Public Interface IDunksBrewsCoffee
{
void DoSomething;
void DoSomethingElse;
}
public abstract class CoffeeHouse
{
public CoffeeHouse(IBrewCoffee) { ... }
}
Public Starbucks : CoffeeHouse
{
public Starbucks(IStarbucksBrewsCoffee starbucksBrewsCoffee) : base(starbucksBrewsCoffee) { }
}
Public Dunks : CoffeeHouse
{
public Dunks(IDunksBrewsCoffee dunksBrewsCoffee) : base(dunksBrewsCoffee) { }
}
@PetersonDave
Copy link
Author

Use interface inheritance:

IStarbucksBrewsCoffee : IBrewCoffeee
IDunksBrewsCoffee : IBrewCoffeee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment