<?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: Ruby on Rails books teach wrong OO</title>
	<atom:link href="http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/</link>
	<description>Just another rants and opinions weblog</description>
	<lastBuildDate>Tue, 12 Jan 2010 13:45:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: drunken fly</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2491</link>
		<dc:creator>drunken fly</dc:creator>
		<pubDate>Thu, 09 Aug 2007 00:14:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2491</guid>
		<description>LineItem may have additional fields and may not. Its implementation specific. &lt;br&gt;&lt;br&gt;Putting additional attributes complicates db mapping, but simplifies control layer. I prefer to have pure OO in my control layer and let db layer to deal with the tables and mappings.</description>
		<content:encoded><![CDATA[<p>LineItem may have additional fields and may not. Its implementation specific. </p>
<p>Putting additional attributes complicates db mapping, but simplifies control layer. I prefer to have pure OO in my control layer and let db layer to deal with the tables and mappings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: drunken fly</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2073</link>
		<dc:creator>drunken fly</dc:creator>
		<pubDate>Wed, 08 Aug 2007 23:14:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2073</guid>
		<description>LineItem may have additional fields and may not. Its implementation specific. 

Putting additional attributes complicates db mapping, but simplifies control layer. I prefer to have pure OO in my control layer and let db layer to deal with the tables and mappings.</description>
		<content:encoded><![CDATA[<p>LineItem may have additional fields and may not. Its implementation specific. </p>
<p>Putting additional attributes complicates db mapping, but simplifies control layer. I prefer to have pure OO in my control layer and let db layer to deal with the tables and mappings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2490</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 08 Aug 2007 19:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2490</guid>
		<description>Not sure who I&#039;m responding to...&lt;br&gt;&lt;br&gt;Anyway,  LineItem has additional fields that do not belong on either Product or Cart.  Putting that data on the Product object complicates the database mapping because it is wrong.  Trying to hide the fact that LineItem is a necessary concept is a useless and complicated exercise, reflected in the fact that it is confusing and complicated (that&#039;s usually an indication you are doing something wrong.)</description>
		<content:encoded><![CDATA[<p>Not sure who I&#39;m responding to&#8230;</p>
<p>Anyway,  LineItem has additional fields that do not belong on either Product or Cart.  Putting that data on the Product object complicates the database mapping because it is wrong.  Trying to hide the fact that LineItem is a necessary concept is a useless and complicated exercise, reflected in the fact that it is confusing and complicated (that&#39;s usually an indication you are doing something wrong.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2072</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 08 Aug 2007 18:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2072</guid>
		<description>Not sure who I&#039;m responding to...

Anyway,  LineItem has additional fields that do not belong on either Product or Cart.  Putting that data on the Product object complicates the database mapping because it is wrong.  Trying to hide the fact that LineItem is a necessary concept is a useless and complicated exercise, reflected in the fact that it is confusing and complicated (that&#039;s usually an indication you are doing something wrong.)</description>
		<content:encoded><![CDATA[<p>Not sure who I&#8217;m responding to&#8230;</p>
<p>Anyway,  LineItem has additional fields that do not belong on either Product or Cart.  Putting that data on the Product object complicates the database mapping because it is wrong.  Trying to hide the fact that LineItem is a necessary concept is a useless and complicated exercise, reflected in the fact that it is confusing and complicated (that&#8217;s usually an indication you are doing something wrong.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: drunken fly</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2489</link>
		<dc:creator>drunken fly</dc:creator>
		<pubDate>Tue, 07 Aug 2007 23:17:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2489</guid>
		<description>What am I trying to say is that in database realm product state is expressed as LineItem. In OO code there is no such thing as LineItem. There is only the state of Product object. &lt;br&gt;&lt;br&gt;Product, freshly inserted into ShoppingCart has one state. Product retrieved from saved has different state. Product, retrieved from order history may have state different to those two. Its up to OO persistence layer (read OR mapper) to decide whether Product stored as LineItem. But who said that ROR has proper OR mapper?</description>
		<content:encoded><![CDATA[<p>What am I trying to say is that in database realm product state is expressed as LineItem. In OO code there is no such thing as LineItem. There is only the state of Product object. </p>
<p>Product, freshly inserted into ShoppingCart has one state. Product retrieved from saved has different state. Product, retrieved from order history may have state different to those two. Its up to OO persistence layer (read OR mapper) to decide whether Product stored as LineItem. But who said that ROR has proper OR mapper?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: drunken fly</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2071</link>
		<dc:creator>drunken fly</dc:creator>
		<pubDate>Tue, 07 Aug 2007 22:17:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2071</guid>
		<description>What am I trying to say is that in database realm product state is expressed as LineItem. In OO code there is no such thing as LineItem. There is only the state of Product object. 

Product, freshly inserted into ShoppingCart has one state. Product retrieved from saved has different state. Product, retrieved from order history may have state different to those two. Its up to OO persistence layer (read OR mapper) to decide whether Product stored as LineItem. But who said that ROR has proper OR mapper?</description>
		<content:encoded><![CDATA[<p>What am I trying to say is that in database realm product state is expressed as LineItem. In OO code there is no such thing as LineItem. There is only the state of Product object. </p>
<p>Product, freshly inserted into ShoppingCart has one state. Product retrieved from saved has different state. Product, retrieved from order history may have state different to those two. Its up to OO persistence layer (read OR mapper) to decide whether Product stored as LineItem. But who said that ROR has proper OR mapper?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2488</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 07 Aug 2007 20:11:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2488</guid>
		<description>Line Items are critical to business logic.  They contain much information, such as:&lt;br&gt;- shipping information (can the line item be shipped separately, to a different location, etc)&lt;br&gt;- quantity (albeit this could be done less efficiently by adding multiple pointers, but then you just have to count them later.  you may also want to distinguish line items referencing the same product though, such as for different shipping addresses)&lt;br&gt;- price (price can change while someone is shopping, and you don&#039;t always want that to affect carts.  many stores will have a policy that a price is valid for x hours after added to a cart)&lt;br&gt;- discounts&lt;br&gt;- line item specific notes (e.g. &quot;please make sure items are from lot #XX&quot;)&lt;br&gt;&lt;br&gt;Every ERP system has a line item concept for good reason.  I think you spoke too soon here...</description>
		<content:encoded><![CDATA[<p>Line Items are critical to business logic.  They contain much information, such as:<br />- shipping information (can the line item be shipped separately, to a different location, etc)<br />- quantity (albeit this could be done less efficiently by adding multiple pointers, but then you just have to count them later.  you may also want to distinguish line items referencing the same product though, such as for different shipping addresses)<br />- price (price can change while someone is shopping, and you don&#39;t always want that to affect carts.  many stores will have a policy that a price is valid for x hours after added to a cart)<br />- discounts<br />- line item specific notes (e.g. &#8220;please make sure items are from lot #XX&#8221;)</p>
<p>Every ERP system has a line item concept for good reason.  I think you spoke too soon here&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2070</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 07 Aug 2007 19:11:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2070</guid>
		<description>Line Items are critical to business logic.  They contain much information, such as:
- shipping information (can the line item be shipped separately, to a different location, etc)
- quantity (albeit this could be done less efficiently by adding multiple pointers, but then you just have to count them later.  you may also want to distinguish line items referencing the same product though, such as for different shipping addresses)
- price (price can change while someone is shopping, and you don&#039;t always want that to affect carts.  many stores will have a policy that a price is valid for x hours after added to a cart)
- discounts
- line item specific notes (e.g. &quot;please make sure items are from lot #XX&quot;)

Every ERP system has a line item concept for good reason.  I think you spoke too soon here...</description>
		<content:encoded><![CDATA[<p>Line Items are critical to business logic.  They contain much information, such as:<br />
- shipping information (can the line item be shipped separately, to a different location, etc)<br />
- quantity (albeit this could be done less efficiently by adding multiple pointers, but then you just have to count them later.  you may also want to distinguish line items referencing the same product though, such as for different shipping addresses)<br />
- price (price can change while someone is shopping, and you don&#8217;t always want that to affect carts.  many stores will have a policy that a price is valid for x hours after added to a cart)<br />
- discounts<br />
- line item specific notes (e.g. &#8220;please make sure items are from lot #XX&#8221;)</p>
<p>Every ERP system has a line item concept for good reason.  I think you spoke too soon here&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-209</link>
		<dc:creator>Kent</dc:creator>
		<pubDate>Sun, 03 Dec 2006 21:50:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-209</guid>
		<description>&gt;Many-to-many association through LineItems should be kept in the database logic, which has nothing
&gt;to do with the object oriented world. And I don’t care if UML has a special notation for something, 
&gt;which has no sense in the object world.

What I was trying to say is that if it were a plain many-to-many link then this statement would be correct. In OO world that would be something like:

Order.getProducts(): List of Products

But in case of Shopping Cart it is not true. LineItem has a very specific business purpose, it stores quantity of the ordered products and the price at the moment the order was created. It might also contain some additional logic like deducting the product inventory when the order is confirmed. Note that you must keep the price in LineItem, because the product price has a tendency to change and believe me you don&#039;t want to have an order where the sum of prices of all ordered products doesn&#039;t match order&#039;s subtotal.

So we have these signatures:

Order.getLineItems(): List of LineItems
LineItem.getProduct(): Product

It has nothing to do with the way you store these objects in the database, this is the domain model of any Shopping Cart application.

&gt;Look at that from another perspective. You have shopping cart. You have products on the shelves.
&gt;You take products and put them into shopping cart. Does behavior of the objects change once you 
&gt;put them into cart? In real world, which is Object Oriented world - product behavior is not 
&gt;changed. When why it needs to change in your computer implementation? The only way it has to 
&gt;change behavior is because relational database has no way to store objects and their state.

I don&#039;t understand your point here. We are looking at the class diagram here which has nothing to do with objects&#039; behavior, but only with their relationships.

&gt;But what if you have a way to store state and object relationships? Would you still express your 
&gt;state in relational terms?

&gt;What I am trying to say is that objects are not 1-to-1 representation of the database and when 
&gt;you trying to create 1-to-1 you are probably doing something twice. And doing something twice 
&gt;is not good at all.

The only case where this is not 1-to-1 representation is with pure many-to-many relationships (with no additional attributes), but I don&#039;t think it applies to this particular case. Do you know of any other cases?</description>
		<content:encoded><![CDATA[<p>&gt;Many-to-many association through LineItems should be kept in the database logic, which has nothing<br />
&gt;to do with the object oriented world. And I don’t care if UML has a special notation for something,<br />
&gt;which has no sense in the object world.</p>
<p>What I was trying to say is that if it were a plain many-to-many link then this statement would be correct. In OO world that would be something like:</p>
<p>Order.getProducts(): List of Products</p>
<p>But in case of Shopping Cart it is not true. LineItem has a very specific business purpose, it stores quantity of the ordered products and the price at the moment the order was created. It might also contain some additional logic like deducting the product inventory when the order is confirmed. Note that you must keep the price in LineItem, because the product price has a tendency to change and believe me you don&#8217;t want to have an order where the sum of prices of all ordered products doesn&#8217;t match order&#8217;s subtotal.</p>
<p>So we have these signatures:</p>
<p>Order.getLineItems(): List of LineItems<br />
LineItem.getProduct(): Product</p>
<p>It has nothing to do with the way you store these objects in the database, this is the domain model of any Shopping Cart application.</p>
<p>&gt;Look at that from another perspective. You have shopping cart. You have products on the shelves.<br />
&gt;You take products and put them into shopping cart. Does behavior of the objects change once you<br />
&gt;put them into cart? In real world, which is Object Oriented world &#8211; product behavior is not<br />
&gt;changed. When why it needs to change in your computer implementation? The only way it has to<br />
&gt;change behavior is because relational database has no way to store objects and their state.</p>
<p>I don&#8217;t understand your point here. We are looking at the class diagram here which has nothing to do with objects&#8217; behavior, but only with their relationships.</p>
<p>&gt;But what if you have a way to store state and object relationships? Would you still express your<br />
&gt;state in relational terms?</p>
<p>&gt;What I am trying to say is that objects are not 1-to-1 representation of the database and when<br />
&gt;you trying to create 1-to-1 you are probably doing something twice. And doing something twice<br />
&gt;is not good at all.</p>
<p>The only case where this is not 1-to-1 representation is with pure many-to-many relationships (with no additional attributes), but I don&#8217;t think it applies to this particular case. Do you know of any other cases?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent</title>
		<link>http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/comment-page-1/#comment-2487</link>
		<dc:creator>Kent</dc:creator>
		<pubDate>Sun, 03 Dec 2006 21:50:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellowbluebus.com/blog/2006/11/22/ruby-on-rails-books-teach-wrong-oo/#comment-2487</guid>
		<description>&gt;Many-to-many association through LineItems should be kept in the database logic, which has nothing&lt;br&gt;&gt;to do with the object oriented world. And I don’t care if UML has a special notation for something, &lt;br&gt;&gt;which has no sense in the object world.&lt;br&gt;&lt;br&gt;What I was trying to say is that if it were a plain many-to-many link then this statement would be correct. In OO world that would be something like:&lt;br&gt;&lt;br&gt;Order.getProducts(): List of Products&lt;br&gt;&lt;br&gt;But in case of Shopping Cart it is not true. LineItem has a very specific business purpose, it stores quantity of the ordered products and the price at the moment the order was created. It might also contain some additional logic like deducting the product inventory when the order is confirmed. Note that you must keep the price in LineItem, because the product price has a tendency to change and believe me you don&#039;t want to have an order where the sum of prices of all ordered products doesn&#039;t match order&#039;s subtotal.&lt;br&gt;&lt;br&gt;So we have these signatures:&lt;br&gt;&lt;br&gt;Order.getLineItems(): List of LineItems&lt;br&gt;LineItem.getProduct(): Product&lt;br&gt;&lt;br&gt;It has nothing to do with the way you store these objects in the database, this is the domain model of any Shopping Cart application.&lt;br&gt;&lt;br&gt;&gt;Look at that from another perspective. You have shopping cart. You have products on the shelves.&lt;br&gt;&gt;You take products and put them into shopping cart. Does behavior of the objects change once you &lt;br&gt;&gt;put them into cart? In real world, which is Object Oriented world - product behavior is not &lt;br&gt;&gt;changed. When why it needs to change in your computer implementation? The only way it has to &lt;br&gt;&gt;change behavior is because relational database has no way to store objects and their state.&lt;br&gt;&lt;br&gt;I don&#039;t understand your point here. We are looking at the class diagram here which has nothing to do with objects&#039; behavior, but only with their relationships.&lt;br&gt;&lt;br&gt;&gt;But what if you have a way to store state and object relationships? Would you still express your &lt;br&gt;&gt;state in relational terms?&lt;br&gt;&lt;br&gt;&gt;What I am trying to say is that objects are not 1-to-1 representation of the database and when &lt;br&gt;&gt;you trying to create 1-to-1 you are probably doing something twice. And doing something twice &lt;br&gt;&gt;is not good at all.&lt;br&gt;&lt;br&gt;The only case where this is not 1-to-1 representation is with pure many-to-many relationships (with no additional attributes), but I don&#039;t think it applies to this particular case. Do you know of any other cases?</description>
		<content:encoded><![CDATA[<p>&gt;Many-to-many association through LineItems should be kept in the database logic, which has nothing<br />&gt;to do with the object oriented world. And I don’t care if UML has a special notation for something, <br />&gt;which has no sense in the object world.</p>
<p>What I was trying to say is that if it were a plain many-to-many link then this statement would be correct. In OO world that would be something like:</p>
<p>Order.getProducts(): List of Products</p>
<p>But in case of Shopping Cart it is not true. LineItem has a very specific business purpose, it stores quantity of the ordered products and the price at the moment the order was created. It might also contain some additional logic like deducting the product inventory when the order is confirmed. Note that you must keep the price in LineItem, because the product price has a tendency to change and believe me you don&#39;t want to have an order where the sum of prices of all ordered products doesn&#39;t match order&#39;s subtotal.</p>
<p>So we have these signatures:</p>
<p>Order.getLineItems(): List of LineItems<br />LineItem.getProduct(): Product</p>
<p>It has nothing to do with the way you store these objects in the database, this is the domain model of any Shopping Cart application.</p>
<p>&gt;Look at that from another perspective. You have shopping cart. You have products on the shelves.<br />&gt;You take products and put them into shopping cart. Does behavior of the objects change once you <br />&gt;put them into cart? In real world, which is Object Oriented world &#8211; product behavior is not <br />&gt;changed. When why it needs to change in your computer implementation? The only way it has to <br />&gt;change behavior is because relational database has no way to store objects and their state.</p>
<p>I don&#39;t understand your point here. We are looking at the class diagram here which has nothing to do with objects&#39; behavior, but only with their relationships.</p>
<p>&gt;But what if you have a way to store state and object relationships? Would you still express your <br />&gt;state in relational terms?</p>
<p>&gt;What I am trying to say is that objects are not 1-to-1 representation of the database and when <br />&gt;you trying to create 1-to-1 you are probably doing something twice. And doing something twice <br />&gt;is not good at all.</p>
<p>The only case where this is not 1-to-1 representation is with pure many-to-many relationships (with no additional attributes), but I don&#39;t think it applies to this particular case. Do you know of any other cases?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
