Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,125 | Comments: 45,488

filter by tags archive

Hiring Questions–The phone book

time to read 2 min | 216 words

One of the things that we ask some of our interviewees is to give us a project that would answer the following:

We need a reusable library to manage phone books for users. User interface is not required, but we do need an API to create, delete and edit phone book entries. An entry contains a Name (first and last), type (Work, Cellphone or Home) and number. Multiple entries under the same name are allowed. The persistence format of the phone book library is a file, and text based format such as XML or Json has been ruled out.

In addition to creating / editing / deleting, the library also need to support iterating over the list in alphabetical order or by the first or last name of each entry.

The fun part with this question is that it is testing so many things at the same time, it gives me a lot of details about the kind of candidate that I have in front of me. From their actual ability to solve a non trivial problem, the way they design and organize code, the way they can understand and implement a set of requirements, etc.

The actual problem is something that I remember doing as an exercise during high school (in Pascal, IIRC).


Simon Skov Boisen

Since the persistence format is a file and you rule out text based formats what other choice than binary serialization do people have? sqllite?

I'm also wondering what other than first or last name can be ordered alphabetically?

Anton Gogolev

Do perf considerations play any role? If not, this is trivially simple with the only tricky part of reading variable-length strings from binary files. But still: load file in memory and then iterate over loaded data to your heart's content. If performance considerations do play a role, though, it becomes a much more complex task and amounts to basically implementing a DBMS with indexes and such.

Marcel Popescu

Are all text based formats rejected, including CSV and fixed-width?

Matt Davey

BSON seems like the obvious choice :)

Trevor Pilley

Would RavenDB be acceptable for the persistence?


Simon - I believe the fact that he specifically says XML and JSON have been ruled out is to see what kind of developer you are.

You blindly accepted the specification. I expect the kind of candidate Ayende is looking for, he wants you to ask him, question him and explain why XML and JSON would be the way to go

Simon Skov Boisen

James, your probably right and I would have asked for an elaboration for that decision had I've been at an actual job interview. My question was more meant as a clarification as to what other types of storage he imagined would be suitable, maybe I had missed something or misunderstood the phrasing of the question.

Ryan Heath

Ok guys, submit your API :)

// Ryan

Frank Quednau

Do you ask here for an actual implementation or rather an overview of the work involved, decisions taken, etc.?

Ryan Heath

Here's my take. Viewed from the actual usage point. The internals are leftout. ;)

// Ryan

enum EntryType { Work, Cellphone, Home }

class PhoneEntry { public string FirstName {get;set} public string LastName {get;set} public EntryType EntryType {get;set} public string PhoneNumber {get;set} }

class PhoneEntryValidator { public bool IsValid(PhoneEntry entry); }

enum SortBy { FirstName, LastName, }

class PhoneBook { public PhoneBook(string phoneBookFilename);

public void Save(PhoneEntry entry); public void Delete(PhoneEntry entry);

public IEnumerable Entries(SortBy sortBy); }


"text based format such as XML or Json has been ruled out" - that's not something I could easily accept. You can't really suggest an alternative without asking why.


API:Linq to XML calls


Use sql lite, it still uses a file!


Firebird Embedded, MS SQL Express, MS SQL Compact, SQL Lite, etc


I would be surprised if there isn't already a "good" library available for download out there. Out-of-context questions are always a little odd. -What is this going to be integrated into? -What is the business reason for disallowing certain formats? I've run into those in the "real world", where a manager simply dislikes Technology X because he read an article 18 months ago that gave him a bad impression, which sometimes cannot be overcome with logic. -When you say "phone bookS for users" do you mean a single user may have multiple phone books? Are those user-managed? Is storage an issue such that a single contact should never be stored twice?

I know I'm probably overthinking a plate of beans and this is simply an exercise where I should ignore the business/integration stuff, but I hate not knowing that other stuff.




.WAB files! http://msdn.microsoft.com/en-us/library/ms629733.aspx http://contacts.codeplex.com/


That is a pretty nice idea. I am not sure if it can be applied to a company which does not have such an excessive amount of great applications available. It might cause good candidates to skip your company because it is too much (speculative) work.

Mike McG

Guys, give up on the text formats. The problem clearly states text-based formats are not acceptable. Does anyone here really think he's looking for someone who just knows how to invoke the SQLite driver?

He spells out the requirements for a basic database engine with indexing. It's a multifaceted problem that can expose a lot about a candidate in their solution. Are concerns separated logically? How is performance addressed against disk I/O? How is code correctness validated (e.g. testing)? To submit a project that just wraps another database is disingenuous. He's looking for people that can solve problems head-on, not just pass the buck.


Mike, yes off course but I will still always suggest the simplest possible solution first. That tells you a lot about a candidate too.


Excel, baby!

Robert O'Donnell

Is this a practical exersize where you want some code as the answer? or simply a detailed description of the proposed solution?

Bartek Sarul

We all know that Ayende would like to see this built on RavenDB ;-)

Bartek Sarul

We all know Ayende would like to see this built on RavenDB ;-)


Just make sure you don't make a mistake, or you will be the subject of a future blog post telling the world just how shit you are.


I'll use ESE (esent.dll) I had heard that @ayende uses it in Raven, so... ;)

Bart Verkoeijen

Interesting mixed answers. Thanks for the hint Ayende, I'll use it in future interviews. :-)

Matt Warren

Is using Munin (https://github.com/ravendb/raven.munin) an acceptable answer ;-)


Ayende, What did you want to heard? Enlighten us!

Tim Wilde

As much as I like writing code, my initial question would be "Can we use an existing system, rather than writing code that we'd then have to maintain?" and in this case, it's squarely in the sweet spot for an LDAP server which gives us a couple of well documented APIs for "free" (the LDAP protocol and the System.DirectoryServices namespace.) AD LDS or OpenLDAP, perhaps? If it turns out that the aim is specifically to see your code, rather than to see how you solve the problem more broadly, then I'd ask more specific questions and fire up an editor having considered these other options first :)

Rik Hemsley

I'll hire Tim Wilde please. Most sensible answer by far.

Comment preview

Comments have been closed on this topic.


  1. The design of RavenDB 4.0: Physically segregating collections - 6 hours from now
  2. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - about one day from now
  3. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 4 days from now
  4. The design of RavenDB 4.0: Voron has a one track mind - 5 days from now
  5. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 6 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    03 May 2016 - Making Lucene reliable
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats