Microsoft Interview Question
InternsCountry: India
Interview Type: In-Person
Stock Market System is about a "Market" - i.e. Buying and Selling.
Your solution should talk about how you will satisfy the order, will that be atomically satisfied or not, How will you avoid starvation of orders, What happens to huge orders?, Strategy for that... All that would matter in a potential solution.
Can make use of Observer Design Pattern.
Here is a simple implementation of the Publisher/Subscriber model for StockMarket. As and when interviewer pose with some more questions, we can add on to it.
Publisher Interface:
Subscriber(Observer) Interface:
StockMarket Class which implements the Publisher interface:
As a sample i will implement the PayPalStock which implements the Observer Interface. This inturn maintains a reference to the Publisher.
A more detailed design can be looked up at: http://read.pudn.com/downloads152/doc/663610/Software%20Design.pdf
- R@M3$H.N January 24, 2017