1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

4. Object-Oriented Programming Procedural programming Structs and objects Object-oriented programming Concepts and terminology Related keywords.
Inheritance. Many objects have a hierarchical relationship –Examples: zoo, car/vehicle, card game, airline reservation system Inheritance allows software.
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
Inheritance Inheritance Reserved word protected Reserved word super
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Inheritance Polymorphism Briana B. Morrison CSE 1302C Spring 2010.
Sucha Smanchat  Steps in OOAD using UML  Use Case Diagram  Sequence Diagram / Communication Diagram  Class Diagram  State.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
UML – Class Diagrams.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Unified Modeling Language (UML)
© Wolfgang Pelz Introduction Object-Oriented Methods: Analysis, Design & Programming Dr. Wolfgang Pelz Dr. Yingcai Xiao The University of Akron.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Object-oriented Programming Concepts
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
Distribution of Marks Internal Sessional Evaluation Assignments – 10 Quizzes – 10 Class Participation Attendence – 5 Mid – Term Test – 25 External Evaluation.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
The Unified Modeling Language (UML) Class Diagrams.
Introduction To System Analysis and design
Programming Languages and Paradigms Object-Oriented Programming.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Eclipse – making OOP Easy
Writing Classes (Chapter 4)
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
SE-1010 Dr. Mark L. Hornick 1 Introduction to Object-Oriented Programming (OOP) Part 1.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Design.ppt1 Top-down designs: 1. Define the Problem IPO 2. Identify tasks, Modularize 3. Use structure chart 4. Pseudocode for Mainline 5. Construct pseudocode.
Object-Oriented Design Justin Callanan CS 597. Object-Oriented Basics ● Data is stored and processed in “objects” ● Objects represent generalized real.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Object Oriented Programming
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
OOP Review CS 124.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Testing in OO Environment The reasons for testing is not any different for any of the design and implementation methodologies, including OO methodology.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
Chapter 11 Inheritance © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured and Object-Oriented.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Object-Oriented Design
Sections Inheritance and Abstract Classes
Lecture 12 Inheritance.
Inheritance and Polymorphism
The Object-Oriented Thought Process Chapter 1
Advanced Programming in Java
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
An Introduction to Inheritance
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Object Oriented Analysis and Design
Week 6 Object-Oriented Programming (2): Polymorphism
Object-Oriented Programming
Presentation transcript:

1

2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage / Disadvantage

3 Originated in 1970s. Imitation of things in the real world. Interactions between objects form a task.

4 Class is a template of objects of a same kind or type. Person Movie University Object is an instantiation of class. Leonardo da Vinci The Hobbit KMUTNB Many objects of the same class have the same set of attributes and behavior but their values may vary.

5 Class contains: Class name. Attributes or data of that class. Type of each attribute should be specified. Methods (operations / functions) or what that class can do or the behavior of that class.

6 Name Attributes Methods Compartments Class name Data stored in the class What this class can do

7 Class University University Name Location Faculties No. of Student … open close Instantiate Objects of Class University University KMUTNB BKK {IT, …} 5347 … open close University … …

8 class University { String uName; String location; Collection faculties; int numberOfStudent; … public void open() {…} public void close() {…} }

9 What are you interested in? Both concrete and abstract. Is it just a value? - attribute Or is it composed of a group of data? Similar to identifying Entities in ERD.

10 Encapsulation Inheritance Polymorphism

11 Data are hidden within object. Methods are included in the object. Communication with the object is through methods (interface) In OOP, class usually has setters and getters methods E.g. from University public void setUniversityName(String newName) { uName = newName; } public String getUniversityName() { return uName; }

12 Three levels of visibility Public – Visible to all Private – Visible to that class only Protected – Visible to that class and its subclasses Unspecified (Java only) – Visible to all within the same package or folder (not recommended, especially in large- scale program)

13 A class formed by inheriting the attributes and behavior of another class. Class A inherits from Class B Class A is a subclass of the parent class B. Class B is a parent class of the subclass A. Can a class inherit from 2 parent classes? Subclass / Derived Class Parent Class / Base Class / Superclass

14 Transport Airliner ShipVehicle CarTruckMotorcycleTrain Steam-Powered ElectricDieselMaglev Spacecraft

15 Sports Weapons Games Animals Food Drink

16 Subclass initially has the same attributes and methods as its parent class. Subclass can alter or override the inherited attributes and methods. Subclass can add new attributes and methods. How is inheritance useful? Help reuse source code – how?

17 Subclass can be passed as argument for method that specifies its parent class as parameter But not the other way around! Why? How useful?

18 Method Overriding A method in a subclass with the same name, parameter set, and return type as the method in its parent class. Method Overloading A method in a class with the same name and return type but different parameter set as a method in the same class or its parent class. public void getName() {…} public void getName(String type) {…} public void getName(int type) {…}

19 Poly = Many, Morph = Form Invoking a method name may give different action and/or result depending on the kinds of objects. What would you do when you are told to “Find one million Baht” ? “Play your favorite sport”?

20 How do mammals reproduce? Human, Dogs, Cats, … etc. What about platypus? See Transport example again Referred to method overriding

21 Association – uses, other common verbs Aggregation – is in Composition – is part of Inheritance / Generalization – is a See UML for correct notation.

22 You need to know what each object can do (methods) and how to use them. You don’t need to know the detail of the methods. Tell the object to do something by calling its methods and give proper parameters. A task is form by interactions among objects. Imitation of the real world activities. Parameter vs Argument

23 Logically Student tells the librarian who he/she is. Student tells the librarian which books he/she wants to borrow. The librarian records the loan. The librarian tells the student by which date he must return the books.

24 Order a flower for your friend in England. Buy 2 movie tickets. Make a withdrawal from your bank account. Travel by Skytrain.

25 Unified Modeling Language (UML) Specification by Object Management Group (OMG) Consist of 9 diagrams to explain a system. Rational Rose Object-Oriented software development tool utilizing UML. Provide source code generation. Microsoft Visio

26 Java Cross-platform Java Virtual Machine C++ C# …

27 Support source code reuse. Faster development time. Both data and operation aspects are combined. Object-Oriented software are easier to maintain. Low dependency between objects. An object can be replaced easily with minimum modification to other objects.

28 Hard to understand for beginner and even some experienced programmers. Object-Oriented programming requires more computation power (no longer matters) Anything else?