Department of Computer Science Undergraduate Events

Similar documents
Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100

1 10 3:30 5: :30 1:30 206, ICICS/CS

Location: Planet Laser Interview Skills Workshop

Location: Planet Laser Interview Skills Workshop

Administrivia. CPSC Winter 2008 Term 1. Department of Computer Science Undergraduate Events

Principles of Software Construction: Objects, Design, and Concurrency

Principles of Software Construction: Objects, Design, and Concurrency

Administrivia. CSSS Movie Night: Zombieland & Iron Man Date: Thurs., Mar 11 Time: 6 10 pm Location: DMP 310 Free pop & popcorn for every attendee!

COURSE 2 DESIGN PATTERNS

Software Development

Principles of Software Construction: Objects, Design, and Concurrency

Location: Planet Laser Interview Skills Workshop

CPSC 427: Object-Oriented Programming

Administrivia. Events this week Drop-In Resume and Cover Letter Editing Date: Tues., Mar 23 Time: 12:30 2:30 pm Location: Rm 255, ICICS/CS

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

Software Engineering

The following topics will be covered in this course (not necessarily in this order).

CS 61B Data Structures and Programming Methodology. July 2, 2008 David Sun

San Jose State University - Department of Computer Science

Software Engineering Fall 2014

GRASP Design Patterns A.A. 2018/2019

Originality is Overrated: OO Design Principles

Object-Oriented Design

CSCI 1060U Programming Workshop

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

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

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

CMPE/SE 135 Object-Oriented Analysis and Design

Object Fundamentals Part Two. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 3 09/01/2009

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017

CPSC 410? Advanced Software Engineering Mid-term Examination (Term I ) SOLUTION Instructor: Gail Murphy

Chapter 5 Object-Oriented Programming

08. DESIGN PRINCIPLES. Originality is Overrated PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT

SOLID Principles. Equuleus Technologies. Optional Subheading October 19, 2016

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

Object-Oriented Design

[ L5P1] Object-Oriented Programming: Advanced Concepts

Object-Oriented Design II

Object-Oriented Design

Student Responsibilities. Mat 2170 Week 9. Notes About Using Methods. Recall: Writing Methods. Chapter Six: Objects and Classes

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

CMPS 115 Winter 04. Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD <break> Design Patterns

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Object Orientated Analysis and Design. Benjamin Kenwright

CS 116 Week 8 Page 1

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

CSC207H: Software Design SOLID. CSC207 Winter 2018

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison

Practice Problems. Review, with SOME solutions

CS 520 Theory and Practice of Software Engineering Fall 2018

CS 215 Software Design Sample midterm solutions

REVIEW OF THE BASIC CHARACTERISTICS OF OBJECT ORIENTATION

Announcements. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Intuition: Type Signature is a Specification.

Understading Refactorings

CPSC 427: Object-Oriented Programming

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

C++ Modern and Lucid C++ for Professional Programmers

Mat 2170 Week 9. Spring Mat 2170 Week 9. Objects and Classes. Week 9. Review. Random. Overloading. Craps. Clients. Packages. Randomness.

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

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

Lecture: Modular Design

EINDHOVEN UNIVERSITY OF TECHNOLOGY

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

CSC207H: Software Design Lecture 6

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma

CS246 Software Abstraction and Specification Final Examination

San José State University Department of Computer Science CS151, Section 04 Object Oriented Design Spring 2018

Introduction to Object-Oriented Programming

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

Administrivia. Events this week Drop-In Resume and Cover Letter Editing Date: Tues., Mar 23 Time: 12:30 2:30 pm Location: Rm 255, ICICS/CS

A formal design process, part 2

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Intro to: Design Principles

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

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

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

UML Views of a System

Modelling with Classes. CITS1220 Software Engineering

Welcome (back) to CS1007!

CS Lecture #6. Administrative... Assignment #2 Graded NN Turned In, Average Grade: XX Assignment #3 due on Thursday

CSE 403 Lecture 8. UML Class Diagrams. Thanks to Marty Stepp, Michael Ernst, and other past instructors of CSE 403

Object-Oriented Concepts and Design Principles

Patterns in Software Engineering

Progress Report. Object-Oriented Software Development: Requirements elicitation (ch. 4) and analysis (ch. 5) Object-oriented software development

Conformance. Object-Oriented Programming Spring 2015

Topics. Passing objects to functions. Sections 7.9, 7.10, Objects and functions

Design. Eric McCreath

PROCESS DEVELOPMENT METHODOLOGY The development process of an API fits the most fundamental iterative code development

Object Oriented Programming

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

ACS-3913 Ron McFadyen 1. UML Notation for Class diagrams Object diagrams

CS111: PROGRAMMING LANGUAGE II

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

Inheritance Abstraction Polymorphism

CS1004: Intro to CS in Java, Spring 2005

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages

Announcement. Agenda 7/31/2008. Polymorphism, Dynamic Binding and Interface. The class will continue on Tuesday, 12 th August

Transcription:

