Chapter 12 Object Oriented Design.  Complements top-down design  Data-centered view of design  Reliable  Cost-effective.

Slides:



Advertisements
Similar presentations
Object-Oriented Programming
Advertisements

Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
Chapter 1 Object-Oriented Concepts. A class consists of variables called fields together with functions called methods that act on those fields.
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Object Oriented Programming CS115. Object Oriented Design Most modern computer applications are designed using a data-centered view of computing called.
I210 review (for final exam) Fall 2011, IUB. What’s in the Final Exam Multiple Choice (5) Short Answer (5) Program Completion (3) Note: A single-sided.
Chapter 9 High-Level Programming Languages: C++. Chapter Goals Describe the expectations of high level languages Distinguish between functional design.
Object Oriented Software Development
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Introduction to Object-oriented programming and software development Lecture 1.
Chapter 8 More Object Concepts
CIT 590 Intro to Programming Style Classes. Remember to finish up findAllCISCourses.py.
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Guide to Programming with Python Week 11 Chapter Nine Inheritance Working with multiple objects.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
1 Programming for Engineers in Python Autumn Lecture 6: More Object Oriented Programming.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Data Structures Using C++ 2E
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Salman Marvasti Sharif University of Technology Winter 2015.
Object-Oriented Programming Chapter Chapter
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Guide to Programming with Python Chapter Eight (Part I) Object Oriented Programming; Classes, constructors, attributes, and methods.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Object-Oriented Principals Dwight Deugo Nesa Matic
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.
Chapter 4Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapters 4 and 5: Excerpts l Class and Method Definitions l Information.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
CMSC201 Computer Science I for Majors Lecture 25 – Classes
OOP - Object Oriented Programming
Object-Oriented Design
Algorithms and Problem Solving
Guide to Programming with Python
Programming Logic and Design Seventh Edition
Advanced Object-Oriented Programming
About the Presentations
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Lecture VI Objects The OOP Concept Defining Classes Methods
MSIS 670 Object-Oriented Software Engineering
Algorithms and Problem Solving
Workshop for Programming And Systems Management Teachers
Chapter 22 Object-Oriented Systems Analysis and Design and UML
C++ Object Oriented 1.
Presentation transcript:

Chapter 12 Object Oriented Design

 Complements top-down design  Data-centered view of design  Reliable  Cost-effective

Black Boxes (provide services) Interfaces Clients/ Users

 In top-down design, black boxes are functions.  In OOD, black boxes are objects.  This is just a simplification of SEPARATION OF CONCERNS. Services or tasks to be performed are ENCAPSULATED in a function or object.  Of course, the guts of any object is the class definition behind it.  OOD centers on breaking the problem down into logical groupings and defining classes for those groupings.

 Look at nouns in problem statement  Find things that can be grouped together  Find things/data that might be represented with a primitive data type (numbers, strings).

 Once you’ve located logical groupings of data or tasks, identify the kinds of data needed to make this grouping of data/tasks work within the whole program.

 Go back to your original list of objects needed (now complicated with the instance variables needed) and identify the actions which must be taken on that dtata.  Circle verbs in the problem statement.  All manipulation of an object’s data must be performed through methods defined in the class statement which creates the object.

 Find the most complicated methods, and work at coding them.  Use top-down design and step-wise refinement to flesh out the methods.  Step-wise refinement: start with high-level, abstract description and add details.  Look for other classes the method may have to interact with.  Look for new methods that need to be added to other classes, or new classes that are needed.

 As you work on modules, functions and classes, you will need to go back to other classes, functions, etc., to make changes. Working on just one module means it may not work at all when you run it; it needs interaction with other modules.  Add just a line or two of code, and test to see if it a) meets syntax rules and b) performs what it’s supposed to perform.

 Sometimes a whole module just doesn’t seem to work out. You can tell this when you’re repeating code in another class or in main() that should have been handled in one module.  You can keep that code by either commenting it out or saving multiple versions of your program as you go ( jehp7ver04.py )

 Keep asking yourself, is this instance variable needed? Does this method accomplish what it’s supposed to do?  Eschew complexity. Embrace simplicity.

 Packaging data and methods together on one object is encapsulation.  We can also define encapsulation as hiding the details of an operation in an object.  Encapsulation is the primary concept which distinguishes OOP because it groups data and actions intuitively in objects, mimicking real life.  The implementation of an object (its definition) is independent of its use because of encapsulation.

 Encapsulation allows us to isolate major tasks or decisions in a program by grouping data and methods in one package.  Revisions to the code will be easier—change the definition (implementation) of an object but not its use.  Because revisions are easier, fewer errors will be introduced  Supports code re-use  By itself it makes a language object-based.

 “many forms”: allows a single line of code to implement different actions depending on the type or class of the object.  The same method invocation/call could be used with different objects with different results.  myArtBox = [myCirc, myOval, myLine] for obj in myArtBox: obj.draw(win)  The last line is polymorphic: it invokes many different forms—circle, oval, line.

 class Animal:  def __init__(self, name): # Constructor of the class  self.name = name  class Cat(Animal):  def talk(self):  return 'Meow!'  class Dog(Animal):  def talk(self):  return 'Woof! Woof!'  animals = [Cat('Missy'),  Cat('Mr. Bojangles'),  Dog('Lassie')]  for animal in animals:  print animal.name + ': ' + animal.talk()  # prints the following:  # Missy: Meow!  # Mr. Bojangles: Meow!  # Lassie: Woof! Woof!

 Flexibility. An action similar for different objects can be written once but executed correctly and differently depending on the object(s) on which it is executed.  Simplicity of code. Reduces the necessity of writing multiple functions or methods to achieve processes.

 Inheritance is the idea that a subclass, created from a superclass, inherits behavior from its superclass.  Or, in other words, if a new class is created as a smaller specialization of a larger class, the new class will borrow attributes from the existing class.  In the example preceding, Cat and Dog are subclasses of the superclass Animal.  We can also think of subclasses as children classes and the superclass as a parent class.

 In Python, a subclass can actually inherit from more than one superclass. In the animals— dogs—cats example, Dog and Cat classes might also inherit attributes from another superclass called Pets. If Pets included a Boolean instance variable for ‘groomed’ (True or False) then subclasses Dog and Cat would inherit that data field as well as everything in the Animal superclass.

 Classes can be structured to avoid duplicating methods.  This reduces the introduction of new error.  Inheritance promotes code re-use.

 In groups of two or three, locate data groupings needed for Programming Exercise # 3 or 4, depending on which you have been assigned.  List actions/methods specified.  Using pseudocode, plan modules that will perform the needed tasks and make use of the objects you identified.

 Use the OOD principles you used in the previous workshop to block out objects and actions for our final project.