<?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=Sren</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=Sren"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sren"/>
	<updated>2026-04-16T01:06:33Z</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_2012/ch2a_2w23_sr&amp;diff=68658</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68658"/>
		<updated>2012-10-27T00:47:12Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Responsibility-driven design principles and constructs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RDD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and analysis==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
The analysis stage of RDD consists of three phases&lt;br /&gt;
*System Deﬁnition&lt;br /&gt;
High-level view of system&lt;br /&gt;
*Detailed Description&lt;br /&gt;
Detailed view of development process, functional requirements, and non-functional requirements.&lt;br /&gt;
*Object Analysis&lt;br /&gt;
Construction of domain objects。&amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients, ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison of Responsibility-driven design with Data-driven design ==&lt;br /&gt;
&lt;br /&gt;
Adapting abstract data type design methods to object-oriented programming results in a data-driven design. On the other hand, Responsibility-driven design is in direct contrast with Data-driven design, which promotes defining the behavior of a class along the data that it holds. &lt;br /&gt;
&lt;br /&gt;
'''''Why responsibility-driven design over data-driven design?'''''&lt;br /&gt;
&lt;br /&gt;
While data-driven design does prevent coupling of data and functionality, in some cases, data-driven programming has been argued to lead to bad object-oriented design, especially when dealing with more abstract data. This is because a purely data-driven object or entity is defined by the way it is represented. Any attempt to change the structure of the object would immediately break the functions that rely on it. As a, perhaps trivial, example, one might represent driving directions as a series of intersections (two intersecting streets) where the driver must turn right or left. If an intersection (in the United States) is represented in data by the zip code (5-digit number) and two street names (strings of text), you might run into bugs when you discover a city where streets intersect multiple times. While this example may be over simplified, restructuring of data is fairly common problem in software engineering, either to eliminate bugs, increase efficiency, or support new features. In these cases responsibility-driven design may be promoted as a better approach, where functionality and data can be coupled together, so functions don't have to deal with the data representation itself.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Responsibility-Driven Design is A way to design software that emphasizes modeling of objects’ roles, responsibilities, and collaborations.  Its principle is to maximize abstraction, delegate control and preserve flexibility. RDD increased encapsulation by focusing on the contractual responsibilities of a class and it facilities polymorphism by encouraging the designer to focus on responsibilities independently of implementation.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68634</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68634"/>
		<updated>2012-10-27T00:36:33Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RDD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients, ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Responsibility-Driven Design is A way to design software that emphasizes modeling of objects’ roles, responsibilities, and collaborations.  Its principle is to maximize abstraction, delegate control and preserve flexibility. RDD increased encapsulation by focusing on the contractual responsibilities of a class and it facilities polymorphism by encouraging the designer to focus on responsibilities independently of implementation.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68633</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68633"/>
		<updated>2012-10-27T00:36:22Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RDD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients, ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
Conclusion:&lt;br /&gt;
Responsibility-Driven Design is A way to design software that emphasizes modeling of objects’ roles, responsibilities, and collaborations.  Its principle is to maximize abstraction, delegate control and preserve flexibility. RDD increased encapsulation by focusing on the contractual responsibilities of a class and it facilities polymorphism by encouraging the designer to focus on responsibilities independently of implementation.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68624</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68624"/>
		<updated>2012-10-27T00:33:25Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RDD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients, ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68619</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68619"/>
		<updated>2012-10-27T00:29:12Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Advantages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients, ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68614</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68614"/>
		<updated>2012-10-27T00:27:28Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Constructs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://www.wirfs-brock.com/ RRD principles and constructs&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients [Halb86], ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68600</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68600"/>
		<updated>2012-10-27T00:23:12Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Advantages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
*Increased encapsulation:&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients [Halb86], ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
*Facilitates polymorphism:&lt;br /&gt;
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68599</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68599"/>
		<updated>2012-10-27T00:22:53Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Constructs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
* Facilitates polymorphism&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68583</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68583"/>
		<updated>2012-10-27T00:17:43Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles and constructs==&lt;br /&gt;
=== Principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
* Facilitates polymorphism&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68577</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68577"/>
		<updated>2012-10-27T00:15:14Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Responsibility-driven design principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Responsibility-driven design principles ===&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
=== Responsibility-Driven Design Constructs===&lt;br /&gt;
*an application = a set of interacting objects&lt;br /&gt;
*an object = an implementation of one or more roles&lt;br /&gt;
*a role = a set of related responsibilities&lt;br /&gt;
*a responsibility = an obligation to perform a task or know information&lt;br /&gt;
*a collaboration = an interaction of objects or roles (or both)&lt;br /&gt;
*a contract = an agreement outlining the terms of a collaboration&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
* Facilitates polymorphism&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68572</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68572"/>
		<updated>2012-10-27T00:12:55Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Advantages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
* Facilitates polymorphism&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68566</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68566"/>
		<updated>2012-10-27T00:11:45Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
== Example ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68560</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68560"/>
		<updated>2012-10-27T00:10:33Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Advantages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
