<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xgao2</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xgao2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Xgao2"/>
	<updated>2026-05-22T06:34:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9193</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9193"/>
		<updated>2007-11-19T04:23:34Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Some related concepts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
&lt;br /&gt;
SoR is closely related with other OO design principles, and hence we explore some related concepts below.&lt;br /&gt;
&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling , more often than not, correlates with high cohesion, and tight coupling means low cohesion.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===Project/Architecture Level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf&lt;br /&gt;
&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9143</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9143"/>
		<updated>2007-11-19T02:34:26Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* project/architecture level SoR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
&lt;br /&gt;
SoR is closely related with other OO design principles, and hence we explore some related concepts below.&lt;br /&gt;
&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===Project/Architecture Level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf&lt;br /&gt;
&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9142</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9142"/>
		<updated>2007-11-19T02:32:51Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Some related concepts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
&lt;br /&gt;
SoR is closely related with other OO design principles, and hence we explore some related concepts below.&lt;br /&gt;
&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf&lt;br /&gt;
&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9141</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9141"/>
		<updated>2007-11-19T02:30:17Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf&lt;br /&gt;
&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9140</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9140"/>
		<updated>2007-11-19T02:29:07Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9139</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9139"/>
		<updated>2007-11-19T02:28:58Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Information_hiding&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9138</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9138"/>
		<updated>2007-11-19T02:27:43Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Class Level SoR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
The method name is createCustomer, but it does far more than creating a customer. As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot;(validate the customer) and &amp;quot;saveCustomer&amp;quot; (save the customer). And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9137</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9137"/>
		<updated>2007-11-19T02:24:06Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* In Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot; and &amp;quot;saveCustomer&amp;quot;. And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
&lt;br /&gt;
In sum, the elegance of code can be greatly enhanced by adhering to the separation of responsibility design principle. And it would also be highly desirable to implement SoR in software architecture level, which is evidenced by the MVC style.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9135</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9135"/>
		<updated>2007-11-19T02:16:52Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* SoR categories by scope */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class or method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot; and &amp;quot;saveCustomer&amp;quot;. And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9134</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9134"/>
		<updated>2007-11-19T02:16:15Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* SoR categories by scope */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class and method focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
