I'll Be Backend
Principles

Separation of Concerns: Untangle the Request Handler

Separation of concerns means each job the code does, like reading a request, applying a business rule or keeping data, lives in its own place, so a change to one does not touch the others. A request handler that does all three forces every new way in to copy the rule. These lessons take a car rental desk whose web handler prices and saves bookings, move the rule and the storage into their own classes, and then add a partner file import that reuses them.

Pick your language

When to use it

Use it when

The same rule is needed from more than one way in, like a web request, a file import or a scheduled job.

Skip it when

A small script has one way in and nobody else calls it. Splitting it adds classes to read and nothing to reuse.

Spot it by

A request handler that parses input, holds a business rule and writes storage in one method.