Introduce Null Object

You have repeated checks for a null value.

Replace the null value with a null object.

if (customer == null) plan = BillingPlan.basic();
else plan = customer.getPlan();

image/svg+xml

image/svg+xml Null Customer getPlan Customer getPlan