<?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=Pramasw3</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=Pramasw3"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Pramasw3"/>
	<updated>2026-05-22T17:37:26Z</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_2011/ch1_1e_ap&amp;diff=54750</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54750"/>
		<updated>2011-11-03T22:02:21Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
&lt;br /&gt;
CashDispenser &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Deposit&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to deposit transaction use case || 		CustomerConsole &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
EnvelopeAcceptor &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
|}&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54749</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54749"/>
		<updated>2011-11-03T22:01:38Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
&lt;br /&gt;
CashDispenser &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to deposit transaction use case || 		CustomerConsole &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
EnvelopeAcceptor &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
|}&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54748</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54748"/>
		<updated>2011-11-03T22:00:17Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
&lt;br /&gt;
CashDispenser &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54747</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54747"/>
		<updated>2011-11-03T21:55:04Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
&lt;br /&gt;
CashDispenser &lt;br /&gt;
&lt;br /&gt;
Message &lt;br /&gt;
&lt;br /&gt;
Receipt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54746</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54746"/>
		<updated>2011-11-03T21:53:47Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
CashDispenser &lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
Message &lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54745</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54745"/>
		<updated>2011-11-03T21:53:07Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case  || CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54744</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54744"/>
		<updated>2011-11-03T21:52:23Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case&lt;br /&gt;
|-&lt;br /&gt;
| CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Block-Structured Languages&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Object Oriented Languages&lt;br /&gt;
|-&lt;br /&gt;
| Block Structure involves section of code grouped together with one or more declaration and statements || Object Oriented Programming involves programming around objects which is an instance of a class representing data fields and methods for interaction. &lt;br /&gt;
|-&lt;br /&gt;
| Block Structure provides no means of access to variables and limits the scope within the block. || Object Oriented Programming allows to define different access specifiers(public,private,protected) when defining any field or method.&lt;br /&gt;
|-&lt;br /&gt;
| Maintainibility is difficult as the programs size increases || Easy to maintain as objects can be maintained separately thus making easy to locate and manage. &lt;br /&gt;
|-&lt;br /&gt;
| Program flow has a single point of entry and exit  || Program flow depends on the state and interaction within objects.&lt;br /&gt;
|-&lt;br /&gt;
| Has limited modifiability where a procedure is defined for performing certain function which cannot be modified to a greater extent  || Easy to make changes in the data representation and methods as changes within a class do not affect others.&lt;br /&gt;
|-&lt;br /&gt;
| No re-usability  || Objects can be re-used in another programs.&lt;br /&gt;
|-&lt;br /&gt;
| Not preferable when working with large programs|| Can handle large programs due to its design, organization and flow of the program.&lt;br /&gt;
|-&lt;br /&gt;
| Limited Modularity || The objects form a separate entity whose internal workings are decoupled from other parts of the system. &lt;br /&gt;
|-&lt;br /&gt;
| Limited extensibility as very difficult to extend the modules and its function which requires re-structuring || Introduction of few new objects can help in adding or changing new features. &lt;br /&gt;
|-&lt;br /&gt;
| Example :- Algol 60,Pascal, C || Example:- Simula,C++,JAVA,Ruby&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54743</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54743"/>
		<updated>2011-11-03T21:51:44Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case&lt;br /&gt;
|-&lt;br /&gt;
| CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54742</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54742"/>
		<updated>2011-11-03T21:51:03Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Perform operations peculiar to withdrawal transaction use case&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54741</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54741"/>
		<updated>2011-11-03T21:48:59Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Responsibilities&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; | Collaborators&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54737</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54737"/>
		<updated>2011-11-03T06:32:19Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in developing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54736</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54736"/>
		<updated>2011-11-03T06:29:52Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in designing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;br /&gt;
&lt;br /&gt;
* ATM example - http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54735</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54735"/>
		<updated>2011-11-03T06:20:44Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in designing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54734</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54734"/>
		<updated>2011-11-03T06:20:10Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in designing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : &lt;br /&gt;
A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : &lt;br /&gt;
&lt;br /&gt;
A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54733</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54733"/>
		<updated>2011-11-03T06:19:04Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
