Design an inventory management system
medium 80 minCount goods in several places, promise them to orders without ever promising too much, ship or let go, and explain every count.
Watch lesson4:28
Problem
What is asked, and what hides in it
The point: somebody must decide, at any moment, how many of a thing may still be promised, and must never promise more than there are.
The task
As it is usually given
Design an inventory system for a seller with several storage places. Goods arrive. Orders reserve goods and later ship them or let them go. The seller wants to know when something runs low, and why a count is what it is. Write the important classes.
The first three minutes
You
Before I draw, may I ask what changes the design?
- One storage place or several, and may one order come from two?
- Is there time between ordering and shipping?
- If one of three products is missing, do we take the other two?
- Are the pieces all the same, or do they have dates or serial numbers?
- Is this one program, or many machines with a database?
Interviewer
Several places, and an order may be split. People have fifteen minutes to pay. All or nothing. Pieces are the same for now. One program with many threads.
You
Then I need reservations with an end, one atomic step for a whole order, and a rule for choosing the place. Dates and a database I will keep for the end and show where they would go.
Underneath
What it tests
| Sentence in the task | What hides in it |
|---|---|
| "Orders reserve goods" | A promise is its own object, with a life |
| "Several storage places" | The counted unit is product and place |
| "Ship them or let them go" | Exactly one ending for each promise |
| "Why a count is what it is" | A history that cannot be edited |
| "When something runs low" | Tell others without knowing them |
| "Many threads" | Checking and taking must be one step |
The way to the answer
- 1
Name the three numbers
On hand, held, available. Say which are stored.
- 2
Find the verbs
Receive, reserve, ship, release. Make a table of what each changes.
- 3
Draw five boxes
Inventory, StockLine, Reservation, Movement, PickPolicy.
- 4
Write reserve
It is the only hard method. Plan, then hold.
- 5
Prove it
Two orders for the last jar, half an order, a late customer.