Atul Gupta
State
Behavior
Vary in complexity
Brush
Desktop lamp
Desktop radio
Space shuttle
Software Objects
class Bicycle {
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:"+cadence+" speed:"+speed+" gear:"+gear);
}
}
Software Objects
Advantages
Abstraction
Encapsulation (Modularity)
Information-hiding
Code re-use
Pluggability and debugging ease
Essence of an Object
Object-Oriented Concepts
Objects
Classes
Interfaces
Inheritance
Attributes
Methods
Encapsulation
Information Hiding, or
Visibility
Instances
Delegation
Polymorphism
Dynamic Binding
Aggregation
Association
Message Passing, or
interactions
Genericity
Class Modeling
Objects
Identifier
values
Behavior
Classes
Name
Attributes (also termed as variables, fields, or properties)
Methods (also termed as operations, features, behavior,
functions)
Class
BankAccount
accountNumber
balance
b2:BankAccount
0000012
$2000
getBalance()
b3:BankAccount
0000202
$25000
Object Relationships
Association
Aggregation
Composition
Inheritance
Dependency
Summary