Events this week Public Speaking 101 Date: Mon., Jan 25 Time: 5 6 pm Location: DMP 101 CS Co op Info Session Date: Wed., Jan 27 Time: 5:00 6:30 pm Location: DMP 201 OR Date: Thurs., Jan 28 Time: 12:30 2 pm Location: DMP 201 Department of Computer Science Undergraduate Events Undergrad Research Poster Competition Date: Thurs., Jan 28 Time: Location: 3:30 5:30 pm Atrium, ICICS/CS Building FOOD WILL BE PROVIDED! Events next week EADS Info Session Date: Mon., Feb 1 Time: 3:30 5 pm Location: CEME 1202 RIM Info Session Date: Thurs., Feb 4 Time: 5:30 7 pm Location: DMP 110 Administrivia Lecture slides (day by day) are on the web: http://www.cs.ubc.ca/~norm/211/2009w2 Reminder: Assignment #1 is due tomorrow Due Thursday, January 28 th, 10:00pm

Where are we? We are discussing designing multiple classes how to identify the classes we need in order to provide a solution to a problem what relationships exist between these classes good design principles Simple Design Example Problem Description: We want to simulate a simple betting game. In this game, a player with money to gamble makes a bet and then rolls a single die. If a 1 is rolled, the player wins an amount equal to the bet, otherwise (s)he loses the bet. Let us try to identify the classes and their behaviour Nouns: game, player, money, bet, die, amount Verbs : gamble, makes (a bet), rolls, wins, loses

Putting it Together Player Game Die Putting it Together (version 2) Player money: double name: String bet: double makebet(): void win(): void lose(): void Game Die roll() : int

Properties of a Good Design In most case there are many ways to break a problem into classes that would provide a solution (implementation) for it Some of these ways are better than the others in the sense that it is easier to understand the software system it is easier to revise and modify the code it is easier to extend the code (add new functionality) Basic Design Principles How would we know if our design is good? it must satisfy some properties Two basic principles (properties) of a good design: 1. design should have high cohesion 2. design should have low coupling

Cohesion A class should represent one concept; it should be cohesive its public interface must be cohesive If a class is not cohesive (i.e., represents many concepts) there's a greater chance that it might have to change in the future changing one concept may inadvertently break an unrelated concept Violations of this rule are acceptable in some special cases: utility classes that contain only static methods and constants (like the Math class) classes that contain just a main method Coupling A class A depends on another class B if it uses instances of the class B If many classes of a program depend on each other, we say that they have high coupling The coupling among classes is low, if there are only a few dependencies among them high coupling low coupling We want classes with high cohesion and low coupling

Use Interfaces to Reduce Coupling Use most general classes and interfaces to reduce coupling For instance: instead of this we should do this Appointment Appointment Book Appointment Appointment Book Personal Business Personal Business A larger example: a Restaurant Suppose we want to simulate a restaurant. We will use the following classes: Bill CashPayment CreditCardPayment IndividualBill Menu MenuItem Order Payment Table TableBill Waiter What are the relationships between these classes?

Summary UML diagrams help us to specify relationships between classes. Five important relationships: Association Aggregation Composition Dependency Generalization The classes for a software system should be defined in such a way that they have high cohesion low coupling Class Design III: Good Practices and Bad Practices You should be able to: describe the open-closed principle, why it matters, and how it applies to object-oriented code. use overloading correctly and recognize inappropriate uses describe the Liskov Substitution Principle (LSP) explain whether or not a given design adheres to the LSP incorporate inheritance into the design of software systems so that the LSP is respected compare and contrast the use of inheritance and delegation Additional References Object-Oriented Software Development Using Java, Xiaoping Jia, Addison Wesley, 2002 Core Java 2, Cay Hortsmann, Gary Cornell, Sun Microsystems Press, 2003 use delegation and interfaces to realize multiple inheritance in design (e.g., to support the implementation of multiple types) identify elements of a given design that violate the basic design principles of low coupling and high cohesion

To Overload or Not to Overload Overloading: Same name is used for more than one method in the same class Mainly used for convenience Misuse may reduce program readability Should use overloading only in two situations: There is a general description that fits all overloaded methods All overloaded methods have the same functionality (some may provide default arguments) Overloading Examples Good: public class StringBuffer { public StringBuffer append(char c) public StringBuffer append(int i) public StringBuffer append(float f) Bad: public class Employee { //sets employee s name public void name(string s) // returns employee s name public String name() Do both fit under a common description?

Overloading Example another problem public class Employee { public void name(string s) public void name(object o) In Main: String stringasstring = new String( astring ); Object stringasobject = stringasstring; Employee e = new Employee(); e.name(stringasobject); // what gets called? e.name(stringasstring); // what gets called? * It is a very bad idea to overload methods in a way that all parameters of one method are subclasses of those in the other Open-Closed Principle Classes should be open for extension but closed for modification Want to extend the behaviour of our system by adding subclasses without having to modify the superclasses The principle suggests you should consider possible future subclasses when defining a class