I am trying to figure out the best way to change an existing class. So the class is called ExcelReport and it has one method Create(data,headings). This is live and used in many places. Now recently I want to change the method so I can format columns in excel. Create(data,headings,columnformats) So as not to upset my existing programs the best I can come up with is to add another method Create2(data,headings,columnformats) to the class. o.k I got a lot of suggestions saying I should modify the existing class with a overloaded method, which I did. But does this not break the Open/Close Principle as my existing class was in production ? Should I have created a new class ExcelReport2(and Interface) with the new improved method and passed this into my new program using dependency injection ?
Aucun commentaire:
Enregistrer un commentaire