This design model will help in designing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Design ===&lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border = 1&amp;gt;&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54732</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54732"/>
		<updated>2011-11-03T06:15:51Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Concepts ===&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Abstraction_(computer_science) '''Abstraction''']:  To implement real world entity into program, class uses the concept of abstraction.  Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) '''Encapsulation''']: Binding the data and code to access that data. Encapsulation only refers to a container which has a data and its related functions in it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) '''Inheritance''']: Defining new classes from the existing one. The new class will get all the methods and properties of the existing class.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Polymorphism_(object-oriented_programming) '''Polymorphism''']: Ability to acquire different forms. There are basically two types of polymorphism. Compile Time (also knows as Early binding) and Run Time (also knows as Late binding) Polymorphism.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Information_hiding '''Information Hiding''']: As encapsulation bind data and methods together, data hiding restrict sensitive data accessing to the system. It is also achieved by using access modifiers i.e. Private, Protected and Public.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Principles ===&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple '''The LiskovSubstitutionPrinciple (LSP)''']: &amp;quot;An instance of a derived should be able to replace any instance of its superclass&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?OpenClosedPrinciple '''The OpenClosedPrinciple (OCP)''']: &amp;quot;A reusable class should be open for extension, but closed for modification.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?DependencyInversionPrinciple '''The DependencyInversionPrinciple (DIP)''']: &amp;quot;The modules that implement a high level policy should not depend on the modules that implement the low level policies, but rather, they should depend on some well-defined interfaces.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?InterfaceSegregationPrinciple '''The InterfaceSegregationPrinciple (ISP)''']: &amp;quot;The dependency of one class to another one should depend on the smallest possible interface.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?ReuseReleaseEquivalencePrinciple '''The ReuseReleaseEquivalencePrinciple (REP)''']: &amp;quot;The granule of reuse is the granule of release.&amp;quot; module == type, the fusion of distinct notions is what gives OO its distinctive flavor.&lt;br /&gt;
&lt;br /&gt;
*[http://c2.com/cgi/wiki?CommonClosurePrinciple '''The CommonClosurePrinciple (CCP):''']: &amp;quot;The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Object Oriented Design Patterns ===&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Singleton_pattern '''Singleton'''] - Ensure that only one instance of a class is created and Provide a global access point to the object.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Factory''']  - Creates objects without exposing the instantiation logic to the client and Refers to the newly created object through a common interface.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Command_pattern'''Command'''] - Encapsulate a request in an object, Allows the parameterization of clients with different requests and Allows saving the requests in a queue.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Iterator_pattern '''Iterator'''] - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Strategy'''] - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Factory_pattern '''Adapter'''] - Convert the interface of a class into another interface clients expect. / Adapter lets classes work together, that could not otherwise because of incompatible interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
This section discusses about the ATM example using OOD, developed by Dr.Bjork. The overview of this example is explained below. &lt;br /&gt;
Complete example can be found here http://math-cs.gordon.edu/courses/cs211/ATMExample/&lt;br /&gt;
&lt;br /&gt;
The process of object oriented design starts with the requirements followed by analysis, design and the implementation. Let us dicuss about each of these steps in detail.&lt;br /&gt;
&lt;br /&gt;
Requirements:&lt;br /&gt;
&lt;br /&gt;
This design model will help in designing a software that will control a simulated automatic teller machine (ATM). &lt;br /&gt;
For a complete list of requirements check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Requirements.html&lt;br /&gt;
&lt;br /&gt;
Though there will be more detailed requirements with secuirty constraints, this page provides the basic requirements an ATM should satisfy.&lt;br /&gt;
&lt;br /&gt;
1.) A customer must be able to make a cash withdrawal from any suitable account linked to the card, in multiples of $20.00. Approval must be obtained from the bank before cash is dispensed.&lt;br /&gt;
2.) A customer must be able to make a deposit to any account linked to the card, consisting of cash and/or checks in an envelope. The customer will enter the amount of the deposit into the ATM, subject to manual verification when the envelope is removed from the machine by an operator. Approval must be obtained from the bank before physically accepting the envelope.&lt;br /&gt;
3.) A customer must be able to make a transfer of money between any two accounts linked to the card.&lt;br /&gt;
4.) A customer must be able to make a balance inquiry of any account linked to the card.&lt;br /&gt;
&lt;br /&gt;
Analysis:&lt;br /&gt;
&lt;br /&gt;
The analysis phase involves in finding the use cases, initial test cases and the basic parts (classes) involved in the system.&lt;br /&gt;
&lt;br /&gt;
1.) Use cases:&lt;br /&gt;
&lt;br /&gt;
With the above requirements, we will discuss two important use cases.&lt;br /&gt;
&lt;br /&gt;
Withdrawal Transaction Use Case : A withdrawal transaction asks the customer to choose a type of account to withdraw from (e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a menu of possible amounts. The system verifies that it has sufficient money on hand to satisfy the request before sending the transaction to the bank. (If not, the customer is informed and asked to enter a different amount.) If the transaction is approved by the bank, the appropriate amount of cash is dispensed by the machine before it issues a receipt. &lt;br /&gt;
&lt;br /&gt;
Deposit Transaction Use Case : A deposit transaction asks the customer to choose a type of account to deposit to (e.g. checking) from a menu of possible accounts, and to type in a dollar amount on the keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a deposit from this customer to this account. If the transaction is approved, the machine accepts an envelope from the customer containing cash and/or checks before it issues a receipt. Once the envelope has been received, a second message is sent to the bank, to confirm that the bank can credit the customer's account - contingent on manual verification of the deposit envelope contents by an operator later. &lt;br /&gt;
&lt;br /&gt;
Use cases are represented using Interaction diagrams. This section is not going to explain the interaction diagrams. &lt;br /&gt;
For the interaction diagrams, check here http://math-cs.gordon.edu/courses/cs211/ATMExample/Interactions.html#Startup&lt;br /&gt;
&lt;br /&gt;
2.) Classes&lt;br /&gt;
&lt;br /&gt;
The basic classes of the system can be found using the following conditions&lt;br /&gt;
&lt;br /&gt;
is a singular noun,&lt;br /&gt;
does not really have the same functionality as some other class,&lt;br /&gt;
is not simply a primitive type.&lt;br /&gt;
&lt;br /&gt;
The classes required for the ATM model will be,&lt;br /&gt;
&lt;br /&gt;
Card reader.&lt;br /&gt;
Customer console, consisting of a display and keyboard.&lt;br /&gt;
Cash dispenser.&lt;br /&gt;
Envelope acceptor.&lt;br /&gt;
Receipt printer.&lt;br /&gt;
Session.&lt;br /&gt;
Transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Design : &lt;br /&gt;
&lt;br /&gt;
The design part includes the process of finding the resposiblities and the interaction of the classes. &lt;br /&gt;
&lt;br /&gt;
The designs can be represented using various methods like&lt;br /&gt;
&lt;br /&gt;
CRC Cards&lt;br /&gt;
Class Diagram&lt;br /&gt;
State Charts&lt;br /&gt;
Interaction Diagrams&lt;br /&gt;
&lt;br /&gt;
In this example we will examine CRC cards closely.&lt;br /&gt;
&lt;br /&gt;
A CRC card has a class name, responsiblities of the class and collobarotars (other classes required to complete the responsiblity).&lt;br /&gt;
&lt;br /&gt;
So for the &amp;quot;Withdrawl&amp;quot; class, a CRC card will be designed as follows,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Responsibilities	Collaborators&lt;br /&gt;
Perform operations peculiar to withdrawal transaction use case	CustomerConsole &lt;br /&gt;
CashDispenser &lt;br /&gt;
Message &lt;br /&gt;
Receipt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this the design is complete. So the rest of the software design includes implemenation and testing which will be convered under ibject oriented programming.&lt;br /&gt;
http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
*'''Simplicity:''' software objects model real world objects, so the complexity is reduced and the program structure is very clear.&lt;br /&gt;
&lt;br /&gt;
*'''Modularity:''' each object forms a separate entity whose internal workings are decoupled from other parts of the system.&lt;br /&gt;
&lt;br /&gt;
*'''Maintainable:''' objects can be maintained separately, making locating and fixing problems easier.&lt;br /&gt;
&lt;br /&gt;
*'''Re-usability:''' objects contain both data and functions that act on data, objects can be thought of as self-contained “boxes”.This feature    &lt;br /&gt;
makes it easy to reuse code in new systems.&lt;br /&gt;
&lt;br /&gt;
*'''Scalability:''' object’s interface provides a roadmap for reusing the object in new software and thus provides you with all the information&lt;br /&gt;
you need to replace the object without affecting other code.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Principles of Object Oriented Design - http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Programming - http://en.wikipedia.org/wiki/Object-oriented_programming&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Design - http://en.wikipedia.org/wiki/Object-oriented_design&lt;br /&gt;
&lt;br /&gt;
* Object Oriented Concepts - http://download.oracle.com/javase/tutorial/java/concepts&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54638</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54638"/>
		<updated>2011-11-02T15:55:53Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Abstraction ===&lt;br /&gt;
=== Encapsulation ===&lt;br /&gt;
=== Inheritance ===&lt;br /&gt;
=== Polymorphism ===&lt;br /&gt;
&lt;br /&gt;
== Design principles and patterns ==&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54637</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54637"/>
		<updated>2011-11-02T15:51:45Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Abstraction ===&lt;br /&gt;
=== Encapsulation ===&lt;br /&gt;
=== Inheritance ===&lt;br /&gt;
=== Polymorphism ===&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54636</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1e ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1e_ap&amp;diff=54636"/>
		<updated>2011-11-02T15:51:19Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction to Object Oriented Design&lt;br /&gt;
