Loading…
Loading…
Main had a minimal ShoppingCart — just displayed items and total. A colleague sent a huge PR adding "everything at once": promo codes, VAT, stock checks, payment fetch, order creation. All in one component. Your job as architect is to explain why this can't be merged and how to split it.
A UI component is a function from state to DOM. Its job: show the user what's in state right now. It **shouldn't**: 1. Compute business rules (taxes, discounts, shipping cost). 2. Validate promo codes, coupons, limits. 3. Generate order or transaction IDs. 4. Manage the atomicity of multi-step operations. 5. Make security decisions. All of that belongs on the **backend**. The UI receives finished values and displays them. Why: - **Security** — anything on the client is vulnerable. DevTools lets anyone change any value. - **Consistency** — logic should live in one place; otherwise frontend and backend diverge. - **Testability** — pure functions and services are easier to test than components. - **Reuse** — the same logic may be needed in mobile, CLI, or a cron job. Look at the PR and find every place this principle is broken.