You have public methods not implementing an interface - reidev275/SignsYouShouldProbablyRefactor GitHub Wiki
Example
interface IBaker
{
void Bake();
}
class PizzaBaker : IBaker
{
public void Bake() { ... }
public void AddToppings() { ... }
}
Why is this bad?
- If we have any code that actually calls AddToppings we are probably breaking the Liskov Substitution Principal.
- Code that calls the non interface method must be dealing with the concrete class rather than utilizing polymorphism.
Resolved
We could choose to add a method to IBaker or we could create a new interface. I like [Role-based interfaces] (http://martinfowler.com/bliki/RoleInterface.html), so I created a new interface so that the Interface Segregation Principal is followed.
interface IBaker
{
void Bake();
}
interface IPizzaTopper
{
void AddToppings();
}
class PizzaBaker : IBaker, IPizzaTopper
{
public void Bake() { ... }
public void AddToppings() { ... }
}