Skip to main content
wording
Source Link
thepacker
  • 893
  • 7
  • 11

The suggested IsWithinSpec in Widget-Class knows too much implementation detail about the WidgetDescription-class, e.g. that it contains a MeasurementSpecification. A so called TrainWreck. You could instead create a method in WidgetDescription-class and delegate there.

public class Widget 
{
    ...
    public Boolean IsWithinSpec() 
    {
        return this.WidgetDescription.IsWithinSpec(this.MeasurementValue)
    }
}

public class WidgetDesciption
{
    ...
    public Boolean IsWithinSpec(Decimal measurementValue) 
    {
        return this.MeasurementSpecification.IsWithinSpec(measurementValue)
    }
}

The thisThis will reduce unncessecary dependencies and make your code easier to test and you will need less mocking when testing.

hth.

The suggested IsWithinSpec in Widget-Class knows too much implementation detail about the WidgetDescription-class, e.g. that it contains a MeasurementSpecification. A so called TrainWreck. You could instead create a method in WidgetDescription-class and delegate there.

public class Widget 
{
    ...
    public Boolean IsWithinSpec() 
    {
        return this.WidgetDescription.IsWithinSpec(this.MeasurementValue)
    }
}

public class WidgetDesciption
{
    ...
    public Boolean IsWithinSpec(Decimal measurementValue) 
    {
        return this.MeasurementSpecification.IsWithinSpec(measurementValue)
    }
}

The this will reduce unncessecary dependencies and make your code easier to test and you will need less mocking when testing.

hth.

The suggested IsWithinSpec in Widget-Class knows too much implementation detail about the WidgetDescription-class, e.g. that it contains a MeasurementSpecification. A so called TrainWreck. You could instead create a method in WidgetDescription-class and delegate there.

public class Widget 
{
    ...
    public Boolean IsWithinSpec() 
    {
        return this.WidgetDescription.IsWithinSpec(this.MeasurementValue)
    }
}

public class WidgetDesciption
{
    ...
    public Boolean IsWithinSpec(Decimal measurementValue) 
    {
        return this.MeasurementSpecification.IsWithinSpec(measurementValue)
    }
}

This will reduce unncessecary dependencies and make your code easier to test and you will need less mocking when testing.

hth.

Source Link
thepacker
  • 893
  • 7
  • 11

The suggested IsWithinSpec in Widget-Class knows too much implementation detail about the WidgetDescription-class, e.g. that it contains a MeasurementSpecification. A so called TrainWreck. You could instead create a method in WidgetDescription-class and delegate there.

public class Widget 
{
    ...
    public Boolean IsWithinSpec() 
    {
        return this.WidgetDescription.IsWithinSpec(this.MeasurementValue)
    }
}

public class WidgetDesciption
{
    ...
    public Boolean IsWithinSpec(Decimal measurementValue) 
    {
        return this.MeasurementSpecification.IsWithinSpec(measurementValue)
    }
}

The this will reduce unncessecary dependencies and make your code easier to test and you will need less mocking when testing.

hth.