RubyConf 2019
Kevin Murphy from the Gnar Company is presenting at RubyConf! You can see his talk, Don’t Hang Me Out To DRY, on Wednesday at 11:20am in the Arlington Room. A recording of his presentation at RubyConf is now available.
Say Hi
Are you at RubyConf? You can get in touch with Kevin on Twitter to meet up. He’d love to hear any feedback on his presentation, share opinions on the other great talks in the program, discuss how we at The Gnar Company can help you and your company with its interesting challenges, or talk about what it's like to work here. He’ll also have plenty of Gnar stickers to share (if that’s your thing).
Presentation Resources
Kevin's slides are available for review on SpeakerDeck. The code examples that accompanied the talk are available in the context of a full Rails app.
Common Guiding Principles
Full test coverage, DRY code, and optimized code are all incredibly valuable, and we, as craftspeople, are better off for having them overall. But when should we push back on these ideals? What problems can they introduce?
☂️
Code coverage provides a valuable signal about the extent to which some code is tested, but it is not sufficient for a quality metric. 100% test coverage does not mean all code paths are fully exercised, just that all lines are hit at least once in the execution of the test suite. An application with 100% test coverage can still have bugs and can still have sections of code that don't have all scenarios tested. Additionally, testing every line of code has a cost that is felt initially in the time to conceive of the tests and the test strategy. However, the larger costs are felt over time if it leads to a long test suite run time, flakey or inconsistent tests, and a large suite that needs to be continually maintained as both the technologies and requirements of the application change.
💧
DRY code helps to ensure you don't have to make a change in multiple places when the way the system should work changes; instead, everything is in the isolated abstraction. However, not repeating yourself can lead to premature optimizations or abstractions that end up saddling the codebase with a difficult-to-change architecture when it’s discovered that use cases aren’t as similar as initially thought. Certainly reach for design patterns and well-known architectural principles when the opportunity presents itself. But, consider how one might back out of such an introduction should it turn out that the choice was premature - or hold off on introducing it entirely until it’s more clear or there’s sufficient churn in that area of the codebase to warrant the attention.
🐆
Performant code is objectively better than non-performant code, right? As always, the answer is, "maybe." Code that is preemptively performance-tuned may or may not be necessary or accurate. Without the data and benchmarking, under load, to illustrate the performance impact, any improvements made in service of performance are done so based on conjecture. This could lead to unnecessary time in developing the believed performance benefit or may even introduce subtle bugs.
Learn More
If you’d like to discuss how The Gnar Company can work with you on your technical challenges, please email us.