CMPUT 301: Lecture 04 Practical OO constructs & UML Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes based on previous.

Slides:



Advertisements
Similar presentations
Chapter 6 Objects and Classes F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and.
Advertisements

Purpose : To convert this string to a new character array. Return Type : char[ ] Parameters : none Declaration : public char[ ] toCharArray() Returns.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Programming Languages and Paradigms
L3:CSC © Dr. Basheer M. Nasef Lecture #3 By Dr. Basheer M. Nasef.
Lecture 9: More on objects, classes, strings discuss hw3 assign hw4 default values for variables scope of variables and shadowing null reference and NullPointerException.
Chapter 1 Object Oriented Analysis and Design. UML, Patterns, and Object-Oriented Analysis and Design  The essential skills for the creation of well-designed,
CS-I Final Review Hao Jiang Computer Science Department Boston College.
CS 106 Introduction to Computer Science I 11 / 09 / 2007 Instructor: Michael Eckmann.
CS 180 Problem Solving and Object Oriented Programming Fall 2011 Notes for the Final Lecture Dec 7, 2011 Aditya Mathur Department of Computer Science Purdue.
Introduction To System Analysis and Design
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
UML – Class Diagrams.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
CMPUT 301: Lecture 25 Graphic Design Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes based on previous courses by.
Enhancing classes Visibility modifiers and encapsulation revisited
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
UML Notations Activity diagrams State diagrams Class diagrams Use-case diagrams.
1 CSC241: Object Oriented Programming Lecture No 07.
Introduction To System Analysis and design
CSC 142 C 1 CSC 142 Object based programming in Java [Reading: chapter 4]
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 1 Algorithm Analysis
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Java Classes Using Java Classes Introduction to UML.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
CSE 1302 Lecture 7 Object Oriented Programming Review Richard Gesick.
Introduction To System Analysis and Design
Object-Oriented Analysis and Design An Introduction.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 8 Objects and Classes.
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
CMPUT 301: Lecture 05 More Java & UML Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes based on previous courses.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Chapter 21 Using Objects of A Single Class. Chapter 22 Classes and Objects Defining a class: class Frame {// represent a graphical user // interface window.
The Unified Modeling Language Part II Omar Meqdadi SE 2730 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
(14-2) UML Instructor - Andrew O’Fallon CptS 122 (December 2, 2015) Washington State University.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 6 Objects and Classes.
C++ Inheritance Data Structures & OO Development I 1 Computer Science Dept Va Tech June 2007 © McQuain Generalization versus Abstraction Abstraction:simplify.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Unit 1 - Introducing Abstract Data Type (ADT) Part 1.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Chapter No. : 1 Introduction to Java.
CMPUT 301: Lecture 06 Interfaces, Abstract classes and Inheritance
Programming Language Concepts (CIS 635)
Inheritance April 7, 2006 ComS 207: Programming I (in Java)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Lecture 11 Parameters CSE /26/2018.
Object Oriented Programming
Presentation transcript:

CMPUT 301: Lecture 04 Practical OO constructs & UML Lecturer: Martin Jagersand Department of Computing Science University of Alberta Notes based on previous courses by Ken Wong, Eleni Stroulia Zach Dodds, Martin Jagersand

2 Goals today: 1.Introducing UML 2.Some more basic OO examples in Java Note: Many examples taken from: Dennis Kafura “Object oriented software design and construction” On-line version of book:

3 UML Unified Modeling Language Class notationObject Notation

4 GUI Window

5 UML class example public class Frame { // version 1 … public Frame ( String name, int initXCoord, int initYCoord, int initWidth, int initHeight ) { … } public void resize( int newHeight, int newWidth ) { … } public void moveTo( int newXCoord, int newYCoord ) { … } public void drawText( String text, int atX, int atY ) { … } … } Java

6 UML Object Notation

7 Named Constants public class Frame { … public static final int MOUSE_DOWN = 1; public static final int MOUSE_UP = 2; public static final int MOUSE_DRAG = 3; public static final int MOUSE_MOVE = 4; … } if (eventType == Frame.MOUSE_DOWN) { … }

8 UML Constant Notation Public class-level attributes in the Frame class: +MOUSE_DOWN: Integer = 1; {invariant} +MOUSE_UP: Integer = 2; {invariant} +MOUSE_DRAG: Integer = 3; {invariant} +MOUSE_MOVE: Integer = 4; {invariant}

9 Overloaded Methods Overloaded methods are a set of methods (of a class) that have the same name (and same conceptual action) but different argument lists.

10 Overloaded Methods public class Frame { … // constructors overloaded to provide defaults public Frame( String name, int initXCoord, int initYCoord ); public Frame( String name ); public Frame(); … // methods overloaded for different inputs public void resize( int newHeight, int newWidth ); public void resize( float factor ); … }

11 UML Class Notation

12 Interacting Objects An object can be passed around, representing a bundle of related information. The information exchange occurs between a sender object and receiver object.

13 Interacting Objects To pass information from a sender object to a receiver object: –parameter passing –return value

14 Parameter Passing public class Sender { … public void callerMethod() { Receiver receiver = new Receiver(); Info argRef = new Info(); … receiver.calledMethod( argRef ); … } } public class Receiver { … public void calledMethod( Info infoRef ) { // do something with passed Info object … } }

15 Return Value public class Receiver { … public void callerMethod() { Sender sender = new Sender(); Info infoRef = sender.calledMethod(); // do something with returned Info object … } } public class Sender { … public Info calledMethod() { Info resultRef = new Info(); … // return a reference to an Info object return resultRef; } }

16 Call By Value In Java, there is essentially only call by value. A primitive value (e.g., int, char, etc.) is copied when passed. An object has its reference copied when passed; the object itself is not copied. Strings and arrays are passed like objects.

17 Call By Value public class Sender { … public void callerMethod() { Receiver receiver = new Receiver(); Info argRef = new Info(); … receiver.calledMethod( argRef ); argRef.doSomeMore(); } } public class Receiver { … public void calledMethod( Info infoRef ) { infoRef.doSomething(); infoRef = null; } }

18 Collaborating Objects A group of interacting objects can form: –associations (or acquaintances) –aggregations (or containments)

19 Collaborating Objects Each object has a role in the group and collaborates with (i.e., uses, connects to, knows about) other objects to perform its role.

20 Collaborating Objects Connections between objects: –client/server (unidirectional) –client object invokes methods of server object –client object knows about the server object –peer (bidirectional) –peers know about each other and use each others’ methods

21 Sequences of Interactions A controlling object might perform a sequence of operations over a set of objects.

22 UML Sequence Diagram

23 UML Sequence Diagram Participating objects. Time flows down. Method invocations. Iteration and conditionals. Activation of objects. Creation of objects. Optional return arrows. Notes. Not to scale.

24 Sequence Displaying an image: –ask user for filename of image –create image using contents of given file –draw image in a Frame

25 Sequence Classes of participating objects: –ImageTest (implements Program interface) –FileChooser (asks for filename) –Image (create image from file) –Frame (draw image)

26 UML Sequence diagram

27 Assignment 1 You are to design and implement a simple image viewer that allows the user to: – load and view an image – view the image size – rescale the size of the image – adjust the brightness of the image See detailed specification on the course www page

28 Study (unix/linux) image editor: xv

29 Mathematical / Computational image models Continuous mathematical: I = f(x,y) Discrete (in computer) addressable 2D array: I = matrix(i,j) Discrete (in file) e.g. ascii or binary sequence:

30 Image representation for display True color, RGB, …. (R,G,B) (R,G,B) … (R,G,B) : (R,G,B)

31 Image representation for display Indexed image (I) (I) … (I) : (I) (R,G,B) : (R,G,B)

32 Point operations on images Point operations perform some operation on one pixel at a time (independent on the neighboring pixels) For each ( x,y ) I 2 ( x,y ) = f(I( x,y )) Contrast to image transforms (later in course) perform operations on the whole image

33 Common point operations Brightness adjustment Contrast adjustment –Dynamic range compression –Gray level slicing Histogram equalization Image (sequence) averaging Background subtraction

34 Linear brightness and contrast adjustment As seen on TV! Brightness For each ( x,y ) I 2 ( x,y ) = I( x,y )+const Contrast I 2 ( x,y ) = const*I( x,y )

35 Contrast adjustment example