Movie Store Interview Question
A real programming interview question implemented using TDD
This interview question is taken from a real interview which I ran for several years and continues to be used in a number of institutions.
The interview was conducted as a TDD, pair-programming challenge. This is important to note. It was not the eventual solution that mattered so much as the journey there. Sometimes we would hire people who didn’t get the solution, and other times we wouldn’t hire people who did.
The Challenge
Implement a “movie store” (like blockbusters or Netflix). The store needs to hold a number of movies (let’s say a maximum of 100, but for our testing purposes 4 or 5 is sufficient). We need to be able to search the movie store for titles based on a number of different criteria.
Sounds pretty simple huh?
It’s amazing how many people it trips up though.
In the interview we would reveal each requirement one by one. As we’re doing TDD we’re building the requirements one at a time. Just like in the interview, I'll reveal each requirement one at a time.
The goals
The solution should have beautiful, clean code, without repetition or hacks. It should be code that you would be proud to have in production.
It should be well tested.
You do not need to worry about databases, threading, user interfaces, API access or 3rd party libraries. This a pure Java question.
You should be mindful about performance, but it’s not a major concern.
You should not over engineer the solution.
The solution
Don’t worry if you’ve never done TDD- I even teach you how to do TDD from the start.
This course is approximately an hour long and comes with all the code available to download.
The training is about much more than just coming up with a solution- we discuss many of the areas that candidates fall down in interview and how to avoid them.
Your Instructor
Course Curriculum
-
PreviewWhat is TDD? (4:21)
-
StartCreating a project (1:24)
-
PreviewProject overview (1:08)
-
StartIntelliJ Cheat Sheets
-
PreviewDownload IntelliJ from here
-
StartCreating a project using IntelliJ and Maven
-
PreviewThe Does Nothing Test (6:00)
-
StartDo the simplest thing possible (1:24)
-
StartA better test (3:38)
-
StartOur first proper implementation (3:27)
-
StartIterating our test coverage (1:41)
-
StartYou must know how to operate your IDE (1:14)
-
StartImproving our implementation (1:59)
-
StartYou don't need null checks (0:55)
-
StartRefactoring our Test for ease and beauty (1:47)
-
StartThe second requirement (1:22)
-
StartCutting refactoring from 15 minutes to 15 seconds with one shorcut (3:54)
-
StartA harder requirement with edge cases (3:10)
-
StartAfter red and green comes REFACTOR (1:59)
-
StartJava 7 Code solution
-
StartMoving the solution to Java 8 (2:51)
-
StartThe big solution unveil (4:43)
-
StartFinal Solution Code