From Problem to Solution
summary
A simple network client that starts with four testable branches grows to 96 branches after adding auth, background tasks and a request counter, so the code becomes brittle. The fix is to extract three responsibilities into a RequestBehavior protocol (additional headers, before-send, after-success/after-failure), provide an empty request behavior and a combined request behavior, and implement small behaviors (auth header needs two tests). Result: decoupling, easy logging and timing, reusability and clear testability.
AI-written summary Β· about
chapters (40)
- 0:00Introduction
- 0:48Welcome
- 1:05Presentation Overview
- 2:22Code Complexity
- 2:39Code Walkthrough
- 3:46No Code Gets to Stay Good
- 4:02The Tangled Mess
- 4:49Single Responsibility Principle
- 5:18Line Length
- 5:38Cyclomatic Complexity
- 6:17Singletons
- 7:07What do we need
- 7:18Feeling the pain
- 8:26Abstract code
- 8:43Sliced code
- 9:23Background task identifier
- 9:56Background task responsibility
- 10:41Step 2 Develop abstraction
- 11:57The magic step
- 13:59Default
- 14:26Abstracts
- 14:43Dont repeat yourself
- 15:42Code doesnt look the same
- 16:44Duplication is cheaper
- 17:18Empty request behavior
- 18:01Combined request behavior
- 18:32Combined request behaviors
- 19:30AuthToken header
- 19:40Mock out user defaults
- 20:10Network activity indicator behavior
- 20:41Log every error
- 21:04How long are requests
- 21:21Override before send
- 21:54Why do this again
- 22:22Handle
- 22:39Reuse
- 23:02Separate code
- 23:17Look at code
- 23:27Error logger
- 23:48Pablo Picasso
related talks
31mFrom Problem to Solution
55mAll TheLittle Things
51mResponsible Microservices
52mBreaking Bad Code: From simple problems to complicated solutions and back
31mBuilding a Sustainable CodeBase with FP
24mArchitecting the Unconventional: A Case Study in Software Design
41mOTP behaviours and how to behave around them
46mThe Zen of Programming. A personal journey towards writing beautiful code.
