Tuesday, July 21, 2015

OO Design Interview - How



Cracking the Tech Career: Insider Advice on Landing a Job at Google, Microsoft, Apple, or any Top Tech Company
Object-Oriented Design
What are your goals? Imagine, for example, you are asked to design the classes for a generic deck of cards. What kind of cards? Are they standard playing cards, UNO cards, or some other kind? Just how generic is it supposed to be?
What are the core objects? For example, if you're doing the OOD for a restaurant, your core objects might be Restaurant, Patron, Party, Host, Server, Busser, Table, and so on. Each of these will become a class.
How do the objects relate to each other? There is probably only one Restaurant, so this can be a singleton class. Restaurant has many Servers, one Host, many Bussers, many Tables, many Parties, and many Patrons. (Note: This is just an assumption; talk to your interviewer about this.) Each Table has one Server and one Party. Look for and remove redundancies. For example, Restaurant may not need a list of Patrons, since it can get that from the list of Parties.
How do the objects interact? Think about what the major actions that occur in the restaurant are. For example, a Party makes a Reservation with a Host. The Host sits the Party at a Table and assigns them a Server. Each of these actions should generally correspond to one or more methods. By walking through these methods, you may discover that you missed some objects or that your design isn't quite right. That's okay—now is a great time to add them!
Are there any tricky algorithms? In some cases, there may be an algorithm that impacts the design. For example, implementing findNextReservation(int partySize) might require some changes to how the reservations are referenced.

Remember that object-oriented design questions require a lot of communication with your interviewer about how flexible your design should be and how to balance certain trade-offs. There is no “right” answer to an object-oriented design question.

https://www.quora.com/In-OO-design-interview-questions-like-designing-a-parking-lot-or-elevator-what-are-all-the-things-expected-by-the-interviewer
Its a kind of open-ended question, between a interviewer and interviewee. 

Interviewer would like to test your thought process and see how you actually design/code or think when such type of problems come to you, how you decompose such problem in various parts. How actually you convert those parts in objects/classes/functions for its software part ? 

You need to have continuous discussion with interviewer to understand the type of elevator or parking lot { e.g. what type of elevator this is, for small building , big building, residential , commercial, for airport , for mall, for two floor building. }

You need to find out what type of software/oo would be helpful for such system.

Eventually interviewer will narrow down the things , and he will ask you some classes/objects/functions for one part or more. { he will see how you use inheritance,polymorphism etc..}

He would like to test your thought process to talk about the problem, also your object oriented design skills..

http://programmers.stackexchange.com/questions/182451/oo-design-related-questions-in-technical-interviews
In a live interview, the ideal steps I'd expect a candidate to take would be :
  • Talk about the problem with the recruiter and start expressing a basic solution verbally, asking questions and adjusting as the recruiter gives more precise needs.
  • Stand up and sketch an overall view of the system and how components could interact together. Might be the purest style of UML, might be just boxes and circles.
  • Write a test, either high level acceptance test or unit test for one of the components/classes.
  • Start writing the corresponding implementation.
It's about communication, assumptions and interaction; not just an answer!

http://www.sgdevs.com/2013/12/interview-question-design-object.html
1. In my interviews, I wrote down interfaces and base classes which occurred as I described use cases to the interviewers. Then I began writing out the interactions between the objects. I asked questions when I faced ambiguity in my assumptions. This approach allowed me to engage the interviewer in the design process. However I thought it was a vague method when we got into the details and the interviewers started adding and modifying requirements. 

2. A more precise way is to write down use cases first
Based on the use cases, come up with the objects. 
Then use a method like CRC cards to flush out the interactions between the objects. 
Use a message sequence diagram to refine the interactions. 

Finally use a deployment diagram to show various processes which host the objects as they run on computers and network elements. While this is a methodical way of doing object oriented design, it may not be the best approach within the constraints of a job interview. 

1. The system to be designed is most important; any concepts used in the process should be to help in this design.
2. Articulate any design trade-offs you recognize to the interviewer.
3. Avoid buzzwords or terminology which you don’t understand well.
4. If you are faced with ambiguity, discuss a resolution with the interviewer.
5. At some point, reason with code, it can help focus the design process. Choose a language you are comfortable with.
6. Assume that data structures and algorithms cannot be avoided.
7. Assume that the interviewer will modify the constraints and requirements you have assumed in the initial design process.
8. With an open ended question like object oriented design, you have as much as of an opportunity to gauge your future colleagues and work environment as they have to judge you. Use it as an input while deciding if you want to take the job.

to-read:
http://programmingpraxis.com/contents/chron/

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts