Open closed principle vs Strategy pattern

design-patterns, solid-principles

Solution

OCP comes at a much more general level than Strategy - that's why it is a principle rather than a pattern. OCP doesn't state that there should be a class X that does Y and Z and collaborates in W way with another class. It only states that classes should be closed to modification but open for extension.

You can achieve OCP in a class by externalizing some of its responsibilities to a Strategy and writing new Strategies instead of modifying the class itself, but it is not the only way of respecting OCP. There are other patterns that help achieve OCP, like Abstract Factory.

Problem

I have read both strategy pattern and open closed principle both look same to me.If they are same why we have different name pattern \principle for them. Please share your thoughts on this one.

Original source