Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should take a look what <a href="http://tekpub.com/view/concepts/1" rel="nofollow noreferrer">dependency injection</a> and inversion of control in general means. That would provide ability to control life cycle of <code>ObjectContext</code> "from outside". You could ensure that only 1 instance of object context is used for every http request. To avoid managing dependencies manually, I would recommend using <a href="http://dotnetslackers.com/articles/designpatterns/IntroductionToStructureMap.aspx" rel="nofollow noreferrer">StructureMap</a> as a container.</p> <p>Another useful (but quite tricky and hard to do it right) technique is abstraction of persistence. Instead of using <code>ObjectContext</code> directly, You would use so called <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">Repository</a> which is responsible to provide collection like API for Your data store. This provides useful <em>seam</em> which You can use to switch underlying data storing mechanism or to mock out persistence completely for tests.</p> <p>As Jason suggested already - You should also use <a href="https://stackoverflow.com/questions/2478081/entity-framework-4-poco-where-to-start">POCO`s</a> (plain old clr objects). Despite that there would still be implicit coupling with entity framework You should be aware of, it's much better than using generated classes.</p> <p>Things You might not find elsewhere fast enough:</p> <ol> <li>Try to avoid usage of <a href="https://stackoverflow.com/questions/4425750/should-a-repository-implement-unitofwork/4428982#4428982">unit of work</a>. Your model should define transactional boundaries.</li> <li>Try to avoid usage of <a href="https://stackoverflow.com/questions/1230571/advantage-of-creating-a-generic-repository-vs-specific-repository-for-each-objec/1231473#1231473">generic repositories</a> (do note point about IQueryable too). </li> <li>It's not mandatory to spam Your code with <a href="http://fragmental.tw/2010/12/23/how-to-write-a-repository/" rel="nofollow noreferrer">repository pattern name</a>.</li> </ol> <p>Also, You might enjoy reading about <a href="http://rads.stackoverflow.com/amzn/click/0321125215" rel="nofollow noreferrer">domain driven design</a>. It helps to deal with complex business logic and gives great guidelines to makes code less procedural, more object oriented.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload