How to approach Object Oriented Design Questions step by step

How to approach Object Oriented Design Questions step by step

Any interview process for software engineer will have atleast one Object Oriented Design round. This is true for senior software developer role as well as for entry level developer roles.

Image for post

The main ojective of the round is to identify :

1. given a generic problem statement candidate can ask the right questions and come up with a technical solution2. is he able to identify the different objects and entities from a problem statement3. Identify how much the candidate is comfortable with OOPs concepts and principles

Prerequisites:

  1. have some Programming experinece OOPs language such as Java/C++/Python etc.
  2. You must have good understanding of OOPs concepts such as : a. Abstraction b. Encapsulation c. Inheritance d. Polymorphism e. Association , Agreegation, Composition
  3. Having good understanding of Object Oriented Design principles such as SOLID/DRY principles etc helps
  4. Having good command over Deisign pattenrs is a bonus point for entry level developers and kind of expected for senior level developers

Steps to approach the the problem:

1. Requirements [5?7 mins]

First of all identify if the interviewer is looking for a System Level Design or Object Level Design.

a. talk about and write down the top requirements.b. talk about the use cases and possible other use cases on high levelc. define your assumptionsd. Clarify the scope that you are going to address in the interview

2. Use case Diagram : [3 mins]

While discussing the requirements you effectively already have identified the use cases to address. Now it?s time to trnsform it into a Use case diagram. a. identify the actorsb. Identify the what the different actors can do

Image for post

3. Activity Diagram [3 mins]

Till now you have identified the actors and what each actors needs to do. In this step you will focus on the logic how the overall flow of the system will look like. Writing down the flow diagram will solidify your understaing of the problem as well as it will give you a chance to correct any mistake you made.

a. create the flow diagram for the main use cases

Image for post

4. Class diagram [10 mins]

This is the main part where the interviewer is most interested in. Although if you have followed the above steps you have all the materials ready to finish this step with ease.

a. Identify the core objects

Rule to identify Objects :i. Nouns in requirements are possible candidates for Objectsii. Verbs in the requirements are possible methods

b. Identify the relationship between objects.c. Identify whether to use abstract class or interface for abstractionsd. Identify if you can can use some Design Pattern c. Design the class diagram

Image for post

Possibly once you come up with the class diagram, the interviewer will ask you few questions regarding your design choices. You need to justify why you made the choices. Remember that in a design round there are no wrong answers ? so defend your design. Although keep in mind the basic design principles while justifying your design.

5. Code [15 mins]

Mostly the coing part is optional for an Object Oriented Design round. But Interviewer might ask you to implement some specific parts of the problem.If you are asked to code the whole problem then prioritize : a. Start with the Interfaces or abstract classes b. Code for the core objects and the skeleton structures c. Write the implementations d. Write Junit

Hope it helps. Have a good day.

Image for post

Related articles :

Object Oriented Design Principles

First lets talk about the basic concepts of Object orinented design :

medium.com

How to approach System Design Interview questions step by step

System design is probably the last technical round question that you will face in any interview process. This type of?

medium.com

System design Interview question: Design airbnb

If you have not please go through ?How to approach System Design Interview questions step by step?.

medium.com

10

No Responses

Write a response