Understanding the Object Paradigm

Size: px
Start display at page:

Download "Understanding the Object Paradigm"

Transcription

1 2 Understanding the Object Paradigm M MAJOR A J O R T TOPICSO P I C S Objectives Pre-Test Questions Introduction Classes Classes and Functions Abstraction Adding and Naming Classes Operation Visibility Class Responsibility Instantiation Object Communication Object Relationships Application Objects Summary Post-Test Questions... 32

2 18 Chapter 2 Understanding the Object Paradigm OBJECTIVES At the completion of this chapter, you will be able to: Explain the difference between classes and instances. Describe two common method types and their applications. Identify the benefits of abstraction and encapsulation. Describe communication among objects. Define a simple object model using the has a and uses a relationships. Describe Jacobson's application object types. PRE-TEST QUESTIONS The answers to these questions are in Appendix A at the end of this manual. 1. How do abstraction and encapsulation augment the reusability of objects? What three types of objects did Jacobson identify in object-oriented software systems?......

3 Introduction 19 INTRODUCTION In object oriented software design, object dynamics and object communication are vital to system integrity. The organization and accessibility of object properties can be implemented by a variety of structures, including classes, methods, and functions. These are manipulated by processes, such as data instantiation, encapsulation, and abstraction. The classification of object relationships also plays a vital role in organizing object abstraction and inter-system communication. CLASSES Objects are the building blocks of an object-oriented software system. They model realworld collections of information (such as a purchase order) and are able to modify themselves. A class provides the blueprint for an object. For example, a library check-out system manages the movement of thousands of books, as patrons check them out and return them. Each book is represented by an object that maintains properties, such as the title, the author, and the ISBN. A class provides a blueprint for these objects. Throughout this chapter and the next, you will study short code examples written in Java and C++. The following Java code is the class definition of a book: class Book { String title; String author; String isbn; }

4 20 Chapter 2 Understanding the Object Paradigm The same class is defined using C++ as follows: class Book { char *title; char *author; char *isbn; } The properties that form a class are its member variables. The Book class has three member variables: title, author, and ISBN. Once a Book object is instantiated, values can be assigned to its member variables to define the unique characteristics of this book. Both Java and C++ use dot notation to access member variables. The following Java code assigns values to the member variables: catcherintherye.title = "Catcher in the Rye"; catcherintherye.author = "J. D. Salinger"; catcherintherye.isbn = " "; CLASSES AND FUNCTIONS In addition to member variables, classes have methods, which access and modify member data. Programmers who have experience using structured programming languages, such as C and Pascal, will recognize that methods are similar to functions. A method, however, is specific to a particular class. It always takes an action, with respect to the class in which it is defined. As part of a specific class, a method is associated with any object of that class. While it is possible for a class or object to have multiple methods, a method may only access information pertaining to one object. This prevents the exchange of data among objects and limits data corruption.

5 Classes and Functions 21 Imagine a library system developed using a structural programming language. Two abstract data types exist: one representing a book, and a second representing a binary search tree of all books (a book collection). Using C, the code to add a book to the book collection might be similar to the following: addbook(bookcollection, book); A function addbook takes two parameters: a Book to be added and a BookCollection to which you add the Book. The addbook function is defined outside of the definition of the BookCollection data type, even though the two are closely related. In an object-oriented system, addbook would be defined as a method of a BookCollection class. Member methods can be accessed using the same dot notation used to access member data: bookcollection.addbook(book); The addbook method can be thought of as a function in which an instance of BookCollection is implicitly passed. This bundling of functionality with data is fundamental to object-oriented programming. Two common types of methods are accessors and mutators, which are used to access and modify member data. They are used as an alternative to accessing member data directly using the dot notation discussed in the previous section.

