Java Object Oriented Analysis And Design Problem

As I said, there are multiple ways to implement Vending machine in Java e.g. you could have easily used state design pattern to implement a vending machine, in fact, it's one of the best examples of State design pattern. Vending machine behaves differently on different states e.g. return a product if the machine is not empty, otherwise, it just returns coins, so it ideally fits in state design pattern. Though, In our solution, I have not used the state design pattern but have just coded the solution with an if else block. This is easier because of a limited number of state and not many state transition but in more real world scenario, state design pattern is better as it uses Polymorphism and removes the logic we have put inside the if-else block.

Design Document

Here is a sample design document for Vending Machine problem. Well, it's not that great but conveys my design decisions in text format. Since in a real test, time is critical you need to balance your time between coding, testing, and designing activity, it's better to choose text over an image. If you are good with UML than adding a class diagram would certainly help here.

In Short Design Document in Java Should include

Here is our sample design document, it's very basic because I have generated it very quickly, but it's good for learning and doing Object Oriented Analysis and design. One thing which I would like to add on this document is UML class diagram because that's another way to convey your design to fellow Java developers.

1) High-level Design

Includes overview of the problem, not necessary if you are writing this as part of the test because evaluator should be familiar with problem specification. Important if your design document is intended for someone who is not very familiar with the problem domain.

Not used BigDecimal to represent money, because the vending machine can only hold limited amount, due to finite capacity of coin inventory.

2) Low Leven Design

2) Testing Strategy

-

3) Benefits

4) Assumption