<?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=Kstsai</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=Kstsai"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Kstsai"/>
	<updated>2026-08-06T17:48:17Z</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_ab&amp;diff=10124</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10124"/>
		<updated>2007-11-28T20:20:30Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, Ruby on Rails has three layers, View, Model and Controller. Different layers handle different rules. When we change database, we only need to change models. And when we change business logics, we only need to change Controllers. &lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In other word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[5]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? It is show how it works although it might not improve the readability of the code.&lt;br /&gt;
&lt;br /&gt;
Each methods only doing one thing and have only one responsibility. The blind, validate and save separately in different methods.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html OOD - Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10122</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10122"/>
		<updated>2007-11-28T20:19:36Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, Ruby on Rails has three layers, View, Model and Controller. Different layers handle different rules. When we change database, we only need to change models. And when we change business logics, we only need to change Controllers. &lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[5]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? It is show how it works although it might not improve the readability of the code.&lt;br /&gt;
&lt;br /&gt;
Each methods only doing one thing and have only one responsibility. The blind, validate and save separately in different methods.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html OOD - Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10112</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10112"/>
		<updated>2007-11-28T20:12:36Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example for Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, the data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[5]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? It is show how it works although it might not improve the readability of the code.&lt;br /&gt;
&lt;br /&gt;
Each methods only doing one thing and have only one responsibility. The blind, validate and save separately in different methods.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html OOD - Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10108</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=10108"/>
		<updated>2007-11-28T20:08:40Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example for Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, the data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[5]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? It is show how it works although it might not improve the readability of the code.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html OOD - Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8818</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8818"/>
		<updated>2007-11-17T21:34:56Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Single Responsibility Principle(SRP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, the data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. It’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8817</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8817"/>
		<updated>2007-11-17T21:34:43Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class has to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects. In another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, the data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is ''create''. While others viewing the the code will expect to have a create function. But instead it has three functionalities, creates a customer, checks if it's already exist and then save it. It should divide these functionalities into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. It’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that an object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[11]&lt;br /&gt;
&lt;br /&gt;
We have an object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsibilities, having only one responsibility for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understood.&lt;br /&gt;
&lt;br /&gt;
===Example for Encapsulation principle===&lt;br /&gt;
&lt;br /&gt;
One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Person {&lt;br /&gt;
 &lt;br /&gt;
    private String firstName;&lt;br /&gt;
    private String lastName;&lt;br /&gt;
    private String suffixName;&lt;br /&gt;
 &lt;br /&gt;
    public String getFirstName() {&lt;br /&gt;
    }&lt;br /&gt;
    public void setFirstName(String _x) {&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, class ''Person'' is responsible for the data ''firstName'', ''lastName'', ''suffixName''. ''Person'' uses methods ''getFirstName'' and ''setFirstName'' to get or set data. Other classes that need to use these data have to call these methods of objects declared as ''Person'', they can not use or modify these data directly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8800</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8800"/>
		<updated>2007-11-17T20:51:15Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Information Expert(Expert pattern) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[11]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8798</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8798"/>
		<updated>2007-11-17T20:46:40Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[11]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[10]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8797</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8797"/>
		<updated>2007-11-17T20:43:31Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Single Responsibility Principle(SRP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[11]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[10]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8796</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8796"/>
		<updated>2007-11-17T20:43:18Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[10]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8795</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8795"/>
		<updated>2007-11-17T20:43:00Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Information Expert(Expert pattern) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[10]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8794</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8794"/>
		<updated>2007-11-17T20:42:17Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html Single Responsibility Principle]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8793</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8793"/>
		<updated>2007-11-17T20:41:45Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Single Responsibility Principle(SRP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.[10]&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8792</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8792"/>
		<updated>2007-11-17T20:41:12Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.oodesign.com/oo_principles/oo_principles/single_responsibility_principle.html]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8791</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8791"/>
		<updated>2007-11-17T20:39:49Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example for Single Responsibility Principle(SRP) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Why using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
Before we discuss the separation of responsibility, let us have a look at the following class [4]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Employee&lt;br /&gt;
{&lt;br /&gt;
  public Money calculatePay()&lt;br /&gt;
  public void save()&lt;br /&gt;
  public String reportHours()&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This class have to be changed when the following aspects are changed.&lt;br /&gt;
&lt;br /&gt;
*The business rules having to do with calculating pay. &lt;br /&gt;
*The database schema. &lt;br /&gt;
*The format of the string that reports hours. &lt;br /&gt;
&lt;br /&gt;
That is to say, the class ''Employee'' is impacted by three completely different responsibilities. Every time the accounts decide to change the format of the hourly report, or every time the DBAs make a change to the database schema, as well as every time the managers change the payroll calculation, we have to change the class ''Employee''.&lt;br /&gt;
&lt;br /&gt;
Separation of responsibility can avoid this trouble. When using separation of responsibility, these three functions ''calculatePay()'', ''save()'', ''reportHours()'' will be separated into different classes so that they can change independently without influence others. Using separation of responsibility, programs are easy to maintain and change.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
&lt;br /&gt;
Single responsibility principle is to say that a object should only has one reason to change. If there are more than one reason to change the object then we should split the object into smaller object which has one responsibility.&lt;br /&gt;
&lt;br /&gt;
We have a object to keep an email message as below. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - bad example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(String content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(String content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IEmail interface has two responsibilities. &lt;br /&gt;
*One would be the use of the class in some email protocols such as pop3 or imap. If other protocols must be supported the objects should be serialized in another manner and code should be added to support new protocols. &lt;br /&gt;
*Another one would be for the Content field. Even if content is a string maybe we want in the future to support HTML or other formats. &lt;br /&gt;
&lt;br /&gt;
We can create a new interface and class called IContent and Content to split the responsabilities. Having only one responsability for each class give us a more flexible design.&lt;br /&gt;
&lt;br /&gt;
*adding a new protocol causes changes only in the Email class.&lt;br /&gt;
&lt;br /&gt;
*adding a new type of content supported causes changes only in Content class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// single responsability principle - good example&lt;br /&gt;
&lt;br /&gt;
interface IEmail {&lt;br /&gt;
   public void setSender(String sender);&lt;br /&gt;
   public void setReceiver(String receiver);&lt;br /&gt;
   public void setContent(IContent content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Content {&lt;br /&gt;
   public String getAsString(); // used for serialization&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Email implements IEmail {&lt;br /&gt;
   public void setSender(String sender) {// set sender; }&lt;br /&gt;
   public void setReceiver(String receiver) {// set receiver; }&lt;br /&gt;
   public void setContent(IContent content) {// set content; }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Single Responsibility Principle represents a good way of identifying classes during the design phase of an application and it reminds you to think of all the ways a class can evolve. A good separation of Responsibility is done only when the full picture of how the application should work is well understand.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.codinghorror.com/blog/archives/000805.html Curly's Law: Do One Thing]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8787</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8787"/>
		<updated>2007-11-17T20:25:05Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
1. Programs that follow separation of responsibility are easy to be modified.  &lt;br /&gt;
2.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
===Example for Single Responsibility Principle(SRP)===&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8786</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8786"/>
		<updated>2007-11-17T20:03:04Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
1. Programs that follow separation of responsibility are easy to be modified.  &lt;br /&gt;
2.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8785</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8785"/>
		<updated>2007-11-17T20:02:39Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
1. Programs that follow separation of responsibility are easy to be modified.  &lt;br /&gt;
2.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example for Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8784</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8784"/>
		<updated>2007-11-17T20:02:14Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Information Expert(Expert pattern) Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
1. Programs that follow separation of responsibility are easy to be modified.  &lt;br /&gt;
2.&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example for Information Expert(Expert pattern)===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8782</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8782"/>
		<updated>2007-11-17T19:59:06Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Information Expert(Expert pattern) Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Information Expert(Expert pattern) Example===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example[9]. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8781</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8781"/>
		<updated>2007-11-17T19:58:55Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Information Expert(Expert pattern) Example===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://web.cs.wpi.edu/~gpollice/cs4233-a05/CourseNotes/maps/class4/InformationExpert.html Information Expert]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8780</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8780"/>
		<updated>2007-11-17T19:58:16Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[8]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Information Expert(Expert pattern) Example===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8779</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8779"/>
		<updated>2007-11-17T19:57:19Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Information Expert Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Information Expert(Expert pattern) Example===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Topic14NotesImage2.jpg&amp;diff=8778</id>
		<title>File:Topic14NotesImage2.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Topic14NotesImage2.jpg&amp;diff=8778"/>
		<updated>2007-11-17T19:56:39Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Topic14NotesImage1.jpg&amp;diff=8777</id>
		<title>File:Topic14NotesImage1.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Topic14NotesImage1.jpg&amp;diff=8777"/>
		<updated>2007-11-17T19:56:25Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8776</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8776"/>
		<updated>2007-11-17T19:56:08Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example of Information Expert */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. Following this principle, a class should have one clearly defined responsibility. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Information Expert Example===&lt;br /&gt;
&lt;br /&gt;
There is a simple part of a POS system example. &lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage1.jpg]]&lt;br /&gt;
&lt;br /&gt;
We make choices about the assignment of responsibilities to classes. Information Expert helps us decide, once we know the task (responsibility), which class to make responsible for carrying out the task.&lt;br /&gt;
&lt;br /&gt;
Assign a responsibility to the information expert; the class that has the information necessary to fulfill the responsibility.&lt;br /&gt;
So after we apply the expert pattern to the example above, it become following diagram.&lt;br /&gt;
&lt;br /&gt;
[[Image:Topic14NotesImage2.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8773</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8773"/>
		<updated>2007-11-17T19:47:23Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. In separation of concern, there are two important concepts: '''Separation of Responsibility''' and '''Separation of knowledge''' (information and environment hiding).&lt;br /&gt;
&lt;br /&gt;
'''Separation of responsibility''' states that specific functionality or specific actions are assigned to design components and are not distributed throughout a design [3], in another word, each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Example of Information Expert===&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8769</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8769"/>
		<updated>2007-11-17T19:33:40Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. &lt;br /&gt;
&lt;br /&gt;
Separation of responsibility states that specific functionality&lt;br /&gt;
or specific actions are assigned to design components and&lt;br /&gt;
are not distributed throughout a design,&lt;br /&gt;
&lt;br /&gt;
each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.[9]&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8768</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8768"/>
		<updated>2007-11-17T19:33:25Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. &lt;br /&gt;
&lt;br /&gt;
Separation of responsibility states that specific functionality&lt;br /&gt;
or specific actions are assigned to design components and&lt;br /&gt;
are not distributed throughout a design,&lt;br /&gt;
&lt;br /&gt;
each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.[9]&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8767</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8767"/>
		<updated>2007-11-17T19:33:08Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. &lt;br /&gt;
&lt;br /&gt;
Separation of responsibility states that specific functionality&lt;br /&gt;
or specific actions are assigned to design components and&lt;br /&gt;
are not distributed throughout a design,&lt;br /&gt;
&lt;br /&gt;
each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx Single-Responsibility Principle]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8766</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8766"/>
		<updated>2007-11-17T19:32:21Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. &lt;br /&gt;
&lt;br /&gt;
Separation of responsibility states that specific functionality&lt;br /&gt;
or specific actions are assigned to design components and&lt;br /&gt;
are not distributed throughout a design,&lt;br /&gt;
&lt;br /&gt;
each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility[4]. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8765</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8765"/>
		<updated>2007-11-17T19:31:16Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Principle of Separation of Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), '''Separation of Concern''' is well known as a principle or process of &lt;br /&gt;
breaking computer program codes into different components that have little coupling with each other and have strong cohesion. &lt;br /&gt;
&lt;br /&gt;
Separation of responsibility states that specific functionality&lt;br /&gt;
or specific actions are assigned to design components and&lt;br /&gt;
are not distributed throughout a design,&lt;br /&gt;
&lt;br /&gt;
each individual object should have as few responsibilities as possible, ideally one responsibility per object.&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation. We can only say '''A class should have only one reason to change.''' We want to focus classes, functions, etc. so that there is only one reason for them to change. This is why many people separate their application into layers. For example, The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://codebetter.com/blogs/jeremy.miller/pages/129542.aspx TDD Design Starter Kit – Responsibilities, Cohesion, and Coupling]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8760</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8760"/>
		<updated>2007-11-17T19:17:31Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), each individual object should have as few responsibilities as possible, ideally one responsibility per object. That is to say,&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility. &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;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
&lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last method ''saveCustomer'' has only 1 line of code, why were we let it become a individual method? Although it might not improve readability for programmers, it’s a paradigm shift in how the method is addressed. Because it calls ''customerService.save()''. it’s responsible that the save method is actually called right. Instead if we let it delegate to a newly extracted method (''saveCustomer'') it isn’t responsible for the explicit saving.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://ieeexplore.ieee.org/iel5/32/21774/01010059.pdf?arnumber=1010059 A Logical Theory of Interfaces and Objects]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8756</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8756"/>
		<updated>2007-11-17T19:02:12Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Java Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), each individual object should have as few responsibilities as possible, ideally one responsibility per object. That is to say,&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
===Java Example===&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility. &lt;br /&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;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8755</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8755"/>
		<updated>2007-11-17T19:01:34Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented Design (OOD), each individual object should have as few responsibilities as possible, ideally one responsibility per object. That is to say,&lt;br /&gt;
&lt;br /&gt;
===Advantage of using separation of responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
There are several principles of Separation of Responsibility [1]:&lt;br /&gt;
* '''Single Responsibility Principle (SRP)'''. Different responsibilities should be divided among different objects, in another word, one object should have only one responsibility in ideal situation.&lt;br /&gt;
* '''Encapsulation'''. One class should be responsible for knowing and maintaining a set of data, even if that data is used by many other classes. In another word, Data should be kept in only one place.&lt;br /&gt;
* '''Expert pattern'''. The object that contains the necessary data to perform a task should be the object that manipulates the data.&lt;br /&gt;
* '''The Dry principle'''. Code should not be duplicated. A given functionality should be implemented only in one place in the system.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
=Java Example=&lt;br /&gt;
&lt;br /&gt;
There is an Java example of principle of Separation of responsibility. &lt;br /&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;
&lt;br /&gt;
The method name is create. While others viewing the the code will expect to have a create function. But instead it has three functionality, creates a customer, checks if it's already exist and then save it. It should divide these functionality into 4 methods. &lt;br /&gt;
#''bindValidateAndSave'' The application method. It tells what to do rather than how's done.&lt;br /&gt;
#''bindCustomer''  bind and add new shoppingCart.&lt;br /&gt;
#''validateCustomer'' validate if customer exist.&lt;br /&gt;
#''saveCustomer'' save customer&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Separation_of_concerns Separation of concerns]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8578</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8578"/>
		<updated>2007-11-16T01:37:11Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
In Object-Oriented programming, each individual object should have as few responsibilities as possible, ideally one responsibility per object. That is to say,&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://courses.ncsu.edu/csc517/common/lectures/notes/lec20.pdf Elegance and classes]&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;br /&gt;
#[http://www.codeproject.com/vb/net/OOPbyExample.asp OO Programming By Example]&lt;br /&gt;
#[http://www.babysentry.com/tech_specs_benefits.htm Benefits of the Three-Tiered Architecture]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8574</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8574"/>
		<updated>2007-11-16T01:15:18Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Introduction==&lt;br /&gt;
===Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
===Principle of Separation of Responsibility===&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
#[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
#[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
#[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;br /&gt;
#[http://designparadigm.wordpress.com/ Java by Experience]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8547</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8547"/>
		<updated>2007-11-16T00:40:50Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Reference==&lt;br /&gt;
*[http://www.owlnet.rice.edu/~comp201/07-spring/assignments/finalproject/]&lt;br /&gt;
*[http://www.genwise.com/documentation/index.html?beginners_guide_to_orm_and_nhibernate.html]&lt;br /&gt;
*[http://msdn2.microsoft.com/en-us/library/ms954621.aspx]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8541</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 3 ab</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_3_ab&amp;diff=8541"/>
		<updated>2007-11-16T00:38:59Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Topic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Topic==&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;
==Reference==&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8152</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8152"/>
		<updated>2007-10-30T01:56:44Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Teaching in a Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book: the information about the book, include title, author, register code...etc. &lt;br /&gt;
*Librarian: the role who manage books.&lt;br /&gt;
*Borrower: the one borrow books include their contact. &lt;br /&gt;
*Date: to record which day the book been borrow and return.&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
To let the activities approach, this paper has some suggestions. &lt;br /&gt;
*Carefully distinguish between classes and objects.&lt;br /&gt;
*Make scenarios as specif as possible.&lt;br /&gt;
*Start with the simplest possible meaningful scenario.&lt;br /&gt;
*Initialize the role-play properly.&lt;br /&gt;
*Be careful with object names.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
and then with the small increment you are able to do more practices to learn more about CRC cards. You can create a single requirement  such as user story,  business rule, or  system use case, instead of the entire collection of requirements for your system.&lt;br /&gt;
&lt;br /&gt;
I think this is an easy example for student to self-study. This the example here is related to student experience. Compare to other examples, some are hard for student to understand and some are too complicated. This one with simple case and short description will help student to learn the general idea of CRC cards.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8151</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8151"/>
		<updated>2007-10-30T01:56:14Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book: the information about the book, include title, author, register code...etc. &lt;br /&gt;
*Librarian: the role who manage books.&lt;br /&gt;
*Borrower: the one borrow books include their contact. &lt;br /&gt;
*Date: to record which day the book been borrow and return.&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
To let the activities approach, this paper has some suggestions. &lt;br /&gt;
*Carefully distinguish between classes and objects.&lt;br /&gt;
*Make scenarios as speci�c as possible.&lt;br /&gt;
*Start with the simplest possible meaningful scenario.&lt;br /&gt;
*Initialize the role-play properly.&lt;br /&gt;
*Be careful with object names.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
and then with the small increment you are able to do more practices to learn more about CRC cards. You can create a single requirement  such as user story,  business rule, or  system use case, instead of the entire collection of requirements for your system.&lt;br /&gt;
&lt;br /&gt;
I think this is an easy example for student to self-study. This the example here is related to student experience. Compare to other examples, some are hard for student to understand and some are too complicated. This one with simple case and short description will help student to learn the general idea of CRC cards.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8150</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8150"/>
		<updated>2007-10-30T01:54:51Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Teaching in a Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book: the information about the book, include title, author, register code...etc. &lt;br /&gt;
*Librarian: the role who manage books.&lt;br /&gt;
*Borrower: the one borrow books include their contact. &lt;br /&gt;
*Date: to record which day the book been borrow and return.&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
To let the activities approach, this paper has some suggestions. &lt;br /&gt;
*Carefully distinguish between classes and objects.&lt;br /&gt;
*Make scenarios as speci�c as possible.&lt;br /&gt;
*Start with the simplest possible meaningful scenario.&lt;br /&gt;
*Initialize the role-play properly.&lt;br /&gt;
*Be careful with object names.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
and then with the small increment you are able to do more practices to learn more about CRC cards. You can create a single requirement  such as user story,  business rule, or  system use case, instead of the entire collection of requirements for your system.&lt;br /&gt;
&lt;br /&gt;
I think this is an easy example for student to self-study. This the example here is related to student experience. Compare to other examples, some are hard for student to understand and some are too complicated. This one with simple case and short description will help student to learn the general idea of CRC cards.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8149</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=8149"/>
		<updated>2007-10-30T01:46:45Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Self-study */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book: the information about the book, include title, author, register code...etc. &lt;br /&gt;
*Librarian: the role who manage books.&lt;br /&gt;
*Borrower: the one borrow books include their contact. &lt;br /&gt;
*Date: to record which day the book been borrow and return.&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
and then with the small increment you are able to do more practices to learn more about CRC cards. You can create a single requirement  such as user story,  business rule, or  system use case, instead of the entire collection of requirements for your system.&lt;br /&gt;
&lt;br /&gt;
I think this is an easy example for student to self-study. This the example here is related to student experience. Compare to other examples, some are hard for student to understand and some are too complicated. This one with simple case and short description will help student to learn the general idea of CRC cards.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7685</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7685"/>
		<updated>2007-10-25T01:59:20Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Teaching in a Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book: the information about the book, include title, author, register code...etc. &lt;br /&gt;
*Librarian: the role who manage books.&lt;br /&gt;
*Borrower: the one borrow books include their contact. &lt;br /&gt;
*Date: to record which day the book been borrow and return.&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why I think this is a good web site for self study? The example here is easy and close to student’s experience, therefore student can understand easily without others help.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7682</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7682"/>
		<updated>2007-10-25T01:55:40Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Self-study */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book&lt;br /&gt;
*Librarian &lt;br /&gt;
*Borrower&lt;br /&gt;
*Date&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
How to create CRC model? just follow these steps:&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why I think this is a good web site for self study? The example here is easy and close to student’s experience, therefore student can understand easily without others help.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CrcCardStudent.jpg&amp;diff=7679</id>
		<title>File:CrcCardStudent.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CrcCardStudent.jpg&amp;diff=7679"/>
		<updated>2007-10-25T01:53:06Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7678</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7678"/>
		<updated>2007-10-25T01:52:49Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Self-study */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book&lt;br /&gt;
*Librarian &lt;br /&gt;
*Borrower&lt;br /&gt;
*Date&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
Here's the example of one of the CRC card look like:&lt;br /&gt;
[[Image:crcCardStudent.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why I think this is a good web site for self study? The example here is easy and close to student’s experience, therefore student can understand easily without others help.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7671</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7671"/>
		<updated>2007-10-25T01:49:04Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Teaching in a Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book&lt;br /&gt;
*Librarian &lt;br /&gt;
*Borrower&lt;br /&gt;
*Date&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
&lt;br /&gt;
[[Image:roles.JPG]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
Why I think this is a good web site for self study? The example here is easy and close to student’s experience, therefore student can understand easily without others help.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Roles.JPG&amp;diff=7667</id>
		<title>File:Roles.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Roles.JPG&amp;diff=7667"/>
		<updated>2007-10-25T01:48:05Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7666</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 5 kq</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_5_kq&amp;diff=7666"/>
		<updated>2007-10-25T01:47:37Z</updated>

		<summary type="html">&lt;p&gt;Kstsai: /* Exercise for Teaching in a Class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This Wiki Page is edited by Kunta Tsai and Qinyi Ding'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Topic=&lt;br /&gt;
''CRC cards. Hundreds of Web pages cover CRC cards. Which explain them best? Which explain them in the context of specific languages, e.g., Ruby and Java? Which exercises can be used to teach them best, (i) interactively over the Web, (ii) to a class of students, via in-class exercises, (iii) for self-study?''&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
A Class Responsibility Collaborator (CRC) model ([http://c2.com/doc/oopsla89/paper.html#cards Beck &amp;amp; Cunningham] 1989; Wilkinson 1995; [http://www.ambysoft.com/books/theObjectPrimer.html Ambler] 1995) is a collection of standard [http://en.wikipedia.org/wiki/Index_card index cards] that are used when first determining which [http://en.wikipedia.org/wiki/Class_%28computer_science%29 classes] are needed and how they will interact. &lt;br /&gt;
A CRC card always contain these sections:&lt;br /&gt;
* The class name: represents a collection of similar objects&lt;br /&gt;
* Its Super and Sub classes (if applicable)&lt;br /&gt;
* The responsibilities of the class: represents something a class knows or does&lt;br /&gt;
* The collaborator: The names of other classes with which the class will collaborate to fulfill its responsibilities. &lt;br /&gt;
* Author&lt;br /&gt;
&lt;br /&gt;
An example of CRC card is shown in figure 1.&lt;br /&gt;
&lt;br /&gt;
Figure 1:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCard.gif]]&lt;br /&gt;
&lt;br /&gt;
=Advantages of CRC Card=&lt;br /&gt;
Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.&lt;br /&gt;
&lt;br /&gt;
=Best Page Related to CRC ---- Example of ATM Machine=&lt;br /&gt;
[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html CRC Cards for ATM Example] is a very good page for a CRC card instantiation. We have browsed through hundreds of websites regarding to CRC card, and this page offers a clearest and most complete example using CRC card and Java implementation.&lt;br /&gt;
&lt;br /&gt;
The example the page provides is how to design an [http://en.wikipedia.org/wiki/Automated_teller_machine ATM machine]. It is absolutely not an easy task since an ATM machine has to interact with the bank and the user, and a transaction is also related to reading card and printing receipt. Moreover, the login system is essential to ensure security. In order to deal with the relationship of so many distinct classes of objects, we need the help of CRC card. &lt;br /&gt;
&lt;br /&gt;
The description on the CRC card of each class makes it clear of the responsibility and collaborate class of the specific class, and facilitate the designer to design interfaces more easily.&lt;br /&gt;
&lt;br /&gt;
Below is a complete list of the class used in an ATM machine design. You can click the link to access to the corresponding CRC card.&lt;br /&gt;
*[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ATM Class ATM]&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;table width = 60%&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Boundary/entity objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Controller objects&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Entity objects&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CardReader Class CardReader]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Session Class Session]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Balances Class Balances]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CashDispenser Class CashDispenser]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transaction Class Transaction]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Card Class Card]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#CustomerConsole Class CustomerConsole]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Withdrawal Class Withdrawal]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Message Class Message]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#EnvelopeAcceptor Class EnvelopeAcceptor]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Deposit Class Deposit]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Receipt Class Receipt]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Log Class Log]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Transfer Class Transfer]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Status Class Status]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#NetworkToBank Class NetworkToBank]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#Inquiry Class Inquiry]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#OperatorPanel Class OperatorPanel]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;[http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/CRCCards.html#ReceiptPrinter Class ReceiptPrinter]&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are many other websites which introduce the concept and examples of CRC card. Please refer to the [http://pg.ece.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_5_kq#Reference Reference] of this page if you are interested.&lt;br /&gt;
&lt;br /&gt;
=Examples of CRC=&lt;br /&gt;
Since CRC card is a kind of conceptual description of classes, it uses more natual language than programming language like Java and Ruby. There are few websites which introduce the implementation of CRC card using Java, and fewer using Ruby. Let's take a look at a brief example from our best CRC page.&lt;br /&gt;
&lt;br /&gt;
A card reader is important to an ATM machine. The card reader is the interface to connect ATM and the card. It should tell ATM when a card is inserted, and should be able to read the information in the card. To eject card and retain card are also key functions of a card reader. &lt;br /&gt;
Therefore, the CRC card of a card reader could look like:&lt;br /&gt;
&lt;br /&gt;
[[Image:CRCCardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
The UML diagram of the class is:&lt;br /&gt;
&lt;br /&gt;
[[Image:CardReader.JPG]]&lt;br /&gt;
&lt;br /&gt;
Hence the card reader class should have:&lt;br /&gt;
*Variables:&lt;br /&gt;
atm: The ATM to which this card reader belongs &lt;br /&gt;
 &lt;br /&gt;
*Constructor:&lt;br /&gt;
CardReader(ATM): Constructor &lt;br /&gt;
 &lt;br /&gt;
*Methods:&lt;br /&gt;
ejectCard() : Eject the card that is currently inside the reader. &lt;br /&gt;
readCard()  : Read a card that has been partially inserted into the reader &lt;br /&gt;
retainCard(): Retain the card that is currently inside the reader for action by the bank.&lt;br /&gt;
----&lt;br /&gt;
From the design above, we can easily code the class as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * ATM Example system - file CardReader.java&lt;br /&gt;
 *&lt;br /&gt;
 * copyright (c) 2001 - Russell C. Bjork&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
package atm.physical;&lt;br /&gt;
import atm.ATM;&lt;br /&gt;
import banking.Card;&lt;br /&gt;
import simulation.Simulation;&lt;br /&gt;
&lt;br /&gt;
/** Manager for the ATM's card reader.  In a real ATM, this would &lt;br /&gt;
 *  manage a physical device; in this simulation, it uses classes &lt;br /&gt;
 *  in package simulation to simulate the device.  &lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
public class CardReader&lt;br /&gt;
{&lt;br /&gt;
    /** Constructor&lt;br /&gt;
     *&lt;br /&gt;
     *  @param atm the ATM that owns this card reader&lt;br /&gt;
     */&lt;br /&gt;
    public CardReader(ATM atm)&lt;br /&gt;
    {&lt;br /&gt;
        this.atm = atm;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // In a real ATM, code would be needed to sense insertion of a card into the&lt;br /&gt;
    // slot and notify the ATM - simulated in this case by a button in the GUI&lt;br /&gt;
    &lt;br /&gt;
    /** Read a card that has been partially inserted into the reader&lt;br /&gt;
     *&lt;br /&gt;
     *  @return Card object representing information on the card if read&lt;br /&gt;
     *          successfully, null if not read successfully&lt;br /&gt;
     */&lt;br /&gt;
    public Card readCard()&lt;br /&gt;
    {&lt;br /&gt;
        return Simulation.getInstance().readCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Eject the card that is currently inside the reader.  &lt;br /&gt;
     */&lt;br /&gt;
    public void ejectCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().ejectCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Retain the card that is currently inside the reader for action by the&lt;br /&gt;
     *  bank.&lt;br /&gt;
     */&lt;br /&gt;
    public void retainCard()&lt;br /&gt;
    {&lt;br /&gt;
        Simulation.getInstance().retainCard();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** The ATM to which this card reader belongs&lt;br /&gt;
     */&lt;br /&gt;
    private ATM atm;    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Teaching Exercises for CRC=&lt;br /&gt;
We read many webpages and we selected the ones below as the most suitable examples for different teaching purposes.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching Interactively over the Web==&lt;br /&gt;
Of course the ATM machine example mentioned above is a very good case to study and to teach interactively over the web, since the content is detailed and each class in it is a good exercise to practice using CRC card. Besides the ATM website, another website [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ Object Oriented Analysis and Design using CRC Cards] is also very instructive and worth reading.&lt;br /&gt;
&lt;br /&gt;
This website is an online tutorial for how to use CRC card. The tutorial contains two stages: CRC card for analysis and CRC card for design. In the analysis stage there are two activities. The first one is to design an operation system for a technical library for an R&amp;amp;D organization. The author provides a list of possible classes for readers to choose and analyze. The second activity is to stabilize the system by consider more possible flaws of the system. The author summarize the strength of CRC card for analysis are:&lt;br /&gt;
&lt;br /&gt;
*Common Project Vocabulary&lt;br /&gt;
*Spread Domain Knowledge &lt;br /&gt;
*Making the Paradigm Shift &lt;br /&gt;
*Live Prototyping &lt;br /&gt;
*Identifying Holes in Requirements&lt;br /&gt;
&lt;br /&gt;
In the design stage the author lists some major elements for CRC design and some additional information to be added to cards in this stage: subresponsibilities, collaborating responsibilities and the data passed. There is the third activity to redo the scenarios in the analysis stage, with consideration of all design heuristics discussed. The author summarize the strength of CRC card for design are:&lt;br /&gt;
&lt;br /&gt;
*Spreading Objet-Oriented Design Expertise &lt;br /&gt;
*Design Reviews &lt;br /&gt;
*Framework for Implementation &lt;br /&gt;
*Informal Notation&lt;br /&gt;
&lt;br /&gt;
All in all, the material in this tutorial is in detail, and is suitable to be used for teaching interactively over web. The teacher could add more features and more detailed thinkings to the activites and the students could practice based on the tutorial.&lt;br /&gt;
&lt;br /&gt;
==Exercise for Teaching in a Class==&lt;br /&gt;
&lt;br /&gt;
There is an example of how to use role playing to teach OO design through CRC cards by [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf Jürgen Börstler] Umeå University, Sweden. It not only works well at teaching CRC cards in class but also a good activity in class. Divide class into groups. Each member in the group presents an object (a CRC card). They can only think of their role. Their responsibilities and how they collaborate with others. Via this way, students can know how to define each CRC card by naming each role; to list what each role can do is to understand how to list responsibilities; to interact with other roles helps to figure out the collaborator of CRC cards.&lt;br /&gt;
It takes a small library system as example. There are four roles:&lt;br /&gt;
*Book&lt;br /&gt;
*Librarian &lt;br /&gt;
*Borrower&lt;br /&gt;
*Date&lt;br /&gt;
[[Image:Library diagram.JPG]]&lt;br /&gt;
Each student play a role to discuss with others.&lt;br /&gt;
[[Image:roles.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Exercise for Self-study==&lt;br /&gt;
Here is a good web page (http://www.agilemodeling.com/artifacts/crcModel.htm) for CRC cards self-study. It simple describes CRC cards at first and using an easy example to teach the rest. The example has only three main roles, student, seminar and professor. Because it’s an example relate to the student experience so it’s easy to understand. &lt;br /&gt;
&lt;br /&gt;
*First, find the classes and how to name the classes. &lt;br /&gt;
*Second, find the responsibility. &lt;br /&gt;
*Third, define the collaborators to find out how each role interactive with others. &lt;br /&gt;
*Forth, move the cards around to more clearly figure out the relation of each class.&lt;br /&gt;
Why I think this is a good web site for self study? The example here is easy and close to student’s experience, therefore student can understand easily without others help.&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Class-Responsibility-Collaboration_card Class Responsibility Collaboration Card]&lt;br /&gt;
* [http://www.agilemodeling.com/artifacts/crcModel.htm Class Responsibility Collaborator (CRC) Models]&lt;br /&gt;
* [http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/ CRC Cards Tutorial]&lt;br /&gt;
* [http://c2.com/doc/oopsla89/paper.html#cards Paper of Beck &amp;amp; Cunningham 1989]&lt;br /&gt;
* [http://www.ambysoft.com/books/theObjectPrimer.html Book of Ambler 1995]&lt;br /&gt;
* [http://www.c2.com/cgi/wiki?CrcCard CRC Card]&lt;br /&gt;
* [http://courses.knox.edu/cs292/ATMExample/index.html An Example of Object-Oriented Design: An ATM Simulation]&lt;br /&gt;
* [http://www.cs.umu.se/~jubo/Papers/CRC_CeTUSS07.pdf CRC-Cards and Roleplay Diagrams Informal Tools to Teach OO Thinking]&lt;/div&gt;</summary>
		<author><name>Kstsai</name></author>
	</entry>
</feed>