Northwind Starter Kit Review: Data Access and the essence of needless work, Part II
2012-01-12 11:50
561 查看
This is a review of the Northwind Starter Kit project, this review revision 94815 from Dec 18 2011.
Yes, this is another repositories are evil if you are using an OR/M post.
That is probably going to cause some reaction, so I am going to back this up with code from this NSK project. Let us talk about repositories, in particular. Let us see what we have here:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_5.png)
Okaay…
Now here are a few problems that I have with this:
There is no value gained by introducing this abstraction. You aren’t adding any capability what so ever.
In fact, since all OR/Ms provide an abstraction that isn’t dependent on type, creating IRepository<T> and things like ICustomerRepository is just making things more complicated.
There are going to be changes in behavior between different repositories implementations that will break your code.
Let us see what we actually have as a result. This is the Entity Framework POCO implementation:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_6.png)
You can probably guess how the rest of it is actually implemented. Yes, we have a LOT of code that is dedicated solely for this sort of forwarding operations.
And then we have the actual implementation of the delete:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_7.png)
Just to remind you, here is the NHibernate implementation of the same function:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_8.png)
Leaving aside the atrocious error handling code, the EF POCO version will do an immediate delete. The NHibernate version will wait for the transaction to be committed.
And don’t worry, I do remember the error handling. This is simply wrong.
And then we have implementations such as this:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_9.png)
This is for the Entity Framework Code First implementation. There is a message here that is coming to me loud and clear. This code wants to be deleted. It is neglected and abused and doesn’t serve any purpose in life except gobble up pieces of valuable disk space that could be filled with the much more valuable result of reading from/dev/random.
Yes, this is another repositories are evil if you are using an OR/M post.
That is probably going to cause some reaction, so I am going to back this up with code from this NSK project. Let us talk about repositories, in particular. Let us see what we have here:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_5.png)
Okaay…
Now here are a few problems that I have with this:
There is no value gained by introducing this abstraction. You aren’t adding any capability what so ever.
In fact, since all OR/Ms provide an abstraction that isn’t dependent on type, creating IRepository<T> and things like ICustomerRepository is just making things more complicated.
There are going to be changes in behavior between different repositories implementations that will break your code.
Let us see what we actually have as a result. This is the Entity Framework POCO implementation:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_6.png)
You can probably guess how the rest of it is actually implemented. Yes, we have a LOT of code that is dedicated solely for this sort of forwarding operations.
And then we have the actual implementation of the delete:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_7.png)
Just to remind you, here is the NHibernate implementation of the same function:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_8.png)
Leaving aside the atrocious error handling code, the EF POCO version will do an immediate delete. The NHibernate version will wait for the transaction to be committed.
And don’t worry, I do remember the error handling. This is simply wrong.
And then we have implementations such as this:
![](http://ayende.com/blog/Images/Windows-Live-Writer/Northwind-Starter-Kit-Review-Data-Access_4221/image_thumb_9.png)
This is for the Entity Framework Code First implementation. There is a message here that is coming to me loud and clear. This code wants to be deleted. It is neglected and abused and doesn’t serve any purpose in life except gobble up pieces of valuable disk space that could be filled with the much more valuable result of reading from/dev/random.
相关文章推荐
- Application review: Northwind Starter Kit
- How to get the Diagnostic data and debug file of Sales Order pick release
- 106.Examine the data in the LIST_PRICE and MIN_PRICE columns of the PRODUCTS table:
- 海洋工作室——网站建设专家:The version of SQL Server in use does not support datatype datetime2 and the Entity Framework.
- A Data Access Layer to persist business objects using attributes and reflection - Part II [无常译]
- Machine-Learning Maestro Michael Jordan on the Delusions of Big Data and Other Huge Engineering Effo
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- BigQueue:The Architecture and Design of a Publish & Subscribe Messaging System Tailored for Big Data
- Python Web-第六周-JSON and the REST Architecture(Using Python to Access Web Data)
- Zhenjiang deployment of current and the first quarter of next year to start work
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- Data migration to generate the maximum value of the sequence between beta scheme and appbeta scheme
- [Clojure] Data Collection and Data Analysis on the music of www.xiami.com - Part 3
- The Essence of Object-Oriented Programming with Java and UML
- BlueROV-6: Quick Start of Dronekit and Connect Dronekit to the Vehicle
- Automating the Creation of Data-Rich Business Documents with Word 2007 and ASP.NET
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- Review the Bit and Version and Kernel of CentOS
- Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10)