Chapter 1 - 1 Chapter 1 Introduction to Object-Oriented Programming and Software Development.

Slides:



Advertisements
Similar presentations
Introduction to Object Orientation System Analysis and Design
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall A.1.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
Object-Oriented Analysis and Design
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Introduction To System Analysis and Design
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
Object-oriented programming concepts An Introduction.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Lecture 1 Introduction to Computers and Object-
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 1 Introduction to Object-Oriented Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction To System Analysis and design
TCU CoSc Introduction to Programming (with Java) Getting to Know Java.
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.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 1: Introduction to Object-Oriented Programming.
BCS 2143 Introduction to Object Oriented and Software Development.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
1 CS 456 Software Engineering. 2 Contents 3 Chapter 1: Introduction.
SE-1010 Dr. Mark L. Hornick 1 Introduction to Object-Oriented Programming (OOP) Part 1.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
Introduction To System Analysis and Design
Object-Oriented Analysis and Design An Introduction.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Object-oriented programming concepts An Introduction.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
CSC480 Software Engineering Lecture 11 September 30, 2002.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
UML as a Specification Language for Embedded Systems. By, Mir Ahmed Ali, Asst. Professor, ECM department, SNIST. By, Prof. Narsiah sir, Director of School.
Programs and Classes A program is made up from classes Classes may be grouped into packages A class has two parts static parts exist independently Non-static.
Design Model Lecture p6 T120B pavasario sem.
© 2000 McGraw-Hill Modified by C.W.Pang with author's permission Intro to OOP with Java--Wu Chapter Chapter 1 Introduction to Object-oriented Programming.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Using Objects 1 of 22 Computer Programming Object Classes.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Getting Started with Java: Object declaration and creation Primitive.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
بسم الله الرحمن الرحيم CPCS203: Programming II. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display., Modifications by Dr.
Introduction to Computers and Programming Languages CS 180 Department of Computer Science Purdue University.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Chapter 0: Introduction
Class Diagrams.
Introduction to OOP with Java 4th Ed, C. Thomas Wu
Basic OOP Concepts and Terms
Intro to OOP with Java, C. Thomas Wu
Presentation transcript:

Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development

Chapter Objectives Understand the basic of object-oriented programming –Differentiate classes and objects. –Differentiate class and instance methods. –Differentiate class and instance data values. –Draw UML diagrams for classes and objects –Describe significance of inheritance in object-oriented programs Name and explain the stages of the software lifecycle

Chapter What is an Object ? Real-world objects: –Concrete objects: Apple1, Car1, TV2, Teacher2, Student3, … –Conceptual Objects: 1, 2.3, Date1, Meeting2, point2, … Objects have: –Properties (attributes): color, weight, height, sex, name, speed, position,… –Capabilities (behaviors): can receive commands(, request, query) and respond (do actions) based on its internal states to change its internal state and/or external environment. The properties of an object constitutes its current state.

Chapter What is a Software object ? a software bundle of data and functions used to model real-world objects you find in everyday life. In OOP, Software objects are building block of software systems –program is a collection of interacting objects –objects cooperate to complete a task –to do this, they communicate by sending “messages” to each other Software objects can model –tangible things: School, Car, Bicycle, –conceptual things: meeting, date –Processes: finding paths, sorting cards Note: Software objects are only abstraction of real-world objects; properties and behavior of irrelevance will not be modeled in software objects.

Chapter What is a Java Object? In Java, an object consists of 0 or more fields and 0 or more methods. –Fields are used to model properties. –Methods are used to model capabilities. Fields are variables. –like the fields of a C struct. –An object without methods is equivalent to a C struct. A method is similar to a C function. –Normally, it will operate on the fields of the object. –These fields are accessible by name in the method. Java variables can not hold objects, but only references to them. –Object do not have a names. –Object are created only at runtime.

Chapter Classes and Objects Current conception: –a java/software object  a real-life object, –e.g., a Java car  a real car Disadvantage: impractical to work with objects this way –may be indefinitely many (i.e., modeling all atoms in the universe) –do not want to describe each individual separately, because they may have much in common Classifying objects into classes of similar properties/behaviors –factors out commonality among sets of similar objects –lets us describe what is common once –then “stamp out” any number of copies later –Ex: Student: { S1, S2, S3 } Course:{C1,C2,C3} Teacher:{ T1,T2} – but not {s1, t1}, {s2, t2}, {c1,c2,c3,s3} Analog: –blueprint (class) –constructions (objects)

