Sandi Metz: Making is Easy, Mending is a Challenge
Apr 13, 2020
auto_awesome
Guest Sandi Metz, a 40-year programming veteran, discusses why teaching maintenance skills is difficult, the challenges of messy situations, her 'Rules for Developers', thoughts on Ruby and Rails, and using the phrase 'Lambs to the Slaughter'.
Writing code with good intentions and readability in mind is crucial for future maintainability.
Teams should focus on documentation and creating clear mental models of the system to facilitate code understanding and contribution.
Deep dives
The importance of readable code and good intentions
Sandy Metz emphasizes the importance of writing software with good intentions and readability as key factors. She suggests that code should be written for the readers, with clear names and organization that is friendly to newcomers. Metz highlights the need to avoid writing overly clever code that even the author may struggle to understand later. By focusing on writing code that is gentle, easy to understand, and conveys good intentions, developers can ensure that future readers can appreciate and work with the code effectively.
Maintaining code readability through effective documentation
Metz discusses the need for teams to think about documentation and its impact on code readability. She suggests that good object-oriented design consists of small, understandable pieces that can be easily replicated or extended. While excessive documentation at the object level may not be necessary, Metz advocates for integrating tests or visual representations that demonstrate how the components fit together. This approach allows developers to have a clear mental model of the system, making it easier for them to contribute to and understand the code base, especially when joining a project at a later stage.
Identifying and addressing code base issues
Metz identifies common problems in code bases with missing experience, noting their tendency to degrade into large, messy procedures over time. Such problems often occur when easy tasks are repeatedly performed without considering their long-term impact. When working with these code bases, Metz suggests that teams should avoid letting the code deteriorate further and make a collective decision to control the growth of complex code. She emphasizes the significance of not making big things bigger, focusing on incremental improvements, and constantly striving to make the code base better instead of worse.
The value of readable code and focusing on changing existing software
Metz highlights the importance of readable code and suggests that rewriting the entire code base is not always the most practical solution. Instead, she encourages focusing on making incremental changes and improvements to the existing software. By considering the long-term maintainability and avoiding making code worse, developers can gradually enhance the code base while maintaining a clear understanding of the application's behavior. Metz also makes the case for a shift in mindset, where developers see themselves as code menders rather than solely creators of new features, recognizing the value in changing existing code for a living.
In this episode of the Maintainable Software Podcast, Robby is joined by Sandi Metz, a renowned programmer, author, and speaker known for her expertise in object-oriented programming and maintainable code. Sandi shares her invaluable insights on various aspects of software development, focusing on writing code that stands the test of time.
Episode Highlights
Maintaining Readable Code: Sandi emphasizes that the cost of software lies in its readability. She discusses the importance of writing code with good names and gentle organization, making it easier for future developers to understand.
Avoiding Clever Code: Sandi warns against writing overly clever code that even the author might not understand later. Instead, she advocates for clear and simple code that conveys the programmer's good intentions to future readers.
Documentation and Integration Tests: While Sandi believes in minimal documentation at the object level, she stresses the importance of integration tests and visual aids that show how everything fits together.
Common Legacy Code Issues: Sandi identifies common patterns of problematic code in legacy systems, often resulting from neglected complexity and social bargains within teams that lead to unwieldy classes and procedures.
Technical Debt vs. Bad Code: She discusses the nuanced difference between technical debt and bad code, emphasizing the need for shared language and understanding between developers and stakeholders.
Training and Education: Sandi reflects on the importance of proper training for developers and how educational institutions might better prepare students for the real-world challenges of maintaining existing codebases.
Small Pieces, Big Impact: Advocating for the creation of small, manageable pieces of code, Sandi explains how this approach simplifies maintenance and enhances code readability.
Refactoring Strategies: Sandi shares strategies for refactoring large classes and objects, often seen in Rails applications, and the benefits of creating service objects and other intermediary classes.
Long-Term Framework Viability: Sandi discusses the future of frameworks like Rails, the importance of not being overly reliant on them, and preparing for potential technological shifts.
You'll also hear some thoughts on Ruby and Rails and how Sandi uses the phrase "Lambs to the Slaughter."
Tune in to this insightful episode and learn from one of the best in the industry about writing maintainable software that your future self will thank you for!