Reflections on Alec Clarke’s RailsConf 2020 talk
Using lessons from woodworking, Alec gave some practical tips on how to safely and repeatably write better code.
A simple but powerful pattern for incremental feature/version release:
A testable, less hands-on approach to writing and running one-off jobs (one less reason to console in to production servers)
MaintenanceJob
class with a date and timestamped version number to ensure the job only ever gets run onceThis lesson reminds me of the “make the change easy, and then make the easy change” principle (https://twitter.com/KentBeck/status/250733358307500032).
Alec shows an example of improving (refactoring) the old version before trying to build the new version on top (behind the aforementioned staged rollout flag).
Building on a previous example, Alec shows an example of creating a Rails generator to make it easy for future developers to create new MaintenanceJob
s the right way:
MaintenanceJob
AND a failing test to implementCombined, these techniques lower the barriers to doing things the right way (or at least a good way). I particularly like the way the staged rollout gives an easy way to fix a problem at what otherwise might be a very stressful time… when error monitoring is blowing up and I’m scrambling to figure out a fix.