Coding challenges
Next, we will tackle several coding challenges regarding object-oriented programming. For each problem, we will follow Figure 5.2 from Chapter 5, How to Approach a Coding Challenge. Mainly, we will start by asking the interviewer a question such as What are the design constraints? Commonly, coding challenges that orbit OOD are expressed by the interviewer in a general way. This is done intentionally to make you ask details about design constraints.
Once we have a clear picture of the constraints, we can try an example (which can be a sketch, a step-by-step runtime visualization, a bullet list, and suchlike). Then, we figure out the algorithm(s)/solution(s), and finally, we provide the design skeleton.
Example 1: Jukebox
Amazon, Google
Problem: Design the main classes of the jukebox musical machine.
What to ask: What is the jukebox playing – CDs, MP3s? What should I design – the jukebox building process, how it works, or something else...