COSC2767: Object-Oriented Programming

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
1 CIS601: Object-Oriented Programming in C++ Note: CIS 601 notes were originally developed by H. Zhu for NJIT DL Program. The notes were subsequently revised.
Object-Oriented Analysis and Design
Introduction To System Analysis and Design
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
© Wolfgang Pelz Introduction Object-Oriented Methods: Analysis, Design & Programming Dr. Wolfgang Pelz Dr. Yingcai Xiao The University of Akron.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Introduction to Object-oriented Programming Introduction to Object-oriented Programming CMPS 2143.
BACS 287 Basics of Object-Oriented Programming 1.
Introduction To System Analysis and design
Object Oriented Software Development
Object Oriented Programming Development
Introduction to Object-oriented programming and software development Lecture 1.
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
CSCI-383 Object-Oriented Programming & Design Lecture 4.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Introduction To System Analysis and Design
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 COSC3306: Programming Paradigms Lecture 6: Object-Oriented Programming Specifications Haibin Zhu, Ph.D. Computer Science Nipissing University (C) 2003.
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.
Dale Roberts Object Oriented Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department.
Data Abstaraction Chapter 10.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Learners Support Publications Object Oriented Programming.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Nipissing University, North Bay, Ontario, Canada 1 Challenges to Reusable Services - IBM Eclipse Innovation Grant - IBM Eclipse Innovation Grant - IBM.
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Methodology First and Language Second -A Way to Teach Object-Oriented Programming Haibin Zhu, PhD Department of Computer Science and Mathematics Nipissing.
Introduction to OOP CPS235: Introduction.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
CSCI 383 Object-Oriented Programming & Design Lecture 4 Martin van Bommel.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Chapter 2 Principles of Programming and Software Engineering.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
Basic Characteristics of Object-Oriented Systems
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Programming paradigms
Visit for more Learning Resources
Object-Oriented Analysis and Design
Lecture 2 of Computer Science II
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
OOP vs Structured Programming
CIS601: Object-Oriented Programming in C++
What Is Good Software(Program)?
Presentation transcript:

COSC2767: Object-Oriented Programming 2017/4/16 COSC2767: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University

Contact Me Haibin Zhu, Ph. D. 2017/4/16 Contact Me Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University Room: A124A Ext.: 4434 Email: haibinz@nipissingu.ca URL: http://www.nipissingu.ca/faculty/haibinz Office Hour: Mon. & Tue.12:30pm-3:30pm; or by appointment

Course Description Covers the concepts of OOP languages and systems 2017/4/16 Course Description Covers the concepts of OOP languages and systems fundamental abstraction, modularity and encapsulation mechanisms in OOP Advanced OOP concepts polymorphism and operator overloading; message passing via generic functions; late versus early binding times; and inheritance mechanisms and their relationship to the type systems of programming languages. Templates, Design Patterns Java and Eclipses

How to get the goals Read and remember Think Practice Ask 2017/4/16 How to get the goals Read and remember Read the books, remember the language Think Think in objects, think in classes Practice Do as many coding as possible and make them running Ask Email me questions

Prerequisite Basic knowledge of Programming COSC1557, COSC1567 2017/4/16 Prerequisite Basic knowledge of Programming COSC1557, COSC1567

2017/4/16 The Textbooks Used Timothy A. Budd, The Introduction to Object-Oriented Programming (3rd Edition), Addison-Wesley, 2001, ISBN 0201760312 Avinash C. Kak, Programming with Objects: A comparative presentation of object-oriented programming with C++ and Java, John Wiley & Sons, 2003. ISBN: 0-471-26852-6.

2017/4/16 Lecture 1 Thinking in Objects

Contents Methodology(Philosophy) Programming Techniques 2017/4/16 Contents Methodology(Philosophy) Programming Techniques Object-Oriented Languages Object and Large Systems