__TOC__&lt;br /&gt;
== Introduction to Object Oriented Programming ==&lt;br /&gt;
Object-oriented programming (OOP) is a programming language model organized around &amp;quot;objects&amp;quot; rather than &amp;quot;actions&amp;quot; and data rather than logic. It uses &amp;quot;objects&amp;quot; - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. &lt;br /&gt;
&lt;br /&gt;
Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).&lt;br /&gt;
&lt;br /&gt;
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects. &lt;br /&gt;
&lt;br /&gt;
*'''Classes'''&lt;br /&gt;
The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.&lt;br /&gt;
&lt;br /&gt;
*'''Objects'''&lt;br /&gt;
An &amp;quot;Object&amp;quot; is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem.&lt;br /&gt;
What makes an &amp;quot;object&amp;quot; unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Design ==&lt;br /&gt;
&lt;br /&gt;
Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first question in OOD ,especially for newcomers, is &amp;quot;How can I decide what classes my program should have in it?&amp;quot; The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask &amp;quot;What kinds of entities does my application manipulate?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some examples of potential classes in different application areas would include: &lt;br /&gt;
&lt;br /&gt;
a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point&lt;br /&gt;
&lt;br /&gt;
b) Architecture - Building, Plot, Room &lt;br /&gt;
&lt;br /&gt;
b) Geography - River, Country, Sea, Continent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.&lt;br /&gt;
&lt;br /&gt;
== Object Oriented Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Abstraction ===&lt;br /&gt;
=== Encapsulation ===&lt;br /&gt;
=== Inheritence ===&lt;br /&gt;
=== Polymorphsim ===&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
== Advantages of OOD ==&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=51075</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=51075"/>
		<updated>2011-09-26T01:21:46Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. An object-oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent &amp;quot;machine&amp;quot; with a distinct role or responsibility. The actions (or &amp;quot;methods&amp;quot;) on these objects are closely associated with the object. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Objects form the basis of OOP. Every Object wraps the data within a set of functions which helps to handle different appropriately. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Getters and Setters and their Advantages ==&lt;br /&gt;
