A lot has been written all over the Internet about what is wrong with repository pattern. A simple Google search would give you lot of interesting articles to read and ponder about. In this section, we would spend some time trying to understand problems introduced by repository pattern.
In the previous chapter, we implemented search employee functionality. We added a FindAll
method on repository for that. From a clean code and maintenance point of view, this method has some issues that need to be addressed. FindAll
takes name of the employee as input along with some other parameters required for performing the search. When we started putting together a repository, we said that Repository<T>
is a common repository class that can be used for any entity. But now FindAll
takes a parameter that is only available on Employee,
thus locking the implementation of FindAll
to the Employee
entity only. In order to keep the repository still reusable...