Thinking Methodology Induction (Abstract) 2017/4/16 Thinking Methodology Induction (Abstract) From specialization to generalization From different dogs to create the word “dog” Dog

Thinking Methodology Deduction(infer) 2017/4/16 Thinking Methodology Deduction(infer) From generalization to specialization From the word “dog” you have learnt to know an animal is or not a dog. DOG

Design Methodologies Functional decomposition (Top-Down) 2017/4/16 Design Methodologies Functional decomposition (Top-Down) The whole system is characterized by a single function, and then the function is decomposed into a set of functions in a process of stepwise refinement.

Functional decomposition 2017/4/16 Functional decomposition The System Studying Function1 Function2 Function3 . . . . . . Desk Table top Filing cabinet Bookshelves . . . . . . . . . . . . Function11 Function12 Left drawer Middle drawer Right drawer

Design Methodologies Functional composition (bottom-up) 2017/4/16 Design Methodologies Functional composition (bottom-up) You can have different components of functions such as that from a function library You can compose them into a module with a more significant function.

Functional composition 2017/4/16 Functional composition The System Studying Function1 Function2 Function3 . . . . . . Desk Table top Filing cabinet Bookshelves . . . . . . . . . . . . Function11 Function12 Left drawer Middle drawer Right drawer

Functional (De)Composition 2017/4/16 Functional (De)Composition Also known as top-down development Widely deemed to be a “good thing” Regard thing to be developed as a hierarchy State top level, and decomposing into smaller functions. Decomposition continues until code level. Modules with well-defined semantics that can be directly implemented. Procedures owe the data Data plays a secondary role Does not necessarily reflect the states of abstraction in the application.

Object-Orientation It is a kind of thinking methodology 2017/4/16 Object-Orientation It is a kind of thinking methodology Everything in the world is an object; Any system is composed of objects (certainly a system is also an object); The evolution and development of a system is caused by the interactions among the objects inside or outside the system

Everything in the world is an object 2017/4/16 Everything in the world is an object A flower, a tree, an animal A student, a professor A desk, a chair, a classroom, a building A university, a city, a country The world, the universe A subject such as CS, IS, Math, History, …

Any system is composed of objects 2017/4/16 Any system is composed of objects A law system A cultural system An educational system An economic system An Information system A computer system

The development of a system is caused by the interactions 2017/4/16 The development of a system is caused by the interactions Nipissing University is developed by the interactions among: students professors staffs officers of Ontario officers of Canada … ... Inside Nipissing Outside Nipissing

2017/4/16 Design Methodologies Object-Orientation is one of the computational thinking methodologies. Object-Orientation is a kind of design methodology(OOA/OOD) Objects are the building blocks of the program(interface object(editor, menu, file, etc), data managing object(db), etc.). Objects represent real-world abstractions within the application.

Design Methodologies Object-orientation supports both 2017/4/16 Design Methodologies Object-orientation supports both induction: objects -> a class This needs the tools for OOA/OOD. and deduction: a class ->objects This needs the programmers to learn about the class library.

Design Methodologies Object-orientation supports both Top-down: 2017/4/16 Design Methodologies Object-orientation supports both Top-down: from a superclass to subclasses; complex objects to simple objects. Bottom-up: from subclasses to a superclass Simple objects to complex objects

Object-Orientation “The World is Object-Oriented” 2017/4/16 Object-Orientation “The World is Object-Oriented” ----Alan Kay said. If you know the world, you know object-orientation. So, object-orientation is easy.

Programming Programming is like writing. 2017/4/16 Programming Programming is like writing. If you can write a demonstration, you can make a program. So, programming is also easy. Then, Object-oriented programming equals easy + easy, that’s too(2) easy.

2017/4/16 Programming But, actually, programming is not so easy, because a real good program is not easily programmed. It needs the programmers’ lots of wisdom, lots of knowledge about programming and lots of experience. It is like writing, to be a good writer needs lots of experience and lots of knowledge about the world. Learning and practice are necessary.

Programming Techniques 2017/4/16 Programming Techniques The evolution of programming techniques is to make programming languages more expressive to develop complex systems more easily

Programming Techniques 2017/4/16 Programming Techniques Unstructured Programming Procedural Programming Modular & Structural Programming Abstract Data Type Object-Oriented Programming

Unstructured Programming 2017/4/16 Unstructured Programming Usually, people start learning programming by writing small and simple programs consisting only of one main program. Here ``main program'' stands for a sequence of commands or statements which modify data which is global throughout the whole program. Main Program Data

2017/4/16 Drawbacks This programming technique can only be used in a very small program. For example, if the same statement sequence is needed at different locations within the program, the sequence must be copied. If an error needed to be modified, every copy needs to be modified. This has lead to the idea to extract these sequences(procedure), name them and offering a technique to call and return from these procedures.

Procedural Programming 2017/4/16 Procedural Programming With procedural programming, you are able to combine sequences of calling statements into one single place. A procedure call is used to invoke the procedure. After the sequence is processed, flow of control proceeds right after the position where the call was made . Main Program Procedure

2017/4/16 Procedures With parameters and sub-procedures (procedures of procedures) , programs can now be written more structured and error free. For example, if a procedure is correct, every time it is used it produces correct results. Consequently, in cases of errors you can narrow your search to those places which are not proven to be correct.

Procedure Program view 2017/4/16 Procedure Program view Now a program can be viewed as a sequence of procedure calls. The main program is responsible to pass data to the individual calls, the data is processed by the procedures and the resulting data is presented. Thus, the flow of data can be illustrated as a hierarchical graph, a tree.

Procedure Program view 2017/4/16 Procedure Program view Main Program Data Procedure3 Procedure1 Procedure2

2017/4/16 Modular Programming Modular programming is subdividing your program into separate subprograms such as functions and subroutines. With modular programming, procedures of a common functionality are grouped together into separate modules. A program therefore no longer consists of only one single part. It is now divided into several smaller parts which interact through procedure calls and which form the whole program.

Main Program(Also a module) 2017/4/16 Main Program(Also a module) Data Module1 + Module2 + Data Data Data1 Data1 Data Data2 Procedure2 Procedure3 Procedure1 The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters.

2017/4/16 Modular Programming Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module. Each module has its own special functionalities that supports the implementation of the whole program.

Structural Programming 2017/4/16 Structural Programming Also structured programming A subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada, Pascal, and dBASE are designed with features that encourage or enforce a logical program

Structural Programming 2017/4/16 Structural Programming How many basic structures for programming? Three Types of Structures in a structured program Statement sequence(s1,s2,…,sn) Branch(if-then-else) Loop(for,do, and while loops) Keep no goto!!! Keep modules!!!

Abstract Data Types (ADTs) 2017/4/16 Abstract Data Types (ADTs) A set of data values and associated operations that are precisely specified independent of any particular implementation. Come with Modular Programming Abstraction Model Properties of Abstract Data Types Abstract Data Types and Object-Orientation

Abstraction: Handling Problems 2017/4/16 Abstraction: Handling Problems A process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose. Try to understand the problem to separate necessary from unnecessary details: You try to obtain your own abstract view, or model, of the problem. This process of modeling is called abstraction.

Problem Model Abstraction 2017/4/16 Abstraction Problem Model Two of the most important types of abstraction are the following: Division into parts: Has-A abstraction Division into specialization: Is-A abstraction

2017/4/16 Has-A Abstraction Division into parts takes a complex system, and divides into component parts, which can then be considered in isolation. Characterized by sentences that have the words ``has-a'' A car has-a engine, and has-a transmission A bicycle has-a wheel A window has-a menu bar Allows us to drop down a level of complexity when we consider the component in isolation.