6 22 Chapter 2 Understanding the Object Paradigm Accessors Accessor methods can be used to ask an object about itself. Rather than accessing member data directly, accessors provide a safe interface to an object. Following is the Book class definition with accessors added using Java: class Book { String title; String author; String isbn; String gettitle(); String getauthor(); String getisbn(); } The same class is defined using C++ as follows: class Book { char *title; char *author; char *isbn; } char *gettitle(); char *getauthor(); char *getisbn(); In the new class definition, prototypes are added for three accessor methods: gettitle, getauthor, and getisbn. These methods are used to access the member data.

7 Classes and Functions 23 Mutators Mutators are member methods that are used to modify member data. Like accessors, mutators prevent programmers from accessing member data directly. Following is the Book class definition with mutators added using Java: class Book { private String title; private String author; private String isbn; public String gettitle(); public String getauthor(); public String getisbn(); } public void settitle(string); public void setauthor(string); public void setisbn(string);

8 24 Chapter 2 Understanding the Object Paradigm The same class is defined using C++ as follows: class Book { private: char *title; char *author; char *isbn; public: char *gettitle(); char *getauthor(); char *getisbn(); } void settitle(char*); void setauthor(char*); void setisbn(char*); Three mutators have been added to the Book class: settitle, setauthor, and setisbn. The public and private keywords set access privileges for the Book class. The member data is declared as private, which prevents member data from being accessed directly from outside the class. To access the member data, you must use the publicly declared accessors and mutators. Encapsulation The use of accessors and mutators offers many advantages. By hiding the implementation of the Book class, you can make changes to the implementation without disrupting the design of other classes. Consider the C++ class definition in the previous example. Replace the character arrays used to hold the title, author, and ISBN with a string class. Provided that all access to Book data is restricted to accessors and mutators, the change will be transparent to the rest of the program. This type of data protection is called encapsulation. Accessors and mutators can be thought of as surrounding the data that forms a class. Figure 2-1 illustrates the encapsulation of the Book class.

9 Abstraction 25 getisbn title author isbn gettitle getauthor Figure 2-1: Book class ABSTRACTION Encapsulation plays an important role in developing objects as black boxes. The process of developing classes in terms of their interfaces and functionality, instead of their implementation details, is called abstraction. Abstraction is used to manage complexity; software engineers use abstraction to break complex systems into smaller components. As development progresses, programmers know the functionality they can expect from as yet undeveloped subsystems. Thus, programmers are not burdened by considering the ways in which the implementation of later subsystems will affect the design of earlier development.

10 26 Chapter 2 Understanding the Object Paradigm ADDING AND NAMING CLASSES As shown, each class has unique properties, which are known as the class definitions. In the above examples, class definitions include the accessor methods of gettitle(), getauthor(), and getisbn(), and the mutator methods of settitle(), setauthor(), and setisbn(). These definitions are part of a class. Before they can be used, however, an instance must be created. OPERATION VISIBILITY In the above examples of mutators, the functions were grouped into two areas: private and public. This exemplifies the used of object visibility. Object visibility specifies which parts, if any, of a class are visible (i.e. modifiable or viewable) to other parts of a program. There are three major classes of object visibility: public, protected, and private. Public data are those that are visible from anywhere inside a program. In the above examples, the mutators settitle(), setauthor(), and setisbn() are declared public. This occurs because the entire program must be able to see and use those functions to modify the Book class data. Private data are only visible from within their class. The actual variables of Title, Author, and ISBN in the above examples are private, because they do not need to be visible and/or modifiable by the rest of the program. If users can use the publically declared mutators to modify the private data, why make the variables private at all? Although there are many reasons, safety is the most important. By making the data private and only modifiable by the mutators, the data is not directly modifiable by other functions in the program. This way, error checking can be performed before the data is modified, or there can be a log recording which part of the program modified the data. There is also the type of protected. Protected data will only be visible within a certain hierarchy of classes. For example, in a class named Vehicle, which includes subclasses of Car, Truck, and Van, protected data can be visible to the subclasses of Car, Truck, and Van.