&amp;lt;p&amp;gt;One of the principles of Objected Oriented Design is that an object's implementation should not be exposed to other classes. This is to avoid difficulty in maintenance. Getters and setters provide a way to read or write private data of a class for any kind of manipulation. They also provide for easy maintenance, in that, if any change needs to be made in the way the variable is set, only the setter method needs to be changed rather than looking for it and changing in every place. These methods also improve the code readability and bring about uniformity across the code.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|ObjectName.MethodName(parameters) [Eg: x.method()]&lt;br /&gt;
|ObjectName.Attribute [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|ObjectName-&amp;gt;Attribute&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Having getters and setters in the implementation has its own advantages and disadvantages. The advantages are that&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They provide data encapsulation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They improve the code readability.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Changes can be made only to the implementation without making changes to the code that uses the object.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
Using getters and setters also has a disadvantage. They largely provide access to implementation details. But this could hinder &amp;lt;i&amp;gt;data abstraction&amp;lt;/i&amp;gt;, i.e. hiding the object's implementation of a message handler. Consider a getter function that returns a number. Wherever this method is called, the variable which holds the return value must match the return type of this function. Now if we change they way this method is implemented by changing the return type, then there could be trouble.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Therefore it is important to design such that there is minimal data movement thereby minimizing possible errors.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html?page=1/ Why getters and setters are evil?]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html/ Ruby Classes- Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet/ VB.Net Object oriented programming]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript/ Javascript - Functions/Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/ PHP - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm/ Perl - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=51074</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=51074"/>
		<updated>2011-09-26T01:20:57Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. An object-oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent &amp;quot;machine&amp;quot; with a distinct role or responsibility. The actions (or &amp;quot;methods&amp;quot;) on these objects are closely associated with the object. &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Objects form the basis of OOP. Every Object wraps the data within a set of functions which helps to handle different appropriately. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Getters and Setters and their Advantages ==&lt;br /&gt;
&amp;lt;p&amp;gt;One of the principles of Objected Oriented Design is that an object's implementation should not be exposed to other classes. This is to avoid difficulty in maintenance. Getters and setters provide a way to read or write private data of a class for any kind of manipulation. They also provide for easy maintenance, in that, if any change needs to be made in the way the variable is set, only the setter method needs to be changed rather than looking for it and changing in every place. These methods also improve the code readability and bring about uniformity across the code.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|ObjectName.MethodName(parameters) [Eg: x.method()]&lt;br /&gt;
|ObjectName.Attribute [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|ObjectName-&amp;gt;Attribute&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Having getters and setters in the implementation has its own advantages and disadvantages. The advantages are that&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They provide data encapsulation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They improve the code readability.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Changes can be made only to the implementation without making changes to the code that uses the object.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
Using getters and setters also has a disadvantage. They largely provide access to implementation details. But this could hinder &amp;lt;i&amp;gt;data abstraction&amp;lt;/i&amp;gt;, i.e. hiding the object's implementation of a message handler. Consider a getter function that returns a number. Wherever this method is called, the variable which holds the return value must match the return type of this function. Now if we change they way this method is implemented by changing the return type, then there could be trouble.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Therefore it is important to design such that there is minimal data movement thereby minimizing possible errors.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html?page=1/ Why getters and setters are evil?]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html/ Ruby Classes- Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet/ VB.Net Object oriented programming]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript/ Javascript - Functions/Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/ PHP - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm/ Perl - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=50886</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=50886"/>
		<updated>2011-09-25T22:58:19Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Getters and Setters and their Advantages ==&lt;br /&gt;
&amp;lt;p&amp;gt;One of the principles of Objected Oriented Design is that an object's implementation should not be exposed to other classes. This is to avoid difficulty in maintenance. Getters and setters provide a way to read or write private data of a class for any kind of manipulation. They also provide for easy maintenance, in that, if any change needs to be made in the way the variable is set, only the setter method needs to be changed rather than looking for it and changing in every place. These methods also improve the code readability and bring about uniformity across the code.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|ObjectName.MethodName(parameters) [Eg: x.method()]&lt;br /&gt;
|ObjectName.Attribute [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|ObjectName-&amp;gt;Attribute&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Having getters and setters in the implementation has its own advantages and disadvantages. The advantages are that&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They provide data encapsulation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They improve the code readability.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Changes can be made only to the implementation without making changes to the code that uses the object.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
Using getters and setters also has a disadvantage. They largely provide access to implementation details. But this could hinder &amp;lt;i&amp;gt;data abstraction&amp;lt;/i&amp;gt;, i.e. hiding the object's implementation of a message handler. Consider a getter function that returns a number. Wherever this method is called, the variable which holds the return value must match the return type of this function. Now if we change they way this method is implemented by changing the return type, then there could be trouble.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Therefore it is important to design such that there is minimal data movement thereby minimizing possible errors.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html?page=1/ Why getters and setters are evil?]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html/ Ruby Classes- Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet/ VB.Net Object oriented programming]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript/ Javascript - Functions/Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/ PHP - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm/ Perl - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=50884</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=50884"/>
		<updated>2011-09-25T22:57:59Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Getters and Setters and their Advantages ==&lt;br /&gt;
&amp;lt;p&amp;gt;One of the principles of Objected Oriented Design is that an object's implementation should not be exposed to other classes. This is to avoid difficulty in maintenance. Getters and setters provide a way to read or write private data of a class for any kind of manipulation. They also provide for easy maintenance, in that, if any change needs to be made in the way the variable is set, only the setter method needs to be changed rather than looking for it and changing in every place. These methods also improve the code readability and bring about uniformity across the code.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|ObjectName.MethodName(parameters) &lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|ObjectName.MethodName(parameters) [Eg: x.method()]&lt;br /&gt;
|ObjectName.Attribute [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|ObjectName-&amp;gt;Attribute&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|ObjectName.MethodName(parameters)&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Having getters and setters in the implementation has its own advantages and disadvantages. The advantages are that&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They provide data encapsulation.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They improve the code readability.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Changes can be made only to the implementation without making changes to the code that uses the object.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
Using getters and setters also has a disadvantage. They largely provide access to implementation details. But this could hinder &amp;lt;i&amp;gt;data abstraction&amp;lt;/i&amp;gt;, i.e. hiding the object's implementation of a message handler. Consider a getter function that returns a number. Wherever this method is called, the variable which holds the return value must match the return type of this function. Now if we change they way this method is implemented by changing the return type, then there could be trouble.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Therefore it is important to design such that there is minimal data movement thereby minimizing possible errors.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html?page=1/ Why getters and setters are evil?]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html/ Ruby Classes- Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet/ VB.Net Object oriented programming]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript/ Javascript - Functions/Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/ PHP - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm/ Perl - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47448</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47448"/>
		<updated>2011-09-08T05:22:41Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html/ Ruby Classes- Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet/ VB.Net Object oriented programming]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript/ Javascript - Functions/Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/ PHP - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm/ Perl - Objects]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://lua-users.org/wiki/SimpleLuaClasses/ Lua - Object oriented scripting]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47446</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47446"/>
		<updated>2011-09-08T05:21:00Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.vbtutor.in/getting-started-with-visual-basic-net/object-oriented-programming-in-vbnet]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.massassi.com/php/articles/classes/]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.tutorialspoint.com/perl/perl_oo_perl.htm]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://lua-users.org/wiki/SimpleLuaClasses]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47443</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47443"/>
		<updated>2011-09-08T05:18:28Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47442</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47442"/>
		<updated>2011-09-08T05:18:11Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47441</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47441"/>
		<updated>2011-09-08T05:17:56Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47440</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47440"/>
		<updated>2011-09-08T05:17:28Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47439</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47439"/>
		<updated>2011-09-08T05:16:59Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47438</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47438"/>
		<updated>2011-09-08T05:15:07Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47437</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47437"/>
		<updated>2011-09-08T05:05:42Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|&lt;br /&gt;
ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
  local index = getters and&lt;br /&gt;
    function(self, key)&lt;br /&gt;
      -- read from getter, else from fallback&lt;br /&gt;
      local func = getters[key]&lt;br /&gt;
      if func then return func(self) else return fallback[key] end&lt;br /&gt;
    end&lt;br /&gt;
    or fallback  -- default to fast property reads through table&lt;br /&gt;
  local newindex = setters and&lt;br /&gt;
    function(self, key, value)&lt;br /&gt;
      -- write to setter, else to proxy&lt;br /&gt;
      local func = setters[key]&lt;br /&gt;
      if func then func(self, value)&lt;br /&gt;
      else rawset(self, key, value) end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47433</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47433"/>
		<updated>2011-09-08T04:55:19Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|&lt;br /&gt;
ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
BEGIN {&lt;br /&gt;
    my @attr = qw(author title number);&lt;br /&gt;
    no strict 'refs';&lt;br /&gt;
    for my $a (@attr){&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::get_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a}         };&lt;br /&gt;
        *{__PACKAGE__ . &amp;quot;::set_$a&amp;quot;} = sub { $_[0]-&amp;gt;{$a} = $_[1] };&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47427</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47427"/>
		<updated>2011-09-08T04:47:34Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|&lt;br /&gt;
ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47426</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47426"/>
		<updated>2011-09-08T04:46:38Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|&lt;br /&gt;
ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Message&lt;br /&gt;
  attr_reader :message&lt;br /&gt;
  def message=(m)&lt;br /&gt;
    @message = m.dup&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Message&lt;br /&gt;
  attr_writer :message&lt;br /&gt;
  def message&lt;br /&gt;
    @message.encode!(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47425</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47425"/>
		<updated>2011-09-08T04:45:29Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|&lt;br /&gt;
ObjectName.MethodName(Parameters);&lt;br /&gt;
ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47417</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47417"/>
		<updated>2011-09-08T04:32:36Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
 ObjectNmae.MethodName&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
Public Property myProperty As String&lt;br /&gt;
    Get&lt;br /&gt;
        Return String.Empty&lt;br /&gt;
    End Get&lt;br /&gt;
    Private Set(ByVal value As String)&lt;br /&gt;
        somethingElse = value&lt;br /&gt;
    End Set&lt;br /&gt;
End Property&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax may be same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is same for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47410</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47410"/>
		<updated>2011-09-08T04:20:30Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|VB.NET&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Ruby&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Lua&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Perl&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47408</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47408"/>
		<updated>2011-09-08T04:18:05Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47406</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47406"/>
		<updated>2011-09-08T04:17:07Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47405</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47405"/>
		<updated>2011-09-08T04:15:48Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47404</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47404"/>
		<updated>2011-09-08T04:15:13Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|Javascript&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|PHP&lt;br /&gt;
|$ObjectName-&amp;gt;MethodName(Parameters);&lt;br /&gt;
|$ObjectName-&amp;gt;Attribute&lt;br /&gt;
|N/A. Attributes can be accessed directly.&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47386</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47386"/>
		<updated>2011-09-08T03:58:16Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|ObjectName.MethodName(Parameters);&lt;br /&gt;
|ObjectName.Attribute&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47380</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47380"/>
		<updated>2011-09-08T03:54:57Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
&lt;br /&gt;
  this.retCirc = function () { &lt;br /&gt;
  return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
testcircle.retArea();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
&lt;br /&gt;
  this.retCirc = function () { &lt;br /&gt;
  return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
alert(testcircle.radius);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47376</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47376"/>
		<updated>2011-09-08T03:54:08Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retCirc = function () { &lt;br /&gt;
  return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
testcircle.retArea();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retCirc = function () { &lt;br /&gt;
  return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
alert(testcircle.radius);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47373</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47373"/>
		<updated>2011-09-08T03:52:35Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|PHP&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retArea = getTheArea;&lt;br /&gt;
  this.retCirc = function () { return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
testcircle.retArea();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retCirc = function () { return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
alert(testcircle.radius);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47370</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=47370"/>
		<updated>2011-09-08T03:51:45Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world i.e it's modeled around data rather than logic. Objects form the basis of OOP. Let us now look at objects, their manipulation and the ways to do so.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects - Attributes and Methods ==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Similar to real world objects, software objects also consist of state and related behavior. An object stores it's state in &amp;lt;i&amp;gt;attributes&amp;lt;/i&amp;gt; and exposes its behavior through &amp;lt;i&amp;gt;methods&amp;lt;/i&amp;gt;. Let's look at the pseudo code for a bicycle object.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CLASS Bicycle&lt;br /&gt;
ATTRIBUTES:&lt;br /&gt;
	speed: NUMBER&lt;br /&gt;
	gear: NUMBER&lt;br /&gt;
	pedal_cadence: NUMBER&lt;br /&gt;
METHODS:&lt;br /&gt;
	ride(speed)&lt;br /&gt;
	changeGear(gear)&lt;br /&gt;
	changeCadence(pedal_cadence)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[[File:concepts-object.gif]]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In the above pseudo code, the attributes define the object and the methods provide a way of achieving the desired functionality from that object. The methods use the attributes to manipulate the object and achieve the functionality. From this we can observe that this manipulation is the very essence of programming using objects. Therefore the access of attributes and way of defining method calls very important in OOP.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Method call / Instance Variable reference Syntax ==&lt;br /&gt;
&amp;lt;p&amp;gt;A running debate in O-O languages is whether method calls and instance-variable references should have the same syntax. Different programming languages implement this in different ways. Let's look at them by examples.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Same Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Ruby use the same syntax for method calls and variable references. There is no distinction between these. We can see this in the example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song&lt;br /&gt;
  def duration=(newDuration)&lt;br /&gt;
    @duration = newDuration&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
aSong = Song.new(&amp;quot;Bicylops&amp;quot;, &amp;quot;Fleck&amp;quot;, 260)&lt;br /&gt;
aSong.duration	»	260&lt;br /&gt;
aSong.duration = 257   # set attribute with updated value&lt;br /&gt;
aSong.duration	»	257&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it simpler for the programmer to code. Also, it presents uniformity in the code.&lt;br /&gt;
&lt;br /&gt;
=== Differing Syntax ===&lt;br /&gt;
&amp;lt;p&amp;gt;Languages like Java employ different syntax for method calls and variable references as seen in this example below:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Song{&lt;br /&gt;
	int duration;&lt;br /&gt;
	Song(){}&lt;br /&gt;
	void setDuration(int dur){&lt;br /&gt;
		duration = dur;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Song sng = new Song();&lt;br /&gt;
sng.setDuration(260);&lt;br /&gt;
System.out.println(&amp;quot;Song duration = &amp;quot;+sng.duration);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As seen above, a method is always called using parenthesis, within which arguments may be included if required. However, instance variable is accessed directly.&lt;br /&gt;
&lt;br /&gt;
== Comparison of syntax between various Programming Languages ==&lt;br /&gt;
&amp;lt;p&amp;gt;The usage syntax of methods, instance variables, getters and setters is in the table below&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Programming Languages&lt;br /&gt;
!Method call&lt;br /&gt;
!Fields/Attributes&lt;br /&gt;
!Getter / Setter&lt;br /&gt;
!Comparison&lt;br /&gt;
|-&lt;br /&gt;
|ABAP (Advanced Business Application Programming)&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
CALL METHOD &amp;lt;meth&amp;gt; EXPORTING... &amp;lt;ii&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   IMPORTING... &amp;lt;ei&amp;gt; =.&amp;lt;g i&amp;gt;... &lt;br /&gt;
                   CHANGING ... &amp;lt;ci&amp;gt; =.&amp;lt;f i&amp;gt;... &lt;br /&gt;
                   RECEIVING         r = h &lt;br /&gt;
                   EXCEPTIONS... &amp;lt;ei&amp;gt; = rc i...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;b&amp;gt;data&amp;lt;/b&amp;gt; field &amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; type&lt;br /&gt;
|Same as other methods with the only difference that they start with SET or GET&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|-&lt;br /&gt;
|C++&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;b&amp;gt;type&amp;lt;/b&amp;gt; field&lt;br /&gt;
|Same as methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int getHealth() const { return health; }&lt;br /&gt;
void setHealth(int h) { health = h; }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|C#&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are just like methods. Example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public string GetName()&lt;br /&gt;
    {&lt;br /&gt;
        return m_name;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void SetName(string name)&lt;br /&gt;
    {&lt;br /&gt;
        m_name = name;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|Java&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|They are nothing but method calls&lt;br /&gt;
|Different syntax is used to call methods and instance-variable references&lt;br /&gt;
|-&lt;br /&gt;
|D&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.method(parameters) [Eg: x.method()]&lt;br /&gt;
|&amp;lt;instance-variable&amp;gt;.field [Eg: x.field]&lt;br /&gt;
|No need for getters and setters.  It can be directly accessed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import std.stdio;&lt;br /&gt;
&lt;br /&gt;
class Car&lt;br /&gt;
{&lt;br /&gt;
    float speed = 1.0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(){&lt;br /&gt;
    auto my_car = new Car();&lt;br /&gt;
    my_car.speed = 2.5;&lt;br /&gt;
    writefln(my_car.speed);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Objective C&lt;br /&gt;
|output = [object methodWithOutput]&lt;br /&gt;
|x-&amp;gt;field&lt;br /&gt;
|An example of getter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
@end        &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An example of setter is below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
@interface Photo : NSObject {&lt;br /&gt;
    NSString* caption;&lt;br /&gt;
    NSString* photographer;&lt;br /&gt;
}&lt;br /&gt;
- (NSString*) caption;&lt;br /&gt;
- (NSString*) photographer;&lt;br /&gt;
&lt;br /&gt;
- (void) setCaption: (NSString*)input;&lt;br /&gt;
- (void) setPhotographer: (NSString*)input;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax used for method calls and variable references is different&lt;br /&gt;
|-&lt;br /&gt;
|Python&lt;br /&gt;
|x.method(parameters)&lt;br /&gt;
|x.field&lt;br /&gt;
|Pythonic way of implementing getters and setters is to using public members and turning them into properties when needed&lt;br /&gt;
|Syntax used for method calls and variable references is sometimes the same and different at times (when there are arguments)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|PHP&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retArea = getTheArea;&lt;br /&gt;
  this.retCirc = function () { return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
testcircle.retArea();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
function mycircle(r) {&lt;br /&gt;
  this.radius = r;&lt;br /&gt;
  this.retCirc = function () { return ( Math.PI * this.radius * 2 ); };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var testcircle = new mycircle(5);&lt;br /&gt;
alert(testcircle.radius);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
var lost = {&lt;br /&gt;
	loc : &amp;quot;Island&amp;quot;,&lt;br /&gt;
	get location () {&lt;br /&gt;
		return this.loc;&lt;br /&gt;
	},&lt;br /&gt;
	set location(val) {&lt;br /&gt;
		this.loc = val;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
lost.location = &amp;quot;Another island&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|Syntax is different for method calls and instance-variable reference&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&amp;lt;p&amp;gt;Using the same syntax for method calls and instance variable references have some advantages and disadvantages. One could argue that having the same syntax makes it simpler for the programmer. It makes the code lighter in terms of lines of code, thus avoiding bulky code. However, including distinct ways for using methods and variables enhances readability by enabling better understanding. This is possible because the manipulation is visible whereas if the syntax were the same(i.e. compact), the one reading has no idea about what is happening &amp;quot;under the hood&amp;quot;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm/ Declaring and Calling Methods]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(object-oriented_programming)/ Comparison of Programming Languages]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://forums.sdn.sap.com/thread.jspa?threadID=529448&amp;amp;tstart=6135/ Setters and Getters in ABAP]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://www.zeuscmd.com/tutorials/cplusplus/50-GettersAndSetters.php/ Getters and Setters]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[http://cocoadevcentral.com/d/learn_objectivec/ Objective C]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46910</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46910"/>
		<updated>2011-09-07T22:35:18Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rambo&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attributes ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46906</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46906"/>
		<updated>2011-09-07T22:28:52Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Attributes ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46905</id>
		<title>CSC/ECE 517 Fall 2011/ch1 1h ps</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch1_1h_ps&amp;diff=46905"/>
		<updated>2011-09-07T22:27:20Z</updated>

		<summary type="html">&lt;p&gt;Pramasw3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=5&amp;gt;Common Attribute/Member Syntax&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Different object oriented programming languages include different ways of accessing the member variables and methods. This page discusses the various usages and their advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&amp;lt;p&amp;gt;The purpose of [http://en.wikipedia.org/wiki/Object-oriented_programming/ Object Oriented Programming] is to make programs model things the way people think or deal with the world.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;/div&gt;</summary>
		<author><name>Pramasw3</name></author>
	</entry>
</feed>