Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3242234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:17:28+00:00 2026-05-17T18:17:28+00:00

I have recently been trying to learn about basic design principles and the OCP

  • 0

I have recently been trying to learn about basic design principles and the OCP has me a bit confused. It makes sense that when a change happens it is preferable to extend the system rather than modify existing and working parts. But isn’t this more of a principle for how to implement changes in a system rather than how to design one? Isn’t all code basically open for extension by using subclassing? And how can any code be closed for modification – doesn’t that just depend on how the person implementing a change chooses to use it?

Perhaps an example of some code that doesn’t follow the OCP and how exactly it has violated the principle would be the most helpful for me to understand this.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:17:29+00:00Added an answer on May 17, 2026 at 6:17 pm

    A typical example would be any logic that branches on the type of things.
    Doing this means that every time you need to add a new type, you have to change this code.
    Using virtual functions means that you can just add new classes for new types without changing existing code.

    Open Closed Principle (PDF)

    There are code examples in there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to learn CakePHP's ACL stuff recently but keep getting confused,
I've recently installed Ruby on Rails 3.2 and have been trying to learn it.
I've recently been trying to learn the Object-Oriented aspects of F#, and have become
I have recently begun the process of trying to learn Ruby/Rails and have been
I am trying to learn more about Javascript, I have been coding with PHP
I have been recently trying to deploy a C# application on a computer that
I've recently been trying to port a C++ application. I believe I have all
Recently I have been trying to optimize my tables, mainly because I've learned alot
I recently downloaded the Android Support Package and have been using it trying to
I have recently been assigned a CSS & design project that's in a CakePHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.