Chapter What is a Java Class? In Java, a class is a template (textual description) of a set of similar objects. –All objects in the class have the same types of properties and the same set of capabilities. It defines the fields and methods that all objects in that class will have. –Classes have names. –Class appear in the text of your program. –A java program consists of a set of classes. A defined class is a Java Type, so you can have objects or variables of that type.

Chapter Example class Person { // fields or properties int age ; String name ; Person father, mother ; Person[] : siblings // methods or behavior capability void eat( Food food) ; void play() ; void work() ; void sleep(); } //possible statements m1 = new Person(); p1 = new Person; p1.mother = m1;

Chapter Classes and Objects In OOP, a running application is results of participating objects and their interactions. Similar objects are described or defined by the same (set of ) classes –properties  fields –behavior capability  methods An object is called an instance of its defined classes. –Ex: stusent1 is an instance of both class Student and Person and Object( 萬物 ).

Chapter Graphical Representation of a Class The notation we used here is based on the industry standard notation called UML, which stands for Unified Modeling Language. We use a rectangle to represent a class with its name appearing inside the rectangle. Example: Account Motorcycle

Chapter Graphical Representation of an Object We use a rectangle to represent an object and place the underlined name of the object inside the rectangle. Example: SV198 This is an object named SV198.

Chapter An Object with the Class Name : This notation indicates the class which the object is an instance. This tells an object SV198 is an instance of the BankAccount class. Example: SV198 : BankAccount

Chapter Messages and Methods How do objects interact ? –message passing ; method requests/invocation/call To instruct a class or an object to perform a task, we –send a message (method call) to it. –the message must be understandable to the receiving classes or objects. i.e., –the receiving class or an object must possess a matching method to be able to handle the received message. Kinds of method: –A method defined for a class is called a class method, and –a method defined for all instances of a class is called an instance method. A associated value we pass to an object when sending a message is called an argument of the message. –e.g., p1.eat( apple1 ); // receiver.method ( argument …).

Chapter Sending a Message deposit Message deposit with the argument is sent to a BankAccount object SV198. SV198 : BankAccount Rreceiver caller

Chapter Sending a Message and Getting an Answer current balance getCurrentBalance() Ask for the current balance of this particular account. SV198 : BankAccount The current balance of SV198 is returned.

Chapter Calling a Class Method maximum speed MobileRobot getMaximumSpeed() Ask for the maximum possible speed for all MobileRobot objects is returned.

Chapter Class and Instance Data Values An object is composed of data values (for its properties) and methods. –Property has name, type and value –ex: int age = 10 ; –property name and type are static (time-invariant ) –property value may change with time. An instance data value is a value of one of its properties of an individual instance. –For example, each BankAccount object maintains its balance. A class data value is a value of some property of the whole class. –It is shared by all instances of the class. –Ex: minimum balance and average balance in Account class.

Chapter SV098 : BankAccountSV211 : BankAccountSV129 : BankAccount Sample Instance Data Value current balance All three BankAccount objects possess the same current balance property. The actual dollar amounts (data value) are, of course, different.

Chapter Sample Class Data Value SV098 : BankAccountSV211 : BankAccountSV129 : BankAccount current balance BankAccount minimum balance There is one copy of minimum balance for the whole class and shared by all instances. This line is an instance-of relationship.

Chapter Object Icon with Class Data Value When the class icon is not shown, we include the class data value in the object icon itself. SV129 : BankAccount current balance minimum balance

Chapter Class and object diagrams

Chapter Inheritance Inheritance is a mechanism in OOP to design two or more entities that are different but share many common features. –design/programming by difference. –Features common to all classes are defined in the superclass. –The classes that inherit common features from the superclass are called subclasses. We also call the superclass an ancestor and the subclass a descendant.

Chapter A Sample Inheritance Here are the superclass Account and its subclasses Savings and Checking. Account Checking Savings

Chapter Inheritance Hierarchy An example of inheritance hierarchy among different types of students. Student Graduate Undergrad Commuting Law Resident Masters Doctoral

Chapter Software Engineering Much like building a skyscraper, we need a disciplined approach in developing complex software applications. Software engineering is the application of a systematic and disciplined approach to the development, testing, and maintenance of a program.

Chapter Software Life Cycle The sequence of stages from conception to operation of a program is called software life cycle. Five stages are –Analysis –Design –Coding –Testing –Operation and Maintenance –Update and Evolution