How to approach design problems like "design a vending machine"

architecture, design-patterns, oop

Solution

I'm not sure if theres any universally accepted set of steps, but the easiest thing to do is just break down each and every step as far as you can go.

- Start with the major actions (putting in money, pressing a selection, receiving drink)

- Continue decomposing every action into smaller actions and responses until it becomes almost trivial. So for putting in money, you'd have to know how much was being put in, the total that was put in, the amount to be displayed, etc.

- Think of any scenarios where your actions would no longer be valid (you push a selection and the machine is empty), and how you would deal with it. (return their money, prompt for another choice, etc.)

- Assign the actions and responses to the actors and to the system. Who puts in the money, who keeps track of the running total?

Then you can base your sequence diagrams and class diagram off of what you've come up with.

Problem

I wanted to know what are the steps that I should follow to approach problems like design a vending machine and come up with a number of design documents (like use case, sequence diagram, class diagram). Is there any source/link that I can read where it talks about how to go step by step. Thanks.

Original source