Topic 8.0
1. Step 1: Handel Ambiguity
1) 【Obeject-oriented design questions are ofter intentionally vague in order to test whether you’ll make assumptions or if you’ll ask clarifying questions】After all, a developer who just codes sth without understanding what she is expected to create wastes the companys’s time and money.
2) Iquire who is going to use it and how they are going to use it !!!!!!!!!!!!
3) Six Ws: who, what, where, when, how, why
2. Step 2: Define the Core Objects
3. Step 3: Analyze Relationships
4. Step 4: Investigate Actions.
5. Design Patterns
1) Interviewers are trying to test your capabilities and not your knowledge !!!!!!!!!
2) Singleton Class: ensures that a class has only one instance.
public class Restaurant{//以_开头是一种习惯,表示全局变量
private static Restaurant _instance=null;
public static Restaurant getInstance(){
if (_instance==null){
_instance=new Restaurant();
}
return _instance;
}
}
3) Factory Method: offers an interface for creating an instance of class, with its subclasses deciding which class to instantiate.
publicclass CardGame{
public static CardGame createCardGame(GameType type){ if (type==GameType.Poker){ return new PokerGame(); }else if (type==GameType.BlackJack){ return new BlackJackGame(); } return null; } }