AlgoViz

Design an inventory management system

medium 80 min

Count goods in several places, promise them to orders without ever promising too much, ship or let go, and explain every count.

Watch lesson4:28

Entities

Which nouns are classes

The point: a noun is a class when it has state that changes under a rule. Most nouns in this task are only names.

Nouns

Keep, or reject aloud

NounVerdictWhy
Stock lineClassTwo counts with a rule between them
ReservationClassA life with one ending, and picks to give back
MovementRecordWritten once, never changed
PickRecordThe link from a promise to a line
InventoryClassOrder of steps, lock, lookups
Pick policyInterfaceA business rule that changes
ProductA string hereName and price belong to the catalogue, which another team owns
WarehouseA string hereIt has no rule of its own until it has opening hours or a capacity
OrderAn id hereIt belongs to the shop. We only need to write down whose it is
AlertA callIt is told and forgotten
Product is the surprise. In a catalogue it is a rich class. In an inventory it is a key.

State

From requirement to field

ClassMust knowMust do
StockLineon hand, held, low mark, warnedadd, hold, let go, take, say if it became low
Reservationpicks, end, statusnothing: Inventory moves it
Movementkind, change, reason, numbernothing
PickPolicyperhaps an order of placesplan
Inventorylines, promises, diary, lockthe public verbs

Is this noun a class?

Product, place and order end at E. Pick and movement end at D.

Where do the counts live?

BreaksOn the product
How
product.quantity
Limit
Cannot say where. With a second place the field becomes a map, and the map becomes a line without a name.
Choose when
One place for ever, and no holds.
WorksA map in the warehouse
How
warehouse.stock[sku] = (on_hand, held)
Limit
The rule between the two counts sits in the warehouse methods, beside other things. Moving goods needs two warehouses to agree.
Choose when
When a warehouse has real rules of its own, such as capacity.
StrongA line for each pair
How
lines[sku, place] with guarded methods
Limit
More small objects.
Choose when
The default. A lock, a low mark and batches all have a home.