Lecture 2: UML Class DIAGRAM

Slides:



Advertisements
Similar presentations
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Advertisements

COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.
Chapter 7 Structuring System Process Requirements
Edsger W. Dijkstra Simplicity is prerequisite for reliability.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Lecture 1 CS171: Game Design Studio 1I UC Santa Cruz School of Engineering 5 January 2010.
Introduction to UML (slides adapted from Michael Mateas)
CS 201 Functions Debzani Deb.
Chapter 1 Principles of Programming and Software Engineering.
Modular Programming and Use Case Models Session 3 LBSC 790 / INFM 718B Building the Human-Computer Interface.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
CSC 395 – Software Engineering Lecture 15: Object-Oriented Design –or– Ask For Whom The Data Tolls.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Chapter 7 Structuring System Process Requirements
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
CSC 213 – Large Scale Programming. Today’s Goal  Learn Unified Process to design programs  Understand what are the “types” of Java classes  Methods.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
CSC 213 – Large Scale Programming. Why Do We Test?
Data Flow Diagram A method used to analyze a system in a structured way Used during: Analysis stage: to describe the current system Design stage: to describe.
CSC 213 – Large Scale Programming. Today’s Goals  Look at how Dictionary s used in real world  Where this would occur & why they are used there  In.
COMP 121 Week 7: Object-Oriented Design and Efficiency of Algorithms.
CSC 213 – Large Scale Programming Lecture 2: Object-Oriented Analysis & Object-Oriented Design.
OOD Case Study (For parallel treatment, see Chapter 2 of the text)
CSC 212 – Data Structures Lecture 12: Java Review.
CSC 213 – Large Scale Programming Lecture 3: Object-Oriented Analysis.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
LECTURE 38: REFACTORING CSC 395 – Software Engineering.
CS 46B: Introduction to Data Structures June 16 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
CSC 213 – Large Scale Programming. Today’s Goal  Improve design skills to make usable designs  Noun extraction & UML class diagram reviewed  Connections.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Problem of the Day  Why are manhole covers round?
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Problem of the Day  Why are manhole covers round?
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Modeling system requirements. Purpose of Models Models help an analyst clarify and refine a design. Models help simplify the complexity of information.
Lazy Contemplative Always Using Imagination Most Important Trait.
Object-Oriented Design CSC 212. Announcements This course is speeding up and we are starting new material. Please see me if you feel this is going too.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
Object Oriented Software Development
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis and Design Class and Object Diagrams.
1 CS161 Introduction to Computer Science Topic #9.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Object-Oriented Analysis and Design CHAPTERS 9, 31: DOMAIN MODELS 1.
This recitation 1 An interesting point about A3: Using previous methods to avoid work in programming and debugging. How much time did you spend writing.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
CSC 213 – Large Scale Programming. Today’s Goal  Understand why testing code is important  Result of poor or no testing & embarrassment caused  Learn.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Class Diagrams Chapter 3. Classes and Objects Classes are the descriptions –definitions Objects are the things –instances.
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
Computer Science 313 – Advanced Programming Topics.
DATA FLOW DIAGRAMS.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
Object-Orientated Analysis, Design and Programming
Lecture 9: Birds + BEES = CLASSES?
Class Diagrams – Part I Chapter 3.
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:

Lecture 2: UML Class DIAGRAM CSC 213 – Large Scale Programming Give warning that this is less cut and dry. Explain that most will not pay attention, but will be big win for those that do… Lecture 2: UML Class DIAGRAM

Today’s Goal Learn Unified Process to design programs Understand what are the “types” of Java classes Methods of selecting the potential classes How these designs presented for others to use

Classroom Development Always start from scratch Know all requirements from the start And requirements will not change Coding begins immediately at start Projects are trivial jokes in real-world If lasts 3 weeks, projects “very large” Code cannot be reused Never look at again, anyway

Why These Phases Matter

Our Goal

Our Nemesis

Electric Boogaloo Developing automated DJ for clubs Plays music at party Songs will be chosen using party-goers requests Removes people who do not belong Colleague already developed requirements Now on vacation for next few months

Electric Boogaloo User Stories User wants hip-hop Partier realizes there is a real lack of hip-hop. They request a hip-hop song be played. The system randomly selects a song from its list of hip-hop songs and adds it to the song queue. When removed from the queue, the system plays the song and displays its name and artist. (Similar stories exist for electronica & Stevie Wonder)

Oops… Forgot Something User wants Justin Bieber A user requests a Justin Bieber song be played. The system takes their picture and sends it to the security guards. By looking over our use cases, we can check if we forgot something. In this case, we forgot a means to eject the unacceptable.

