Skip to content

Instantly share code, notes, and snippets.

@MarkNijhof
Created August 1, 2010 20:23
Show Gist options
  • Save MarkNijhof/503729 to your computer and use it in GitHub Desktop.
Save MarkNijhof/503729 to your computer and use it in GitHub Desktop.
public void DoSomthingWithACar(ICar car)
{
// Do something with a any implementation of ICar
}
public void DoSomthingWithACar(Car car)
{
// Do something with a specific Car
}
namespace Fohjin.Refactoring
{
public class ClassToBeRefactored
{
public void DoSomething()
{
DependencyA dependencyA = new DependencyA();
DependencyB dependencyB = new DependencyB();
}
}
}
namespace Fohjin.Refactoring
{
public class ClassToBeRefactored
{
private readonly DependencyA _dependencyA;
private readonly DependencyB _dependencyB;
public ClassToBeRefactored() : this(new DependencyA(), new DependencyB()) {}
public ClassToBeRefactored(DependencyA dependencyA, DependencyB dependencyB)
{
_dependencyA = dependencyA;
_dependencyB = dependencyB;
}
public void DoSomething()
{
// Use _dependencyA and _dependencyB
}
}
}
public double Usage(ICar car)
{
// Calculate average kilometers per liter
}
public double AverageUsageKilometerPerLiter(ICar car)
{
// Calculate average kilometers per liter
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment