The Decorator Pattern

The Decorator Pattern

Decorator - Attach additional reponsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. CName: Wrap OO Principles: Classes should be open for extension but close for modification. Bullet Points: Inheritance is one form of extension, but not necessarily the best way to achieve flexibility in our designs. In our designs we should allow behavior to be extended without the need to modify existing code. Compostion and delegation can often be used to add new...
阅读 1,656 views 次
The Observer Pattern

The Observer Pattern

Observer - defines a ont-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. OO Principles Strive for loosely coupled designs between objects that interact. Bullet Points The Observer Pattern defines a ont-to-many relationship between objects. Subjects, or we also known them, Observables, update Observers using a common interface. Observers are loosely coupled in that the observalbe knows nothing about them, other than that they implement the Observer interface. You can...
阅读 1,631 views 次
The Strategy Pattern

The Strategy Pattern

The Strategy Pattern defines a family of algorithms, encapsulates each once, and makes them interchangebale. Strategy lets the algorithm vary independently from clients that use it. OO Principles: Encapsulate what varies. Favor compostion ove inheritence. Program to interface, not implementation. Bullet Points: Knowing the OO basics does not make you a great OO designer. Good OO designs are reusable, extensible and maitainable. Patterns are proven object-oriented experience. Patterns don't give you code, the give you general solution to design problems....
阅读 1,625 views 次
Road to Excellence

Road to Excellence

看来语言还是很重要的,其实一直都明白这个道理,不过“行胜于言”这句话还是很有道理的。今天看了几篇别人的故事和一些相关的讨论,这种感觉就更加强烈。 多一门语言,路就宽很多。 Tag: Road to Excellence
阅读 1,482 views 次