TIL (Today I Learned) - Programmatic programming #4
Today's 3 Line Summary
- Don't trust evev yourself. When you think "that could never happen", check it
- if use resources, check to freed status when finish
- Always take small, deliberate steps, checking for feedback and adjusting before proceeding.
TIL (Today I Learned) date
2022.03.24
The scope I read today
Chapter 4 Pragmatic Paranoia
What you want to remember in the book
- But Pragmatic Programmers take this a step further. They don’t trust themselves, either.
Topic 23. Design by Contract
- Remember, if your contract indicates that you’ll acceptanything and promise the world in return, then you’ve got a lotof code to write!
Topic 24. Dead Programs Tell No Lies
- Pragmatic Programmers tell themselves that if there is an error,something very, very bad has happened.
- A dead program normally does a lot less damage than a crippledone.
Topic 25. Assertive Programming
- Whenever you find yourself thinking “but of course that could never happen,” add code to check it.
- Don’t use assertions in place of real error handling. Assertions check for things that should never happen
- Turning off assertions when you deliver a program toproduction is like crossing a high wire without a net because you once made it across in practice.
Topic 26. How to Balance Resources
- Finish What You Start
- Because Pragmatic Programmers trust no one, including ourselves, we feel that it is always a good idea to build code thatactually checks that resources are indeed freed appropriately
Topic 27. Don't Outrun Your Headlights
- Always take small, deliberate steps, checking for feedback and adjusting before proceeding. Consider that the rate of feedback is your speed limit. You never take on a step or a task that’s “too big.”
- Avoid Fortune-Telling : Much of the time, tomorrow looks a lot like today. But don’tcount on it.
How did you feel reading it today?
- When I was writing a test case, I sometimes think "Does this situation really happening?". After I read this chapter and the sentence "Pragmatic Programmers don't trust themselves," I thought I should be more assertive in writing a case.