<?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: Composition and Aggregation using Java</title>
	<atom:link href="http://www.javaplex.com/blog/composition-and-aggregation-using-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/</link>
	<description>Java Developers Reputation Building Website</description>
	<lastBuildDate>Sun, 05 Sep 2010 12:04:38 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: AffigOriMit</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-828</link>
		<dc:creator>AffigOriMit</dc:creator>
		<pubDate>Thu, 12 Aug 2010 09:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-828</guid>
		<description>&lt;a href=&quot;http://giftmen.net/&quot; rel=&quot;nofollow&quot;&gt;Gift Men&lt;/a&gt; is the place to go for the best discount prices on dozens of leading brands. We offer a large, constantly updating catalog of products so you&#039;ll always find what you need. With tons of products from dozens of leading brands, We&#039;re sure to have exactly what you want. Why pay regular prices when you can buy discount items online from &lt;a href=&quot;http://giftmen.net/&quot; rel=&quot;nofollow&quot;&gt;Gift Men&lt;/a&gt;? To start browsing our catalog, click on one of our categories on the menu on the left under the section marked &quot;Products&quot;, or use our search utility on the top menu to search using keywords.</description>
		<content:encoded><![CDATA[<p><a href="http://giftmen.net/" rel="nofollow">Gift Men</a> is the place to go for the best discount prices on dozens of leading brands. We offer a large, constantly updating catalog of products so you&#8217;ll always find what you need. With tons of products from dozens of leading brands, We&#8217;re sure to have exactly what you want. Why pay regular prices when you can buy discount items online from <a href="http://giftmen.net/" rel="nofollow">Gift Men</a>? To start browsing our catalog, click on one of our categories on the menu on the left under the section marked &#8220;Products&#8221;, or use our search utility on the top menu to search using keywords.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tabish Habib</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-788</link>
		<dc:creator>Tabish Habib</dc:creator>
		<pubDate>Tue, 01 Jun 2010 20:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-788</guid>
		<description>Composition is strong relationship: A Composes B, means A contains ans owns B i.e. when A is destroyed B will also be destroyed. Aggreagartion: Aggregration between A and B means, A contains but not owns B i.e. when A is destroyed B remains intact.</description>
		<content:encoded><![CDATA[<p>Composition is strong relationship: A Composes B, means A contains ans owns B i.e. when A is destroyed B will also be destroyed. Aggreagartion: Aggregration between A and B means, A contains but not owns B i.e. when A is destroyed B remains intact.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: basanta nandi</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-759</link>
		<dc:creator>basanta nandi</dc:creator>
		<pubDate>Wed, 10 Mar 2010 07:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-759</guid>
		<description>thanks for your help.</description>
		<content:encoded><![CDATA[<p>thanks for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fiza Zaheer</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-525</link>
		<dc:creator>Fiza Zaheer</dc:creator>
		<pubDate>Sun, 04 Oct 2009 05:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-525</guid>
		<description>Hi, Let me explain it via the code example.
Product, Order &amp; OrderLine are the three entities. 
Product relationship with OrderLine is example of Aggregation.
Order relationship with OrderLine is example of Composition.


import java.util.ArrayList;
import java.util.List;

public class Test {
	public static void main(String[] args) {
		
		Order order = new Order();
		
		Product product = new Product();
		product.setName(&quot;BMAW&quot;);
		product.setPrice(9786);
		
		order.addOrderLine(product);
		
		order = null; // OrderLines are destroyed along with order
		//Because orderLine and Order have strong relationships i.e. composition.
		//But Product will exist, even orderLine is deleted because it have weaker relationship
		//i.e. Composition.
	}
}

class OrderLine {
	Product product;
	int quantity;

	// Add many attribute per you order line.

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

}

class Product {
	private String name;
	private int price;
	// Add many attributes as you need.
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
}

class Order {
	private List lines = new ArrayList();
	String customerName;

	// Add many order attributes as you need.
	public boolean addOrderLine(Product product) {
		OrderLine line = new OrderLine();
		line.setProduct(product);
		lines.add(line);
		return true;
	}
}</description>
		<content:encoded><![CDATA[<p>Hi, Let me explain it via the code example.<br />
Product, Order &amp; OrderLine are the three entities.<br />
Product relationship with OrderLine is example of Aggregation.<br />
Order relationship with OrderLine is example of Composition.</p>
<p>import java.util.ArrayList;<br />
import java.util.List;</p>
<p>public class Test {<br />
	public static void main(String[] args) {</p>
<p>		Order order = new Order();</p>
<p>		Product product = new Product();<br />
		product.setName(&#8221;BMAW&#8221;);<br />
		product.setPrice(9786);</p>
<p>		order.addOrderLine(product);</p>
<p>		order = null; // OrderLines are destroyed along with order<br />
		//Because orderLine and Order have strong relationships i.e. composition.<br />
		//But Product will exist, even orderLine is deleted because it have weaker relationship<br />
		//i.e. Composition.<br />
	}<br />
}</p>
<p>class OrderLine {<br />
	Product product;<br />
	int quantity;</p>
<p>	// Add many attribute per you order line.</p>
<p>	public Product getProduct() {<br />
		return this.product;<br />
	}</p>
<p>	public void setProduct(Product product) {<br />
		this.product = product;<br />
	}</p>
<p>}</p>
<p>class Product {<br />
	private String name;<br />
	private int price;<br />
	// Add many attributes as you need.<br />
	public String getName() {<br />
		return name;<br />
	}<br />
	public void setName(String name) {<br />
		this.name = name;<br />
	}<br />
	public int getPrice() {<br />
		return price;<br />
	}<br />
	public void setPrice(int price) {<br />
		this.price = price;<br />
	}<br />
}</p>
<p>class Order {<br />
	private List lines = new ArrayList();<br />
	String customerName;</p>
<p>	// Add many order attributes as you need.<br />
	public boolean addOrderLine(Product product) {<br />
		OrderLine line = new OrderLine();<br />
		line.setProduct(product);<br />
		lines.add(line);<br />
		return true;<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sham</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-521</link>
		<dc:creator>sham</dc:creator>
		<pubDate>Fri, 02 Oct 2009 20:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-521</guid>
		<description>// ShambhuDubey: Composition Example
import java.util.ArrayList;
 
public class Composition {
    public static void main(String[] args) {
        // Frame objects life-cycle is totally under container class controll
        Car car = new Car();
    }
}
 

class Car {
    private ArrayList frames;
 
    public Car() {
        frames = new ArrayList();
        frames.add(new CarFrame());
    }
}
 

class CarFrame {}</description>
		<content:encoded><![CDATA[<p>// ShambhuDubey: Composition Example<br />
import java.util.ArrayList;</p>
<p>public class Composition {<br />
    public static void main(String[] args) {<br />
        // Frame objects life-cycle is totally under container class controll<br />
        Car car = new Car();<br />
    }<br />
}</p>
<p>class Car {<br />
    private ArrayList frames;</p>
<p>    public Car() {<br />
        frames = new ArrayList();<br />
        frames.add(new CarFrame());<br />
    }<br />
}</p>
<p>class CarFrame {}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sham</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-520</link>
		<dc:creator>sham</dc:creator>
		<pubDate>Fri, 02 Oct 2009 19:52:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-520</guid>
		<description>// ShambhuDubey: Aggregation Example

import java.util.ArrayList;
 
public class Aggregation {
    public static void main(String[] args)
    {
        MusicPlayer player = new MusicPlayer();
        Car car = new Car();
        car.addPlayer(player); 
    }
}
 
/**
 * Client, Aggregate, Whole
 */
class Car {
    private ArrayList players;
 
    public Car() {
        // players list is empty, we can attach players via addPlayer(), so
        // that car CONTAINS players, however our car object is not dependant
        // on player for initialization - we can initialize car objects even
        // if we have no intention to put player into them
        players = new ArrayList();
    }
 
    public void addPlayer(MusicPlayer p)
    {
        players.add(p);
    }
}
 
/**
 * Dump MusicPlayer class
 */
class MusicPlayer {}</description>
		<content:encoded><![CDATA[<p>// ShambhuDubey: Aggregation Example</p>
<p>import java.util.ArrayList;</p>
<p>public class Aggregation {<br />
    public static void main(String[] args)<br />
    {<br />
        MusicPlayer player = new MusicPlayer();<br />
        Car car = new Car();<br />
        car.addPlayer(player);<br />
    }<br />
}</p>
<p>/**<br />
 * Client, Aggregate, Whole<br />
 */<br />
class Car {<br />
    private ArrayList players;</p>
<p>    public Car() {<br />
        // players list is empty, we can attach players via addPlayer(), so<br />
        // that car CONTAINS players, however our car object is not dependant<br />
        // on player for initialization &#8211; we can initialize car objects even<br />
        // if we have no intention to put player into them<br />
        players = new ArrayList();<br />
    }</p>
<p>    public void addPlayer(MusicPlayer p)<br />
    {<br />
        players.add(p);<br />
    }<br />
}</p>
<p>/**<br />
 * Dump MusicPlayer class<br />
 */<br />
class MusicPlayer {}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sham</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-519</link>
		<dc:creator>sham</dc:creator>
		<pubDate>Fri, 02 Oct 2009 19:34:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-519</guid>
		<description>yeah...m agree with makiko_fly that where is the java code....... ;)</description>
		<content:encoded><![CDATA[<p>yeah&#8230;m agree with makiko_fly that where is the java code&#8230;&#8230;. <img src='http://www.javaplex.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: makiko_fly</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-502</link>
		<dc:creator>makiko_fly</dc:creator>
		<pubDate>Mon, 21 Sep 2009 06:43:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-502</guid>
		<description>I am sorry, but where is the java code example?</description>
		<content:encoded><![CDATA[<p>I am sorry, but where is the java code example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Balakrishnan</title>
		<link>http://www.javaplex.com/blog/composition-and-aggregation-using-java/comment-page-1/#comment-88</link>
		<dc:creator>Balakrishnan</dc:creator>
		<pubDate>Wed, 01 Oct 2008 11:45:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.faisalgeek.com/blog/composition-and-aggregation-using-java/#comment-88</guid>
		<description>Excellent explanation with very good example.</description>
		<content:encoded><![CDATA[<p>Excellent explanation with very good example.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