2017/4/16 Is-a Abstraction Is-a abstraction takes a complex system, and views it as an instance of a more general abstraction. Characterized by sentences that have the words ``is-a'' A car is a wheeled vehicle, which is-a means of transportation A bicycle is-a wheeled vehicle A pack horse is-a means of transportation Allows us to categorize artifacts and information and make it applicable to many different situations.

2017/4/16 Model A model is an abstraction or conceptual object used in the creation of a predictive formula or a solution. A model defines an abstract view to the problem and focuses only on problem related stuff and that you try to define properties: the data which are affected; the operations which are identified; ADT is a kind of Model.

Abstract data types(ADT) 2017/4/16 Abstract data types(ADT) Abstract data types are a partial solution to models ADT defines the interface to a data abstraction without specifying implementation detail.

2017/4/16 Properties of ADT With abstraction, you create (1) a well-defined entity which can be properly handled. These entities define (2) the data structure of a set of items. For example, each administered employee has a name, date of birth and social number....

Properties of ADT(Cont’d) 2017/4/16 Properties of ADT(Cont’d) The data structure can only be (3) accessed with defined operations. This set of operations is called interface and is exported by the entity. An entity with the properties just described is called an abstract data type (ADT).

ADT Abstract Data Type Operations Abstract Data Structure Interface 2017/4/16 Abstract Data Type ADT Abstract Data Structure Interface Operations

Definition (ADT) ADT is characterized by the following properties: 2017/4/16 Definition (ADT) ADT is characterized by the following properties: 1. It exports a type. 2. It exports a set of operations. This set is called interface. 3. Operations of the interface are the only access mechanism to the type's data structure. 4. Axioms and preconditions define the application domain of the type.

Example: ADT List Type List. 2017/4/16 Example: ADT List Type List. The interface to instances of type List is defined by the interface definition file. Operations: insert, get, append, delete,search,…

2017/4/16 List The application domain is defined by the semantics meaning of the provided operations. Axioms and preconditions include statements such as ``An empty list is a list.'' ``Let l=(d1, d2, d3, ..., dN) be a list. Then l.append(dM) results in l=(d1, d2, d3, ..., dN, dM).'' ``The first element of a list can only be deleted if the list is not empty.''

Encapsulation(1) Combine the data and the operations 2017/4/16 Encapsulation(1) Combine the data and the operations Enclosing of both variables and functions Keep details of the data and operations from the users of the ADT Once you have created an ADT for complex numbers, say Complex, you can use it in the same way like well-known data types such as integers.

Encapsulation(2) Allows Modularity Controlled access to data 2017/4/16 Encapsulation(2) Allows Modularity Controlled access to data Separates implementation from interface It extends the built-in types

Object-Oriented Programming 2017/4/16 Object-Oriented Programming Object is derived from abstract data type Object-oriented programming has a web of interacting objects, each house-keeping its own state. Objects of a program interact by sending messages to each other.

Object1 Data1+Procedures1 Object2 Data2 + Procedures2 Data Data1 2017/4/16 Object1 Data1+Procedures1 Object2 Data2 + Procedures2 Data Data1 Object3 Data3 + Procedures3 Object4 Data4 + Procedures4

Object-Oriented Programming 2017/4/16 Object-Oriented Programming In object-oriented programming , instead of calling a procedure which we must provide with the correct handle, we would directly send a message to the object in questions. Roughly speaking, each object implements its own module.

Object-Oriented Programming 2017/4/16 Object-Oriented Programming Each object is responsible to initialize and destroy itself correctly. Consequently, there is no longer the need to explicitly call a creation or termination procedure.

Kay’s Description of OOP 2017/4/16 Kay’s Description of OOP Everything is an object Objects perform computation by making requests of each other through the passing of messages Every object has it's own memory, which consists of other objects. Every object is an instance of a class. A class groups similar objects. The class is the repository for behavior associated with an object Classes are organized into singly-rooted tree structure, called an inheritance hierarchy.

