// Better but passing in a class and not an inteface public void Run(DateTester dateTester) { if (dateTester.TodayIsAnEvenDayOfTheMonth) { component.Something(); } }
public void Run() { // Bad code smell // DateTester is a dependency that does not belong in this class DateTester dateTester = new DateTester(); if (dateTester.TodayIsAnEvenDayOfTheMonth) { component.Something(); } }
public PredicateComponent(IComponent decoratedComponent, DateTester dateTester) { this.decoratedComponent = decoratedComponent; this.dateTester = dateTester; }