Intro to Computer Science II

Slides:



Advertisements
Similar presentations
Object-Oriented Design Keith T. Weber, GISP GIS Director, ISU.
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
BITS Pilani Avinash Gautam Department of Computer Science and Information Systems.
Chapter 10 Introduction to Objects and Classess 1.
CS-2135 Object Oriented Programming
L3-1-S1 OO Concepts © M.E. Fayad SJSU -- CMPE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
BACS 287 Basics of Object-Oriented Programming 1.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Introduction to Object-oriented programming and software development Lecture 1.
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
Object Oriented Programming Lecturer: Andreas P. Adi
Object Oriented Programming CS160 - OOP. Objects Objects are a Objects are a way to organize and conceptualize a program as a set of interacting objects.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
1 Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill Chapter 2: Object Basics Object-Oriented Systems Development Using the Unified Modeling.
Object-Oriented Programming (OOP) Lecture No. 4. Recap – Inheritance ► Derived class inherits all the characteristics of the base class ► Besides inherited.
CSC480 Software Engineering Lecture 11 September 30, 2002.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
Basic Concepts of Object Orientation Object-Oriented Analysis CIM2566 Bavy LI.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
AP Computer Science A – Healdsburg High School 1 Inheritance - What is inheritance? - “Is-a” vs. “Has-a” relationship - Programming example “CircleBug”
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
CSC241 Object-Oriented Programming (OOP) Lecture No. 2.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Inheritance and Polymorphism
Slide design: Dr. Mark L. Hornick
UML Class & Object Diagram I
Object-Oriented Programming (OOP) Lecture No. 4
OOP - Object Oriented Programming
Unit - 3 OBJECT ORIENTED DESIGN PROCESS AND AXIOMS
CompSci 280 S Introduction to Software Development
Programming paradigms
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Object-Orientated Programming
Object Oriented Programming Spring Semester
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Programming Logic and Design Seventh Edition
Intro to OOP with Java, C. Thomas Wu CHAPTER 2 Introduction to OOP
University of Central Florida COP 3330 Object Oriented Programming
CHAPTER 5 GENERAL OOP CONCEPTS.
Lesson Objectives Aims Key Words
Objects as a programming concept
University of Central Florida COP 3330 Object Oriented Programming
OBJECT ORIENTED PROGRAMMING overview
INTRODUCTION TO OOP Objective:
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
The Object Oriented Approach to Design
Chapter 10 Thinking in Objects
3. Object-oriented Design
MSIS 670 Object-Oriented Software Engineering
Object-Oriented Design
topics object oriented design objects and classes properties
Extended Learning Module G
BCA-II Object Oriented Programming using C++
Workshop for Programming And Systems Management Teachers
Object Oriented Analysis and Design
Object-Oriented PHP (1)
Object-Oriented Programming
Programming For Big Data
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
Object-Oriented Design
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Presentation transcript:

Intro to Computer Science II Object-Oriented Design 1

Object-Oriented Design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design.

Object-Oriented Design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Objects – Any physical or logical elements. Objects are distinguished first by their classification (or just class) Objects classified as Dogs are different than you and I, which are classified as Human Objects of a specific class are called instances of the class. You and I are instances of Human

Objects have a set of characteristics that make them unique What are some of our characteristics that make each of us unique? Eye color, Hair color, Sleeping, Hungry In O-O terminology, these are called attributes, or fields, or properties Characteristics (attributes) have values These values determine the state of an object at any time Most values are temporal, changing over time (for example, hair!) NOTE - If they are not temporal, then they may make good named constants in your code

Examples of Classes and Objects

Fruit Characteristics (attributes) Methods Name Color Weight be_eaten()

Apple(Fruit) Additional attributes None Additional methods throw()

Orange(Fruit) Additional features None Additional methods squeeze()

Person Attributes Name Age Place of birth Methods eat() walk() sleep()

Student(Person) Attributes Methods Major Class year GPA attend_class() take_exam() play_club_sports()

Employee(Person) Attributes Methods Department Work schedule get_paid() attend_meeting()

Your example(s)?

Encapsulation and O-O design The grouping of data and methods together into one package in such a way that the internal representation of the object is hidden All interaction with the object is performed only through the object's methods Why is encapsulation an important part of the design process? An object should always manage its own internal state! An object is responsible for itself and how it carries out its own actions An object should always manage its own internal state. It is responsible for how it carries out its own actions! Analogous to how a restaurant operates

Encapsulation Example Our Array class example: How Array class is defined is hidden, weather an array of ctype objects, or a Python list To the outside world, all we need to know is how to use it grades = Array2D(7, 3) What are the factors here? What would you need to know?

OO Design: Coupling vs. Cohesion Coupling – (aka dependency) – the degree to which each object relies on all of the other objects in the system Cohesion – the degree to which all of the functionality in an object are related What does a good OOD strive for? Low coupling High coupling means high interclass dependencies Minimize coupling to avoid a "snowball effect" of change in one class High cohesion All public data and methods should all be related directly to the concept the class represents

Relationship: Inheritance The strongest class relationship Models the “is-a” relationship From an SE view, inheritance is POWERFUL, yet simple concept. Idea – extend what you already have by adding only those capabilities / features you need It can save an enormous amount of development time through code reuse! - Draw it for Pacman Powerful idea… because I’ve noticed that it is how my son learn Loves T-Rex. This is how he roars

Example: Vehicles What attributes do objects of Sedan have? What attributes do objects of Truck have?

Code Example for Class Bird big_bird = Bird() big_bird.fly() big_bird.eat(20) big_bird.fly()

wheezy = Penguin() wheezy.fly() wheezy.eat(10) wheezy.swim()

Design Exercise Take out your computer Write the code for class Vehicle and its subclasses Car and Truck in a file named vehicle.py Write the code in a separate file named vehicle_app.py for testing the Vehicle class that creates a few Car and Truck objects and prints their information.