Bryan Martin
Dec 9, 2020

--

I don't know if it's the example or what, but this looks pretty bad to me.

I would rather see code that only applies the discount if it exists rather than applies a fictional zero discount by doing nothing. When we talk about replacing null in our code with something else, we should talk about what null means and whether it is meaning full in this context.

In this case, null means that MonthlyDiscountCoupon doesn't exist. If we want to replace this type of logic we should replace it with something equally meaningful.

--

--

Responses (1)