ADT and Object-Orientation 2017/4/16 ADT and Object-Orientation ADTs allows the creation of instances with well-defined properties and behavior. In object-orientation, ADTs are referred to as classes. Therefore, a class defines properties of objects which are the instances in an object-oriented environment.

ADT and Object-Orientation(2) 2017/4/16 ADT and Object-Orientation(2) ADTs define functionality by putting main emphasis on the involved data, their structure, operations as well as axioms and preconditions. Object-oriented programming is ``programming with ADTs'': combining functionality of different ADTs to solve a problem. Therefore instances (objects) of ADTs (classes) are dynamically created, destroyed and used.

ADT and Object-Orientation(3) 2017/4/16 ADT and Object-Orientation(3) ADTs still lack self-reference and conceptual locality of objects. Data types and operations are almost objects, but need to put them together and give the result a name which can be self-referenced.

A Formula Object-Orientation = Object (Abstraction) + 2017/4/16 A Formula Object-Orientation = Object (Abstraction) + Class (ADT & Classification) + Inheritance (Reusing) + Dynamic Binding (Polymorphism, Flexibility)

Inheritance(Hierarchy) 2017/4/16 Inheritance(Hierarchy) Expresses commonality among objects Allows code reusability Highlights Generalization/Specialization relationships We will learn more in the following lectures.

2017/4/16 Polymorphism The ability of objects to respond differently to the same message or function call. We will discuss more in the following lectures.

Object-Orientation Evolution 2017/4/16 Object-Orientation Evolution Modules Information hiding Data encapsulation Abstract data types Classes and Objects

2017/4/16 Simply Remember Encapsulation(Data & Operations)--- A technique for Information Hiding-----the users of the objects could not see the details of the data and operations of the objects. Data Abstraction ---- the procedure to find a class from objects. Abstract Data Type---- Class.

Object-Oriented Languages 2017/4/16 Object-Oriented Languages An object-based programming language is one which easily supports object-orientation. Smalltalk:1972-1980, Alan Kay C++:1986, Bjarne Stroustrup Java:1992 (Smalltalk + C++), James Gosling C#: Developed at Microsoft by Anders Hejlsberg et al, 2000 Event driven, object oriented, visual programming language (C++ and Java) Others: Effile, Objective-C, Ada, ...

Programming in the Small and Programming in the Large 2017/4/16 Programming in the Small and Programming in the Large Programming in the Small: One programmer, understands everything from top to bottom. Major problem is the development of algorithms. Programming in the Large: System is developed by large team of programmers Major problems are management of details and communication between programmers and between their respective software subsystems.

Objects and Large Software Systems(1) 2017/4/16 Objects and Large Software Systems(1) Programming in the Small: One programmer, understands everything from top to bottom. Major problem is the development of algorithms. Programming in the Large: System is developed by large team of programmers Major problems are management of details and communication between programmers and between their respective software subsystems.

Objects and Large Software Systems(2) 2017/4/16 Objects and Large Software Systems(2) Object view Makes systems more intuitively understandable Unifies design and programming method Initial program thoughts are informal objects-and-interactions descriptions, even when using a non-OO language. Divides code into logical chunks individuals of a team can be experts in, and outsiders can understand via interfaces Allows "off the shelf" code libraries to be reused Supports code evolution: internals can always be re-written as long as interface stays the same

Objects and Large Software Systems(3) 2017/4/16 Objects and Large Software Systems(3) So, in large software system, we need more CONCEPTS and STRUCTURES of object-orientation than PROGRAMMING SKILLS Those are OOA(Object-Oriented Analysis) and OOD(Object-Oriented Design), that will be discussed more deeply in Software engineering or Software designing methodology.

Summary Methodology (Philosophy) Programming Techniques 2017/4/16 Summary Methodology (Philosophy) Programming Techniques Object-Oriented Languages Object and Large Systems

2017/4/16 The End The End of Lecture 1