C# State pattern
Move status into states
Duplicate refunds from scattered status checks: the State pattern in C#
A concrete C# case where checking an order's status with if in every method leads to a returned order being refunded twice. The article moves the rules into state classes with the State pattern, so the bug disappears by design.