项目作者: tonyvu2014

项目描述 :
Object-Oriented and System Design Question Analysis and Implementation
高级语言: Java
项目地址: git://github.com/tonyvu2014/design-questions.git
创建时间: 2017-12-19T05:34:21Z
项目社区:https://github.com/tonyvu2014/design-questions

开源协议:MIT License

下载


design-questions

Object-Oriented and System Design Question Analysis and Implementation.

This repo to give analysis and detailed implementations for some of the sample design questions in Java.

Steps

From my experience, the steps to follow when you are asked a design question are:

  1. Ask questions to clarify about the requirements. The few things that you probably want to be clear about are:
  • What are the use cases that are suppported?
  • How many users the system is going to support? (especially for system design question)
  • Definitions and terms that are clear
  1. Come up with list of entities

The rule of thumbs to remember is that trying to map to real-life objects as much as possible. For this steps, just list down the entities first without the properties and methods. Make this step quick.

  1. Add properties and methods to entitites

To save time, you probably want to ignore trivial like contructors or getters and setters. Also try to to come up correct relationships betweem entities, either one-to-one, one-to-many or many-to-many. Many-to-Many relationship is normally modeled with an immediate entity class. Again make this step quick.

  1. Refine the design with abstraction, interface or design patterns.

Make sure that you know the differences between abstract class and interface and also know when you make use of common design patterns like Factory, Singleton, Builder, Strategy. An easier way to look at this is that: if there are something that you need to do more than once, there is a chance for refinement.

Remember to clarify why you use abstract class, interface or a design pattern.

  1. Scaling

Now this is when you apply your knowlege about cache, load balancer, database replication, partitioning and sharding to make sure that the system can handle
high traffic. That’s why the question about the number of users at the beginning.
Draw the diagram on the paper, board or on the page. Do not forget to mention about the pros and cons of your design.