I am really confused about two topics:
1)- Code duplication (I understand very well)
2)- Open-Close Principle (Need explanation when to use it? Which scenarios)
What happened is during an implementation of a new feature, my colleague told me to add a new function (method) in an existing class which was doing a specific job. The problem is that this new function had to do something that was not fine to be in that class. I told him to extends that class and add the function into this new class. He told me if we do that we are going to fall into code duplication but for me, as Junior Developer I was thinking about Open-Close Principle.
So when we should use Open-Close Principle?
Aucun commentaire:
Enregistrer un commentaire