<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Entities: Required Properties And Properties That Shouldn&#8217;t Be Modified</title> <atom:link href="http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Wed, 08 Feb 2012 11:42:42 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10632</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Sat, 28 Mar 2009 09:50:54 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10632</guid> <description>@Peterno, if you have a one-to-many collection of say, Person objects where Persons can be either Customers or Employees or whatever, the collection you&#039;ve used will not contain proxies of these instances... they will just be instances of the type they represent.  The collection however, is the one that enables the lazy-loading in this case.  Access the collection and it will retrieve the data if it&#039;s not there yet, but the retrieved objects themselves will not be proxies (though their many-to-one properties will be proxy instances if lazy-loading isn&#039;t disabled for those associations)</description> <content:encoded><![CDATA[<p>@Peter</p><p>no, if you have a one-to-many collection of say, Person objects where Persons can be either Customers or Employees or whatever, the collection you&#8217;ve used will not contain proxies of these instances&#8230; they will just be instances of the type they represent.  The collection however, is the one that enables the lazy-loading in this case.  Access the collection and it will retrieve the data if it&#8217;s not there yet, but the retrieved objects themselves will not be proxies (though their many-to-one properties will be proxy instances if lazy-loading isn&#8217;t disabled for those associations)</p> ]]></content:encoded> </item> <item><title>By: Peter Morris</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10606</link> <dc:creator>Peter Morris</dc:creator> <pubDate>Fri, 27 Mar 2009 16:16:26 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10606</guid> <description>There are 2 things at the moment really putting me off using NH.1: Using proxies requires me to make my properties virtual, this makes me cringe!  I only expose state when I need to, to make them virtual too makes me feel so dirty, and not the good kind of dirty.2: I read (NHibernate in Action I believe) that when you have a multi association and the instances are really a mixture of base class instances and descendant instances the proxy approach will create a proxy of the base class for every entry.  That CAN&#039;T be right, can it?</description> <content:encoded><![CDATA[<p>There are 2 things at the moment really putting me off using NH.</p><p>1: Using proxies requires me to make my properties virtual, this makes me cringe!  I only expose state when I need to, to make them virtual too makes me feel so dirty, and not the good kind of dirty.</p><p>2: I read (NHibernate in Action I believe) that when you have a multi association and the instances are really a mixture of base class instances and descendant instances the proxy approach will create a proxy of the base class for every entry.  That CAN&#8217;T be right, can it?</p> ]]></content:encoded> </item> <item><title>By: Jan Van Ryswyck</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10523</link> <dc:creator>Jan Van Ryswyck</dc:creator> <pubDate>Wed, 25 Mar 2009 19:28:05 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10523</guid> <description>I completely agree with the gist of this post. I&#039;ll propably go one step further: making a seperate method for changing the mutable as well. In this particular example you can get away with setters, but more involved examples require one atomic change of the mutable properties. This is way I generally consider a setter property a bad thing for entities. I wrote about this in the past:http://elegantcode.com/2008/09/26/properties-a-false-sense-of-encapsulation/</description> <content:encoded><![CDATA[<p>I completely agree with the gist of this post. I&#8217;ll propably go one step further: making a seperate method for changing the mutable as well. In this particular example you can get away with setters, but more involved examples require one atomic change of the mutable properties. This is way I generally consider a setter property a bad thing for entities. I wrote about this in the past:</p><p><a
href="http://elegantcode.com/2008/09/26/properties-a-false-sense-of-encapsulation/" rel="nofollow">http://elegantcode.com/2008/09/26/properties-a-false-sense-of-encapsulation/</a></p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10520</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 25 Mar 2009 19:08:27 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10520</guid> <description>@Bill&quot;Who determines what data is required for an entity?&quot;there is at least some minimum defined in your dabatase (if you use one), and those are the ones you might as well put in your constructor.  No matter what the &quot;business&quot; says, as long as they are required in the database i&#039;d prefer to put those in the constructor. If they really aren&#039;t required anymore you can just lift the not-null restriction in the database and get rid of the argument in the constructor.Until that off the wall requirement is introduced (_if_ it happens), i&#039;d prefer protection against non-nullable database columns over a hypothetical flexibility that i might never need.  And once that off the wall requirement comes along, i&#039;d consider getting rid of the not-null constraint.</description> <content:encoded><![CDATA[<p>@Bill</p><p>&#8220;Who determines what data is required for an entity?&#8221;</p><p>there is at least some minimum defined in your dabatase (if you use one), and those are the ones you might as well put in your constructor.  No matter what the &#8220;business&#8221; says, as long as they are required in the database i&#8217;d prefer to put those in the constructor. If they really aren&#8217;t required anymore you can just lift the not-null restriction in the database and get rid of the argument in the constructor.</p><p>Until that off the wall requirement is introduced (_if_ it happens), i&#8217;d prefer protection against non-nullable database columns over a hypothetical flexibility that i might never need.  And once that off the wall requirement comes along, i&#8217;d consider getting rid of the not-null constraint.</p> ]]></content:encoded> </item> <item><title>By: Bill Pierce</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10515</link> <dc:creator>Bill Pierce</dc:creator> <pubDate>Wed, 25 Mar 2009 15:54:25 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10515</guid> <description>This topic is one of my rant triggers so I apologize in advance.I have this discussion often with devs I work with.  &quot;without too much trouble you can make sure that your entities always have their required data&quot;.  Who determines what data is required for an entity?  The answer should be &quot;the business&quot;.  Why enforce that at the entity level?  Let the consumer of the entity assert whether or not the information is valid.  Or delegate the validation to some business rules validator.  Why don&#039;t you take it all the way and make the quantity and unit price unsigned?In your code I presume you never have a line that looks like this:if( orderLine.Order != null ) or if( orderLine.Product != null )Right?  Because the Order and Product will never be null.  Until some off the wall requirement is introduced.I&#039;m sure there are aspects of an OrderLine that can be tested without an order or a product.</description> <content:encoded><![CDATA[<p>This topic is one of my rant triggers so I apologize in advance.</p><p>I have this discussion often with devs I work with.  &#8220;without too much trouble you can make sure that your entities always have their required data&#8221;.  Who determines what data is required for an entity?  The answer should be &#8220;the business&#8221;.  Why enforce that at the entity level?  Let the consumer of the entity assert whether or not the information is valid.  Or delegate the validation to some business rules validator.  Why don&#8217;t you take it all the way and make the quantity and unit price unsigned?</p><p>In your code I presume you never have a line that looks like this:</p><p>if( orderLine.Order != null ) or if( orderLine.Product != null )</p><p>Right?  Because the Order and Product will never be null.  Until some off the wall requirement is introduced.</p><p>I&#8217;m sure there are aspects of an OrderLine that can be tested without an order or a product.</p> ]]></content:encoded> </item> <item><title>By: Arjan`s World &#187; LINKBLOG for March 25, 2009</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10513</link> <dc:creator>Arjan`s World &#187; LINKBLOG for March 25, 2009</dc:creator> <pubDate>Wed, 25 Mar 2009 14:56:16 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10513</guid> <description>[...] Entities: Required Properties And Properties That Shouldn’t Be Modified - Davy Brion [...]</description> <content:encoded><![CDATA[<p>[...] Entities: Required Properties And Properties That Shouldn’t Be Modified &#8211; Davy Brion [...]</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10504</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 25 Mar 2009 13:04:19 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10504</guid> <description>@Peteras far as i know, everything has to be virtual if you want NH to use proxies.the fact that members aren&#039;t virtual by default is what makes me cringe ;)</description> <content:encoded><![CDATA[<p>@Peter</p><p>as far as i know, everything has to be virtual if you want NH to use proxies.</p><p>the fact that members aren&#8217;t virtual by default is what makes me cringe <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Peter Morris</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10503</link> <dc:creator>Peter Morris</dc:creator> <pubDate>Wed, 25 Mar 2009 12:59:31 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10503</guid> <description>Doesn&#039;t it make you cringe making all your properties virtual?  Also, don&#039;t you only have to make single-association end properties virtual and not simple types such as int, string etc, and not multi-associations (such as Order.Lines)?</description> <content:encoded><![CDATA[<p>Doesn&#8217;t it make you cringe making all your properties virtual?  Also, don&#8217;t you only have to make single-association end properties virtual and not simple types such as int, string etc, and not multi-associations (such as Order.Lines)?</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10497</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 25 Mar 2009 11:06:15 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10497</guid> <description>if you merely generate code for others, without investing time into making sure that everyone knows _why_ the code looks like that, they usually won&#039;t learn from it.integrating patterns &amp; best practices in tools is obviously good, but generated code doesn&#039;t really fit into that category IMO, unless we&#039;re talking about really small stuff.  I&#039;ve seen how code generation based on the database structure leads to a host of problems time and time again, and there&#039;s really nothing that can get me to ever consider it again.</description> <content:encoded><![CDATA[<p>if you merely generate code for others, without investing time into making sure that everyone knows _why_ the code looks like that, they usually won&#8217;t learn from it.</p><p>integrating patterns &#038; best practices in tools is obviously good, but generated code doesn&#8217;t really fit into that category IMO, unless we&#8217;re talking about really small stuff.  I&#8217;ve seen how code generation based on the database structure leads to a host of problems time and time again, and there&#8217;s really nothing that can get me to ever consider it again.</p> ]]></content:encoded> </item> <item><title>By: Steve Degosserie</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10496</link> <dc:creator>Steve Degosserie</dc:creator> <pubDate>Wed, 25 Mar 2009 10:43:08 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10496</guid> <description>Sorry to insist ;o) lolWhy not integrate your knowledge in a tool so that others don&#039;t have to go through the full learning curve you went through, and save yourself some lengthy code reviews ?Isn&#039;t it a possible solution to what you wrote here :
http://davybrion.com/blog/2009/03/why-dont-we-learn/Integrate the collective knowledge in tools (patterns &amp; best practices), so that we can continue to raise the abstraction levels ... sounds good to me :o)</description> <content:encoded><![CDATA[<p>Sorry to insist ;o) lol</p><p>Why not integrate your knowledge in a tool so that others don&#8217;t have to go through the full learning curve you went through, and save yourself some lengthy code reviews ?</p><p>Isn&#8217;t it a possible solution to what you wrote here :<br
/> <a
href="http://davybrion.com/blog/2009/03/why-dont-we-learn/" rel="nofollow">http://davybrion.com/blog/2009/03/why-dont-we-learn/</a></p><p>Integrate the collective knowledge in tools (patterns &amp; best practices), so that we can continue to raise the abstraction levels &#8230; sounds good to me <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> )</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10495</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 25 Mar 2009 10:37:42 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10495</guid> <description>trust me, i really don&#039;t ;)</description> <content:encoded><![CDATA[<p>trust me, i really don&#8217;t <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Steve Degosserie</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10494</link> <dc:creator>Steve Degosserie</dc:creator> <pubDate>Wed, 25 Mar 2009 10:33:53 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10494</guid> <description>Depends on how far you want to scale ... if you want multiple teams to adopt your best practices, you&#039;d really wanna have a look at code generation ;o)</description> <content:encoded><![CDATA[<p>Depends on how far you want to scale &#8230; if you want multiple teams to adopt your best practices, you&#8217;d really wanna have a look at code generation ;o)</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10493</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Wed, 25 Mar 2009 10:27:07 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10493</guid> <description>i use specific Add/Remove methodsas for having to keep it consistent manually... i still see the consequences of code generation taken too far on a semi-daily basis and i&#039;m pretty much convinced by now that keeping your model consistent manually takes less long-term effort than any kind of code generation</description> <content:encoded><![CDATA[<p>i use specific Add/Remove methods</p><p>as for having to keep it consistent manually&#8230; i still see the consequences of code generation taken too far on a semi-daily basis and i&#8217;m pretty much convinced by now that keeping your model consistent manually takes less long-term effort than any kind of code generation</p> ]]></content:encoded> </item> <item><title>By: Steve Degosserie</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10492</link> <dc:creator>Steve Degosserie</dc:creator> <pubDate>Wed, 25 Mar 2009 10:16:37 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10492</guid> <description>Davy, as you know it, it&#039;s a good start but it quickly becomes more complex if you want to encapsulate more aspects of DDD while keeping your model consistent ... and in the end, you definitely don&#039;t want to do that manually again and again.Would be nice if we could integrate a standardized way of creating a DDD model in ActiveWriter (too bad days are not 48 hours long lol).Question : do you usually manage bi-directional relations in a generic way or you handle it in Create / Remove methods ?</description> <content:encoded><![CDATA[<p>Davy, as you know it, it&#8217;s a good start but it quickly becomes more complex if you want to encapsulate more aspects of DDD while keeping your model consistent &#8230; and in the end, you definitely don&#8217;t want to do that manually again and again.</p><p>Would be nice if we could integrate a standardized way of creating a DDD model in ActiveWriter (too bad days are not 48 hours long lol).</p><p>Question : do you usually manage bi-directional relations in a generic way or you handle it in Create / Remove methods ?</p> ]]></content:encoded> </item> <item><title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #314</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10487</link> <dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #314</dc:creator> <pubDate>Wed, 25 Mar 2009 08:31:20 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10487</guid> <description>[...] Entities: Required Properties And Properties That Shouldn&#8217;t Be Modified - Davy Brion looks at a common mistake that gets made with NHibernate mappings, having getter and setter properties for all persisted properties, and looks at how you can improve your entities by avoiding this [...]</description> <content:encoded><![CDATA[<p>[...] Entities: Required Properties And Properties That Shouldn&#8217;t Be Modified &#8211; Davy Brion looks at a common mistake that gets made with NHibernate mappings, having getter and setter properties for all persisted properties, and looks at how you can improve your entities by avoiding this [...]</p> ]]></content:encoded> </item> <item><title>By: anon</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10484</link> <dc:creator>anon</dc:creator> <pubDate>Wed, 25 Mar 2009 05:08:35 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10484</guid> <description>You could have used the private instance modifer for the Id, Order and Product properties.public virtual int Id { get; private set; }</description> <content:encoded><![CDATA[<p>You could have used the private instance modifer for the Id, Order and Product properties.</p><p>public virtual int Id { get; private set; }</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10465</link> <dc:creator>Chris</dc:creator> <pubDate>Tue, 24 Mar 2009 22:20:05 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10465</guid> <description>Pushing it too far? Even outside of DDD, I still want entities valid. :)</description> <content:encoded><![CDATA[<p>Pushing it too far? Even outside of DDD, I still want entities valid. <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10453</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 24 Mar 2009 21:10:31 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10453</guid> <description>@Chrisinteresting comment... first i thought &quot;how could an Order create an OrderLine instance if its constructor was not public?&quot;.  Obviously, making the OrderLine constructor internal would enable the Order class to create instances of it, while at the same time allowing you to control the creation of OrderLines through its aggregate root (Order).  Which is nice, assuming that the rest of your assembly doesn&#039;t create OrderLine&#039;s outside of the control of the aggregate root (which it shouldn&#039;t, although it would be possible).But for people who aren&#039;t doing DDD, that might be pushing it a little bit too far.</description> <content:encoded><![CDATA[<p>@Chris</p><p>interesting comment&#8230; first i thought &#8220;how could an Order create an OrderLine instance if its constructor was not public?&#8221;.  Obviously, making the OrderLine constructor internal would enable the Order class to create instances of it, while at the same time allowing you to control the creation of OrderLines through its aggregate root (Order).  Which is nice, assuming that the rest of your assembly doesn&#8217;t create OrderLine&#8217;s outside of the control of the aggregate root (which it shouldn&#8217;t, although it would be possible).</p><p>But for people who aren&#8217;t doing DDD, that might be pushing it a little bit too far.</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://davybrion.com/blog/2009/03/entities-required-properties-and-properties-that-shouldnt-be-modified/comment-page-1/#comment-10451</link> <dc:creator>Chris</dc:creator> <pubDate>Tue, 24 Mar 2009 20:55:51 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1182#comment-10451</guid> <description>Even better would be to have no public constructor and use a factory to create an OrderLine.ie.order.CreateOrderLine(product, quantity);
order.CreateOrderLine(product, IDiscount, quantity);</description> <content:encoded><![CDATA[<p>Even better would be to have no public constructor and use a factory to create an OrderLine.</p><p>ie.</p><p>order.CreateOrderLine(product, quantity);<br
/> order.CreateOrderLine(product, IDiscount, quantity);</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/23 queries in 0.014 seconds using disk: basic
Object Caching 636/637 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-02-09 03:58:22 -->