What’s Next?

Find the Classes Designing classes next step in process Could help find & fix inconsistent requirements Unclear requirements clarified and made easy Outlining classes makes coding easy Already know methods to call from other classes Will provide chance to do some easy debugging

3 “Types” of Classes Unified Process concept simplifies designs Entity classes hold long-lived data driving program Input & output handled by boundary classes Control classes do complex processing in program "Types" not real, exist for design purposes only A class is a class is a class within Java & program But they can help checking design covers all needs

Noun Extraction Finds entity class candidates to be used in design Initial pass may (will) not find all entity classes Some classes not used even though found early on Provides strong hints for other needed classes Start with plain English requirements Should be easy & comes with most assignments

Entity Classes Highlight all nouns that you find in requirements These nouns are candidate classes for application Many candidates not needed, so can prune list Eliminate all those classes external to program Ignore (for now) some ideas that not entity classes Since not things, prune abstract (non-physical) nouns Nouns used for communication rarely drive program Thinking will change -- must work iteratively Quicker to write & easier to debug a good design

Boundary Classes These classes will perform all input & output May have many details which are all independent Only 1 constant known: these details will change Class for each independent detail to limit rewriting Make life easier, start design at simplest ideas Easy to combine simple classes to create complex ones Taking a complex class and breaking up far harder Rarely rewrite complex classes because of difficulty… … instead often just throw out & start from scratch

Skipping Boundary Classes Boundary classes may duplicate primitive type Can eliminate this class; it adds nothing to design Code will have primitive hard-coded everywhere Saves writing javadoc for class, field, getter & setter When needs change and class now needed…

Control Classes Non-obvious algorithms using many classes Rule of thumb: obvious algorithm have name Control classes already exist for named algorithms Needed when requirements include plural nouns Can use array or enum, if exact number known Else design needs class to hold these instances

Find the Classes Designing classes next step in process For each class, determine fields & methods Link classes that work together so easy to code When done well, coding becomes relatively simple Must communicate design in clear way to others All this information and more highlighted Provides vital check that can often find bugs Will do this by drawing pretty pictures

Why Draw Classes? Pictures used to share ideas easily Gets everyone up & coding at once Group spends lab watching you code… …or get suckers to work while you relax

How To Design Classes Classes represent things Start by finding all nouns in requirements More art than science and highly iterative From initial classes, some nouns external to system Need boundary & control classes even if not listed As you go along will develop rules of thumb Good judgment comes from experience, and experience comes from bad judgment. – Fred Brooks

Start Your (mp3) Engines Classes needed User wants hip-hop Partier requests a hip- hop song be played. Randomly select a song from the list of hip-hop songs & add it to the song queue. When removed from the queue, play the song & displays its name and artist.

name : type UML Class Diagrams Classes drawn in 3-part box Class name written in top portion of box Attributes (fields) written in middle portion Operations (methods) written in bottom portion Language-independent diagrams used in this Work with & used by many languages All variables written using following format : name : type

More Relationships Generalization for extends & implements Use open triangle ( ) from subclass to superclass Class only needs to list methods & field class declares Solid line for extends; dashed for implements Important fields drawn as associations Use open arrow () to fields class In middle section of class, do not list field again

More Relationships Aggregation Composition Source field is data structure holding target instances Source end has open diamond part of connection Used when target instances used outside of source Car aggregates CarParts (e.g., tires, engine, lights…) Composition Similar to aggregation (implies data structure of targets) Use when objects from target used only within source Chessboard composes Squares

Drawing Relationships Nearly all relationships must be labeled Except generalizations; means different thing Near midpoint of arrow, specify name of field Also specify numbers involved on each side Number written down on each end of the link Can be specific number of objects included Could be some range of numbers like ‘2..5’ + means 1 of more objects required to be used Use Kleene’s star ‘*’ for 0 or more objects Make comment about redacting any jokes about this Add that this is also an excellent way of checking for bugs: * Should have a 1 involved in each relationship * If number is unknown, this cannot work

What About the Methods? Uses should become public methods Start assuming this until proven otherwise Requirements verbs become initial method listing Pre- & post-conditions should be also be added Think and then add to javadoc comments Private methods may add to the preconditions Always specify assumptions explicitly Will save TONS of debugging time

For Next Lecture Link to article for Monday on lecture page Reading for Monday available on Angel What else can we do before coding? Are there more tricks that enables our laziness? How to trick smarter suckers into doing our work?