Object oriented fundamentals_in_java

833 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
833
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
34
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Object oriented fundamentals_in_java

  1. 1. Object-Oriented Programming Fundamentals in Java by George Wang
  2. 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. 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)
  4. 4. What is Object-Oriented Programming - continued
  5. 5. Why Object-Oriented Programming? Software Development is inherently a complex process. from OO Analysis and Design by Grady Booch, 2nd Edition
  6. 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. 7. What is Class? a factory or blueprint that define a similar type or group of objects example: HondaAccordCar, Boeing747Airplane
  8. 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. 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. 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. 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. 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

×