close

OCP: the Open-Closed Principle
Software entities (class, modules, functions, etc.) should be open for extension, but closed for modification.


一個軟體個體應該要夠開放使得它可以被擴充,但是也要夠封閉以避免不必要的修改。這樣解釋鄉民們應該還是看不懂,接著看 Robert 在書中所說得這段話就會很清楚了 (p. 99):


When a single change to a program results in a cascade of changes to dependent modules, the design smells of Rigidity. The OCP advises us to refactor the system so that further changes of that kind will not cause more modifications. If the OCP is applied well, then further changes of that kind are achieved by adding new code, not by changing old code that already works.

資料來源:搞笑談軟工(Teddy Chen)

 

arrow
arrow
    文章標籤
    Software Design 軟體設計 OCP
    全站熱搜
    創作者介紹
    創作者 Robert 的頭像
    Robert

    Robert 的部落格

    Robert 發表在 痞客邦 留言(0) 人氣()