Implied Values in Programming

01 Jan 2016

I can only refer to this bad practice as 'implied programming' or 'programming by implied values.' That is, implying meaning from semi or unrelated values.

In some bit of code we discover that one value can be implied by the consequence of another.

function is sellable {

    if (inventory is 0)
        return false

    return true
}

But then in the future sellability shouldn't be tied to inventory (digital goods don't have inventory). So you adjust.

function is sellable {

    if (inventory is 0 and the product isn't digital)
        return false

    return true
}

See where I'm going with this? Sellability should have been defined by its own property.


Categories: programming