Skip to content
Ameen Abozaid
Planned lessonJNR-018-L05

Contract-first design

  • Lesson 5 of 6
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

agree on the API shape before writing code.

Planned topics

  • A contract lists URLs, methods, request and response bodies, and status codes.
  • Write example requests and responses first; they are the cheapest way to find mistakes.
  • Review the design with a peer or a client team before implementation.
  • Changing a contract later costs more than changing a table on a whiteboard.
  • The contract is not your entities: design DTOs for the client's needs.
Draft outline details

Demonstration

one table row plus examples

text
POST /products  body {"name","priceCents","categoryId"}
201 Location: /products/5  body {"id":5,"name":"Pen",...}
400 {"type":"...","title":"Invalid request"}

Check your understanding

What is reviewed before implementation?

Show answer

The contract: endpoints, bodies, status codes.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.