﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Jeffrey Palermo commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I don't like statics anywhere, but I can live with them in cases like SystemClock as a wrapper for service-locating my ISystemClock instance when I do time-sensitive calculations in my domain objects ( or even when setting LastUpdated).  Beyond that, I like to use Interface fields.
  
  
I prefer to pass in IMyRepository to the constructor of classes that need it.
  
  
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment11</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment11</guid><pubDate>Thu, 21 Jun 2007 14:28:52 GMT</pubDate></item><item><title>Bill Pierce commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>With a large domain you could end up with a lot of properties cluttering up your BaseController.  
  
  
Also as a side note, wouldn't this play havoc with the debugger when you quick watch your controller?  I would need to resolve all of your properties which would hit your container?  Not really a big deal but I know that you already punish devenv mercilessly :)
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment10</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment10</guid><pubDate>Tue, 05 Jun 2007 14:07:39 GMT</pubDate></item><item><title>Weex commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I second Ramon on not defining managers in a base class. It's kind of code smell and makes your controllers fragile and dependent on the base implementation. Given the fact I'm using IoC to retrieve my controllers I personally don't  find it a burden for me to generate all the code for member managers using R#. Indeed, just type in something like
  
IRepository&lt;User&gt; _repository; 
  
then Alt-Ins -&gt; generate read properties, generate constructor. That's it. 
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment9</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment9</guid><pubDate>Tue, 05 Jun 2007 13:18:17 GMT</pubDate></item><item><title>Craig Neuwirt commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I think  that is a great approach especially when using dependency injection for those repositories.
  
  
craig
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment8</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment8</guid><pubDate>Tue, 05 Jun 2007 13:16:17 GMT</pubDate></item><item><title>Ayende Rahien commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>Because then I would need something like: Managers.Users, no?
  
Cut the middle management, I say :-)
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment7</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment7</guid><pubDate>Tue, 05 Jun 2007 11:53:35 GMT</pubDate></item><item><title>Ramon Smits commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>Why don't you just define a new class that contains properties that make the typed managers available and use that from the controller class?
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment6</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment6</guid><pubDate>Tue, 05 Jun 2007 10:47:07 GMT</pubDate></item><item><title>Ayende Rahien commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I am thinking about defining them in the base class because that makes them easily accessible for all controllers. Just a way to reduce the amount of things that you need to do.
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment5</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment5</guid><pubDate>Tue, 05 Jun 2007 10:33:04 GMT</pubDate></item><item><title>Ramon Smits commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I also use a a generic wrapper around the session object and derive my entity managers from this wrapper.
  
  
I don't like the way that you define your managers in your base class. Seems like it should just be but in the OrdersController as datamembers. Employees and customers arent managed by the orderscontroller so it would be weird if it could access these through its base class.
  
  
Better use a kind of dependency injection or factory pattern to initialize these at construction/initialisation of your ordercontroller.
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment4</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment4</guid><pubDate>Tue, 05 Jun 2007 09:04:09 GMT</pubDate></item><item><title>Sean Chambers commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>I have a GenericRepository&lt;T&gt; class that holds all common methods like, GetById, GetByQuery, Save, SaveOrUpdate and just wraps the NHibernate session object.
  
  
I also have classes that derive from GenericRepository and implement an interface that lives in my domain model.
  
  
ie.
  
  
public class ItemRepository : GenericRepository&lt;Item, int&gt;, IItemRepository
  
  
Then any specific functionality to that repository I can place in ItemRepository and inherit the rest from GenericRepository. The second type parameter denotes what type the PK is.
  
  
I've only used it on two projects but I like how it works thus far. I can't take complete credit though, I originally saw how Bill McCafferty had a tutorial setup on thecodeproject and used that as a guide. I felt alot of his genercrepository class had a little too much unneeded functionality.
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment3</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment3</guid><pubDate>Tue, 05 Jun 2007 04:21:48 GMT</pubDate></item><item><title>Ayende Rahien commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>Well, what do you call with?
  
  
Where.Order.Customer == customer &amp;&amp; Where.Order.Status == OrderStatus.ReadyToShip &amp;&amp;
  
Where.Order.Date &gt;= DateTime.Today
  
  
To me this _is_ a specification, and for the complex ones I would move it to the repository, for SoC.
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment2</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment2</guid><pubDate>Tue, 05 Jun 2007 03:13:13 GMT</pubDate></item><item><title>Harris commented on Repository&lt;T&gt;, Syntactic Sugar and DDD</title><description>Given that I am still very new to understanding DDD, I'm curious to wonder why the repository (interface or otherwise) isn't abstracted behind either a reusable query or some sort of "service" object?  The fact that the abstraction could be viewed as over-designin the canonical "Customer with Orders of Products" sample, a non-trivial application could/would benefit in a specific query (Specification pattern?) object that would delegate to the Repository; or the encapsulation of many reusable queries and other actionable operations within a Service object?  To apply this to the given example, an OrderService that, when a customer completes an order, updates the customer's record such that their "rewards account" reflects with their most recent purchase.
  
  
Ignoring, for the moment, that my example may violate Single Responsibility/Separation of Concerns, would such an application be valid with regards to the Repository&lt;T&gt;?
  
  
Your blog is a wealth of information.  Thanks so much for contributing to the community in all the ways you do!!!
</description><link>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment1</link><guid>http://ayende.com/2494/repository-t-syntactic-sugar-and-ddd#comment1</guid><pubDate>Tue, 05 Jun 2007 02:34:45 GMT</pubDate></item></channel></rss>