Open/Closed Principle (OCP) ਕਹਿੰਦਾ ਹੈ ਕਿ software entities ਨੂੰ extension ਲਈ ਖੁੱਲੇ ਹੋਣੇ ਚਾਹੀਦੇ ਹਨ ਪਰ modification ਲਈ ਬੰਦ: ਤੁਸੀਂ ਨਵੇਂ ਕੋਡ ਨੂੰ ਜੋੜ ਕੇ ਨਵਾਂ behavior ਜੋੜ ਸਕਦੇ ਹੋ, ਪਰ ਮੌਜੂਦ, tested ਕੋਡ ਨੂੰ edit ਕਰ ਕੇ ਨਹੀਂ।
ਉਹ smell ਜਿਸ ਨੂੰ OCP target ਕਰਦਾ ਹੈ
():
shape.kind == : * shape.r **
shape.kind == : shape.s **
shape.kind == : shape.w * shape.h
