c# - Liskov Substitution Principle and Redundant Methods -


i have interface called irepository. interface defines set of generic methods such as:

 iqueryable<t> get<t>() t : class;  void add<t>(t obj) t : class;  void update<t>(t obj) t : class;  void savechanges(); 

i have class implements interface. class uses entity framework implement these methods. method update redundant entity framework tracks changes made entities retrieved entity want, update call savechanges. in future may want replace concrete implementation of irepository else. won't track changes entity framework does. i'm thinking want leave update method in interface, in concrete implementation of interface leave method in doing nothing. e.g.

public void update<t>(t obj) t : class { } 

this seems fit liskov substitution principle, can replace implementation of interface else. it's somethings might not need implement methods defined on interface.

is approach. thinking okay maybe mark method obsolete in implementation of irepository stating why obsolete in implementation.

it seems bit odd having update method nothing , having called on application though doesn't anything. if changed implemenation of irepository, implmentation need update method can substitute in no code changes required.

imho, having method on interface not implemented in situations tells me scope of interface wide.

you remove update method base repository interface , add alone iupdatablerepository inherits base interface. concrete classes need update can implement iupdatablerepository interface instead.

this may not you're looking for, point...


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -