OO design. Classes, Responsibilities, Collaborations (CRC) 13/9/1999 COSC

Similar documents
ITI Introduction to Computing II

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

ITI Introduction to Computing II

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation

Intro to Computer Science 2. Inheritance

Object-Oriented Design

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

1. BlueJ bank example with subclasses of BankAccount 2. Transparency of UML diagram for BankAccount class hierarchy

There are a few important ways that Smalltalk is different then other languages:

Object Oriented Programming: Based on slides from Skrien Chapter 2

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

CS558 Programming Languages

CSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN

Inheritance in Ruby. You are familiar with the idea of inheritance and how to use this in programming.

The Smalltalk class hierarchy

Week 7. Statically-typed OO languages: C++ Closer look at subtyping

Java Object Oriented Design. CSC207 Fall 2014

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Part I Basic Concepts 1

Object Oriented Software Development CIS Today: Object Oriented Analysis

G Programming Languages - Fall 2012

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Lecture 2: Writing Your Own Class Definition

Inheritance and Polymorphism

OBJECT ORİENTATİON ENCAPSULATİON

Software Design and Analysis for Engineers

MechEng SE3 Lecture 7 Domain Modelling

CSE 70 Final Exam Fall 2009

Testing. Unit, integration, regression, validation, system. OO Testing techniques Application of traditional techniques to OO software

Appendix A - Glossary(of OO software term s)

Binghamton University. CS-140 Fall Chapter 9. Inheritance

CSE 143. "Class Relationships" Class Relationships and Inheritance. A Different Relationship. Has-a vs. Is-a. Hierarchies of Organization

OO System Models Static Views

Accessibility. EEC 521: Software Engineering. Classes and Objects. Inheritance. Classes and Objects (OO Analysis)

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

Object-Oriented Design

Overview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design

CHAPTER 10 INHERITANCE

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

CS-202 Introduction to Object Oriented Programming

Back to ObjectLand. Contents at: Chapter 5. Questions of Interest. encapsulation. polymorphism. inheritance overriding inheritance super

Functional Programming, Classes, and Recursion!

Object-Oriented Systems Development: Using the Unified Modeling Language

Subtyping (Dynamic Polymorphism)

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Introduction to Inheritance

Object-Oriented Programming Design and Analysis Elena Punskaya,

Industrial Programming

What is an Object. Industrial Programming. What is a Class (cont'd) What is a Class. Lecture 4: C# Objects & Classes

Chapter 8: Class and Method Design

Chapter 5 Object-Oriented Programming

CSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes

The System Transcript, Class Point and Inspectors

Object-Oriented Technology. Rick Mercer

Lecture 16: Object Programming Languages

SHRI ANGALAMMAN COLLEGE OF ENGINEERING & TECHNOLOGY (An ISO 9001:2008 Certified Institution) SIRUGANOOR,TRICHY

The class Object. Lecture CS1122 Summer 2008

CHAPTER 9 DESIGN ENGINEERING. Overview

Use the scantron sheet to enter the answer to questions (pages 1-6)

Simula 67. Simula and Smalltalk. Comparison to Algol 60. Brief history. Example: Circles and lines. Objects in Simula

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Design Patterns Revisited

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

Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group

Basic Object-Orientation

Software Engineering II - Specimen Exam Answers Page 1 of 10

CS558 Programming Languages Winter 2013 Lecture 8

CSE1720. General Info Continuation of Chapter 9 Read Chapter 10 for next week. Second level Third level Fourth level Fifth level

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

How Developers Use the Dynamic Features of Programming Languages: The Case of Smalltalk

Architecture and the UML

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

The Object-Oriented Design Process

Notation Part 1. Object Orientated Analysis and Design. Benjamin Kenwright

Chapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.

2. Classes & Inheritance. Classes. Classes. Éric Tanter Objects and Design in Smalltalk. How do you create objects?

An Introduction to Object Orientation

Structured Programming

Exam Duration: 2hrs and 30min Software Design

Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1

Methods Common to all Classes

Introduction to Objects. James Brucker

Testing Object-Oriented Software. COMP 4004 Fall Notes Adapted from Dr. A. Williams

In this Lecture you will Learn: Object Design. Information Sources for Object Design. Class Specification: Attributes

PROGRAMMING LANGUAGE 2

Learning Perl Objects, References, and Modules

Reviewing OO Concepts

JAVA: A Primer. By: Amrita Rajagopal

Testing Object-Oriented Applications. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only

Object Oriented Analysis and Design: An Overview

LABORATORY 1 REVISION

Meltem Özturan

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

Unified Modeling Language (UML) Class Diagram

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

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

Hippo Software BPMN and UML Training

Unified Modeling Language (UML) and Modeling

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Transcription:

OO design Classes, Responsibilities, Collaborations (CRC) 1

bank accounts the system to be modelled: bank accounts with differing fee structures purpose: evaluate different account types with respect to cost easy example to start with what's being 'simulated' is a calculation 2

what classes will we need? BankAccount the class is used to make different bank accounts what are the responsibilities of an account? accept individual transactions keep in mind: different banks have different categories of transactions 3

more responsibilities instance variables -- define state of the account have to remember what will be needed to calculate a fee all accounts have a balance BankAccount can take responsibility for deposit, but not debits -- why? deposits don't usally involve a fee 4

subclassing differing responsiblities imply different classes similarities imply sub-classing make each type of account a separate sub-class of BankAccount 5

transactions responsibilities for Transactions class? operations such as "next transaction" methods related to its internal structure -- suggests this is a datatype based on some built-in datatype such as OrderedCollection 6

collaborations what classes of object does a BankAccount need in order to function? Transactions BankAccounts "collaborate" with Transactions (collaboration can be asymmetric) 7

an overview UML class diagram BankAccount balance minimum balance debit: deposit: fee Transactions BofM planfee waiverbalance : 8

OO Programming in Smalltalk 9

object-oriented programming objects = data structures with local state variables and encapsulated code (methods) objects have limited vision and limited effect on other objects; this increases comprehensibility reduces the amount of context needed to understand what happens objects only receive and respond to messages. They don't usually know about other objects' state variables or code. 10

Smalltalk example Example: suppose we have an object called 'square'. inside the 'square' object, define a variable 'side': side := 10. From outside the square, to find out its size, send it a message, e. g. size size ^side value of square size is 10 11

notational variants Smalltalk-80 assignment operator printed: input: _ Visualworks assignment operator printed & input: := 12

talking in circles Example: an object called circle'. inside the circle' object, a variable called radius : radius := 10. From outside the circle, to find out its size, send it a message, size size ^radius Value of circle size is 10 13

what s happening? How does anything happen in a Smalltalk program? Objects respond to messages What s the object and message in 3 +2? 3 is an object which (like all numbers) reacts to the message + 2. 14

classification Objects are classified into classes with similar properties. This avoids redundant specification. You don't have to describe the structure and behaviour of each individual object in complete detail. 15

instance creation Classes are like types or kinds better metaphor: classes are factories for making instances instance = object the object s properties are defined in its class 16

system image A Smalltalk system development and application environment combined Each user can construct their own system by starting with a default system and modifying it = user s (system) image you need an "engine" (virtual machine) + an image to run Smalltalk code 17

image size about 1000 to 2000 classes in a default image 20,000 to 200,000 objects in an image in active use 18

inheritance & reflexivity An object inherits the properties of the class of which it is an instance as well as the superclasses of its class. Problem: in order to program in Smalltalk,you have to know the major classes of objects. Tools: System browser and debugger which lets you inspect everything, including the internals of the Smalltalk system! 19

classes (structure) & methods (behaviour) 20

class hierarchies what is the function of a class hierarchy (inheritance)? factor out commonalities in state and behavior common variables move up in the hierarchy shared values become values of class variables common method selectors move up the hierarchy 21

selectors simple message (no argument) size selector with argument + 2 initialbalance: amount size: 10 border: red width: 2 this is a message what's the selector? 22

selectors, messages, methods selector = pattern of invocation message = selector + arguments method selected depends on the class to which the message is sent selector can be default method, defined in superclass specialization: override default in a subclass selector can be abstract, only implemented in subclass 23

expressions review handout on Smalltalk expressions 24