یادگیری با مثال و تمرینLearn by building small examples
هر مسیر با یک مسئله کوچک شروع میشود، به یک نمونه قابل اجرا میرسد و در پایان با چند حالت واقعی بررسی میشود.Each path starts with a small problem, becomes an executable example, and ends by checking realistic cases.
طراحی API با قرارداد روشنDesign an API with a clear contract
منبع، ورودی، خروجی و خطاها را قبل از کدنویسی مشخص کنید. بعد اعتبارسنجی و منطق اصلی را جدا نگه دارید.Define resources, inputs, outputs, and failures before coding. Then keep validation and core logic separate.
app.MapGet("/api/health", () =>
Results.Ok(new { status = "ready" }));مدل داده سفارش را درست بچینیدModel order data deliberately
قیمت زمان خرید، تعداد و تخفیف را در ردیف سفارش نگه دارید و ثبت سفارش را به صورت تراکنشی انجام دهید.Store purchase-time price, quantity, and discount on the order line, and persist the order transactionally.
منطق قیمتگذاری را مستقل آزمون کنیدTest pricing logic independently
محاسبه را از UI و دیتابیس جدا کنید و حالتهای عادی، مرزی و نامعتبر را با دادههای واضح پوشش دهید.Separate calculation from UI and database concerns, then cover normal, edge, and invalid cases with clear test data.