11 Class Responsibility 27 CLASS RESPONSIBILITY Each class has its own data and actions, which are known as the class s responsibilities. Anything that the class has knowledge of and/or performs is known as its responsibilities. Using the above examples, the Book class has responsibilities in the form of its Name, Author, and ISBN number. It also has the ability to be checked in or out. This is graphically described in the following diagram. Figure 2-2: Class Responsibility

12 28 Chapter 2 Understanding the Object Paradigm INSTANTIATION Class definitions can be used to create objects. This process is called instantiation, and the objects created are called instances. These instances serve as realizations of the class definitions. Following is the Java code to instantiate a Book object: Book catcherintherye = new Book(); The code to instantiate a Book object using C++ is as follows: Book catcherintherye = Book(); OBJECT COMMUNICATION Due to the black box nature of objects, communication between objects is carried out through messages. Classes not only define objects, but also determine which messages are related to those particular objects. Because all communication and functions of objects are possible with a message interface, no other form of communication is needed. One doesn t even need to know what is contained by an object to use it. In this type of communication, an object cannot be directly modified. Since, code and data are fused within an object in object-oriented software, it is best that the information within an object be left undisturbed so as not to disrupt the normal functionality of the object. Thus, by only allowing communication with objects through their messages, the code and data within the object is protected. This is known as information hiding, or encapsulation. OBJECT RELATIONSHIPS Objects do not exist in isolation, but as part of a larger system of objects that must interact with each other. The most fundamental relationship between objects is the has a relationship. The Java implementation of the Book class has three String attributes: title, author, and ISBN. String is a class, and the relationship between the Book class and the String class is illustrated in Figure 2-3.

13 Object Relationships 29 Figure 2-3: The has a relationship The preceding figure is an example of a Booch class diagram. Grady Booch developed this notation for representing the relationships between the classes that comprise a software system. The simplest relationship is the has a relationship. The filled-in circle at one end of the connecting line indicates that it is the Book that has the String. Objects are more than abstract data types. In addition to their attributes, objects exhibit behavior. In a library check-out system, for example, a library card is issued, a book is checked out, and a patron pays an overdue fine. Accessors and mutators provide an access layer to member data, but other methods exist to give the object more specific behavior. These methods can be denoted with a uses a relationship. Figure 2-4 illustrates the relationship between the Patron, Book and Fine classes. Patron checks out Book pays Fine Figure 2-4: The uses a relationship

14 30 Chapter 2 Understanding the Object Paradigm APPLICATION OBJECTS Ivar Jacobson identified three major types of objects that comprise an object-oriented software system: entity objects, interface objects, and control objects. These types persist in the Unified Process as entity classes, boundary classes, and control classes. Entity objects Entity objects model real-world objects. All of the objects you have studied thus far have been examples of entity objects. The analysis process begins by identifying business information entities, such as different types of reports, customer information, or inventory information. Most of these information entities can be translated directly into entity objects. The business information entities of a library system include books, a book collection, patrons, librarians, addresses, and fees. Each of these can be translated into an entity object. Interface objects Interface objects bridge the gap between a system and its users. The objects that form a graphical user interface are examples of interface objects. Interface objects often take the form of window, terminal, or printer objects. Figure 2-5 illustrates the relationship between interface objects and entity objects. Patron Uses Card Catalog Terminal Searches Book Collection Database Figure 2-5: Interface objects

15 Application Objects 31 For example, patrons interact with a library's information system through a card catalog terminal. In the preceding figure, the card catalog terminal is represented by an interface object. In the completed software system, this interface object would implement the user interface. The Unified Process refers to interface objects as boundary classes because they act as the boundary between a software system and its users. Control objects Control objects implement complex business logic that cannot be easily implemented in either entity or interface objects. Control objects typically represent schedulers, sequencers, and other concepts that can be used to tie a system together. Figure 2-6 illustrates the relationship between control objects and entity objects. Book Collection Database Uses Fine Scheduler Issues Fine Pays Patron Figure 2-6: Control objects For example, fines are issued when a book is overdue. In the preceding figure, the Fine Scheduler object uses information it collects from the Book Collection Database to determine when to issue a fine.

