zoukankan      html  css  js  c++  java
  • Northwind Starter Kit Review: Data Access and the essence of needless work, Part II

    This is a review of the Northwind Starter Kit project, this review revision 94815 from Dec 18 2011.

    Update: Andrea, the project’s leader has posted a reply to this series of posts.

    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:

    image

    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:

    image

    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:

    image

    Just to remind you, here is the NHibernate implementation of the same function:

    image

    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:

    image

    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.

  • 相关阅读:
    如何书写bat文件?(转)
    Bogon
    recursive
    ssh
    verbose
    mii-tool
    ExtJs 中的ext.date
    一个打包机~~~
    图标库--宝藏
    几种常用的控件(下拉框 可选框 起止日期 在HTML页面直接读取当前时间)
  • 原文地址:https://www.cnblogs.com/shihao/p/2320395.html
Copyright © 2011-2022 走看看