The website http://designparadigm.wordpress.com/ has a good example for separating multiple responsibilities within one method to multiple methods. &lt;br /&gt;
&lt;br /&gt;
The following code is flawed in a SoR sense.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public void createCustomer(Map requestParameters) {&lt;br /&gt;
	Customer customer = new Customer();&lt;br /&gt;
	customer.setName = requestParameters.get(&amp;quot;name&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	//Check if a customer was already registered with that name&lt;br /&gt;
	if (customerService.getCustomerByName(customer.getName()) != null) {&lt;br /&gt;
		System.out.println(&amp;quot;Customer already exists&amp;quot;);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	customer.setShoppingCart(new ShoppingCart());&lt;br /&gt;
&lt;br /&gt;
	customerService.save(customer);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, within the method it does three different things: create a user name, check the customer to see if it already registered and then save it.&lt;br /&gt;
&lt;br /&gt;
As a matter of fact, this method should be refactored into 4 methods. The first method can be &amp;quot;bindValidateAndSave&amp;quot;, which provides the algorithm. The 3 other methods can be named as &amp;quot;bindCustomer&amp;quot; (bind and add new shoppingCart), &amp;quot;validateCustomer&amp;quot; and &amp;quot;saveCustomer&amp;quot;. And thus separate different concerns to different methods.&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9131</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9131"/>
		<updated>2007-11-19T02:01:48Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
http://designparadigm.wordpress.com/&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9089</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9089"/>
		<updated>2007-11-19T01:16:57Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* SoR categories by scope */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separates different system responsibilities to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9086</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9086"/>
		<updated>2007-11-19T01:16:10Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* class level SoR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
Separation of Responsibility can be interpreted in both class level and software architecture level. Class level SoR requires a class focus on a single task or goal, not take up multiple responsibilities. Project/Software architecture level of SoR involves multi-tiered system which separate different system responsibility to different tiers.&lt;br /&gt;
 &lt;br /&gt;
===Class Level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9077</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9077"/>
		<updated>2007-11-19T01:08:39Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
===class level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==In Summary==&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9076</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9076"/>
		<updated>2007-11-19T01:08:13Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Aspect-oriented programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
===class level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9075</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=9075"/>
		<updated>2007-11-19T00:58:02Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Some related concepts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic - Separation of Responsibility (SoR)==&lt;br /&gt;
Take the principle of Separation of Responsibility (abbreviated as SoR) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==What is SoR==&lt;br /&gt;
&amp;lt;b&amp;gt;Separation of responsibility&amp;lt;/b&amp;gt; is also known as seperation of concern (SoC. SoR and SoC will be used interchangably from this point on). In the field of software engineering, this concept probably finds its root in one paper from Dijsktra in the year 1974. Since then SoR became a well accepted concept that helps programmers in designing, implementing and many other aspects of software development. &lt;br /&gt;
&lt;br /&gt;
The essence of the SoR concept is that one foucs on doing one thing and do it well, with out being entangled or distracted by other entity. To elaborate, it is well known that developing a fully functional software in time and meet the needs of clients is challenging due to the intricate nature of the process. Often, software developing requires a group of team developers to cooperate on a project. By effectively seperate out non or minimally overlapped concerns (or tasks, even domains), developers are able to concentrate on just one part of the system, instead of having to worry about all other miniture details. In this way, the integrated system achieve the modulizing effect and is therefore more maintainable. In addition to the benifit of increased maintainability, SoR promotes program extensibility and flexibility. In field of software engineering, the needs of client are characterized by constant changing and modification. By separating an entire system into smaller, &amp;quot;independent&amp;quot; pieces, developers can add, update, delete these parts of the system without dramaticly affect the other parts. This makes modifying the program and adding more functionalities to it far more effecient and easier. Without having SoR, even one small change can trigger a cascading effect that spread to the entire system. Trying to figure out what is going wrong, in this case, will be a nightmare.&lt;br /&gt;
&lt;br /&gt;
==Some related concepts==&lt;br /&gt;
;Object Oriented Programming : OO programming paradigm abstracts entities into class/object (an instance of a class) and their behaviors into methods. The target application is built based on these objects and their interactions. OO is a very good example to illustrate the concept of SoR. In OO paradigm, each class with its member variables and methods define an entity. Methods of this class can only be performed on objects belong to this class (with some exceptions like inheritance). Therefore, each class has a particular focus and defines a soft boundaries that separates its own states/behaviors from other classes.&lt;br /&gt;
&lt;br /&gt;
;Encapsulation : This refers to hiding implementation and other details of one class from others, exposing only interfaces to be invoked. The purpose of encapsulation is also related to SoR in that by concealing the internal operations of a class, clients who interact with it does not need to concern how the class is implemented, but instead just using it as a black box.  &lt;br /&gt;
&lt;br /&gt;
;Information Hidding : &amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;br /&gt;
&lt;br /&gt;
;Abstraction : &amp;quot;Abstraction is the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Abstraction)&lt;br /&gt;
&lt;br /&gt;
;Cohesion : &amp;quot;cohesion is a measure of how strongly-related and focused the various responsibilities of a software module are. Cohesion is an ordinal type of measurement and is usually expressed as &amp;quot;high cohesion&amp;quot; or &amp;quot;low cohesion&amp;quot; when being discussed.&amp;quot; from wiki(http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29)&lt;br /&gt;
&lt;br /&gt;
;Coupling : Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa.&lt;br /&gt;
&lt;br /&gt;
==SoR categories by scope==&lt;br /&gt;
&lt;br /&gt;
===class level SoR===&lt;br /&gt;
&lt;br /&gt;
===project/architecture level SoR===&lt;br /&gt;
One of the most widely used web and GUI application design pattern - Model-View-Controller (MVC) - stands out as an zealous advocate for the &amp;quot;Separation of Responsibility&amp;quot; philosophy. We think it will be an excellent example to demonstrate the SoR concept in project/architecture level.&lt;br /&gt;
[[Image:MVC.gif|center]]&lt;br /&gt;
&amp;lt;font align='center' size='0.3' color='blue'&amp;gt;&amp;lt;i&amp;gt;picture source: http://www.codeproject.com/useritems/PraticalMvc.asp&amp;lt;/i&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above diagram illurstrated, MVC pattern separates the appliaction into three areas of responsibility to reduce the coupling between modules. &lt;br /&gt;
;Model : This part is responsible for maintaining the state of the application. Most of the time, this part is related to the data of the system. Through some object relational mapping (ORM), model is used to create/read/update/delete (CRUD) data. What model needs to care is to realize these functionalities correctly and efficiently; it does not need to concern about who will use them, when and how they will be used. (in rare situations, code in model can be involving in other domain)&lt;br /&gt;
;View : View's responsibility is rendered data, usually from data model, in the correct format and display it to client. This is its sole job. Code in view component does not care about how the backend data is stored, or what the business logic is, no matter how complex it may be.&lt;br /&gt;
;Controller : Controller's job is receive user's input, performs defined computation, interacts with models, and invoke the appropriate view template to render the result to client. &lt;br /&gt;
&lt;br /&gt;
As we can see, in MVC, code specialized in one category can always be easily found in a well-known location. Each category has its own focus and rarely overlap with others. By doing this, man power can be properly used: web graphic designer who knows HTML/CSS but not much about Java or C# may just focus on view category in MVC, and not worrying about the logic behind the application; programmers may focus on the logic and the correctness of the result, not have to concern about how it will be rendered to users. Database designers may focus on designing a efficient schema to be represented by data models, not anything more nor anything less. When later the application needs to be extended or changed, project manager can easily know who to talk to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Ruby on Rails&amp;lt;/b&amp;gt; (RoR) is a web application development framework which is based on MVC design pattern. To see how Ruby on Rails uses MVC to achieve SoR, we will take a look at the following example:&lt;br /&gt;
&lt;br /&gt;
Suppose we hava an online store which sells different products. Then we will most likely have a database table named &amp;quot;products&amp;quot; and a corresponding class wrapped about it. This class will go into our &amp;lt;i&amp;gt;Model&amp;lt;/i&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateProducts &amp;lt;ActiveRecord::Migration&lt;br /&gt;
   def self.up&lt;br /&gt;
      creat_table :products do |t|&lt;br /&gt;
         t.column :title        :string&lt;br /&gt;
         t.column :descriprtion :text&lt;br /&gt;
      end&lt;br /&gt;
   end&lt;br /&gt;
   # ...rest of the code #&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Product &amp;lt; ActiveRecord::Base&lt;br /&gt;
   validates_presence_of :title, :description&lt;br /&gt;
&lt;br /&gt;
   def self.find_products_for_sale&lt;br /&gt;
      find( :all, :order =&amp;gt; &amp;quot;title&amp;quot; )&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RoR uses something called &amp;quot;migration&amp;quot; to define a DB table (CreateProducts in above example, for more detail description on RoR, refer to link below) and a matching model class that forms the Object-Relational Mapping (ORM) with it. Product class here is one of our model classes. We can see that the validation process of the data is done inside Prodcut class. In addtion, it reads data products ordered by their titles. The class dose not care how the products will be used or displayed, that is beyond its responsibility.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's look at the 'View':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Products Listing&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;% for product in @products %&amp;gt;&lt;br /&gt;
   &amp;lt;h3&amp;gt;&amp;lt;%= h(product.title) %&amp;gt;&lt;br /&gt;
   &amp;lt;%= product.description %&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a .rhml RoR view template. We can see that is has some RoR code with standard html tags. This template iterate through the variable @products and display title and description of each element in it. Neither does it know nor should it care about which elements are in @products, which are not, how and why they are in it and so forth. Its only job is to render the content of them and nothing more. But we may question why and how, that's when controller comes into play:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class StoreController &amp;lt; ApplicationController&lt;br /&gt;
   @products = Product.find_products_for_sale&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Aspect-oriented programming ==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
http://www.rubyonrails.org/docs&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=To_be_finished&amp;diff=9074</id>
		<title>To be finished</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=To_be_finished&amp;diff=9074"/>
		<updated>2007-11-19T00:51:01Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;quot;The principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.&amp;quot; from (http://en.wikipedia.org/wiki/Information_hiding)&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8485</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8485"/>
		<updated>2007-11-15T02:20:20Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Description==&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==Concept to explore==&lt;br /&gt;
Concept of Separation of responsibility&lt;br /&gt;
Separation of concern &lt;br /&gt;
Separation of responsibility&lt;br /&gt;
&lt;br /&gt;
==Similar principles==&lt;br /&gt;
&lt;br /&gt;
==class level separation of responsibility==&lt;br /&gt;
&lt;br /&gt;
==project/architecture level separation of responsibility==&lt;br /&gt;
MVC&lt;br /&gt;
&lt;br /&gt;
==Aspect-oriented programming ==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8484</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8484"/>
		<updated>2007-11-15T02:19:58Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Description==&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==Concept to explore==&lt;br /&gt;
Concept of Separation of responsibility&lt;br /&gt;
Separation of concern &lt;br /&gt;
Separation of responsibility&lt;br /&gt;
&lt;br /&gt;
==Similar principles==&lt;br /&gt;
&lt;br /&gt;
==class level separation of responsibility==&lt;br /&gt;
&lt;br /&gt;
==project/architecture level separation of responsibility==&lt;br /&gt;
MVC&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8483</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8483"/>
		<updated>2007-11-15T02:17:49Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Description==&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==Concept to explore==&lt;br /&gt;
Concept of Separation of responsibility&lt;br /&gt;
Separation of concern &lt;br /&gt;
Separation of responsibility&lt;br /&gt;
&lt;br /&gt;
==Similar principles==&lt;br /&gt;
&lt;br /&gt;
==class level separation of responsibility==&lt;br /&gt;
&lt;br /&gt;
==project/architecture level separation of responsibility==&lt;br /&gt;
MVC&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
http://en.wikipedia.org/wiki/Separation_of_concerns&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8482</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8482"/>
		<updated>2007-11-15T02:14:24Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Concept to explore */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Description==&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==Concept to explore==&lt;br /&gt;
Concept of Separation of responsibility&lt;br /&gt;
Separation of concern &lt;br /&gt;
Separation of responsibility&lt;br /&gt;
&lt;br /&gt;
==Similar principles==&lt;br /&gt;
&lt;br /&gt;
==class level separation of responsibility==&lt;br /&gt;
&lt;br /&gt;
==project/architecture level separation of responsibility==&lt;br /&gt;
MVC&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8481</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8481"/>
		<updated>2007-11-15T01:59:45Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Problem Description==&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;br /&gt;
&lt;br /&gt;
==Concept to explore==&lt;br /&gt;
&lt;br /&gt;
==Similar principles==&lt;br /&gt;
&lt;br /&gt;
==class level separation of responsibility==&lt;br /&gt;
&lt;br /&gt;
==project/architecture level separation of responsibility==&lt;br /&gt;
MVC&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/MVC.htm&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8480</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8480"/>
		<updated>2007-11-15T01:11:49Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Problem Description===&lt;br /&gt;
' Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.'&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8479</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 33</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_33&amp;diff=8479"/>
		<updated>2007-11-15T01:11:33Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Problem Description===&lt;br /&gt;
&amp;quot; Take the principle of Separation of Responsibility and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&amp;quot;&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=8148</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=8148"/>
		<updated>2007-10-30T01:25:04Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to SDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia SDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Objects==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or special wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of the  Active Record universe. Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms''' is a pattern language for Object-RDBMS integration, which contains several patterns to transform object to relational database according to different situation and different object values. Like other ORM, Crossing Chasms pattern focuses on how to how to transform between data and objects, however, it also includes other issues related to the mapping procedure, such as ''Table Design Time Pattern'', which discuss when to design the database table schema.&lt;br /&gt;
&lt;br /&gt;
'''Service Data Object''' aims to provide a uniform way to access heterogeneous data, unlike the method or patterns mentioned above, it can not only map to relational database data, but also other types of data.&lt;br /&gt;
&lt;br /&gt;
Application programmers using '''Java Data Objects''' can focus on their domain object model and leave the details of persistence to JDO implementations, while '''Crossing Chasms''' specifies details how to mapping between database and objects.&lt;br /&gt;
&lt;br /&gt;
In one word, different OR mappings has different advantages and limitations, developers will have to choose the appropriate OR mapping tools according to the project requirement and their skill set as well.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=8147</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=8147"/>
		<updated>2007-10-30T01:24:29Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to SDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia SDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Objects==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or special wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of the  Active Record universe. Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms''' is a pattern language for Object-RDBMS integration, which contains several patterns to transform object to relational database according to different situation and different object values. Like other ORM, Crossing Chasms pattern focuses on how to how to transform between data and objects, however, it also includes other issues related to the mapping procedure, such as ''Table Design Time Pattern'', which discuss when to design the database table schema.&lt;br /&gt;
&lt;br /&gt;
'''Service Data Object''' aims to provide a uniform way to access heterogeneous data, unlike the method or patterns mentioned above, it can not only map to relational database data, but also other types of data.&lt;br /&gt;
&lt;br /&gt;
Application programmers using '''Java Data Objects''' can focus on their domain object model and leave the details of persistence to JDO implementations, while '''Crossing Chasms''' specifies details how to mapping between database and objects.&lt;br /&gt;
&lt;br /&gt;
In one word, different OR mapping has different advantages and limitations, developers will have to choose the appropriate OR mapping tools according to the project requirement and their skill set as well.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6869</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6869"/>
		<updated>2007-10-23T14:57:47Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to SDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia SDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Objects==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of the  Active Record universe. Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
'''Service Data Object''' aims to provide a uniform way to access heterogeneous data, so it can not only map to relational database data, but also other types of data.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6868</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6868"/>
		<updated>2007-10-23T14:56:53Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to SDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia SDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Objects==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
'''Service Data Object''' aims to provide a uniform way to access heterogeneous data, so it can not only map to relational database data, but also other types of data.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6865</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6865"/>
		<updated>2007-10-23T14:44:18Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Java Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Objects==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6864</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6864"/>
		<updated>2007-10-23T14:44:12Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* JDO */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==Java Data Object==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Jeffrey M. Barnes in ''Object-Relational Mapping as a Persistence Mechanism for Object-Oriented Applications'' indicates that Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6861</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6861"/>
		<updated>2007-10-23T14:35:20Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found [http://ar.rubyonrails.com/ here]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==JDO==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6860</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6860"/>
		<updated>2007-10-23T14:34:31Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO from IBM]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==JDO==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6859</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6859"/>
		<updated>2007-10-23T14:34:16Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==JDO==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6858</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6858"/>
		<updated>2007-10-23T14:34:09Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==JDO==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6857</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6857"/>
		<updated>2007-10-23T14:33:59Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
&lt;br /&gt;
'''Crossing Chasms Pattern''' is a large pattern language that describes how to connect an object system to a RelationalDatabase [9]. &lt;br /&gt;
&lt;br /&gt;
Crossing chasms contains architectural patterns, static patterns that define tables and object models, dynamic patterns that resolve run-time problems of object-table mapping, and client-server patterns.&lt;br /&gt;
&lt;br /&gt;
K. Brown, B. Whitenack defined serveral patterns in ''Crossing Chasms: A Pattern Language for Object-RDBMS Integration'' [7], such as:&lt;br /&gt;
&lt;br /&gt;
*Pattern: Table Design Time&lt;br /&gt;
*Pattern: Representing Objects as Tables&lt;br /&gt;
*Pattern: Representing Object Relationships&lt;br /&gt;
*Pattern: Representing Inheritance in a Relational Database&lt;br /&gt;
*Pattern: Representing Collections in a Relational Database&lt;br /&gt;
*Pattern: Object Identifier&lt;br /&gt;
*Pattern: Foreign Key References&lt;br /&gt;
*Pattern: Foreign Key versus Direct Reference&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
&lt;br /&gt;
There are other useful links:&lt;br /&gt;
&lt;br /&gt;
*[http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
*[http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
*[http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ [3]] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally &lt;br /&gt;
not part of the class-to-table mapping process. Remember, the database is for storing the &lt;br /&gt;
data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following [3]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More details can be found in [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
&lt;br /&gt;
Some other useful links:&lt;br /&gt;
*[http://www.laliluna.de/what-is-hibernate.html What Is Hibernate]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Hibernate_(Java) Hibernate (Java)]&lt;br /&gt;
*[http://www.hibernate.org/ Relational Persistence for Java and .NET]&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
Useful links includes&lt;br /&gt;
[http://www.ibm.com/developerworks/java/library/j-sdo/ introduction to JDO]&lt;br /&gt;
[http://en.wikipedia.org/wiki/Service_Data_Objects wikipedia JDO]&lt;br /&gt;
&lt;br /&gt;
==JDO==&lt;br /&gt;
The Java Data Objects (JDO) API is a standard interface-based Java model abstraction of persistence, developed under the auspices of the Java Community Process. Benefits of Using JDO for Application Programming. Source from [http://java.sun.com/jdo/ Sun website]&lt;br /&gt;
&lt;br /&gt;
'''Ease of use''': Application programmers can focus on their domain object model and leave the details of persistence (field-by-field storage of objects) to the JDO implementation. &lt;br /&gt;
&lt;br /&gt;
'''Portability''': Applications written with the JDO API can be run on multiple implementations without recompiling or changing source code. Metadata, which describes persistence behavior external to the Java source code including most commonly used features of O/R mapping, is highly portable. &lt;br /&gt;
&lt;br /&gt;
'''Database independence''': Applications written with the JDO API are independent of the underlying database. JDO implementations support many different kinds of transactional data stores, including relational and object databases, XML, flat files, and others. &lt;br /&gt;
&lt;br /&gt;
'''High performance''': Application programmers delegate the details of persistence to the JDO implementation, which can optimize data access patterns for optimal performance. &lt;br /&gt;
&lt;br /&gt;
'''Integration with EJB''': Applications can take advantage of EJB features such as remote message processing, automatic distributed transaction coordination, and security, using the same domain object models throughout the enterprise.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In '''Hibernate''', developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Hibernate is a mature traditional O/R mapping, it uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
# [http://people.engr.ncsu.edu/efg/517/f02/common/syllabus/annotations/lec24/ppframe.htm Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations]&lt;br /&gt;
# [http://www.smallmemory.com/almanac/BrownEtc96b.html Crossing Chasms: A Pattern Language for Object-RDBMS Integration]&lt;br /&gt;
# [http://www.ksc.com/article1.htm Crossing Chasms: The Architectural Patterns]&lt;br /&gt;
# [http://c2.com/cgi/wiki?CrossingChasms Crossing Chasms]&lt;br /&gt;
# [http://java.sun.com/jdo/ Java Data Objects (JDO)]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6431</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6431"/>
		<updated>2007-10-21T22:00:00Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access  data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6429</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6429"/>
		<updated>2007-10-21T21:54:08Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord provides a easy approach to map the relational database tables to objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6428</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6428"/>
		<updated>2007-10-21T21:53:26Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambitious goal, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6427</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6427"/>
		<updated>2007-10-21T21:52:58Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access data from different data sources such as primitive data, XML data and relational database data. With SDO, application developers will not interact with data source. And only the persistent layer developer or mediation framework developer would deal data sources. Because of its ambition, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6426</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6426"/>
		<updated>2007-10-21T21:50:21Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provides a uniform way to access data from different data sources such as primitive data, XML data and relational database data. With SDO, the interaction with data source is abstracted from application developers. Those who handle the persistent layer or provide a mediation framework would deal data sources. Because of its ambition, SDO can access more types of data than ordinary O/R mapping approaches.&lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Support Multi-language (Java, C++, etc)&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6424</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6424"/>
		<updated>2007-10-21T21:40:21Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. &lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Multi-language&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
# [http://osoa.org/display/Main/Service+Data+Objects+Specifications SDO2.0 specifications ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6423</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6423"/>
		<updated>2007-10-21T21:39:50Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. &lt;br /&gt;
&lt;br /&gt;
SDO specifications provides:&lt;br /&gt;
&lt;br /&gt;
* Uniform access APIs to heterogeneous data sources&lt;br /&gt;
* Multi-language&lt;br /&gt;
* Maintains a disconnected data graph.&lt;br /&gt;
* A dynamic APIs&lt;br /&gt;
* Generate static APIs from the data source’s schema or UML.&lt;br /&gt;
* Xpath based navigation through data graph&lt;br /&gt;
* Change summary&lt;br /&gt;
* Validations and constraints&lt;br /&gt;
* Metadata access which is useful for tool builders.&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6421</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6421"/>
		<updated>2007-10-21T21:35:56Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Service Data Object */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
&lt;br /&gt;
Service Data Object(SDO) is a data programming architecture and an API. SDO provide a uniform way to access different sources data such as XML data, relational database&lt;br /&gt;
&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6416</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6416"/>
		<updated>2007-10-21T21:21:13Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Object-relational Mapping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6415</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6415"/>
		<updated>2007-10-21T21:20:57Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Object-relational Mapping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming. The relation is illustrated in the graph below&lt;br /&gt;
[[image:figure-1.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6414</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6414"/>
		<updated>2007-10-21T21:19:40Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]   [[image:figure-2.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, developer usually begins development by working on the Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so developer starts by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets developer make sure the data within the database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6413</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6413"/>
		<updated>2007-10-21T21:09:51Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]   [[image:figure-2.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(50)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.address=&amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will fill in a new table record with customer &amp;quot;John&amp;quot; with customer number 3 and address &amp;quot;#202 Heaven Rd, Raleigh, NC&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, you'd usually begin development by working on your Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so you start by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets you make sure the data within your database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6411</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6411"/>
		<updated>2007-10-21T21:07:03Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]   [[image:figure-2.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(20)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declaring a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, you'd usually begin development by working on your Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so you start by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets you make sure the data within your database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6410</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6410"/>
		<updated>2007-10-21T21:06:26Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]   [[image:figure-2.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(20)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declare a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The main features of ActiveRecord of Ruby on Rails includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, you'd usually begin development by working on your Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so you start by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets you make sure the data within your database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6409</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 2 aa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_2_aa&amp;diff=6409"/>
		<updated>2007-10-21T21:05:55Z</updated>

		<summary type="html">&lt;p&gt;Xgao2: /* ActiveRecord in Ruby */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).''&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Object-oriented (o-o) programming uses '''Object''' to manage data. Objects have identity, state, and behavior, which means Object is focus on identity and behavior of the things in real world. However '''relational database''' is focus on information. It is a collection of relation variables between the ''attributes'' of ''tables'', it describes the complete state of an information model.&lt;br /&gt;
&lt;br /&gt;
For instance, a &amp;quot;Customer Object&amp;quot; in on line bookstore system implemented by o-o programming constains the information of the customer such as name, address, email, and phone number. It also constains some methods operated by customer, such as &amp;quot;''ordering_books''&amp;quot;, which defines the ordering behavior of the customer. &lt;br /&gt;
&lt;br /&gt;
However, the popular relational database, such as MS SQL products, can only stores and manipulate the information of the customer within table &amp;quot;Customer&amp;quot;. The ordering behavior is not included in the &amp;quot;Customer&amp;quot; table.&lt;br /&gt;
&lt;br /&gt;
Therefore, programmers have to transform values between object in o-o programming and relational database. Object-ralational mapping is introduced to solve this problem.&lt;br /&gt;
&lt;br /&gt;
==Object-relational Mapping==&lt;br /&gt;
&lt;br /&gt;
'''Object-relational mapping''' (O/RM, ORM, and O/R mapping) is a programming technique or process to transform data between relational database and a set of objects in object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
[[image:figure-1.gif]]   [[image:figure-2.gif]]&lt;br /&gt;
&lt;br /&gt;
=Implementations=&lt;br /&gt;
==ActiveRecord in Ruby==&lt;br /&gt;
&lt;br /&gt;
Ruby ActiveRecord maps the relational database tables with objects. For example, after creating a database table&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
create table customers{&lt;br /&gt;
  customerNumber int&lt;br /&gt;
  name varchar(20)&lt;br /&gt;
  address varchar(20)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and declare a module&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  class Customer &amp;lt; ActiveRecord::Base &lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The table then can be manipulated directly through object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  customer=Customer.new&lt;br /&gt;
  customer.customerNumber=3&lt;br /&gt;
  customer.name=&amp;quot;John&amp;quot;&lt;br /&gt;
  customer.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The main features includes:&lt;br /&gt;
&lt;br /&gt;
*Automated mapping between classes and tables, attributes and columns.&lt;br /&gt;
*Associations between objects controlled by simple meta-programming macros.&lt;br /&gt;
*Aggregations of value objects controlled by simple meta-programming macros.&lt;br /&gt;
*Validation rules that can differ for new or existing objects.&lt;br /&gt;
*Acts that can make records work as lists or trees:&lt;br /&gt;
*Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).&lt;br /&gt;
*Observers for the entire lifecycle&lt;br /&gt;
*Inheritance hierarchies&lt;br /&gt;
*Transaction support on both a database and object level. The latter is implemented by using Transaction::Simple&lt;br /&gt;
*Reflections on columns, associations, and aggregations&lt;br /&gt;
*Direct manipulation (instead of service invocation)&lt;br /&gt;
*Database abstraction through simple adapters (~100 lines) with a shared connector&lt;br /&gt;
*Logging support for Log4r and Logger&lt;br /&gt;
&lt;br /&gt;
A detailed explanation including examples can be found here[http://ar.rubyonrails.com/]&lt;br /&gt;
&lt;br /&gt;
==Crossing Chasms Pattern==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
&lt;br /&gt;
'''Hibernate''' is a mature system following traditional view of O/R mapping, it also introduces innovations to streamline the mapping. Hibernate is originally developed for Java, but now it also support .NET from 2005.&lt;br /&gt;
&lt;br /&gt;
Hibernate uses mapping metadata in the form of XML files, instead of specific interfaces or specicial wrapper object, and Hibernate API interact database through database APIs such as JDBC.&lt;br /&gt;
&lt;br /&gt;
For instance, we have a class ''Customer''[3] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Customer {&lt;br /&gt;
  private int customerNumber;&lt;br /&gt;
  private String name;&lt;br /&gt;
  private String Address;&lt;br /&gt;
  private String telephoneNumber;&lt;br /&gt;
&lt;br /&gt;
  /* Accessors and other methods go here, such as &amp;quot;ordering_books&amp;quot;. These are generally not&lt;br /&gt;
part of the class-to-table mapping process. Remember, the database is for storing the data of the class, not its behavior. */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the mapping document in Hibernate is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
  &amp;lt;class name=&amp;quot;Customer&amp;quot; table=&amp;quot;Customer&amp;quot; discriminator-value=&amp;quot;P&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;id name=&amp;quot;id&amp;quot; column=&amp;quot;CustomerId&amp;quot; type=&amp;quot;long&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;generator class=&amp;quot;native&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/id&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;name&amp;quot; column=&amp;quot;Name&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;streetAddress&amp;quot; column=&amp;quot;Address&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;property name=&amp;quot;telephoneNumber&amp;quot; column=&amp;quot;TelephoneNumber&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every mapping document in Hibernate has a root ''bihernate-mapping'', classes are specified by element ''class'', in the ''class'' elements, children element ''property'' specifies persistent data of the class and the corresponding database columns.&lt;br /&gt;
&lt;br /&gt;
An object '''c''' of class ''Customer'' can be saved to the database using code like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Session session = getSessionFactory().openSession();&lt;br /&gt;
    Transaction tx = session.beginTransaction();&lt;br /&gt;
    session.save(c);&lt;br /&gt;
    tx.commit();&lt;br /&gt;
    session.close();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Service Data Object==&lt;br /&gt;
=Comparison=&lt;br /&gt;
In Hibernate, you'd usually begin development by working on your Java objects because Hibernate is a mapping framework. The object model becomes the center of your Hibernate universe. Active Record is a wrapping framework, so you start by creating a database table. The relational schema is the center of your Active Record universe.&lt;br /&gt;
Active Record also includes some features that many Java frameworks don't have, such as model-based validation.Model-based validation lets you make sure the data within your database stays consistent.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Object-relational_mapping Wikipedia Definition]&lt;br /&gt;
# [http://www.chimu.com/publications/objectRelational/ Foundations of Object-Relational Mapping]&lt;br /&gt;
# [http://digitalcommons.macalester.edu/context/mathcs_honors/article/1006/type/native/viewcontent/ ORM Thesis]&lt;br /&gt;
# [http://www-128.ibm.com/developerworks/java/library/j-cb03076/index.html Crossing borders: Exploring Active Record ]&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
'''&lt;br /&gt;
# [http://www.objectarchitects.de/ObjectArchitects/orpatterns/index.htm?Appendices/products.htm O/R Mapping Products]&lt;br /&gt;
&lt;br /&gt;
222. [http://en.wikipedia.org/wiki/Wikipedia:Extended_image_syntax]&lt;br /&gt;
&lt;br /&gt;
333. [http://ablog.apress.com/?p=857]&lt;br /&gt;
&lt;br /&gt;
444. [http://www.onjava.com/pub/a/onjava/2005/02/02/sqlmaps.html]&lt;/div&gt;</summary>
		<author><name>Xgao2</name></author>
	</entry>
</feed>