Tuesday, March 22, 2011

Interview question: how to OO design a spell checker

question:
How to use OO Design to build a spell checker,and how to dispatch job to developers.

Simple solution
simple factory +singleton pattern

interface Check{
checkWord();
checkGrammar();
checkTense();
checkXX..()
...
}

class checkFactory{
if(Chinese)
return new ChinesCheck();//if singleton return ChinesCheck.getInstance(
);
else
......///other languages instances
}

class ChineseCheck implement Check {
...
}

class EbglishCheck implement Check {
...
}

each program do one language work...

No comments:

Post a Comment