Null Pattern Last time I blogged about “Learn the Null Pattern“, but I forgot to mention one thing about the Null Pattern. That is you have to be mindful of it. For example
1 2 3 4 5 6 |
foreach(var id in IDList) { var employee = db.GetEmployee(id); salary = db.CalculateSalary(id); employee.Pay(salary); } |
The code looks okay but what if the GetEmployee method actually returns a NullEmployee? Well that would still be okay, since […]