Optimize for the debugging experience
Write code that is easy to debug and troubleshoot. This can mean adding meaningful error messages, clear logging, or using tools that make debugging easier. You want to do the setup for these kinds of things now, before production is on fire.
Examples
- When building a file uploader, you add specific error messages for each type of failure (e.g., 'File too large,' 'Unsupported format'). This helps you or another developer quickly diagnose why a file upload failed, reducing the time needed to find the root cause.
- You create a logging utility that includes contextual information, such as the user ID and request ID, with each log entry. This way, if an error occurs in production, you can immediately see which user was affected and trace the error back through their request history, making debugging easier. (You also take care to not include any sensitive information that would get you in trouble with PPI laws).
Share this principle