Published Aug 20, 2019

The Pragmatic Programmer - How to use Exceptions

Delve into the strategic use of exceptions in programming with Joe Zack, Michael Outlaw, and Alan Underwood as they emphasize deliberate coding, clear documentation, and the transition to Kotlin, highlighting crucial error-handling strategies and avoiding programming by coincidence.
Episode Highlights
Coding Blocks logo

Popular Clips

Episode Highlights

  • Coincidence Risks

    Programming by coincidence can lead to unreliable and unpredictable code, as and discuss. They emphasize the importance of avoiding assumptions and ensuring code is well-documented and adheres to a clear contract. Alan warns against the dangers of making changes without understanding the underlying code, as it can introduce performance issues and regressions 1. shares his own experience, admitting,

    I was actually really irritated with myself because the code was doing the wrong thing, but it was working. Doing the wrong thing for a long time. And this is what programming by coincidence is, right?

    ---

    He emphasizes the importance of avoiding implicit assumptions and ensuring that code is well-documented and reliable 1.

       

    Exception Strategy

    The discussion then shifts to the strategic use of exceptions in programming. and explore when it's appropriate to throw exceptions, emphasizing that they should be reserved for truly unexpected events. They caution against relying on implicit exception throwing, such as assuming a file exists without checking, which can lead to unintended errors and performance issues 1. emphasizes the importance of verifying assumptions, stating:

    Don't assume something, prove it. Assumptions that aren't based on fact become a major sticking point in many cases.

    ---

    The hosts encourage developers to avoid programming by coincidence and to ensure their code is both understandable and reliable 1 1.

Related Episodes