Lecture 14 CS202.

Slides:



Advertisements
Similar presentations
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
Advertisements

Introduction to UML. Acknowledgements Slides material are taken from different sources including: Slides material are taken from different sources including:
Software Engineering COMP 201
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
The Unified Modeling Language
© Copyright Eliyahu Brutman Programming Techniques Course.
SE-565 Software System Requirements More UML Diagrams.
Introduction to UML Prashanth Aedunuthula Fall, 2004.
Unified Modeling Language
Object-Oriented Analysis and Design
Introduction to UML Shiyuan Jin Fall, 2006.
CS 360 Lecture 6.  A model is a simplification of reality  We build models to better understand the system being developed.  We build models of complex.
Lecture 7 Object Oriented Design. Outline  What is UML and why we use UML?  How to use UML diagrams to design software system?  What UML Modeling tools.
COP4331UML Lecture Presented By: Antoniya Petkova 9/11/2009 Originally Prepared By: Pengju Shang for EEL5881 Software Engineering I.
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
EEL5881 Software Engineering I UML Lecture Yi Luo.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Use Case Diagram The purpose is to communicate the system’s functionality and behaviour to the customer or end user. Mainly used for capturing user requirements.
(14-2) UML Instructor - Andrew O’Fallon CptS 122 (December 2, 2015) Washington State University.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design,
Chapter 3: Introducing the UML
Introduction to UML Created By: Ajay Bahoriya. Acknowledgements Slides material are taken from different sources including: Slides material are taken.
Lecture 13. Unified Modeling Language (UML) The first applications you wrote in CS201 were easy to think out and code with no intermediate steps. Lab.
Lecture 12 CS 202. FXML JavaFX also offers a way to code UI controls in XML, while writing the event handlers and other application logic in Java. The.
System modeling and the Unified Modeling Language (UML) CS
UML CSE 470 : Software Engineering. Unified Modeling Language UML is a modeling language to express and design documents, software –Particularly useful.
Introduction to UML Mohammad Zubair Ahmad Summer 2007.
Variable Scope & Lifetime
Object-Orientated Analysis, Design and Programming
UML Diagrams: Class Diagrams The Static Analysis Model
UML-Class Diagrams. UML-Class Diagrams Order placement problem A Company has two types of customers, corporate customers and personal customers. All.
Introduction to UML Majid Ali Khan Spring 2005 Introduce myself.
Systems Analysis and Design
Unified Modeling Language
Lec-5 : Use Case Diagrams
Inheritance Allows extension and reuse of existing code
Object-Oriented Analysis and Design
Chapter 16 UML Class Diagrams.
Unified Modeling Language—UML A Very Brief Introduction
Chapter 11 Object-Oriented Design
Unified Modeling Language
Introduction to UML Shiyuan Jin Spring, 2006.
Object-Oriented Systems Analysis and Design Using UML
Reference: COS240 Syllabus
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Design by Contract Fall 2016 Version.
Introduction to UML Introduction to UML Shiyuan Jin September,23,2002
Sequence Diagrams.
Software models and the Unified Modeling Language (UML)
Week 12: Activity & Sequence Diagrams
UML Class Diagram.
CIS 375 Bruce R. Maxim UM-Dearborn
Software Design Lecture : 15.
Use Case Model Use case diagram – Part 2.
Simple UML 13 Nov 2018.
Review CSE116 2/21/2019 B.Ramamurthy.
Shiyuan Jin Fall, 2003 September,16,2003
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Classes CS 21a: Introduction to Computing I
CSE470 Software Engineering UML Lecture.  UML resource page
CIS 375 Bruce R. Maxim UM-Dearborn
Object Oriented System Design Class Diagrams
Information System Design
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Chapter 11: Class Diagram
Presentation transcript:

Lecture 14 CS202

