Separation of concerns 00:00:00 Make a prediction You will trace an order through input, pricing and storage and identify what each boundary should own. A spreadsheet importer and the web order form receive the same basket but compute different tax. Is the discrepancy primarily a UI problem? Both input paths are acting as independent pricing authorities. Let each parse its own input, then pass a domain basket to one pricing rule. 00:00:27 The laundry In a laundry, the front desk labels clothes, the wash station chooses the process, and the collection shelf stores finished bundles. A new shelf layout should not change how wool is washed. Boundaries separate kinds of work and the decisions that change together. Hand each stage a representation suited to the next task instead of exposing every internal detail. A concern is a question you can think about alone: how is this shown, when is it allowed, where is it kept, who may ask. Separation of concerns gives each one its own place in the code. Concerns change at different times. A new page layout should not put the rule about seats at risk. 00:01:10 Change tax without editing a screen An order form parses text fields and validates their basic shape. The pricing rule determines how quantities become money. The store persists the priced invoice. A database column rename should not change the pricing formula or the screen's labels. Submit the same basket through a web form and a batch importer. Both should call the same pricing rule and get the same total. Take two identical units through a checkout calculation. Render the calculated total in an email and a screen. Change only the tax policy and recompute. The two renderers should display the same revised amount without knowing the tax percentage themselves. 00:01:51 Keep policy out of persistence A repository can fetch a customer's outstanding invoices. The decision to waive a fee after thirty days belongs to the business rule, even if the data sits in that same database. Test the waiver using dates and amounts without opening a database connection. Load a purchase from thirty-one days ago. The repository returns its factual date and the policy decides whether it is outside the window. If the database adapter alone suppresses old purchases, an audit screen using that adapter can no longer show them. Moving tax calculations into a database query merely because invoice data is stored there can force every other entry point to reproduce the policy. In a tiny program, separate concerns with clear functions before separating them into services. In the Internet protocol stack, IP routes packets while TCP supplies an ordered byte stream when the application needs one. A route may change while the stream contract stays the same. Those concerns still interact when packets are delayed. A boundary works when the contract makes those effects understandable, even though different components own them. 00:03:05 Try an interview follow-up How do you find a wrong boundary? Look at changes that always cross it, classes that only forward, and tests that need both sides. Count crossings in the commit history, then try moving one feature. An invoice must be delivered as email today and as a downloadable file next month. Work a sample invoice with one discount through both delivery paths. Compute its totals once. Let rendering choose a format and delivery choose a destination. A failed email should leave the calculated invoice available for download. 00:03:43 What to take with you Name the concerns, give each one a place, and make the opening between places small. Tangling is many concerns in one place. Scattering is one concern in many. Layers hold what differs from step to step. Wrappers hold what is the same for every request, and their order matters.