OCP:open-closed principle 不可修改 可扩展 LSP: liskov substitute principle For a function,a subtype must be able to substitute its base type 一个模型,如果孤立地看,并不具有真正意义上的有效性. OOD中Is_a关系是就行为方式的,行为方式是可以合理假设的,是客户程序所依赖的. DBC design by contract 通过contract来获悉可以依赖的行为方式.c
地铁旋转门 最直接的实现FSM策略的方式是使用嵌套switch/case语句. public enum State { LOCKED, UNLOCKED }; public enum Event { COIN, PASS }; public class TurnStile { private State state = State.LOCKED; private TurnstileController turnstileController; public TurnStile(Turnstile