Javadoc Javadoc is a tool that generates html documentation (similar to the reference pages at java.sun.com) from Javadoc comments in the code.  Javadoc Comments Javadoc recognizes special comments  /** .... */ which are highlighted blue by default in Eclipse (regular comments // and /* ... */ are highlighted green). Javadoc allows you to attach descriptions to classes, constructors, fields, interfaces and methods in the generated html documentation by placing Javadoc comments directly before their declaration statements.   Here's an example using Javadoc comments to describe a class, a field and a constructor:      /** Class Description of MyClass */ public class MyClass { /** Field Description of myIntField */ public int myIntField; /** Constructor Description of MyClass() */ public MyClass() { // Do something ... } } Javadoc Tags Tags are keywords recognized by Javadoc which define the type of information that follows. Tags come after the description (separated by a new line). Here are some common pre-defined tags: @author [author name] - identifies author(s) of a class or interface. @version [version] - version info of a class or interface. @param [argument name] [argument description] - describes an argument of method or constructor. @return [description of return] - describes data returned by method (unnecessary for constructors and void methods). @exception [exception thrown] [exception description] - describes exception thrown by method. @throws [exception thrown] [exception description] - same as @exception. from http://www.mcs.csueastbay.edu/~billard/se/cs3340/ex7/javadoctutorial.html

Javadoc package demos; /** * @author John * @version 1.0 */ public class Goose { private double weightInKg; /** @param weightInKg weight of the goose */ public void setWeightInKg(double weightInKg){ this.weightInKg = weightInKg; } public double getWeightInKg(){ return weightInKg;

Javadoc Mouse-hover over references to other classes to see Javadoc comments

Javadoc This is very handy when you use classes written by other programmers.

Javadoc Generating Javadoc creates html in the same format as Oracle's Java documentation. You can do this generate Javadoc in Eclipse with project/generate javadoc. Choose "Command" and find javadoc.exe, which will be in your jdk's bin directory:

Javadoc View Javadoc by finding it in Eclipse (you will need to refresh the project after generating it), right clicking on index.html and choosing Open With / Web Browser. Eclipse currently puts it in a doc subdirectory of the project.

View Declaration and View Call Hierarchy To see the definition of a method in your code or an imported library which contains code, select code that calls the method, right click, and choose Open Declaration To find all calls to a method, select the method name, right click, and choose "view call hierarchy"

Using Libraries Java has a very strong culture of open-source software Students, professors, programming hobbyists, and developers who choose to give back to the profession make many projects available for free This allows you to use functionality you lack the expertise to code or don’t have time for Quality control is nonexistent and malware is probably sometimes spread this way! You will learn several other ways to get libraries and integrate them into your projects, but here is the simple way

Using Libraries Find the website for the library you want and download it. If you have the choice to get the bytecode alone or with the source included, get the version that includes the source You will usually need to unzip or untar the library. The result will include one or more .jar files, which are archives of class files. Often there is also documentation, tutorials, and other material as well. Right click on the project name and choose "Build Path/Configure Build Path", then "Add External JARs", then find the .jar you need to add. The library should now appear under "Referenced Libraries" in your project

Using Libraries This example uses a library called pdfbox to extract plain text from a pdf.

Using Libraries

Using Libraries package pdfboxdemo; import java.io.File; import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; public class Extractor { // adapted from http://www.printmyfolders.com/Home/PDFBox-Tutorial public static void main(String[] args) { PDDocument pd; File input = new File("rj.pdf"); // The PDF file from where you would // like to extract try { pd = PDDocument.load(input); PDFTextStripper stripper = new PDFTextStripper(); stripper.setEndPage(20); String text = stripper.getText(pd); if (pd != null) { pd.close(); } System.out.println(text); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace();

Unified Modeling Language (UML) The first applications you wrote were easy to think out and code with no intermediate steps. Lab 7 involved some communication with your lab partner and the use of an interface to define how the parts of the application fit together. As your applications get larger and involve more people, they will require better planning tools. These often involve documents which specify requirements and describe how the parts of the application fit together. The textbook has introduced bits and pieces of Unified Modeling Language (UML); this lecture covers it in slightly more depth.

Unified Modeling Language (UML) Most of the following slides are slightly revised versions of slides by Yi Luo, Carnegie-Mellon University: http://www.cs.ucf.edu/~turgut/COURSES/EEL5881_SEI_Fall07/UML_Lecture.ppt

UML Diagrams Types of UML Diagrams: Use Case Diagram Class Diagram Sequence Diagram Collaboration Diagram State Diagram This is only a subset of diagrams chosen from among the most widely-used types Source of slides: Yi Luo, Carnegie-Mellon University

Use-Case Diagrams A use-case diagram shows a set of use cases A use case is a model of the interaction between External users of a software product (actors) and The software product itself More precisely, an actor is a user playing a specific role describing a set of user scenarios capturing user requirements contract between end user and software developers Source of slide: Yi Luo, Carnegie-Mellon University

Use-Case Diagrams Use Case Boundary Actor Employee Client Supervisor Library System Borrow Employee Client Order Title Fine Remittance Supervisor

Use-Case Diagrams Actors: A role that a user plays with respect to the system, including human users and other systems. e.g., inanimate physical objects (e.g. robot); an external system that needs some information from the current system. Use case: A set of scenarios that describing an interaction between a user and a system, including alternatives. System boundary: rectangle diagram representing the boundary between the actors and the system.

Use-Case Diagrams Association: communication between an actor and a use case; Represented by a solid line. Generalization: relationship between one general use case and a special use case (used for defining special alternatives) Represented by a line with a triangular arrow head toward the parent use case.

Use-Case Diagrams Include: a dotted line labeled <<include>> beginning at base use case and ending with an arrows pointing to the include use case. The include relationship occurs when a chunk of behavior is similar across more than one use case. Use “include” in stead of copying the description of that behavior. <<include>> Extend: a dotted line labeled <<extend>> with an arrow toward the base case. The extending use case may add behavior to the base use case. The base class declares “extension points”. <<extend>>

Use-Case Diagrams Figure 16.12 The McGraw-Hill Companies, 2005

Use-Case Diagrams Both Make Appointment and Request Medication include Check Patient Record as a subtask (include) The extension point is written inside the base case Pay bill; the extending class Defer payment adds the behavior of this extension point. (extend) Pay Bill is a parent use case and Bill Insurance is the child use case. (generalization) (TogetherSoft, Inc)

Class diagram A class diagram depicts classes and their interrelationships Used for describing structure and behavior in the use cases Provide a conceptual model of the system in terms of entities and their relationships Detailed class diagrams are used for developers

Class diagram Each class is represented by a rectangle subdivided into three compartments Name Attributes Operations Modifiers are used to indicate visibility of attributes and operations. ‘+’ is used to denote Public visibility ‘#’ is used to denote Protected visibility ‘-’ is used to denote Private visibility Sometimes modifiers are not shown. By default, attributes are hidden and operations are visible.

UML Class Diagram Source: Liang

Example: Defining Classes and Creating Objects TV Source: Liang TestTV Run

OO Relationships There are two kinds of Relationships Generalization (parent-child relationship) Association (student enrolls in course) Associations can be further classified as Aggregation Composition

OO Relationships: Generalization Supertype Example: Customer Regular Customer Loyalty Customer Subtype1 Subtype2 -Inheritance is a required feature of OOP -Generalization expresses a parent/child relationship among related classes. Used for abstracting details in several layers

OO Relationships: Association Represent relationship between instances of classes Student enrolls in a course Courses have students Courses have exams Etc. Association has two ends Role names (e.g. enrolls) Multiplicity (e.g. One course can have many students) Navigability (unidirectional, bidirectional)

Association: Multiplicity and Roles student 1 * University Person 0..1 * teacher employer Role Multiplicity Symbol Meaning 1 One and only one 0..1 Zero or one M..N From M to N (natural language) * From zero to any positive integer 0..* From zero to any positive integer 1..* From one to any positive integer Role “A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; a given teacher may or may not be working for the university at a particular time.”

Class diagram [from UML Distilled Third Edition]

OO Relationships: Composition Association Models the part–whole relationship Composition Also models the part–whole relationship but, in addition, every part may belong to only one whole, and If the whole is deleted, so are the parts Example: A number of different chess boards: Each square belongs to only one board. If a chess board is thrown away, all 64 squares on that board go as well. Class W Whole Class Class P1 Class P2 Part Classes [From Dr.David A. Workman] Example Figure 16.7 The McGraw-Hill Companies, 2005

OO Relationships: Aggregation Container Class Aggregation: expresses a relationship among instances of related classes. It is a specific kind of Container-Containee relationship. express a more informal relationship than composition expresses. Aggregation is appropriate when Container and Containees have no special access privileges to each other. Class C AGGREGATION Class E1 Class E2 Containee Classes Example Bag Apples Milk [From Dr.David A. Workman]

Aggregation vs. Composition Composition is really a strong form of association components have only one owner components cannot exist independent of their owner components live or die with their owner e.g. Each car has an engine that can not be shared with other cars. Aggregations may form "part of" the association, but may not be essential to it. They may also exist independent of the aggregate. e.g. Apples may exist independent of the bag.

Interaction Diagrams show how objects interact with one another UML supports two types of interaction diagrams Sequence diagrams Collaboration diagrams

Sequence Diagram(make a phone call) Caller Phone Recipient Picks up Dial tone Dial Ring notification Ring Picks up Hello

Sequence Diagram:Object interaction Synchronous Asynchronous Transmission delayed Self-Call [condition] remove() *[for each] remove() Self-Call: A message that an Object sends to itself. Condition: indicates when a message is sent. The message is sent only if the condition is true. Condition Iteration

Sequence Diagrams – Object Life Spans Creation Create message Object life starts at that point Activation Symbolized by rectangular stripes Place on the lifeline where object is activated. Rectangle also denotes when object is deactivated. Deletion Placing an ‘X’ on lifeline Object’s life ends at that point A B Create X Deletion Return Lifeline Activation bar

Sequence Diagram Message Sequence diagrams demonstrate the behavior of objects in a use case by describing the objects and the messages they pass. The horizontal dimension shows the objects participating in the interaction. The vertical arrangement of messages indicates their order. The labels may contain the seq. # to indicate concurrency.

Interaction Diagrams: Collaboration diagrams start 6: remove reservation 3 : [not available] reserve title User Reservations 5: title available 6 : borrow title 1: look up 2: title data 4 : title returned Catalog 5 : hold title Collaboration diagrams are equivalent to sequence diagrams. All the features of sequence diagrams are equally applicable to collaboration diagrams Use a sequence diagram when the transfer of information is the focus of attention Use a collaboration diagram when concentrating on the classes

State Diagrams (Billing Example) State Diagrams show the sequences of states an object goes through during its life cycle in response to stimuli, together with its responses and actions; an abstraction of all possible behaviors. End Start Unpaid Paid Invoice created paying Invoice destroying

State Diagrams (Traffic light example) Start Traffic Light State Red Transition Yellow timer expires Yellow Car trips sensor Green timer expires Green Event

Installing Eclipse Add Ons There are thousands of add-ons available to add functionality to Eclipse, many of them open source or otherwise free. Some look free but are actually evaluation versions Choose Help/Eclipse Marketplace, then enter text in the search box Many add ons can be installed with a few clicks

Eclipse Add Ons

Ways To Generate UML Diagrams Microsoft Visio UMLet – Free UML tool Several Eclipse plug ins support UML diagrams. In Eclipse, go to Help / Eclipse Marketplace and enter "UML" in the find box. Some tools are evaluation versions of commercial software, while others are open-source. Model Goon provides an easy way to generate class diagrams Many others available