16 32 Chapter 2 Understanding the Object Paradigm SUMMARY Objects are the building blocks of object-oriented software systems. Instantiation is the creation of an object based on class definitions. Encapsulation provides a barrier between users of an object and an object's implementation details. Accessors and mutators accomplish the goal of encapsulation. Encapsulation is closely related to the concept of abstraction. Objects communicate through a message interface. Objects relate to each other in several different ways, and class diagrams are used to denote the relationships between objects. Most objects can be classified as one of three major object types: entity objects, interface objects, or control objects. POST-TEST QUESTIONS The answers to these questions are in Appendix A at the end of this manual. 1. Why do uses a and has a relationships make reusing objects more complicated? Why are class diagrams used?......

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes CS111: PROGRAMMING LANGUAGE II Lecture 1: Introduction to classes Lecture Contents 2 What is a class? Encapsulation Class basics: Data Methods Objects Defining and using a class In Java 3 Java is an object-oriented

More information

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with

More information

Objectives Pre-Test Questions Introduction Collaboration Diagrams Flow of Events and Special Requirements...

Objectives Pre-Test Questions Introduction Collaboration Diagrams Flow of Events and Special Requirements... 10 Analysis Modeling M MAJOR A J O R T TOPICSO P I C S Objectives... 144 Pre-Test Questions...144 Introduction... 145 Collaboration Diagrams... 145 Flow of Events and Special Requirements... 151 Class-Responsibility-Collaboration

More information

Object-Oriented Programming Concepts

Object-Oriented Programming Concepts Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are

More information

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access.

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access. ENCAPSULATION private, public, scope and visibility rules. packages and package level access. Q. Explain the term Encapsulation with an example? Ans: The wrapping up to data and methods into a single units

More information

CS1004: Intro to CS in Java, Spring 2005

CS1004: Intro to CS in Java, Spring 2005 CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a

More information

1. Write two major differences between Object-oriented programming and procedural programming?

1. Write two major differences between Object-oriented programming and procedural programming? 1. Write two major differences between Object-oriented programming and procedural programming? A procedural program is written as a list of instructions, telling the computer, step-by-step, what to do:

More information

Software Development. Modular Design and Algorithm Analysis

Software Development. Modular Design and Algorithm Analysis Software Development Modular Design and Algorithm Analysis Data Encapsulation Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using

More information

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in

More information

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on

More information

Objectives. Explain the purpose and objectives of objectoriented. Develop design class diagrams

Objectives. Explain the purpose and objectives of objectoriented. Develop design class diagrams Objectives Explain the purpose and objectives of objectoriented design Develop design class diagrams Develop interaction diagrams based on the principles of object responsibility and use case controllers

More information

Encapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects

Encapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects Administrative Stuff September 12, 2007 HW3 is due on Friday No new HW will be out this week Next Tuesday we will have Midterm 1: Sep 18 @ 6:30 7:45pm. Location: Curtiss Hall 127 (classroom) On Monday

More information

UML Primer. -Elango Sundaram

UML Primer. -Elango Sundaram UML Primer -Elango Sundaram About UML UML Can be thought of as a blue print for Software Graphical notation for expressing underlying OOA&D ideas Can be used to design any type of application, hardware,

More information

Chapter 4: Writing Classes

Chapter 4: Writing Classes Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own

More information

CS200: Advanced OO in Java

CS200: Advanced OO in Java Object Oriented Programming CS200: Advanced OO in Java n Programming paradigm using Objects : data structures consisting of data fields and methods together with their interaction. n Object? n Class? n

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

Object-Oriented Programming. Objects. Objects. Objects