* Increase encapsulation&lt;br /&gt;
&lt;br /&gt;
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68553</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68553"/>
		<updated>2012-10-27T00:09:37Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68550</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68550"/>
		<updated>2012-10-27T00:09:09Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the [http://en.wikipedia.org/wiki/Client%E2%80%93server_model client/server model]. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68548</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68548"/>
		<updated>2012-10-27T00:08:31Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Client-server model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68529</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68529"/>
		<updated>2012-10-27T00:04:50Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
The goal of responsibility-driven design is to improve encapsulation. It does so by viewing a program in terms of the client/server model.&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68527</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68527"/>
		<updated>2012-10-27T00:04:31Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Advantages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
The goal of responsibility-driven design is to improve encapsulation. It does so by viewing a program in terms of the client/server model.&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.&lt;br /&gt;
&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68524</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68524"/>
		<updated>2012-10-27T00:03:42Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Responsibility-driven design principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
The goal of responsibility-driven design is to improve encapsulation. It does so by viewing a program in terms of the client/server model.&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—-have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68483</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68483"/>
		<updated>2012-10-26T23:51:51Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
The goal of responsibility-driven design is to improve encapsulation. It does so by viewing a program in terms of the client/server model.&lt;br /&gt;
&lt;br /&gt;
== Responsibility-driven design principles ==&lt;br /&gt;
* Maximize Abstraction&lt;br /&gt;
&lt;br /&gt;
Initially hide the distinction between data and behavior.&lt;br /&gt;
&lt;br /&gt;
Think of objects responsibilities for “knowing”, “doing”,and “deciding”&lt;br /&gt;
&lt;br /&gt;
* Distribute Behavior&lt;br /&gt;
&lt;br /&gt;
Promote a delegated control architecture.&lt;br /&gt;
&lt;br /&gt;
Make objects smart—have them behave intelligently, not just hold bundles of data.&lt;br /&gt;
&lt;br /&gt;
*Preserve Flexibility&lt;br /&gt;
&lt;br /&gt;
Design objects so interior details can be readily changed&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68472</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68472"/>
		<updated>2012-10-26T23:49:28Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Client-server model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
The goal of responsibility-driven design is to improve encapsulation. It does so by viewing a program in terms of the client/server model.&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68436</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68436"/>
		<updated>2012-10-26T23:29:17Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;1&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68434</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68434"/>
		<updated>2012-10-26T23:28:44Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Responsibility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client-server model ==&lt;br /&gt;
&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68425</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68425"/>
		<updated>2012-10-26T23:23:46Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68423</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68423"/>
		<updated>2012-10-26T23:23:24Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
RRD is defined as follows:&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:&lt;br /&gt;
&lt;br /&gt;
* What actions is this object responsible for?&lt;br /&gt;
* What information does this object share?&lt;br /&gt;
&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68418</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68418"/>
		<updated>2012-10-26T23:22:09Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinable, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68417</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68417"/>
		<updated>2012-10-26T23:21:40Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinabe, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design methodto focus on increaseing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68416</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68416"/>
		<updated>2012-10-26T23:21:29Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinabe, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
Responsibility-driven design(RRD) is an alternate design methodto focus on increaseing the encapsulation by viewing a program in terms of the client/server model.&amp;lt;ref&amp;gt;http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach&amp;lt;/ref&amp;gt; This method was proposed by [http://en.wikipedia.org/wiki/Rebecca_Wirfs-Brock Rebecca Wirfs-Brock] and Brian Wilkerson.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68405</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68405"/>
		<updated>2012-10-26T23:15:40Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Object-oriented_programming Object-oriented programming(OOP) language] enable software to be reusable, refinabe, testable, maintainable, and extensible by supporting [http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) encapsulation]. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68396</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68396"/>
		<updated>2012-10-26T23:11:43Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
== Definition ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68389</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68389"/>
		<updated>2012-10-26T23:04:01Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
== Introduction ==&lt;br /&gt;
== Responsibility ==&lt;br /&gt;
== Advantages ==&lt;br /&gt;
== Disadvantages ==&lt;br /&gt;
== Comparison ==&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68388</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68388"/>
		<updated>2012-10-26T23:03:25Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
==Introduction==&lt;br /&gt;
==Responsibility==&lt;br /&gt;
==Advantages==&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
==Comparison==&lt;br /&gt;
==Conclusion==&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68387</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=68387"/>
		<updated>2012-10-26T23:02:43Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Responsibility-Driven Design''&lt;br /&gt;
