The document provides an introduction to object-oriented programming fundamentals in Java. It defines key concepts like object, class, abstraction, encapsulation, polymorphism, and inheritance. It explains that objects are instances of classes, and classes provide blueprints to generate objects. The document also gives examples of how objects are created from classes and their attributes and behaviors. It outlines characteristics of OOP like abstraction, encapsulation, and polymorphism. Finally, it mentions some common OOP design principles.
2. Objectives
Definition of Object Oriented, Object, Class and relationship
between Object and Class
General structure of a Class
How Objects are created and used
Characteristics of Object Oriented Programming
3. What is Object-Oriented Programming?
"Object oriented" means that we organize software as a
collection of discrete objects that have both data and structure
Example: to go From point A to point B
Non OO:
Drive(200 miles) (just do it)
OO:
myCar =new HondaAccord();
myCar.drive(200miles)
6. What is Object?
1) Object: eveything in the world is an object - concrete or
conceptual. It is an instance of a Class
2) Object
Can be real-world objects: this desk, this ballpen,etc
Can represent GUI (Graphical User Interface) components
Can represent software entities (events, files, images, etc.)
Can represent abstract concepts (for example, rules of a game, a
particular type of dance, etc.)
---Ask students: can anyone give an example of some Objects???
7. What is Class?
a factory or blueprint that define a similar type or group
of objects
example: HondaAccordCar, Boeing747Airplane
8. Relation between Object and Class
Object Class
has identity, a a blueprint or
unique instance of factory that holds
a Class or produce the
objects
dynamic, static structure
generated in written by
runtime programmers
9. a Class Example
import java.awt.color;
public class HondaAccord {
private Color carColor;
public HondaAccord(Color carColor){
this.carColor= carColor;
}
public void Drive(int miles){
...
}
}
10. Usage example
public class CarUsageExample{
public static void main(Strings args[]){
HondaAccord myBlueHonda=
new HondaAccord(Color.blue);
myBlueHonda.drive(200); //go 200 miles
}
}
11. Characteristics of OO Programming
Abstraction: focus on the essential characteristics of an
object that distinguish it from others, relative to the
perspective of the viewer
Encapsulation: detail or implementation hidden so that
only interface exposed
Polymorphism: same function name can have different
behavior depending on its subtype (airplane.travel() vs car.
travel())
Inheritance: is-a relationship
12. OO design principles
SRP- single responsibility (high cohesion): a class should have
one reason to change
OCP-open-close: class should be open to extension, close to
modification
LSP- Liskov substitution: subtype is-a basetype, therefore can
substitute for it.
DIP - dependency inversion: code to (depend to) interface (high
level modules should not depend on low level modules)
ISP-interface segregation principle: when there is incohesion,
separate them into different interfaces
-from Agile Software Development by Robert Martin