Interview Prep: System Design
Tags: systemdesign, technicalinterview, beginners, interviewprep
Published: 2019-10-27 17:06:07

---
One topic I've been thinking about for the last little bit is System Design. Throughout my informational interviews, I've gotten little tidbits of information to help me prepare for the interview process' at said company. One of these bits of information pertained to system design often phrased in the manner of "be prepared to architect Twitter or FaceBook."

## What is Systems Design?
According to the University of Waterloo: Systems design is identified as the philosophy, methods, and approaches to solving problems that are intrinsically multi-disciplinary. Through the consideration of the objective and subjective performance requirements, a design solution is constructed to meet the needs of the customer, the user, and society. Some of the main tools include strategies, procedures, and techniques that help in architecting a specific product or project. 

## Main Steps
##### Step 1: Understand the goals of the design
Ask clarifying questions to eliminate ambiguity with the interviewer. Who are the users? What is its primary purpose? How will it be used? What are the likely inputs and outputs?
##### Step 2:Establish the scope of the project
Now that basic understanding has been established, this is a good opportunity to ask questions about the features of the application. It's imperative that what you are suggesting is along the lines with what the interviewer wants before you move forward. What type of clients does this application want to support(mobile, web, etc)? Are we requiring authentication? Do we want to incorporate analytics? Are we integrating with existing systems?
##### Step 3: Design for the appropriate scale
We need to determine the scale to gauge if our data is compatible and can fit on one machine. What is the read-to-write ratio? How many simultaneous requests should we expect? Average response time? Limit on data we allow users to provide?
##### Step 4: Start from a high-level perspective, then get into the nitty-gritty
Begin with the end-to-end processes determined from the goals set in __step 1__. This might cover APIs, backend services, network architecture, data stores, outlining different clients, etc. and how they all join together to meet the requirements of those stated goals. This is where the conversation will end up covering potential performance bottlenecks and decisions about the delegation of responsibilities. Whatever way you approach this step, remember to start simple and build it out from there.
##### Step 5: DS&A - Data Structures and Algorithms
Runtime and memory complexity are super important in designing software systems. The efficiency and usability of the application (depending on the scale of the project) are completely dependent on a deep understanding and implementation of DS&A.
##### Step 6: Tradeoffs
Just about every decision you make will have trade-offs. It's important to be able to talk about them in real-time, offer solutions for them and demonstrate that you are aware of the complexities of systems and how they often require compromise and showcase your understanding through the pros and cons of each approach. Remember, there is no correct answer, just be prepared to explain yourself to show the interviewer that you're logical and will use the appropriate tools to get the job done.  

## The Process
This can be broken down into four main compartments and are best illustrated by this image:
+ task definition 
+ conceptual stage 
+ design stage 
+ implementation stage 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ops92y0hdbcxld5ksg52.png)

## Basic Examples 
For the example portion, I am going to keep it simple and stick to Twitter and showcase some smaller examples. As I'm sure you know by now, architecting an entire social media page would be quite extensive and this goes back to __step 2__ of the Main Steps portion of this blog and establishing the scope. Remember to ask lots of questions so you aren't diving deeper than you need to and wasting interview time.

In this first example, I am using a diagram showcasing how to design Twitters REST API:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/610ivj706gfmf4s0v3jf.png)

Next, the Full Object Model:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/sgnpq4tvvhf6284plfna.png)
###### https://www.visual-paradigm.com/tutorials/rest-api-design-twitter-example.jsp

I hope this blog post gave you some clarity on the subject and a better understanding of how to tackle this prompt next time you encounter it.

Good luck!