Modeling Milk: A discussion on domain modeling
I recently had a discussion at work about the complexity of modeling data in real world systems. I used the example of a bottle of milk in the discussion, and I really like it, so I thought it would make for a good blog post.
Consider a supermarket that sells milk. In most scenarios, this is not exactly a controversial statement. How would you expect the system to model the concept of milk? The answer turns out to be quite complex, in practice.
To start with, there is no one system here. A supermarket is composed of many different departments that work together to achieve the end goal. Let’s try to list some of the most prominent ones:
- Cashier
- Stock
- Warehouse
- Product catalog
- Online
Let’s see how each of these think about milk, shall we?
The cashier rings up a specific bottle of milk, but aside from that, they don’t actually care. Milk is fungible (assuming the same expiry date). The cashier doesn’t care which particular milk cartoon was sold, only that the milk was sold.
The stock clerks care somewhat about the specific milk cartoons, but mostly because they need to make sure that the store doesn’t sell any expired milk. They might also need to remove milk cartoons that don’t look nice (crumpled, etc).
The warehouse care about the number of milk cartoons that are in stock on the shelves and in the warehouse, as well as predicting how much should be ordered.
The product catalog cares about the milk as a concept, the nutritional values, its product picture, etc.
The online team cares about presenting the data to the user, mostly similar to the product catalog, until it hits the shopping cart / actual order. The online team also does prediction, based on past orders, and may suggest shopping carts or items to be purchased.
All of these departments are talking about the same “thing”, or so it appears, but it looks, behaves and acted upon in very different ways.
Comments
And you can think about packages. Is milk the product or each possible package of that milk a different product?
Triggering flashbacks to when I worked on supply chain software for a grocer... what the warehouse deals with and what the stores deal with are often multiples of each other. For example the warehouse only handles crates of milk. This of course ends up flowing in to the cost model which may include additional warehouse shipping and handling on the crate which the sales team wants on the individual item level so they can price the product for the customer.
Cassio, You are correct, the packager is another view of this. There, they are interested in the dimensions of the milk, how many other cartoons of milk in the order, etc.
Comment preview