The Pragmatic Programmer - How to use Exceptions

Topics covered
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


The Pragmatic Programmer - How to Build Pragmatic Teams
Answers 383 questionsThe Pragmatic Programmer - How to Estimate
Answers 383 questions

Errors vs Exceptions, Reddit Rebels, and the 2023 StackOverflow Survey
Answers 383 questionsThe Pragmatic Programmer - How to Generate Code
Answers 383 questionsHow to be a Programmer
Answers 383 questions

The Pragmatic Programmer - How to Debug
Answers 383 questionsThe Pragmatic Programmer - The Evils of Duplication
Answers 383 questionsHow to be an Advanced Programmer
Answers 383 questionsHow to be an Intermediate Programmer
Answers 383 questions

Ktor, Logging Ideas, and Plugin Safety
Answers 383 questions

The Pragmatic Programmer - Tracer Bullets and Prototyping
Answers 383 questions

Clean Code - How to Write Classes the Right Way
Answers 383 questionsClean Code - How to Write Amazing Functions
Answers 383 questions

Software Design Anti-patterns
Answers 383 questions

Clean Code - How to Build Maintainable Systems
Answers 383 questions
