Archive For The “Refactoring” Category
In defensive programming, guard clauses are used to protect your methods from invalid parameters. In design by contract, guard clauses are known as preconditions, and in domain driven design, we use them to protect invariants — unbreakable rules that form assumptions about our model: Unfortunately, in examples like this, the true intention of the method [...]
As you may know, I’ve recently started at a new position here in London. Last week I was pair programming all day, every day, with a couple of the other developers, learning the ins and outs of the system. It reminded me of an important tip for beginners: good pair programming requires both driver and [...]
In programming, correctness and robustness are two high-level principles from which a number of other principles can be traced back to. Correctness Robustness Design by Contract Defensive programming Assertions Invariants Fail Fast Populating missing parameters Sensible defaults Getting out of the users way Anticorruption Layer Backwards-compatible APIs Robustness adds built-in tolerance for common and non-critical [...]
Today I had the pleasure of fixing a bug in an unashamedly-procedural ASP.NET application, comprised almost entirely of static methods with anywhere from 5-20 parameters each (yuck yuck yuck). After locating the bug and devising a fix, I hit a wall. I needed some additional information that wasn’t in scope. There were three places I [...]
One of the applications I work on is a planning system, used for managing the operations of the business over the next week, month and financial year. Almost every entity in this application has a fixed ‘applicable period’ — a lifetime that begins and ends at certain dates. For example: An employee’s applicable period lasts [...]


