Object-oriented Design in Processing

Slides:



Advertisements
Similar presentations
Object-Oriented Programming
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Written by: Dr. JJ Shepherd
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Object-Oriented Databases v OO systems associated with – graphical user interface (GUI) – powerful modeling techniques – advanced data management capabilities.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Basic OOP Concepts and Terms
Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 10 Classes Continued
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
11/28/2015B.Ramamurthy1 Object-Oriented Design and Java B.Ramamurthy.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
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.
Object-Oriented Design Bina Ramamurthy SUNY at Buffalo.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object-Oriented Programming Concepts
Chapter 7 Object-Oriented Programming
The Movement To Objects
Inheritance ITI1121 Nour El Kadri.
Classes and OOP.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Creating Your OwnClasses
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Section 11.1 Class Variables and Methods
Introduction to Object-oriented Program Design
Chapter 7 Classes & Objects.
Inheritance B.Ramamurthy 11/7/2018 B.Ramamurthy.
HIGHLEVEL REVIEW Chapter 9 Objects and Classes
Computer Programming.
One class is an extension of another.
Corresponds with Chapter 7
Object-oriented Design in Processing
Object-Oriented Programming
Chapter 9 Classes & Objects.
Chapter 9 Objects and Classes
Problem Solving, Object-Oriented Design and Java
Java Programming Course
Object-Oriented Programming
Object-oriented Design in Processing
Problem Solving, Object-Oriented Design and Java
COP 3330 Object-oriented Programming in C++
Object-Oriented Programming
B.Ramamurthy Copyright 1998 CSE Department
Basic OOP Concepts and Terms
Java Statements B.Ramamurthy CS114A, CS504 4/23/2019 BR.
Object-oriented Design in Processing
CPS120: Introduction to Computer Science
Final and Abstract Classes
Object-Oriented Programming
Chapter 7 Objects and Classes
Object-Oriented Programming and class Design
Presentation transcript:

Object-oriented Design in Processing B. Ramamurthy Pages 395-419

The OO Concept When you write small programs functional decomposition or collection of function efficiently solve the problem When you solve complex problem with multiple objects interacting, a better and proven way to design the solution is using Object-oriented design (OOD). When you implement a OOD using an object-oriented programming language it is called a object-oriented program. We will study here the foundations of OOD and OOP.

Object-Oriented Principles OOP Inheritance -- Hierarchy -- Reusability -- Extensibility -- Expressive power -- Reflects many real-world problems Polymorphism -- Many forms of same function Encapsulation (class) -- Information Hiding -- Interface and Implementations -- Standardization -- Access Control mechanisms (private /public etc.) 8/3/2019

What is an Object? Object-oriented programming supports the view that programs are composed of objects that interact with one another. How would you describe an object? Using its characteristics (has a ----?) and its behaviors (can do ----?) Object must have unique identity (name) : Basketball, Blue ball Consider a ball: Color and diameter are characteristics (Data Declarations) throw, bounce, roll are behaviors (Methods) 8/3/2019

Classes are Blueprints A class defines the general nature of a collection of objects of the same type. The process creating an object from a class is called instantiation. Every object is an instance of a particular class. There can be many instances of objects from the same class possible with different values for data. 8/3/2019

Example objects Object References redRose class Rose blueRose class 8/3/2019

Bouquet Class Many instances of real bouquet objects of this Class can be instantiated 8/3/2019

Elements of a Class class data declarations (variables, constants) methods header body header statements modifiers, type, name variables, constants parameters repetition others selection assignment 8/3/2019

Class Structure class variables constants methods 8/3/2019

Defining Classes Syntax: class class_name { data-declarations constructors methods } Constructors are special methods used for instantiating (or creating) objects from a class. Data declarations are implemented using variable and constant declarations. 8/3/2019

Operator new and “dot” new operator creates a object and returns a reference to that object. After an object has been instantiated, you can use dot operator to access its methods and data declarations (if you have access permissions). 8/3/2019

Example Ball Class Class is an object blueprint; you can create as many objects as you need from a class Objects have attributes/characteristics Objects have behavior/capabilities/operations/functions Need a function to create an object… called a constructor There can more than one constructor for a class depending on the parameters

Class Ball class ball { // attributes float x, y; //position color ballColor; float radius; // operations //constructor ball() { x = random(width); y = random(height); ballColor = color(255, 0, 0); radius = 25; }

Add display behavior void display() { noStroke(); fill(ballColor); ellipse(x,y,2*radius, 2*radius); } Lets see how this works. How to create a ball? Using its constructor: Example b1 = new ball();

Box Class Lets add a box class And create many balls in the box class.