<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://thoughtshapes.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ThoughtShapes - Patterns - Comments</title>
 <link>http://thoughtshapes.com/taxonomy/term/3</link>
 <description>Comments for &quot;Patterns&quot;</description>
 <language>en</language>
<item>
 <title>Thank you for taking the</title>
 <link>http://thoughtshapes.com/node/21#comment-598</link>
 <description>&lt;p&gt;Thank you for taking the time to respond. Everything you said makes perfect sense, and it is nice to have this type of validation when coding DDD. &lt;/p&gt;
&lt;p&gt;I believe passing the Repository to the constructor makes more sense because we should argue that the Customer does not have the “knowledge” to know which repository to create, and therefore it is logical for CustomerFactory to do this job (and it works better with unit tests). So I agree with all your point.&lt;/p&gt;
&lt;p&gt;At this point, I am trying to use NHibrante to implement a prototype on this idea. When I am done, I will post it on my blog (&lt;a href=&quot;http://mikeperetz.blogspot.com/&quot; title=&quot;http://mikeperetz.blogspot.com/&quot;&gt;http://mikeperetz.blogspot.com/&lt;/a&gt;) I would love your feedback on it.&lt;/p&gt;
</description>
 <pubDate>Mon, 19 Nov 2007 22:01:51 -0500</pubDate>
 <dc:creator>Anonymous</dc:creator>
 <guid isPermaLink="false">comment 598 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>Thanks for the complement on</title>
 <link>http://thoughtshapes.com/node/21#comment-597</link>
 <description>&lt;p&gt;Thanks for the complement on the article.  &lt;/p&gt;
&lt;p&gt;You raise an interesting (and common) problem.  If I were to implement lazy loading here to deal with the customer who had placed a million orders I would allow the Customer class to interact with an interface to an order repository (IOrderRepository).  It would obtain an implemenation of that interface by calling a repository factory object to get the concrete implemenation and then use that to retrieve a smaller subset of the data.  Using your example of a date range I would implement the customer get order method like so:&lt;/p&gt;
&lt;pre class=&quot;code cs&quot;&gt;
public class Customer
{
      IList GetOrders(DateTime from, DateTime to)
      {
           return RepositoryFactory.OrderRepository.GetOrders(this, from, to);
       }
}&lt;/pre&gt;&lt;p&gt;
Now since the Customer class is really referring to an IOrderRepository, I&#039;d say that the Repository interface lives in the domain (with its client), and the concrete implementations live in their own namespaces (and probably assemblies).  &lt;/p&gt;
&lt;p&gt;Note that although I&#039;m using a RepositoryFactory in this example, I might provide the indirection by just passing the IOrderRepository to the Customer when I created it.  (This implies that whatever object created the Customer object would get the concrete implementation from the RepositoryFactory because we still want that run-time configurability.)   I usually determine whether or not to pass the repository instances to the object on its constructor or have it use the RepositoryFactory directly based upon whether the object uses multiple repositories.  If it uses one or two different repositories, I pass the instances, otherwise I just have the object use the RepositoryFactory to get the instances.&lt;/p&gt;
&lt;p&gt;Does that make sense to you?&lt;/p&gt;
</description>
 <pubDate>Mon, 19 Nov 2007 12:19:00 -0500</pubDate>
 <dc:creator>Rob Scott</dc:creator>
 <guid isPermaLink="false">comment 597 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>First of all, you wrote a</title>
 <link>http://thoughtshapes.com/node/21#comment-596</link>
 <description>&lt;p&gt;First of all, you wrote a very nice article. I think you are touching very fundamental issues. I am studying DDD now, and having trouble with a few scenarios.&lt;/p&gt;
&lt;p&gt;Where do Repositories live? I feel that I am very limited if the repositories live within the Application layer only. I think lazy loading becomes a must in one point, because you don’t want to bring too much data from the database.&lt;/p&gt;
&lt;p&gt;I also feel, that if you were to implement Specification pattern (Evens), then again you need the Repositories. Having said that, I think you should only use interfaces to them, and never use their true implementation. &lt;/p&gt;
&lt;p&gt;When coding I sometime have a “the million rule”, what if there is a million orders to a customer. Or what if there are a million history records for a transaction. We should never bring that type of data down. We should probably use Query Pattern, which will work with Repositories.&lt;/p&gt;
&lt;p&gt;Now I wonder, if I was to create a Customer and Order classes… does this makes snese?&lt;/p&gt;
&lt;p&gt;List orders = customer.GetOrders(); // use Repository to implement this&lt;br /&gt;
Or&lt;br /&gt;
List order = customer.GetOrders(DateTime fromDate) // use Repository with Query pattern&lt;/p&gt;
&lt;p&gt;What about adding an order?&lt;br /&gt;
customer.AddNewOrder(order);&lt;/p&gt;
&lt;p&gt;Does code like that is DDD? If yes, the Repositories do live within the domain… &lt;/p&gt;
&lt;p&gt;What is your take on this?&lt;br /&gt;
(Let’s assume that you can have a million orders per customer)&lt;/p&gt;
</description>
 <pubDate>Sun, 18 Nov 2007 10:10:13 -0500</pubDate>
 <dc:creator>Anonymous</dc:creator>
 <guid isPermaLink="false">comment 596 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>Office 2000/2003 version of</title>
 <link>http://thoughtshapes.com/node/68#comment-594</link>
 <description>&lt;p&gt;Office 2000/2003 version of documents have been attached to this posting.&lt;/p&gt;
</description>
 <pubDate>Sat, 03 Nov 2007 00:09:11 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">comment 594 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>Much of the material is</title>
 <link>http://thoughtshapes.com/node/68#comment-584</link>
 <description>&lt;p&gt;Much of the material is based on Robert C. Martin&#039;s &lt;a href=&quot;http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445/ref=sr_1_2/104-9536311-7327920?ie=UTF8&amp;amp;s=books&amp;amp;qid=1193417002&amp;amp;sr=8-2&quot;&gt;Agile Software Development, Principles, Patterns, and Practices&lt;/a&gt;. There is also a new &lt;a href=&quot;http://www.amazon.com/Principles-Patterns-Practices-Robert-Martin/dp/0131857258/ref=sr_1_1/104-9536311-7327920?ie=UTF8&amp;amp;s=books&amp;amp;qid=1193417002&amp;amp;sr=8-1&quot;&gt;C#-only revision&lt;/a&gt;.&lt;/p&gt;
</description>
 <pubDate>Fri, 26 Oct 2007 12:45:43 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">comment 584 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>The Monostate design pattern</title>
 <link>http://thoughtshapes.com/node/49#comment-57</link>
 <description>&lt;p&gt;The Monostate design pattern takes the general form:&lt;/p&gt;
&lt;pre class=&quot;code cs&quot;&gt;public class ClassName
{
    private static int theStaticState = 0;

    public virtual int StaticState
    {
        get { return theStaticState; }
        set { theStaticState = value; }
    }
}
&lt;/pre&gt;&lt;p&gt;The type itself is not limited to a single instance but its state is. In this way the benefits of polymorphism are protected (no pun intended ;-).&lt;/p&gt;
</description>
 <pubDate>Mon, 30 Apr 2007 10:37:26 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">comment 57 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>I should add that there is</title>
 <link>http://thoughtshapes.com/node/49#comment-56</link>
 <description>&lt;p&gt;I should add that there is another way for a MarshalByRefObject to indicate infinite lifetime. Return null from InitializeLifetimeService as in:&lt;/p&gt;
&lt;pre class=&quot;code cs&quot;&gt;public override object InitializeLifetimeService()
{
    return null;
}
&lt;/pre&gt;&lt;p&gt;Unless your object needs control over sponsor and renewal lifetime it is best to use this approach.&lt;/p&gt;
</description>
 <pubDate>Mon, 30 Apr 2007 10:19:52 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">comment 56 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>I&#039;d like to point something</title>
 <link>http://thoughtshapes.com/node/49#comment-55</link>
 <description>&lt;p&gt;I&#039;d like to point something out that might not be obvious to all readers.  In Rjae&#039;s post you&#039;ll notice that he doesn&#039;t provide the code for the types he mentions (Message and MessageRepository) but instead provides the test fixtures that test these types.  This is a very important, conscious (and I believe totally correct) decision he must have made and it emphasizes what we practice: The tests are the most important thing in the code.  I say &quot;must have made&quot; in the previous sentence because I normally don&#039;t like making assumptions about another&#039;s thoughts,  but I do know the way Rjae thinks in regards to this area and I also know his thoughts totally jibe with mine.&lt;/p&gt;
&lt;p&gt;One perspective in particular to try to grab hold of is to look at the test fixture method names.  When I read the test method names I gain an instant understanding of what the behavior of the CUT (Class Under Test) is.  I therefore gain a much quicker understanding of the class than I would if I was looking at the actual code for the class.  I&#039;m not sure how obvious this is to readers, so I think it&#039;s worth mentioning.  Even if you&#039;re only developing a class library for a client, it&#039;s a good idea to ship all the tests with the code.  I know that if I hire someone to create a library for me I&#039;d be giddy if they give me all the tests.  (This is really not true, but only because I&#039;d expect all the tests in advance--since that would be part of the contract with the library writer.  If I didn&#039;t have such a contract, then I&#039;d be giddy.)&lt;/p&gt;
&lt;p&gt;And, as I&#039;ve said before and will say again, this is why the tests serve as the documentation.&lt;/p&gt;
</description>
 <pubDate>Fri, 27 Apr 2007 10:15:13 -0400</pubDate>
 <dc:creator>Steve Seymour</dc:creator>
 <guid isPermaLink="false">comment 55 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>(No subject)</title>
 <link>http://thoughtshapes.com/node/20#comment-14</link>
 <description>&lt;p&gt;Hey, I should also say that we’re doing another session on TDD for our user group next Wednesday, if you happen to be in town. It’ll be on TDD and the GUI…should be fun…I think we have a lot of good content to share. Let me know if you can make it.&lt;/p&gt;
</description>
 <pubDate>Wed, 14 Mar 2007 18:59:00 -0400</pubDate>
 <dc:creator>Steve Seymour</dc:creator>
 <guid isPermaLink="false">comment 14 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>(No subject)</title>
 <link>http://thoughtshapes.com/node/20#comment-13</link>
 <description>&lt;p&gt;Hey, massybird.&lt;/p&gt;
&lt;p&gt;I thought about it, and I also thought about using a static readonly NullTheoretical cached in the DomainObjectThatHasTheoreticalValue. I didn’t do it your way because I don’t want anyone setting the value to null. The best way would probably be to check to see if the value it is set to is null, and, if so, then set it to a cached static readonly instance of NullTheoretical. Agree? There was a bit of me that didn’t do it this way because I wanted to display the concept of not optimizing up front, but I would probably do it with the static readonly instance.&lt;/p&gt;
&lt;p&gt;Are you Chief Architect/CEO/President/Superman over there yet?&lt;/p&gt;
&lt;p&gt;:)&lt;/p&gt;
</description>
 <pubDate>Wed, 14 Mar 2007 18:56:00 -0400</pubDate>
 <dc:creator>Steve Seymour</dc:creator>
 <guid isPermaLink="false">comment 13 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>(No subject)</title>
 <link>http://thoughtshapes.com/node/20#comment-12</link>
 <description>&lt;p&gt;Hey Steve,&lt;/p&gt;
&lt;p&gt;Good illustration of polymorphism. Why not altogether get rid of IFs from your example, as follows:&lt;/p&gt;
&lt;p&gt;public class DomainObjectThatHasTheoreticalValue&lt;br /&gt;
{&lt;br /&gt;
private ITheoretical itsTheoretical = new NullTheoretical( );&lt;/p&gt;
&lt;p&gt;public virtual ITheoretical TheoreticalValue&lt;br /&gt;
{&lt;br /&gt;
get { return itsTheoretical; }&lt;br /&gt;
set { itsTheoretical = value ; }&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;Is there a chance that ThoreticalValue getter will never be accessed and you’re delaying object creation? But then again, as you said, NullTheoretical has small overhead. CU!&lt;/p&gt;
</description>
 <pubDate>Wed, 14 Mar 2007 16:44:00 -0400</pubDate>
 <dc:creator>massybird</dc:creator>
 <guid isPermaLink="false">comment 12 at http://thoughtshapes.com</guid>
</item>
</channel>
</rss>
