O'Reilly logo

Mastering JavaScript Object-Oriented Programming by Andrea Chiarelli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Open/Closed Principle

The second SOLID principle concerns the extensibility of components and is called the Open/Closed Principle. Its focus is on avoiding changes when we need to extend a component's feature. The principle states:

Software entities like classes, modules and functions should be open for extension but closed for modifications.

In the design of the components of our application, we have to take into account these two aspects:

  • Open for extension: The components should be adjustable to the changing needs of the application
  • Closed for modifications: The required changes should not involve the original component itself

If we apply this principle, we can get more easily adaptable and maintainable applications.

To illustrate how to apply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required