High-Quality Code

Interview candidates will want to write code of high quality during interviews, but many of them cannot meet their interviewers’ expectations. This chapter provides detailed instructions on how to write clean, complete, and robust code. While solving a set of sample coding interview problems, we will illustrate how functional, boundary, and negative test cases, as well as defensive programming, are used to produce complete and robust code.


Interviewers make their hiring decisions based on candidates’ code. Code clearness has an important impact on the decision. As shown in Figure 5-1, handwriting, layout, ...

Get Coding Interviews: Questions, Analysis & Solutions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.