Open-Closed Principle

As usage; It tells you not to make changes to your existing code because when you make changes, there is a possibility of making changes to the classes derived from the class you changed.

For example, let’s assume that you do not keep first and last names separately in a class with user information. This is how you print it in all of the subclasses you derive from when the first and last name are combined. If you want to separate the name and surname later, you need to make corrections in all the classes you use. However, if you want to add a field called gender to this class, there will be no problem.

You may also like...