Object-Oriented Programming. Objects. Objects. Objects References: Beginning Java by Jacquie Barker; Designing Object-Oriented Software by Rebecca Wirfs- Brock;Object-oriented Analysis & Design by Grady Booch; Sara Stoecklin Object Oriented Programming defined

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking

More information

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature 2D1358 Object Oriented Program Construction in C++ Exercises & Labs Lecturer: Frank Hoffmann hoffmann@nada.kth.se Assistents: Danica Kragic danik @nada.kth.se Anders Orebäck oreback @nada.kth.se Peter

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Object-Oriented Systems Analysis and Design Using UML

Object-Oriented Systems Analysis and Design Using UML 10 Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design, 8e Kendall & Kendall Copyright 2011 Pearson Education, Inc. Publishing as Prentice Hall Learning Objectives Understand

More information

Introduction to OO Concepts

Introduction to OO Concepts Introduction to OO Concepts Written by John Bell for CS 342, Fall 2018 Based on chapters 1, 2, and 10 of The Object-Oriented Thought Process by Matt Weisfeld, with additional material from UML Distilled

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

Module 10 Inheritance, Virtual Functions, and Polymorphism

Module 10 Inheritance, Virtual Functions, and Polymorphism Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:

More information

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation

More information

EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1

EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1 FACULTY OF SCIENCE AND TECHNOLOGY EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1 ACADEMIC SESSION 2014; SEMESTER 2 PRG1203:

More information

Object-Oriented Programming

Object-Oriented Programming References: Beginning Java Objects by Jacquie Barker; Designing Object-Oriented Software by Rebecca Wirfs- Brock;Object-oriented Analysis & Design by Grady Booch; Sara Stoecklin 9/11/2003 1 Object Oriented

More information

CSCE 156 Computer Science II

CSCE 156 Computer Science II CSCE 156 Computer Science II Lab 04 - Classes & Constructors Dr. Chris Bourke Prior to Lab 1. Review this laboratory handout prior to lab. 2. Read Object Creation tutorial: http://download.oracle.com/javase/tutorial/java/javaoo/objectcreation.

More information

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci) Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci) Sung Hee Park Department of Mathematics and Computer Science Virginia State University September 18, 2012 The Object-Oriented Paradigm

More information

13. Java Classes. Educational Objectives. Classes - Technical. Definition: Classes

13. Java Classes. Educational Objectives. Classes - Technical. Definition: Classes Educational Objectives You can create your own classes/data types. You understand how objects are being instantiated and used. You know the term encapsulation and are able to your situation. 13. Java Classes

More information

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator. Comparative Study In Utilization Of Creational And Structural Design Patterns In Solving Design Problems K.Wseem Abrar M.Tech., Student, Dept. of CSE, Amina Institute of Technology, Shamirpet, Hyderabad

More information

1. Software Systems Complexity, OO Paradigm, UML

1. Software Systems Complexity, OO Paradigm, UML 1. Software Systems Complexity, OO Paradigm, UML Software Systems Complexity Inherent Arbitrary Complexity Problem Domain Complexity Expressing the Requirements Changing Requirements System Evolution -

More information

JAVA: A Primer. By: Amrita Rajagopal

JAVA: A Primer. By: Amrita Rajagopal JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management

More information

JAVA GUI PROGRAMMING REVISION TOUR III

JAVA GUI PROGRAMMING REVISION TOUR III 1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

Classes and Objects. CGS 3416 Spring 2018

Classes and Objects. CGS 3416 Spring 2018 Classes and Objects CGS 3416 Spring 2018 Classes and Objects An object is an encapsulation of data along with functions that act upon that data. It attempts to mirror the real world, where objects have

More information

CS 152 Computer Programming Fundamentals Lab 7: Book and Author Objects

