Object-Oriented Design

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Object Oriented System Development with VB .NET
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Object-oriented Programming Concepts
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 2 Object-Oriented Design. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 2-2 Chapter Objectives Review the core concepts underlying.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
Programming Languages and Paradigms Object-Oriented Programming.
Systems Analysis and Design in a Changing World, Fifth Edition
Eclipse – making OOP Easy
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
What is inheritance? It is the ability to create a new class from an existing class.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
ISBN Object-Oriented Programming Chapter Chapter
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
OOP Review CS 124.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
Outline Anatomy of a Class Encapsulation Anatomy of a Method Copyright © 2014 Pearson Education, Inc.
ISBN Chapter 12 Support for Object-Oriented Programming.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
Sections Inheritance and Abstract Classes
Object-Oriented Programming Concepts
Polymorphism, Interfaces & Operator Overloading
Inheritance and Polymorphism
Chapter 11 Object-Oriented Design
OOP What is problem? Solution? OOP
Chapter 3: Using Methods, Classes, and Objects
Types of Programming Languages
Anatomy of a Class & Method
Chapter 4: Writing Classes
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Object Oriented Programming
Object Oriented Analysis and Design
Encapsulation & Visibility Modifiers
Ch 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: Classes and Objects.
Advanced Java Topics Chapter 9
Java Inheritance.
Chapter 9 Carrano Chapter 10 Small Java
Workshop for Programming And Systems Management Teachers
Inheritance and Polymorphism
Object Oriented Analysis and Design
Final and Abstract Classes
Lecture 10 Concepts of Programming Languages
Chapter 11 Inheritance and Encapsulation and Polymorphism
Extending Classes Through Inheritance
Presentation transcript:

Object-Oriented Design Chapter 2

Objectives Review core concepts underlying object-oriented programming Review how these concepts are accomplished in a Java program Discuss the use of generic types to define collection classes

Object-Orientation An object is a fundamental entity in a Java program. Java programs also manage primitive data. Primitive data includes common, fundamental values such as numbers and characters. An object usually represents something more sophisticated than primitive data.

OO Orientation An object is defined by a class. A class can be thought of as the data type of the object. A data type is the values and operations on those values Objects manages and protects their own data, this is an example of encapsulation. To request an object to perform an action, you send the object a message

More OO Classes can be inherited from other classes, this is a form of reuse. Using inheritance you can create class hierarchies. Classes, objects, encapsulation, and inheritance are the primary ideas that make up the world of oo software.

Using Objects An object is an abstraction An abstraction hides the precise details of how it works. In fact, those details are irrelevant from the point of view of the client Abstraction is one of the most powerful ideas of OO design

Class Libraries and Packages A class library is a set of classes that supports development of programs. Java has a very rich set of class libraries. Sometimes these are called the Java APIs http://java.sun.com/j2se/1.5.0/docs/api/ The classes in the library are organized into packages.

Packages Packages group logically related classes into a compilation unit Package names have to correspond to a directory structure on your computer Web-CAT will want your package names to be of a form like this: edu.vt.cs.cs1706.projectname I’ll probably go with cs1706.projectname

State and Behavior An object has a set of attributes which define the object state of being. The set of attributes an object will have will depend on context. An object representing a ball in a game will different set of attributes from a ball in an inventory system.

Encapsulation Objects should be encapsulated. The rest of the program should interact with an object only through a well-defined interface. Visibility modifiers allow us to implement encapsulation in Java Public, private and protected

Effects of Public and Private Visibility Variables Violates encapsulation Enforces encapsulation Methods Provides services to clients Supports other methods in the class

References Revisited Objects are stored as references A reference variable that does currently point to an object is a null reference The this reference is a special reference that refers to the currently executing object An alias occurs when two object references refer to the same object. This should be avoided, but isn’t always a bad thing

Interfaces An interface is a collection of constants and abstract methods. Some examples are: Comparable Iterator Comparator Clonable

Inheritance Private data is private even in an inheritance hierarchy A way to allow the subclass to have access to the private data of the parent class is to declare the fields as protected. A subclass can invoke methods of the parent class through the use of the super keyword.

Polymorphism Polymorphism is the ability for a software system to decide at runtime which method is invoked. This is sometimes called dynamic dispatch. You need an inheritance hierarchy. The subclass must overload at least one method. You can then declare an object of the super class and have it refer to the subclass and the subclass method will be invoked.

Generic Types A generic type allows us to define a class so that it stores, operates on, and manages objects whose types is not specified until the class is instantiated. class Box<T> { } T is a placeholder to allow us to define the class.