开发者

Pros and cons of having static repositories in ASP.NET MVC application

开发者 https://www.devze.com 2022-12-19 17:22 出处:网络
What are the pros and cons of using static repositories in an ASP.NET MVC application? Wouldn\'t it be bette开发者_开发技巧r to have all the methods available all the time -> means that the class get

What are the pros and cons of using static repositories in an ASP.NET MVC application?

Wouldn't it be bette开发者_开发技巧r to have all the methods available all the time -> means that the class get's instantiated only once instead of having multiple controllers referencing to the same repository class and its methods?

Or do I get something wrong here?

All help is more than appreciated!


Pros:

  • Repository is accessible everywhere

Cons:

  • Repositories don't implement a contract which leads to a strong coupling between consumers of the repository and the implementation
  • Impossible to unit test
  • Might run into threading issues

Remark: Instantiating the repository on every request shouldn't be regarded as a performance issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号