Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

MT2 Question Patterns

+11 votes
If you are working for a online shop. And you need to keep tracking the different states of the orders. Which pattern will be used mainly?
asked Oct 23, 2015 in Fall 15-16 by Amiao Gao (100 points)
Could I suggest adding "and why?"
Yes, and why. Thank you!

1 Answer

+5 votes
Best answer
The state pattern.... because the orders are in different categories and they may behave differently. Such as with certain orders that have an "incomplete state" you may send the potter an email saying when the due date is 10 days after it has been put into the system.
answered Oct 23, 2015 by Kelsey Self (100 points)
selected Nov 1, 2015 by Amiao Gao
I guess the question here will come down to whether the different states of the orders *actually* result in different behavior for the program -- are there different method bodies that should be called depending on the state -- if so, the State pattern may be useful.   Or are we just storing / keeping track of which state the order is in, but the behavior is basically the same... then the State pattern wouldn't apply.