TIL (Today I Learned) - Programmatic programming #5
Today's 3 Line Summary
- Try to decoupling between codes
- If you need to use external golbal data or static configuration wrap an API
- Try to write code around events
TIL (Today I Learned) date
2022.03.26
The scope I read today
Chapter 5 Bend, or Break
What you want to remember in the book
Topic 28. Decoupling
- Tell, Don’t Ask
- Try not to have more than one “.” when you access something. There’s a big exception to the one-dot rule: the rule doesn’t apply if the things you’re chaining are really, really unlikely to change.
- Any mutable external resource is global data.the solution is to make sure you always wrap these resources behind code that you control.
- If It’s Important Enough to Be Global, Wrap It in an API
Topic 29. Juggling the Real World
- But whatever their source, code that’s crafted around events can be more responsive and better decoupled than its more linear counterpart
Topic 30. Transforming Programming
- Thinking of code as a series of (nested) transformations can be aliberating approach to programming
Topic 31. Inheritance Tax
- Inheritance is coupling. Not only is the child class coupled tothe parent, the parent’s parent, and so on, but the code that usesthe child is also coupled to all the ancestors.
- Interfaces and protocols give us polymorphism without inheritance.
Topic 32. Configuration
- The idea that we should have to stop and restart an application to change a single parameter is hopelessly out of touch with modern realities.
- Instead, wrap the configuration information behind a (thin) API.
- DON’T WRITE DODO-CODE. Without external configuration, your code is not as adaptable or flexible as it could be.
How did you feel reading it today?
-
I lack understanding "Topic 29. Juggling the Real World". I should read it again.
-
When I first learned about inheritance, I thought it was convenient to share common parts. Reading this chapter, I learned that using inheritance increases the coupling and inherit unnecessary things.
-
The main topic of this chapter is decoupling, reducing the coupling between codes.