==Introduction==&lt;br /&gt;
==Responsibility==&lt;br /&gt;
==Advantages==&lt;br /&gt;
==Disadvantages==&lt;br /&gt;
==Comparison==&lt;br /&gt;
==conclusion==&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=67662</id>
		<title>CSC/ECE 517 Fall 2012/ch2a 2w23 sr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2a_2w23_sr&amp;diff=67662"/>
		<updated>2012-10-21T03:21:28Z</updated>

		<summary type="html">&lt;p&gt;Sren: Created page with &amp;quot;=Responsibility-Driven Design=&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Responsibility-Driven Design=&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=67661</id>
		<title>CSC/ECE 517 Fall 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=67661"/>
		<updated>2012-10-21T03:16:24Z</updated>

		<summary type="html">&lt;p&gt;Sren: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE 517 Fall 2012/ch1 n xx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w1 rk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w20 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w5 su]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w6 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w4 aj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w7 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w8 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w9 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w10 pk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w12 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w14 gv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w17 ir]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w22 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 wi]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w31 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w16 br]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w23 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w24 nr]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w15 rt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w3 pl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w32 cm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w37 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w67 ks]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w27 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w29 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w33 op]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w19 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w34 vd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w35 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w30 rp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w58 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w47 sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w69 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w44 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w45 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w53 kc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 ar]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w39 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w54 go]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w56 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w64 nn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w66 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w42 js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w46 sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w71 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w63 dv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w55 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w57 mp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w52 an]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch1b 1w38 nm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w60 ac]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w62 rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w29 st]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch 2w30 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w17 pt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w31 up]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w9 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w19 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w16 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w8 vp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w3 jm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w23 sr]]&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63535</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63535"/>
		<updated>2012-09-11T03:27:34Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Not supporting utility methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
     public void test1(){&lt;br /&gt;
        int a=1,b=1;&lt;br /&gt;
        long startTime1 = System.currentTimeMillis();&lt;br /&gt;
        for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
           a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
        long endTime1 = System.currentTimeMillis();&lt;br /&gt;
        System.out.println(endTime1-startTime1);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     public void test2(){&lt;br /&gt;
         Integer c=new Integer(1);&lt;br /&gt;
         Integer d=new Integer(1);&lt;br /&gt;
         long startTime2 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            c=c+d;&lt;br /&gt;
         }&lt;br /&gt;
         long endTime2 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime2-startTime2)&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
     struct compose&lt;br /&gt;
     {&lt;br /&gt;
         char name;&lt;br /&gt;
         int a;&lt;br /&gt;
         int b;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
    class Person&lt;br /&gt;
  &lt;br /&gt;
        def initialize( name, age=18 )&lt;br /&gt;
            @name = name&lt;br /&gt;
            @age = age&lt;br /&gt;
            @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
  &lt;br /&gt;
        def talk&lt;br /&gt;
            puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
               puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
               puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        attr_writer :motherland   &lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
    class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
         def talk&lt;br /&gt;
             puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
         end  &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ArrayListaList=newArrayList();&lt;br /&gt;
    aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
    aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
    aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
    parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
    parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
    parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
    parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
    Vector　v=new Vector();  &lt;br /&gt;
    int k=121; &lt;br /&gt;
    v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63533</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63533"/>
		<updated>2012-09-11T03:27:05Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Inability on handling large scale data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
     public void test1(){&lt;br /&gt;
        int a=1,b=1;&lt;br /&gt;
        long startTime1 = System.currentTimeMillis();&lt;br /&gt;
        for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
           a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
        long endTime1 = System.currentTimeMillis();&lt;br /&gt;
        System.out.println(endTime1-startTime1);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     public void test2(){&lt;br /&gt;
         Integer c=new Integer(1);&lt;br /&gt;
         Integer d=new Integer(1);&lt;br /&gt;
         long startTime2 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            c=c+d;&lt;br /&gt;
         }&lt;br /&gt;
         long endTime2 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime2-startTime2)&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
     struct compose&lt;br /&gt;
     {&lt;br /&gt;
         char name;&lt;br /&gt;
         int a;&lt;br /&gt;
         int b;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
    class Person&lt;br /&gt;
  &lt;br /&gt;
        def initialize( name, age=18 )&lt;br /&gt;
            @name = name&lt;br /&gt;
            @age = age&lt;br /&gt;
            @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
  &lt;br /&gt;
        def talk&lt;br /&gt;
            puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
               puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
               puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        attr_writer :motherland   &lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
    class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
         def talk&lt;br /&gt;
             puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
         end  &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ArrayListaList=newArrayList();&lt;br /&gt;
    aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
    aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
    aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
    aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63532</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63532"/>
		<updated>2012-09-11T03:26:41Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Cannot be extended */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
     public void test1(){&lt;br /&gt;
        int a=1,b=1;&lt;br /&gt;
        long startTime1 = System.currentTimeMillis();&lt;br /&gt;
        for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
           a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
        long endTime1 = System.currentTimeMillis();&lt;br /&gt;
        System.out.println(endTime1-startTime1);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     public void test2(){&lt;br /&gt;
         Integer c=new Integer(1);&lt;br /&gt;
         Integer d=new Integer(1);&lt;br /&gt;
         long startTime2 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            c=c+d;&lt;br /&gt;
         }&lt;br /&gt;
         long endTime2 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime2-startTime2)&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
     struct compose&lt;br /&gt;
     {&lt;br /&gt;
         char name;&lt;br /&gt;
         int a;&lt;br /&gt;
         int b;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
    class Person&lt;br /&gt;
  &lt;br /&gt;
        def initialize( name, age=18 )&lt;br /&gt;
            @name = name&lt;br /&gt;
            @age = age&lt;br /&gt;
            @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
  &lt;br /&gt;
        def talk&lt;br /&gt;
            puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
               puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
               puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        attr_writer :motherland   &lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
    class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
         def talk&lt;br /&gt;
             puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
         end  &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63531</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63531"/>
		<updated>2012-09-11T03:25:47Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Space performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
     public void test1(){&lt;br /&gt;
        int a=1,b=1;&lt;br /&gt;
        long startTime1 = System.currentTimeMillis();&lt;br /&gt;
        for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
           a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
        long endTime1 = System.currentTimeMillis();&lt;br /&gt;
        System.out.println(endTime1-startTime1);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     public void test2(){&lt;br /&gt;
         Integer c=new Integer(1);&lt;br /&gt;
         Integer d=new Integer(1);&lt;br /&gt;
         long startTime2 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            c=c+d;&lt;br /&gt;
         }&lt;br /&gt;
         long endTime2 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime2-startTime2)&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
     struct compose&lt;br /&gt;
     {&lt;br /&gt;
         char name;&lt;br /&gt;
         int a;&lt;br /&gt;
         int b;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63530</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63530"/>
		<updated>2012-09-11T03:25:24Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Time performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
     public void test1(){&lt;br /&gt;
        int a=1,b=1;&lt;br /&gt;
        long startTime1 = System.currentTimeMillis();&lt;br /&gt;
        for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
           a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
        long endTime1 = System.currentTimeMillis();&lt;br /&gt;
        System.out.println(endTime1-startTime1);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     public void test2(){&lt;br /&gt;
         Integer c=new Integer(1);&lt;br /&gt;
         Integer d=new Integer(1);&lt;br /&gt;
         long startTime2 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            c=c+d;&lt;br /&gt;
         }&lt;br /&gt;
         long endTime2 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime2-startTime2)&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63529</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63529"/>
		<updated>2012-09-11T03:24:49Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Time performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
      public void test1(){&lt;br /&gt;
         int a=1,b=1;&lt;br /&gt;
         long startTime1 = System.currentTimeMillis();&lt;br /&gt;
         for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
            a=a+b;&lt;br /&gt;
                        }&lt;br /&gt;
         long endTime1 = System.currentTimeMillis();&lt;br /&gt;
         System.out.println(endTime1-startTime1);&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      public void test2(){&lt;br /&gt;
          Integer c=new Integer(1);&lt;br /&gt;
          Integer d=new Integer(1);&lt;br /&gt;
          long startTime2 = System.currentTimeMillis();&lt;br /&gt;
          for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
             c=c+d;&lt;br /&gt;
          }&lt;br /&gt;
          long endTime2 = System.currentTimeMillis();&lt;br /&gt;
          System.out.println(endTime2-startTime2)&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63528</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63528"/>
		<updated>2012-09-11T03:23:43Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
       public void test1(){&lt;br /&gt;
          int a=1,b=1;&lt;br /&gt;
          long startTime1 = System.currentTimeMillis();&lt;br /&gt;
          for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
             a=a+b;&lt;br /&gt;
                         }&lt;br /&gt;
          long endTime1 = System.currentTimeMillis();&lt;br /&gt;
          System.out.println(endTime1-startTime1);&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       public void test2(){&lt;br /&gt;
           Integer c=new Integer(1);&lt;br /&gt;
           Integer d=new Integer(1);&lt;br /&gt;
           long startTime2 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              c=c+d;&lt;br /&gt;
           }&lt;br /&gt;
           long endTime2 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime2-startTime2)&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell, composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63527</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63527"/>
		<updated>2012-09-11T03:23:20Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Time performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
       public void test1(){&lt;br /&gt;
          int a=1,b=1;&lt;br /&gt;
          long startTime1 = System.currentTimeMillis();&lt;br /&gt;
          for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
             a=a+b;&lt;br /&gt;
                         }&lt;br /&gt;
          long endTime1 = System.currentTimeMillis();&lt;br /&gt;
          System.out.println(endTime1-startTime1);&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       public void test2(){&lt;br /&gt;
           Integer c=new Integer(1);&lt;br /&gt;
           Integer d=new Integer(1);&lt;br /&gt;
           long startTime2 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              c=c+d;&lt;br /&gt;
           }&lt;br /&gt;
           long endTime2 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime2-startTime2)&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell,composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. It bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63525</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63525"/>
		<updated>2012-09-11T03:22:10Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Cannot be extended */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
      class Person&lt;br /&gt;
  &lt;br /&gt;
          def initialize( name, age=18 )&lt;br /&gt;
              @name = name&lt;br /&gt;
              @age = age&lt;br /&gt;
              @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
          end&lt;br /&gt;
  &lt;br /&gt;
          def talk&lt;br /&gt;
              puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
              if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                 puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
              else&lt;br /&gt;
                 puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
              end&lt;br /&gt;
          end&lt;br /&gt;
          attr_writer :motherland   &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
      class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
           end  &lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
In a nutshell,composite data type is more likely to stand out the features of object-oriented language and be widely used. However,primitive data type would not disappear in a foreseeable future because of its advantage in performance and use. What's more, it bridges the gap between novice programmers and experienced programmers by making powerful features basic to the language and makes coding simpler. Dealing with primitive objects is easier at times. In brief, the primitive objects help to increase the productivity of the programmers.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63523</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63523"/>
		<updated>2012-09-11T03:21:27Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Inability on handling large scale data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      ArrayListaList=newArrayList();&lt;br /&gt;
      aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
      aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
      aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
      aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63522</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63522"/>
		<updated>2012-09-11T03:21:09Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Not supporting utility methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       ArrayListaList=newArrayList();&lt;br /&gt;
       aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
       aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
       aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
      parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
      parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
      parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
      parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63521</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63521"/>
		<updated>2012-09-11T03:20:46Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       ArrayListaList=newArrayList();&lt;br /&gt;
       aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
       aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
       aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
       parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
       parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
       parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
       parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html Composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63520</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63520"/>
		<updated>2012-09-11T03:17:02Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Space performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment（C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       ArrayListaList=newArrayList();&lt;br /&gt;
       aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
       aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
       aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
       parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
       parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
       parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
       parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63519</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63519"/>
		<updated>2012-09-11T03:14:55Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Disdvantages of primitives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment （C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html Inability on handling large scale data&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       ArrayListaList=newArrayList();&lt;br /&gt;
       aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
       aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
       aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html Limitation on size&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html Not supporting utility methods&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
       parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
       parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
       parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
       parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63514</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w21 wi</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w21_wi&amp;diff=63514"/>
		<updated>2012-09-11T03:02:08Z</updated>

		<summary type="html">&lt;p&gt;Sren: /* Disdvantages of primitives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Primitive objects in object-oriented languages'''&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
In any programming language, the [http://en.wikipedia.org/wiki/Data_type data type] refers to the class of data which contains specific type or range of values. Data types are used along with variables used in the program. The data type tells us what kind of values the variable can store, what is the range of the values and how much space the values take in memory etc.&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Primitive_data_type primitive data types] refer to the built-in data types which are supported by the programming language. Often 'data types' and 'primitive data types' are used interchangeably. But not all data types are primitive. Programming languages have some non-primitive data types or derived data types which are provided by the language by making use of its primitive data types.&lt;br /&gt;
&lt;br /&gt;
The common built-in data types or primitive data types are integers, floating point numbers, characters, strings and boolean.&lt;br /&gt;
* Integers - Integers represent the whole numbers which can be positive or negative or zero, e.g. 9999, 0, -25, etc. &lt;br /&gt;
* Floating point numbers - Floating point numbers represent the numbers which are fractions or contain floating-decimal points, e.g. -3.002, 2.5, 22.0, etc.&lt;br /&gt;
* Characters - Characters represent any single letter, number, space, punctuation mark, or symbol that can be typed on a computer, e.g. 'a', '9', ' ', '!' , '\n', etc.&lt;br /&gt;
* Strings - Strings represent the sequences of characters or simply any text, e.g. &amp;quot;Hello!&amp;quot;, &amp;quot;9 am to 6 pm&amp;quot;, etc. &lt;br /&gt;
* Booleans - Booleans represent the true or false values. Sometimes, instead of true and false, 1 and 0 are used to represent the boolean values.&lt;br /&gt;
&lt;br /&gt;
Many [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented programming] languages provide support for primitive data types while some object-oriented programming languages provide support for primitive objects along with primitive types.&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
&lt;br /&gt;
Primitive objects refer to the objects of built-in classes which provide more functionality than the primitive types. Some object-oriented programming languages provide support for only primitive objects (i.e., in such languages all primitive types are objects).&lt;br /&gt;
&lt;br /&gt;
Different object-oriented programming languages implement these primitive data types and primitive objects in a different manner.&lt;br /&gt;
&lt;br /&gt;
== Primitive objects in different OO languages ==&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
In [http://en.wikipedia.org/wiki/Java_%28programming_language%29 Java], there are 8 primitive types: boolean, char, byte, short, int, long, float, and double. &amp;lt;ref&amp;gt;http://www.cafeaulait.org/course/week2/02.html Java's Primitive Data Types&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each of these primitive types, Java provides [http://en.wikipedia.org/wiki/Primitive_wrapper_class wrapper classes] to create primitive objects which wrap the primitive data values. A wrapper  not only contains the primitive data value, but it also defines properties and methods that can be used to manipulate that data. In Java, the primitive values are not implicitly converted to primitive objects. Instead, methods are provided for doing explicit conversion.&lt;br /&gt;
The primitive objects are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack heap] in memory while the variables containing primitive values are stored on [http://www.maxi-pedia.com/what+is+heap+and+stack stack].&amp;lt;ref&amp;gt;http://www.informit.com/articles/article.aspx?p=31755&amp;amp;seqNum=8 Stack and Heap memory&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class!! Size&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean || 1-bit&lt;br /&gt;
|-&lt;br /&gt;
| char || Character || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| byte || Byte || 8-bit&lt;br /&gt;
|-&lt;br /&gt;
| short || Short || 16-bit&lt;br /&gt;
|-&lt;br /&gt;
| int || Integer || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| long || Long || 64-bit&lt;br /&gt;
|-&lt;br /&gt;
| float || Float || 32-bit&lt;br /&gt;
|-&lt;br /&gt;
| double || Double || 64-bit&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 20;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I+II);            &lt;br /&gt;
    System.out.println(I.equals(II));    &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    30&lt;br /&gt;
    false&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To find out if these wrapper classes are primitive or not, we can use the isPrimitive() method.&lt;br /&gt;
&lt;br /&gt;
    System.out.println(INTEGER.TYPE.isPrimitive());&lt;br /&gt;
    System.out.println(BOOLEAN.TYPE.isPrimitive());&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    true&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Java, the comparison operations work in the same way on the primitive objects as well as any other class objects but different on the primitive types. The == operator when used on objects checks whether they refer to the same object but when used on variables of primitive types checks whether they contain the same value.&amp;lt;ref&amp;gt;http://leepoint.net/notes-java/data/expressions/22compareobjects.html Comparisons in Java&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example: &lt;br /&gt;
    int i = 10;&lt;br /&gt;
    int ii = 10;&lt;br /&gt;
    Integer I = new Integer(i);&lt;br /&gt;
    Integer II = new Integer(ii);&lt;br /&gt;
    System.out.println(I==II);            &lt;br /&gt;
    System.out.println(i==ii);&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    false&lt;br /&gt;
    true&lt;br /&gt;
&lt;br /&gt;
=== C# ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29 C#] is a [http://en.wikipedia.org/wiki/Strong_typing strongly typed] language, where it is necessary to declare the data type of a variable and also be aware of the data type conversion. C# provides a significant number of primitive data types.&amp;lt;ref&amp;gt;http://condor.depaul.edu/sjost/ndp/notes/cs1/CSDatatypes.htm C# Primitive Datatypes&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.java2s.com/Tutorial/CSharp/0040__Data-Type/PrimitivesinC.htm Primitives in C#&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because C# represents all primitive data types as objects, it is possible to call an object method on a primitive data type. For example:&lt;br /&gt;
 &lt;br /&gt;
    static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int x = 7;&lt;br /&gt;
        object o = x;&lt;br /&gt;
        System.Console.WriteLine(o.ToString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Some data types (e.g. Decimal and String) can appear like primitives at first sight, but are actually not. So it is important to exercise caution before making such assumptions. To test whether a particular type is a primitive or not you can use the property Type.IsPrimitive.&lt;br /&gt;
&lt;br /&gt;
Consider the following example:&lt;br /&gt;
&lt;br /&gt;
    if (t.IsPrimitive)    // where t is the type&lt;br /&gt;
    {&lt;br /&gt;
        // Is Primitive&lt;br /&gt;
    } else if (t == typeof(Decimal))&lt;br /&gt;
    {&lt;br /&gt;
        // Is Decimal&lt;br /&gt;
    } else if (t == typeof(String))&lt;br /&gt;
    {&lt;br /&gt;
        // Is String&lt;br /&gt;
    } else&lt;br /&gt;
    {&lt;br /&gt;
        // Other type&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&lt;br /&gt;
There are 5 primitive data types in [http://en.wikipedia.org/wiki/JavaScript JavaScript]: string, number, boolean, null and undefined. &amp;lt;ref&amp;gt;http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For string, number and boolean values, there are corresponding classes just like in Java to create primitive objects which wrap the primitive values. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
! Primitive Type !! Wrapper Class&lt;br /&gt;
|-&lt;br /&gt;
| string || String&lt;br /&gt;
|-&lt;br /&gt;
| number|| Number&lt;br /&gt;
|-&lt;br /&gt;
| boolean || Boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In JavaScript, the primitive value is implicitly converted to a primitive object whenever someone tries to access a property or invoke a method on the primitive value and the primitive object is used in place of the primitive value. Since the object contains properties and methods, the use of primitive value as an object succeeds. After the property is accessed or the method is processed, the primitive object is no longer needed and hence discarded. The same is true for the other primitive types and their corresponding primitive objects.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    var upperCaseString = &amp;quot;APPLE&amp;quot;;&lt;br /&gt;
    var lowerCaseString = upperCaseString.toLowerCase();  // assigns string &amp;quot;apple&amp;quot; to lowerCaseString &lt;br /&gt;
    var s = &amp;quot;Hello&amp;quot;&lt;br /&gt;
    var len = s.length;                                   // assigns value 5 to len&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
Since [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a [http://www.jvoegele.com/software/langcomp.html pure object oriented] language, everything in Ruby is an object. Hence, all primitive types such as integers, floating point numbers, strings, are objects of a built-in class.&amp;lt;ref&amp;gt;http://ruby-doc.org/docs/ProgrammingRuby/html/builtins.html Classes in Ruby&amp;lt;/ref&amp;gt; &lt;br /&gt;
All integers are primitive objects of either class [http://corelib.rubyonrails.org/classes/Fixnum.html Fixnum] or [http://corelib.rubyonrails.org/classes/Bignum.html Bignum]. A numeric literal with a decimal point and/or an exponent is a primitive object of [http://corelib.rubyonrails.org/classes/Float.html Float]. Single quoted literals and double quoted literals are primitive objects of [http://corelib.rubyonrails.org/classes/String.html String].&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    puts 10.class&lt;br /&gt;
    puts 7.45.class&lt;br /&gt;
    puts 'hi'.class&lt;br /&gt;
    puts &amp;quot;hello&amp;quot;.class&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Fixnum&lt;br /&gt;
    Float&lt;br /&gt;
    String&lt;br /&gt;
    String&lt;br /&gt;
&lt;br /&gt;
This indicates that 10 is converted into an object of type Fixnum, 7.45 is converted into an object of type Float, 'hi' and &amp;quot;hello&amp;quot; are both converted into an object of type String.&lt;br /&gt;
&lt;br /&gt;
Since all primitive types in Ruby are objects, we should be able to call methods of the Object class on them. Let us demonstrate the same for integer and float using the following example:&lt;br /&gt;
&lt;br /&gt;
    a=10&lt;br /&gt;
    puts a.to_f  &lt;br /&gt;
    b=20.5&lt;br /&gt;
    puts b.to_i&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
    10.0&lt;br /&gt;
    20&lt;br /&gt;
&lt;br /&gt;
== Advantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
Advantages that use of primitive data type offers are as follows:&lt;br /&gt;
===Consistency===&lt;br /&gt;
Many ideas of Java originate in C and in C++, objects and primitive type also co-exist. When object-oriented constructs were grafted onto the C language, C’s data types remained as is. The motivation behind this is that Bjarne Stroustrup, C++’s designer, wanted to be as consistent as possible with the base C language, hoping to capitalize on programmers’ pre-C++ knowledge.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://www.research.ibm.com/people/a/alpert/ptch/ptch.html Primitive Types Considered Harmful&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Simplicity===&lt;br /&gt;
It is simple and intuitive to use primitive data type in basic utility.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
1. Recurring number in a loop.(C++)&lt;br /&gt;
&lt;br /&gt;
   for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Temp variables that record only one or two data.&lt;br /&gt;
&lt;br /&gt;
===Time performance===&lt;br /&gt;
Processing primitive data type operation would be faster than processing composite data type in most cases. There are several reasons result in this differences. &lt;br /&gt;
*Hardware processing discrepancy&lt;br /&gt;
Many primitive data operations (like integer addition) can be performed as a single machine instruction while processing of composite data type would be transformed to a combination of primitive data types. eg. Some processors offer specific instructions to process sequences of characters with a single instruction.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
[http://www.research.ibm.com/people/a/alpert/ptch/ptch.html  Difference in data fetching between primitive data and composite data in Java]&lt;br /&gt;
 &lt;br /&gt;
*Allocating and Garbage collection overhead for composite data type&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Performance_implications Garbage collection&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html Java theory and practice: Garbage collection and performance&amp;lt;/ref&amp;gt;&lt;br /&gt;
There are many initialization operations for composite data type that will generate high overheads for example boxing and unboxing, constructors and destructors.Composite data type like class will also have garbage collection overheads that may be beyond the control of the programmer and can sometimes lead to performance problems. For example, commonly used stop-the-world garbage collectors, which pause program execution at arbitrary times, may make garbage collection inappropriate for some [http://en.wikipedia.org/wiki/Embedded_system embedded systems], high-performance [http://en.wikipedia.org/wiki/Server_(computing)  server] software, and applications with [http://en.wikipedia.org/wiki/Real-time_computing real-time] needs.In the early days of Java technology, allocating objects got a high overheads. There were lots of articles advising developers to avoid creating temporary objects unnecessarily because allocation (and the corresponding garbage-collection overhead) was expensive. Although the costs have been greatly reduced nowadays. It still much slower than primitive data type which don’t have such troubles.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
        public void test1(){&lt;br /&gt;
           int a=1,b=1;&lt;br /&gt;
           long startTime1 = System.currentTimeMillis();&lt;br /&gt;
           for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
              a=a+b;&lt;br /&gt;
                          }&lt;br /&gt;
           long endTime1 = System.currentTimeMillis();&lt;br /&gt;
           System.out.println(endTime1-startTime1);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        public void test2(){&lt;br /&gt;
            Integer c=new Integer(1);&lt;br /&gt;
            Integer d=new Integer(1);&lt;br /&gt;
            long startTime2 = System.currentTimeMillis();&lt;br /&gt;
            for(int i=0;i&amp;lt;N;i++){&lt;br /&gt;
               c=c+d;&lt;br /&gt;
            }&lt;br /&gt;
            long endTime2 = System.currentTimeMillis();&lt;br /&gt;
            System.out.println(endTime2-startTime2)&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
Average execution time for test1 is: 1 mm&lt;br /&gt;
&lt;br /&gt;
Average execution time for test2 is: 702mm&lt;br /&gt;
&lt;br /&gt;
(test case number: 1000 times )&lt;br /&gt;
&lt;br /&gt;
===Space performance===&lt;br /&gt;
Composite data type will cost more memory space than primitive data type in general. The reason is not only for the overheads generated by constructors, destructors etc, but also the feature of data alignment. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Data_structure_alignment#Data_structure_padding Data structure alignment&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of data alignment （C++）&lt;br /&gt;
       struct compose&lt;br /&gt;
       {&lt;br /&gt;
           char name;&lt;br /&gt;
           int a;&lt;br /&gt;
           int b;&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
We all know the size of char is 1 byte, the size of int is 4 bytes. But the size of the struct compose as shown above is 12 bytes but not 9 bytes.&lt;br /&gt;
&lt;br /&gt;
== Disdvantages of primitives ==&lt;br /&gt;
&lt;br /&gt;
The various disadvantages of using the primitive data types are as follows:&lt;br /&gt;
&lt;br /&gt;
===Cannot be extended===&lt;br /&gt;
We can use a class or array to model the intricate data or functional structure. With the feature of class, programmers can create subtypes, modify their operations and even redefine them. In addition with the feature of class, programmers can make their variables unchangeable to any code outside the class, or make the implementation hidden to other code with call the methods. That means with composite data types, it will be more convenient for the programmers to handle sophisticated data and also make the code easier to maintain.&lt;br /&gt;
&lt;br /&gt;
In the following example, we create a Person type in RUBY. We defined a “talk” method to make a Person can talk about himself. We also hope to only make the variable “motherland” changeable by the code outside this class. &lt;br /&gt;
&lt;br /&gt;
Example: (in RUBY)&lt;br /&gt;
&lt;br /&gt;
       class Person&lt;br /&gt;
  &lt;br /&gt;
           def initialize( name, age=18 )&lt;br /&gt;
               @name = name&lt;br /&gt;
               @age = age&lt;br /&gt;
               @motherland = &amp;quot;US&amp;quot;&lt;br /&gt;
           end&lt;br /&gt;
  &lt;br /&gt;
           def talk&lt;br /&gt;
               puts &amp;quot;my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
               if  @motherland == &amp;quot;US&amp;quot;&lt;br /&gt;
                  puts &amp;quot;I\'m American.&amp;quot;&lt;br /&gt;
               else&lt;br /&gt;
                  puts &amp;quot;I\'m International.&amp;quot;&lt;br /&gt;
               end&lt;br /&gt;
           end&lt;br /&gt;
           attr_writer :motherland   &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
Later when we need to create a “Student” type, we can just inherent the “Person” type and make some adjustment based on our needs. Here we redefine the “talk” method to make a student talk in a different way.&lt;br /&gt;
&lt;br /&gt;
       class Student &amp;lt; Person&lt;br /&gt;
 &lt;br /&gt;
            def talk&lt;br /&gt;
                puts &amp;quot;I am a student. my name is &amp;quot;+@name+&amp;quot;, age is &amp;quot;+@age.to_s&lt;br /&gt;
            end  &lt;br /&gt;
       end&lt;br /&gt;
&lt;br /&gt;
===Inability on handling large scale data===&lt;br /&gt;
Though it means more processing time, it is necessary for programmers to create composite type to handle the data whose length is too large or changing all the time. If we have a set or integers to maintain in memory, but the number of integers will change every second, it will be impossible if we only use primitive types to handle. But we can make use of the “Arraylist” type in Java or other composite types. With the “Arraylist”, the programmers do not need to pay attention to the storage in the memory or the space it takes. The compiler of Java will reallocate more space automatically for the Arraylist if more elements are putted. &amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.5.0/docs/api/java/util/ArrayList.html uncertainty of array&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of the insert and sorting methods of the Arraylist type in Java:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       ArrayListaList=newArrayList();&lt;br /&gt;
       aList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;b&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;c&amp;quot;);&lt;br /&gt;
       aList.Add(&amp;quot;d&amp;quot;); &lt;br /&gt;
       aList.Add(&amp;quot;e&amp;quot;);&lt;br /&gt;
       aList.Sort();&lt;br /&gt;
&lt;br /&gt;
===Limitation on size===&lt;br /&gt;
&lt;br /&gt;
For the primitive data types in most programming languages, there are some limits of the size. For example we can put an integer between -(2^16) and (2^16)-1 into an “int” in Java. That will be enough for some most of the cases but definitely not all of them. For example, the primitive types are not enough for a scientific calculation if we need an accuracy on 10^-500. And a more extreme case is to calculate the last 100 numbers for the PI has a 100 million length.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For these situations, the programmers usually need to create a composite data type by themselves. They can even redefine the operators (“+”, “-”) to make the super-long float also can make addition, subtraction with ordinary operators instead of method calling. For more details to create a super long float please see reference.&amp;lt;ref&amp;gt;http://en.verysource.com/code/1285797_1/tlargefloat.h.html limitation of primitive&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Not supporting utility methods===&lt;br /&gt;
Most of the object oriented languages have certain utility methods associated with non primitive data types that ease their use as compared to primitive data types that do not have such methods.&amp;lt;ref&amp;gt;http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html utility function associated with non primitive data types&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An especially useful example is the method of parsing integers in a specified radix in Java (Integer.parseInt). &lt;br /&gt;
&lt;br /&gt;
       parseInt(&amp;quot;1100110&amp;quot;, 2); //returns 102&lt;br /&gt;
       parseInt(&amp;quot;-0&amp;quot;, 10); //returns 0&lt;br /&gt;
       parseInt(&amp;quot;-FF&amp;quot;, 16); //returns -255&lt;br /&gt;
       parseInt(&amp;quot;99&amp;quot;, 8); //throws a NumberFormatException&lt;br /&gt;
&lt;br /&gt;
From the above examples, it is obvious that “Integer” type not just support ordinary methods an integer should have (such as Integer.equals), but also some more utility methods which are helpful for the programmers.&lt;br /&gt;
&lt;br /&gt;
In addition, for some data structure which only take object but not primitive type (such as Vector in Java), it is necessary to box a primitive data type to a corresponding object. For example if a programmer needs to make use of a vector to store some integer, it is necessary to box the ints and floats first:&lt;br /&gt;
&lt;br /&gt;
      Vector　v=new Vector();  &lt;br /&gt;
      int k=121; &lt;br /&gt;
      v.addElemt(new Integer(k));&lt;br /&gt;
&lt;br /&gt;
===Functionality===&lt;br /&gt;
Discussion of advantages and disadvantages should concerned the functionality you want to implement. For example if you want to operate a serials of int number. The performance of array may be better than int. &amp;lt;ref&amp;gt;http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH05/CH05-2.html composite datatypes&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:1w1.gif]]&lt;br /&gt;
&lt;br /&gt;
To access an element of an array, you need a function that converts an array index into the address of the indexed element. For a single dimension array, this function is very simple. It is&lt;br /&gt;
Element_Address = Base_Address + ((Index - Initial_Index) * Element_Size)&lt;br /&gt;
&lt;br /&gt;
However, If you use five primitive data type to implement the same function. It may cost more time for the cpu to search the address of each data.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sren</name></author>
	</entry>
</feed>