D
Dikong42
Guest
public interface IRepositoryBase<T>
{
object Create(T obj);
T Retrieve(Guid key);
int Update(T obj);
int Delete(object key);
}
I often saw this kind of interface every time i'm reading about Repository pattern. Some might be slightly different but the intent is to make sure all the inheriting class will implement all these methods. Aside from that, i don't see any much benefit following this approach. I can easily create those methods myself without needing the inheritance as some table might not need one of those methods resulting in throwing not implemented exception(You can use interface segregation here though). I guess interface inheritance is not only making sure the inheriting class implement those methods but to solve problems like polymorphism. That's what i'm interested to look into but haven't find any example yet on using this pattern.
I would love to see a simple code snippet showing how can i achieve polymorphism here.
Regards
Continue reading...
{
object Create(T obj);
T Retrieve(Guid key);
int Update(T obj);
int Delete(object key);
}
I often saw this kind of interface every time i'm reading about Repository pattern. Some might be slightly different but the intent is to make sure all the inheriting class will implement all these methods. Aside from that, i don't see any much benefit following this approach. I can easily create those methods myself without needing the inheritance as some table might not need one of those methods resulting in throwing not implemented exception(You can use interface segregation here though). I guess interface inheritance is not only making sure the inheriting class implement those methods but to solve problems like polymorphism. That's what i'm interested to look into but haven't find any example yet on using this pattern.
I would love to see a simple code snippet showing how can i achieve polymorphism here.
Regards
Continue reading...