CS 152 Computer Programming Fundamentals Lab 7: Book and Author Objects CS 152 Computer Programming Fundamentals Lab 7: Book and Author Objects Brooke Chenoweth Fall 2018 1 Assignment Description To give you some practice creating and using classes, you are going to write

More information

Anatomy of a Class Encapsulation Anatomy of a Method

Anatomy of a Class Encapsulation Anatomy of a Method Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and

More information

Defining Classes and Methods

Defining Classes and Methods Defining Classes and Methods Chapter 5 Modified by James O Reilly Class and Method Definitions OOP- Object Oriented Programming Big Ideas: Group data and related functions (methods) into Objects (Encapsulation)

More information

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is

More information

Object- Oriented Design with UML and Java Part I: Fundamentals

Object- Oriented Design with UML and Java Part I: Fundamentals Object- Oriented Design with UML and Java Part I: Fundamentals University of Colorado 1999-2002 CSCI-4448 - Object-Oriented Programming and Design These notes as free PDF files: http://www.softwarefederation.com/cs4448.html

More information

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis UNIT I INTRODUCTION OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis Design Implementation Testing Maintenance

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

James Newkirk

James Newkirk Private Interface Class Structural James Newkirk newkirk@oma.com Intent Provide a mechanism that allows specific classes to use a non-public subset of a class interface without inadvertently increasing

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes

More information

10. Java Classes. Classes - Technical. Example: Earthquake catalog. Classes - Conceptual

10. Java Classes. Classes - Technical. Example: Earthquake catalog. Classes - Conceptual Classes - Technical A class is an entity with a name that contains data and functionality 10. Java Classes Classes, types, objects, declaration, instantiation, constructors, encapsulation, static fields

More information

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3

More information

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Today we are going to talk about an important aspect of design that is reusability of design. How much our old design

More information

Course 3 7 March

Course 3 7 March Course 3 7 March adiftene@info.uaic.ro 1 From Courses 1, 2 Modeling Modeling Languages Graphic Languages UML History UML Definition UML Diagram Types UML Use Case Diagram Actors Use Case UML Class Diagrams

More information

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

Lecturer: Sebastian Coope Ashton Building, Room G.18   COMP 201 web-page: Lecturer: Sebastian Coope Ashton Building, Room G.18 E-mail: coopes@liverpool.ac.uk COMP 201 web-page: http://www.csc.liv.ac.uk/~coopes/comp201 Lecture 17 Concepts of Object Oriented Design Object-Oriented

More information

OOAD - OBJECT MODEL. The concepts of objects and classes are intrinsically linked with each other and form the foundation of object oriented paradigm.

OOAD - OBJECT MODEL. The concepts of objects and classes are intrinsically linked with each other and form the foundation of object oriented paradigm. OOAD - OBJECT MODEL http://www.tutorialspoint.com/object_oriented_analysis_design/ooad_object_oriented_model.htm Copyright tutorialspoint.com The object model visualizes the elements in a software application

More information

Objects and Classes -- Introduction

Objects and Classes -- Introduction Objects and Classes -- Introduction Now that some low-level programming concepts have been established, we can examine objects in more detail Chapter 4 focuses on: the concept of objects the use of classes

More information

Object oriented programming Concepts

Object oriented programming Concepts Object oriented programming Concepts Naresh Proddaturi 09/10/2012 Naresh Proddaturi 1 Problems with Procedural language Data is accessible to all functions It views a program as a series of steps to be

More information

Methods and Data (Savitch, Chapter 5)

