If I have to add a new database column, and by consequence, a new attribute to an Entity, it gonna break the OCP principle?
The government changes the law and we need to persist a new attribute to the database. It's ok about modifying the entity?
Let's say we should persist data about cars and now the government wants us to store in our database another attribute about the car and it became a law to keep this new attribute. It's a main attribute of a car entity, not something like CarAcessory and is a primitive type like a string.
What should I do to keep the OCP?
Thanks
As per Open Close Principle you should be able "Add new functionality by adding new code without modifying old code".
It would be difficult (if not impossible) to make your code always open close.
When you make you your code open close, the complexity of the code increases. If you have a section of code where new requirements are often, then its better to make that part open-close. If you have a section of code where new requirements are not so often, then making it open-close is an over kill.
If you are programming in C#, Java, C++ or C, can you make the Main open close? If you can, what is the cost?