busbud/coding-challenge-backend-c — pull request #11 by kiasaki (2014-10-28 16:05:36+00:00)
Title: My submission for Coding Challenge C

Here's my submission for Coding Challenge C

_During the whole process I documented my thoughts and steps in a blog post over [HERE](http://fredericgingras.ca/2014/10/25/coding-challenges-are-exciting.html). This might help understand more than the quick overview I'll write below._

Before beginning to code anything I looked and the dataset to be used, the code given and what was needed.

I decided upon what I'd do and what I won't:

__Do__

- Write code in small modules fitting the nodejs mentality
- Test functionally those modules so other developers aren't scared of breaking thing when editing code
- Stay concise in the code written so it's easily readable by others
- Value performance right after modular and readable code
- Have the cities loaded in memory
- Use a trie (prefix tree) to index cities names and allow faster searches than the sequential scan of an array / hash table
- If a memcache url is provided store search _results_ in there, common searches will be much faster (not asked for but seems like a must to me, how many time will you compute _New York_ for nothing without a cache?)

__Don't__

- Over complicate the scoring or the indexing of results with multiple algoritms stick with one good and performant one.
- Store the cities in a database, yes this would give me searching for free but would be much slower less flexible that comming up with an in memory representation of the cities. I understand that if we were dealing with a changing dataset I would simply have no choice other than storing it in a database but since cities change far from often were are good with loading the cities from a file on boot.
- Mess with the Zohan

_Yes I know that was taken from what I have written up, but why rewrite was already said._

Comment at will, feedback is welcomed!