loading...

re: To comment or not to comment? VIEW POST

FULL DISCUSSION
 

I love function name / variable name like a comment,

It can easily to read like a flowchart,
And comments

public static Coffee CreateCoffee(
CoffeeTypeEnum coffeeType)
{
    var coffee = new Coffee();
    var shouldAddMilk = IsNeedMilk(coffeeType);

    if (shouldAddMilk)
    {
        coffee.Add(Milk);
    }

    coffee.Add(Espresso);

    return coffee;
}

But if you have any technical issue / temporary fix / some business walk around
It should be write a command, create some tickets and fix it

private bool IsNeedMilk(CoffeeTypeEnum coffeeType)
{
    // FIXME #123 MilkFoam shouldn't is a type of Coffee
    if (coffeeType == CoffeeTypeEnum.MilkFoam)
    {
        return true;
    }

    var result = MilkCoffeeTypes.Contains(coffeeType);
    return result;
}
Code of Conduct Report abuse