Professional Documents
Culture Documents
2
Problem Description
3
Procedural Approach
bool MakeDeposit(int accountNum,float amount);
float Withdraw(int accountNum,float amount);
struct Account {
char *name;
int accountNum;
float balance;
char accountType;
};
4
Procedural Approach
• Focus is on procedures
• More difficult to modify
• Hard to manage complexity
5
Procedural vs. Object-Oriented
6
Procedural vs. Object-Oriented Programming
• The unit in procedural programming is function, and
unit in object-oriented programming is class
• Procedural programming concentrates on creating
functions, while object-oriented programming starts
from isolating the classes, and then look for the
methods inside them.
• Procedural programming separates the data of the
program from the operations that manipulate the data,
while object-oriented programming focus on both of
them
7
Outline
• Procedural approach vs. Object-Oriented
approach
• Basic Object Oriented concepts
• Classes and Objects
• Course Syllabus
• Summary
8
Concept of Class and Object
• “Class” refers to a blueprint. It defines the variables
and methods the objects support
9
Outline
• Procedural approach vs. Object-Oriented
approach
• Basic Object Oriented concepts
• Classes and Objects
• Course Syllabus
• Summary
10
Objects
• An object has:
– state - descriptive characteristics
– behaviors - what it can do (or what can be done to it)
• The state of a bank account includes its account
number and its current balance
• The behaviors associated with a bank account include
the ability to make deposits and withdrawals
• Note that the behavior of an object might change its
state
11
Classes
• An object is defined by a class
• A class is the blueprint of an object
• The class uses methods to define the behaviors of
the object
• A class represents a concept, and an object
represents the embodiment of that concept
• Multiple objects can be created from the same
class
12
Objects and Classes
A class An object
(the concept) (the realization)
13
Class
What this basically means is that we provide
a blueprint, or a design of an object.
14
Methods
15
Methods
OOP 17
Class Point
Class Point has:
two fields:
xCoord
yCoord
one constructor
Point(int, int)
one method
void move(int, int)
OOP 18
Programming with Points
OOP 19
Variables Declaration
• Field Declaration
– a type name followed by the field name, and optionally an
initialization clause
– primitive data type vs. Object reference
• boolean, char, byte, short, int, long, float, double
– field declarations can be preceded by different modifiers
• access modifiers
• static
• final
20
Mapping the world to software
21
Object Oriented
• Data and operations are grouped together
Account Interface:
Withdraw
Deposit
Set of available operations
Transfer
22
Data Encapsulation
class Account {
public:
float withdraw();
void deposit(float amount);
private:
float balance;
);
23
Objects and Classes
24
Objects and Classes
Operations
Class BankAccount
MakeDesposit
Balance
Interest Transfer
Owner WithDraw
Account_number
GetBalance
25
Objects as instances of Classes
26
Instantiation
• An Object is instantiated from a Class
BankAccount myAccount;
myAccount = new BankAccount;
27
Object
• Object
– Own copy of data
– Active in running program
– Occupies memory
– Has the set of operations given in
the class
28
Summary
• What is Object Oriented Programming?
Object-oriented programming is a method of
implementation in which programs are
organized as cooperative collections of
objects, each of which represents an instance
of some class, and whose classes are all
members of one or more hierarchy of classes
united via inheritance relationships
29
Outline
• Procedural approach vs. Object-Oriented
approach
• Basic Object Oriented concepts
• Classes and Objects
• Course Syllabus
• Summary
30
Syllabus
Instances, Initialization.
31
Syllabus
Method overriding
Generics
Implementation Strategies.
32
Outline
• Procedural approach vs. Object-Oriented
approach
• Basic Object Oriented concepts
• Classes and Objects
• Course Syllabus
• Summary
33
Object Oriented Programming
Programming in an object oriented language
is more than just learning new functions,
syntax, etc. OOP is more than learning a new
language; it requires a new way of thinking.
The idea is to not mainly concentrate on the
cornerstones of procedural languages - data
structures and algorithms - but instead think
in terms of objects.
34
OOP Languages
35
.NET
What Is Microsoft dot NET?
Microsoft .NET is software that connects
information, people, systems, and devices. It
spans clients, servers, and developer tools, and
consists of:
The .NET Framework programming model that
enables developers to build Web-based
applications, smart client applications, and XML
Web services applications which expose their
functionality programmatically over a network
using standard protocols such as HTTP.
36
.NET
Developer tools, such as Microsoft Visual Studio.NET,
which provide a rapid application integrated
development environment for programming with the
.NET Framework.
37
END