28 December 2010

Software Design Puzzle #6 - Design A Dictionary

Think about a dictionary now and kind of things that you will do with a dictionary. Normally a dictionary will have simple operations of add, delete, edit and search words. Being a software dictionary, won't it be good that it suggests you list of words based on the words you type.

For example, when you type "sim", it should display first "N" closest match with the prefix supplied. I don't need to emphasize that the first word should be the exact match (if any) and then followed by list of words that matches closely.

Assume that you have many data store in which the words are stored (database, XML file, txt file, CSV file etc). It is enough to perform the search/auto-suggestion on the data in local database. If the user is willing, the user can also hear the word through audio and for doing that you have to contact a remote web service that gives a audio file for a specific word. You can also assume that there exists a audio file for every word in the database.

Can you design the application, come up with set of classes, assign responsibilities to the classes and a brief architectural diagram too.

Put your design patterns knowledge in action :-)