Object Oriented Programming

Similar documents
Comp-361 : Game Programming Lecture 5

Introduction to System Design

Comp-304 : Command Lecture 22. Alexandre Denault Original notes by Marc Provost and Hans Vangheluwe Computer Science McGill University Fall 2007

Purpose of Data Structures

Procedural Abstraction

Observer / Template Methods (cont.) Comp-304 : Observer / Template Methods (cont.) Lecture 27

Programmazione. Prof. Marco Bertini

COURSE 2 DESIGN PATTERNS

CMPT Data and Program Organization

Chapter 1: Principles of Programming and Software Engineering

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004

CHAPTER 5 GENERAL OOP CONCEPTS

Lecture Chapter 2 Software Development

System Design. Design Issues. System Design. System Design. Design: HOW to implement a system. Strategic vs. Local Design Decisions.

Design: HOW to implement a system

Data Structures and Algorithms. Chapter 1

Chapter 1: Programming Principles

System Design. Design: HOW to implement a system

Information System Design (IT60105)

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Software Design. Levels in Design Process. Design Methodologies. Levels..

Software Design Fundamentals. CSCE Lecture 11-09/27/2016

UNIT II Requirements Analysis and Specification & Software Design

Object-Oriented Programming Concepts

Comp-304 : Object-Oriented Design What does it mean to be Object Oriented?

Abstract Data Types (ADT) and C++ Classes

Design Patterns. Visitor Pattern. Hans Vangheluwe and Alexandre Denault

Computer Science 145

Object-Oriented Design

Testing and Debugging

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

Originality is Overrated: OO Design Principles

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Unit-3 Software Design (Lecture Notes)

CHAPTER 9 DESIGN ENGINEERING. Overview

Programming, numerics and optimization

CD Player Implementation: A simple example for Statecharts Based GUI Design. Statecharts Based GUI Design

CS504-Softwere Engineering -1 Solved Subjective Midterm Papers For Preparation of Midterm Exam

Topic : Object Oriented Design Principles

OOPs: The Harsh Realities of Programming

Object-Oriented Modeling Using UML. CS151 Chris Pollett Aug. 29, 2005.

CSC207 Week 3. Larry Zhang

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading

Recursion 1. Recursion is the process of defining something in terms of itself.

Elementary Concepts of Object Class

Information Hiding and Aspect-Oriented Modeling

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

Object Oriented Analysis & Design (OOAD)

Iteration Abstraction

ENTITIES IN THE OBJECT-ORIENTED DESIGN PROCESS MODEL

Ans 1-j)True, these diagrams show a set of classes, interfaces and collaborations and their relationships.

MSO Object Creation Singleton & Object Pool

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

LECTURE 2: The Object Model. Ivan Marsic Rutgers University

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

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

PC204. Lecture 5 Programming Methodologies. Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

CS342: Software Design. November 21, 2017

Model Solutions. COMP 102: Test 1. 6 April, 2016

Database Design. 8-4 Drawing Conventions for Readability. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

A Hierarchical Model for Object- Oriented Design Quality Assessment

Structures and Pointers

Chapter 10 Object-Oriented Design Principles

Defining Classes and Methods

Lecture 11. Instructor: Craig Duckett. Instance Variables

Software Architecture and Design I

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

WBEM Web-based Enterprise Management

Lecture 5: Inheritance

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

COMP-202. Objects, Part III. COMP Objects Part III, 2013 Jörg Kienzle and others

CS1004: Intro to CS in Java, Spring 2005

More on Inheritance. Interfaces & Abstract Classes

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1

The Unified Modelling Language. Example Diagrams. Notation vs. Methodology. UML and Meta Modelling

Systems Analysis and Design in a Changing World, Fourth Edition

Recursion is a fundamental programming technique that can provide an elegant solution certain kinds of problems. COMP Week 8 & 9 1

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Principles of Software Construction: Objects, Design, and Concurrency

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

CSE 403: Software Engineering, Spring courses.cs.washington.edu/courses/cse403/15sp/ UML Class Diagrams. Emina Torlak

10조 이호진 이지 호

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

ITI Introduction to Computing II

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

The Software Design Process. CSCE 315 Programming Studio, Fall 2017 Tanzir Ahmed

Summary of the course lectures

C# MOCK TEST C# MOCK TEST II

Distributed Storage Networks and Computer Forensics

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination

C++ Programming: Introduction to C++ and OOP (Object Oriented Programming)

Application Architectures, Design Patterns

Programming for Mobile Computing

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

Second Midterm Review

Unified Modeling Language (UML) and Modeling

Thread Programming. Comp-303 : Programming Techniques Lecture 11. Alexandre Denault Computer Science McGill University Winter 2004

Transcription:

Object Oriented Programming Comp-361 : O.O. Programming Lecture 4 Alexandre Denault Original notes by Jörg Kienzle and Hans Vangheluwe Computer Science McGill University Winter 2008

On my desk You should all have a team by now. For Monday, on a sheet of paper Name of team members, with email Name of the team (be creative, or I chose for you) A number between 0 and 100 Course conflict with on Monday/Wednesday between 10h30 and 12h00.

Decomposition Divide a large tasks in smaller components. Easier to complete smaller components individually. Dividing into subproblems Subproblems can be solved independently. Solutions to subproblems can be combined to solve the whole problem. Cooking supper example

Naval Battle What are the components of Naval Battle?

Naval Battle (2) Units Terrain Actions Rules Players

What is O.O. programming? A computer programming paradigm. Emphasizes the following Abstraction Information/Implementation hiding (encapsulation) Modularity

Abstraction simplify different things and treat them as the same Decomposition by changing the level of detail to be considered. Forget information and consequently to treat different things as if they were the same. Files on a hard disk Units in a game

Abstraction / Type Hierarchy A type family is defined by a type hierarchy. At the top of the hierarchy is a supertype that defines behavior common to all family members. Other members are subtypes of this supertype. A hierarchy can have many levels.

Example of Abstraction Hierarchy DVD Disc Optical Media Magnetic CD Tape

Example of Abstraction Hierarchy Media Optical Magnetic CD DVD Disc Tape

Info. / Implementation hiding separating implementation from interfaces When observing an encapsulation, we can have two point of view: From the outside ( public view ) From the inside ( private view ) The advantages of a good encapsulation is the separation of the private and public views.

Player In a video game, how can I store the direction a player is facing?

Player How do I store the direction a player is facing? An integer? 4 possible values : 1=North, etc Values from 0 to 360? A float? Values from 0 to 99.9? A character? n,s,e and w? 4 booleans? north, south, east, west?

Player How do I hide this from the user? IsFacingNorth() : boolean IsFacingSouth() : boolean IsFacingEst() : boolean IsFacingWest() : boolean GetDegreeFacing(): int GetDirectionFacing(): int

Get / Set Rule Never allow other class to directly access your attribute. Once an attribute is public, it can never be changed. Ex: img.pixelddata Make your attributes available using get/set methods. this.connectionstatus Bad! this.getconnectionstatus() Good!

public interface Point { public set(int x, int y); public int getx(); public int gety(); } Point

Point Inside, point could be using Cartesian or Polar coordinates. Cartesian coordinates are more efficient when dealing with lots of translations. Polar coordinates are more efficient when dealing with lots of rotations.

Modularity decomposing into a set of cohesive and loosely coupled units Break down elements into units depending on themes and concerns. Minimizing interaction between these units improves maintainability.

Modularity in Mammoth World/Logic Replication Pathfinding Physics Network

Specifications in English Company XYZ is a manufacturing company that produces cartoon figurines for big entertainment companies. This company needs an inventory and tracking system. The inventory system keeps track of how many of each figurines is stored in each warehouse. Figurines are stored in cases. Clients order the figurines and the cases are eventually shipped to clients.

This time, in UML

Unified Modeling Language (UML) A language, both graphical and textual, used throughout the entire process of project design (from requirements analysis to deployment). Semi-formal specification that captures structure of O.O.D. A standard tool for communicating a design.

Diagrams

Class Diagram

Class Example

Classes vs Objects Classes are static, depict the design and structure at design-time Objects are dynamic and are instantiated (from a class) at run-time, they have state

Attributes vs Variables Attributes are considered at design-time, are some abstractly defined property Variables are considered at implementation-time, are concretely defined properties

Objects