This document discusses the importance of developing software with a pessimistic mindset by anticipating errors and unexpected inputs rather than assuming everything will work correctly. It recommends techniques like defensive coding with input validation, assertions and error handling, designing by contract to define responsibilities and exceptions, and programming deliberately by expecting the unexpected and writing code that is robust to unintended use cases. The goal is to build software that is resilient to human and technical errors rather than fragile.
15. PROGRAM DELIBERATELY
NOT BY COINCIDENCE
> Always be Aware of what you are doing - Stone Soup &
Boiled Frogs
> Don't Code Blindfolded
> Proceed from a plan
> Rely on reliable things -
23. C# EXAMPLE
public ProductDto ConvertProductToDto(Product product)
{
if (product == null) throw new ArgumentNullException("product");
...
return productDto;
}
25. HANDLING ASSERTIONS WITH GRACE
> Alert User of Error
> When calling another component/service/module,
expect the unexpected
> Be proactive with assertions in your own code
26. PRACTICAL USES
> Always alert errors in promises error block
> Log API errors to services like BugSnag (and deal with
them)