Chapter 10 Thinking in Objects Part 1

Slides:



Advertisements
Similar presentations
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
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 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
Introduction To System Analysis and Design
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 9 Thinking in Objects.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 7 Object-Oriented Programming.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Computer Science 240 Principles of Software Design.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction To System Analysis and design
Object Oriented Software Development
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Thinking in Objects.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
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.
Introduction to Object-oriented programming and software development Lecture 1.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
Object Oriented Concepts & Principles Ingrid Kirschning & Gerardo Ayala.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 10 Thinking in Objects.
Introduction To System Analysis and Design
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
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.
Abstraction ADTs, Information Hiding and Encapsulation.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 10 More on Objects and Classes.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CS 112 Programming 2 Lecture 04 Thinking in Objects (1)
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Thinking in Objects.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Fall 2013 Chapter 10 Thinking.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
CSC 427: Data Structures and Algorithm Analysis
Chapter 10 Thinking in Objects
Programming paradigms
CSC 222: Computer Programming II
Object Oriented Programming
Chapter 7 Object-Oriented Programming
Chapter 10 Thinking in Objects
Reference: COS240 Syllabus
Chapter 10 Thinking in Objects
Chapter 9 More on Objects and Classes
Chapter 11 Object-Oriented Design
Data Abstraction: The Walls
Reference: COS240 Syllabus
Chapter 10 Thinking in Objects
OBJECT ORIENTED PROGRAMMING overview
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Object Oriented Concepts
 DATAABSTRACTION  INSTANCES& SCHEMAS  DATA MODELS.
Chapter 9 Thinking in Objects
Chapter 10 Thinking in Objects
Chapter 10 Thinking in Objects
Chapter 9 Objects and Classes
Chapter 0 : Introduction to Object Oriented Design
Chapter 9 Thinking in Objects
CIS601: Object-Oriented Programming in C++
Chapter 10 Thinking in Objects
Workshop for Programming And Systems Management Teachers
Chapter 2. Problem Solving and Software Engineering
Object-Oriented PHP (1)
Object Oriented Design & Analysis
Chapter 10 Thinking in Objects
ADVANCED OBJECT-ORIENTED PROGRAMMING
Presentation transcript:

Chapter 10 Thinking in Objects Part 1

Class Abstraction & Encapsulation Class abstraction means to separate class implementation from the use of the class The creator of the class provides a description of the class and let the user know how the class can be used The user of the class does not need to know how the class is implemented. The detail of implementation is encapsulated and hidden from the user Example: The use of a PC does not require the knowledge of its internal workings

Example: The Loan Class A specific loan can be viewed as an object of a Loan class. The interest rate, amount, and period are its properties, and computing the monthly & total payments are its methods. When you buy a car, a loan object is created by instantiating the class with your loan interest rate, amount, and period. You can then use the methods to find the monthly & total payments. As a user of the Loan class, you don’t need to know how these methods are implemented Example: The Loan Class Loan TestLoanClass Run

Object-Oriented Thinking Chapters 1-8 introduced fundamental programming techniques for problem solving using loops, methods, and arrays. The studies of these techniques lay a solid foundation for object- oriented programming Classes provide more flexibility and modularity for building reusable software. This section improves the solution for a problem introduced in Chapter 3 using the object-oriented approach From the improvements, you will gain the insight on the differences between the procedural programming and object- oriented programming and see the benefits of developing reusable code using objects and classes

Example: The BMI Class BMI UseBMIClass In procedural programming, data & operations on the data are separate. It requires passing data to methods. The OO approach mirrors the real world, in which objects are associated with both data & operations. Using objects improves reusability, making programs easier to develop and maintain. An OO program can be viewed as a collection of cooperating objects. This example is an OO version of the procedural program of Listing 3.4 Example: The BMI Class BMI UseBMIClass Run

Class Relationships Association Aggregation Composition Inheritance Association is a general binary relationship that describes an activity between two classes

Aggregation Composition A "uses" B. B exists independently (conceptually) from A Example: A Company is an aggregation of People A Company is a composition of Accounts When a Company ceases to do business its Accounts cease to exist but its People continue to exist Composition A "owns" B. B has no meaning or purpose in the system without A Example: A Text Editor owns a Buffer (composition) A Text Editor uses a File (aggregation) When Text Editor is closes, the Buffer is destroyed but the File is not Source: programmers.stackexchange.com/questions/61376/aggregation-vs-composition/61527#61527

Aggregation & Composition Composition is actually a special case of the aggregation relationship Aggregation models has-a relationships and represents an ownership relationship between two objects The owner object is called an aggregating object and its class an aggregating class. The subject object is called an aggregated object and its class an aggregated class

Aggregation & Composition An aggregation relationship is represented as a data field in the aggregating class

Aggregation Between Same Class Aggregation may exist between objects of the same class public class Person { // The type for the data is the class itself private Person supervisor; ... }

Aggregation Between Same Class What happens if a person has several supervisors?

Example: The Course Class The Course class encapsulates the internal implementation. The user can create a Course object and manipulate it through the public methods addStudent, dropStudent, getNumOfStudents and getStudents. However, the user doesn’t need to know how these methods are implemented This example uses an array to store students, but you could use a different data structure to store students. The program that uses Course does not need to change as long as the contract of the public methods remains unchanged Course TestCourse Run

Source: https://www.youtube.com/watch?v=CgFVgp_VCN8 Stack in Motion Source: https://www.youtube.com/watch?v=CgFVgp_VCN8

Example: Stack of Integers

Stack of Integers

The StackOfIntegers Class TestStackOfIntegers Run