Methods and Data (Savitch, Chapter 5) Methods and Data (Savitch, Chapter 5) TOPICS Invoking Methods Return Values Local Variables Method Parameters Public versus Private 2 public class Temperature { public static void main(string[] args) {

More information

Defining Classes and Methods

Defining Classes and Methods Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 ISBN 0136091113 2009 Pearson Education, Inc., Upper Saddle River, NJ. All Rights Reserved Objectives Describe concepts of class, class

More information

Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis

Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics in C++ Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. 12.1 Procedural and Object-Oriented

More information

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool Design Patterns What are Design Patterns? What are Design Patterns? Why Patterns? Canonical Cataloging Other Design Patterns Books: Freeman, Eric and Elisabeth Freeman with Kathy Sierra and Bert Bates.

More information

5. Defining Classes and Methods

5. Defining Classes and Methods 5. Defining Classes and Methods Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch/info1 Objectives! Describe and define concepts of class and object! Describe use

More information

CLASSES AND OBJECTS IN JAVA

CLASSES AND OBJECTS IN JAVA Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class

More information

administrivia today UML start design patterns Tuesday, September 28, 2010

administrivia today UML start design patterns Tuesday, September 28, 2010 administrivia Assignment 2? promise to get past assignment 1 back soon exam on monday review slides are posted your responsibility to review covers through last week today UML start design patterns 1 Unified

More information

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal COMSC-051 Java Programming Part 1 Part-Time Instructor: Joenil Mistal Chapter 4 4 Moving Toward Object- Oriented Programming This chapter provides a provides an overview of basic concepts of the object-oriented

More information

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System?

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System? Page 1 of 21 Page 2 of 21 and identity. Objects are members of a class, and the attributes and behavior of an object are defined by the class definition. The Essence of Object Oriented Programming with

More information

CHAPTER 5 GENERAL OOP CONCEPTS

CHAPTER 5 GENERAL OOP CONCEPTS CHAPTER 5 GENERAL OOP CONCEPTS EVOLUTION OF SOFTWARE A PROGRAMMING LANGUAGE SHOULD SERVE 2 RELATED PURPOSES : 1. It should provide a vehicle for programmer to specify actions to be executed. 2. It should

More information

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh SOFTWARE DESIGN COSC 4353 / 6353 Dr. Raj Singh UML - History 2 The Unified Modeling Language (UML) is a general purpose modeling language designed to provide a standard way to visualize the design of a

More information

Anatomy of a Method. HW3 is due Today. September 15, Midterm 1. Quick review of last lecture. Encapsulation. Encapsulation

Anatomy of a Method. HW3 is due Today. September 15, Midterm 1. Quick review of last lecture. Encapsulation. Encapsulation Anatomy of a Method September 15, 2006 HW3 is due Today ComS 207: Programming I (in Java) Iowa State University, FALL 2006 Instructor: Alexander Stoytchev Midterm 1 Next Tuesday Sep 19 @ 6:30 7:45pm. Location:

More information

06. Analysis Modeling

06. Analysis Modeling 06. Analysis Modeling Division of Computer Science, College of Computing Hanyang University ERICA Campus 1 st Semester 2017 Overview of Analysis Modeling 1 Requirement Analysis 2 Analysis Modeling Approaches

More information

The Open Group SOA Ontology Technical Standard. Clive Hatton

The Open Group SOA Ontology Technical Standard. Clive Hatton The Open Group SOA Ontology Technical Standard Clive Hatton The Open Group Releases SOA Ontology Standard To Increase SOA Adoption and Success Rates Ontology Fosters Common Understanding of SOA Concepts

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

CSCU9T4: Managing Information

CSCU9T4: Managing Information CSCU9T4: Managing Information CSCU9T4 Spring 2016 1 The Module Module co-ordinator: Dr Gabriela Ochoa Lectures by: Prof Leslie Smith (l.s.smith@cs.stir.ac.uk) and Dr Nadarajen Veerapen (nve@cs.stir.ac.uk)

More information

Design Patterns. An introduction

Design Patterns. An introduction Design Patterns An introduction Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at

More information

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy

More information

Basic Object-Orientation

Basic Object-Orientation Basic Object-Orientation Chapters 2 and 4 / Hour 2 2002, Delroy A. Brinkerhoff Basic Object-Orientation Slide 1 of 21 Chapters 2 and 4 / Hour 2 # Objects and Classes # Abstraction and classification (generalization)

More information

INTERNAL ASSESSMENT TEST III Answer Schema

INTERNAL ASSESSMENT TEST III Answer Schema INTERNAL ASSESSMENT TEST III Answer Schema Subject& Code: Object-Oriented Modeling and Design (15CS551) Sem: V ISE (A & B) Q. No. Questions Marks 1. a. Ans Explain the steps or iterations involved in object

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

Information systems modelling UML and service description languages

Information systems modelling UML and service description languages Internet Engineering Tomasz Babczyński, Zofia Kruczkiewicz Tomasz Kubik Information systems modelling UML and service description languages Overview of design patterns for supporting information systems

More information

ACRONYMS AND GLOSSARY

ACRONYMS AND GLOSSARY Appendix A ACRONYMS AND GLOSSARY SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC. 1 Acronyms Acronym 1NF 1ONF 2NF 2ONF 2ONF 3NF 3ONF API CASE CORBA CRUD DFD FLOOT IDL Java VM ODMG OMG OODBMS OOUI OQL ODBC OOCRUD

More information

Defining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5

Defining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5 Defining Classes and Methods Chapter 5 Objectives Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters in a method Use modifiers public,

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012 UML & OO Fundamentals CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation

More information

Object Oriented Programming

Object Oriented Programming bject riented Programming ecture 3 lide No. n object is like a black box. The internal details are hidden. hat is bject riented Programming? Identifying objects and assigning responsibilities to these

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Introduction to Classes

Introduction to Classes Introduction to Classes Procedural and Object-Oriented Programming Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a program Object-Oriented

More information

CHAPTER 1. Objects, UML, and Java

CHAPTER 1. Objects, UML, and Java chpt_01.fm Page 1 Tuesday, December 4, 2001 10:24 AM CHAPTER 1 Objects, UML, and Java This book is about object-oriented (OO) software development. Writing real object-oriented programs that are used by

More information

CS112 Lecture: Working with Numbers

CS112 Lecture: Working with Numbers CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations

More information

Encapsulation. Mason Vail Boise State University Computer Science

Encapsulation. Mason Vail Boise State University Computer Science Encapsulation Mason Vail Boise State University Computer Science Pillars of Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction (sometimes) Object Identity Data (variables) make

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Unified Modeling Language (UML) Department of Computer Science University of Maryland, College Park UML (Unified Modeling Language) UML is a modeling language for

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Objectives. Defining Classes and Methods. Objectives. Class and Method Definitions: Outline 7/13/09

Objectives. Defining Classes and Methods. Objectives. Class and Method Definitions: Outline 7/13/09 Objectives Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters

More information

An Introduction to Patterns

An Introduction to Patterns An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture

More information

Software Service Engineering

Software Service Engineering Software Service Engineering Lecture 4: Unified Modeling Language Doctor Guangyu Gao Some contents and notes selected from Fowler, M. UML Distilled, 3rd edition. Addison-Wesley Unified Modeling Language

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects Lecture 4: Fundamentals of Object Technology Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Credit where Credit is Due Some material presented in this lecture

More information

May Comp-B 11, Advanced Software Design. 3 hours duration

May Comp-B 11, Advanced Software Design. 3 hours duration May 2016 98-Comp-B 11, Advanced Software Design 3 hours duration NOTES: 1. If doubt exists as to the interpretation of any question, the candidate is urged to submit, with the answer paper, a clear statement

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

Module Outline. What is Object-Oriented? Some Possible Definitions. Why Object-oriented? Fundamentals of Object Orientation

Module Outline. What is Object-Oriented? Some Possible Definitions. Why Object-oriented? Fundamentals of Object Orientation Module Outline Fundamentals of Object Positioning Object Oriented Analysis Fundamentals of Object 1. Encapsulation 2. Abstraction 3. Inheritance 4. Polymorphism The need of Modeling Unified modeling language

More information