I am trying to get my head around the open closed principle:
Modules should be open for extension and closed for modification
In terms of java is the extension specifically inheritance or does it include inheritance as well as the addition of new methods or properties?
I am also struggling to get my head around closed for modification, it seems to be implying to me that once a method is written that it cannot change.
This seems at odds with real work where I will pick up tasks from jira which will require me to change at least one method in the codebase.
I have read lots of posts and articles in the last 24 hours and I am still not entirely sure what this principle is trying to get across.
Any simple explanation would be very helpful.
you should write your code well enough to not have to modify existing code. Ever. If you need functionality of an existing method, you should be able to call that method because it should be highly cohesive have extremely low coupling.
Think of it this way, once you build a house, is it better to try to double the size of your bathroom (moving toilet and show back re-flooring, new walls... etc) or is it easier to build a sunroom off of the front of the house with a new entryway?
You should be closed to modifying the bedroom, while it is not impossible, making a sun room will create the new space much easier.