I am aware of the Open close principle as a part of the SOLID object oriented design patterns. I have a situation where in I have an existing Employee POJO class with 10 fields ,its getter and setter methods, overriden equals and hashcode method. I have a new requirement to add 5 more fields to this old Employee class. Just wanted to know an opinion over this about how to proceed with such a situation? The simple way is to add the new 5 fields to the existing employee class and add it is getters and setters and thus implement the extended functionality. However the open close principle says that you should not touch the existing code and try create a new one by extending the existing one without changing the existing code.
Can somebody please guide me, how to go about it?
Aucun commentaire:
Enregistrer un commentaire