Hi Experts
I have a query regarding the open-closed principle in C#.
As per the principle – classes, functions or modules are open to extension but closed for modification.
Consider the following class: -
public class DBOperations
{
public void Delete()
{ }
public void Upsert(object entity)
{ }
public List<object> GetAll()
{
return new List<object>();
}
}
Now, the requirement is to add one more method to create a stored procedure. As the “DBOperations” class should be closed for modification and open and extension, I will create another class.
public class DBOperationsExt : DBOperations
{
public void ExecuteStoredProcedure(string storedProcName, ....)
{ }
}
Can I say that the above approach qualifies the open-closed principle?