this post was submitted on 20 Nov 2024
240 points (98.4% liked)

Programmer Humor

32561 readers
756 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 day ago

I find it's also helpful to explicitly think about high level flow in the code. There are typically two types of code in an application. There's routing code that figures out where the payload needs to go, and then there's the code that actually cares about the content of the payload. The routing code can be thought of as sort of a railway where you ship packages around. When a package gets to a destination then you pass it to the code that knows what do do with it.

Nowadays, I really like to draw it out as a state machine before I start working on the code. When you just start coding, it's very easy to focus on the happy path and then you end up having to start kludging handling of exceptional cases as they come up. When you sketch out the state machine, it forces you to consider the error cases up front. You don't have to handle them right away, but the design should account for them at the very least. This is an excellent read about this approach https://shopify.engineering/17488160-why-developers-should-be-force-fed-state-machines