UML & Programming Martin Fowler.

Slides:



Advertisements
Similar presentations
Classes And Objects II. Recall the LightSwitch Class class LightSwitch { boolean on = true; boolean isOn() { return on; } void switch() { on = !on; }
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
1 Classes and Objects in Java Parameter Passing, Delegation, Visibility Control, and Object Cleanup.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
JAVA Revision Lecture Electronic Voting System Marina De Vos.
AITI Lecture 19 Linked List Adapted from MIT Course 1.00 Spring 2003 Lecture 26 and Tutorial Note 9 (Teachers: Please do not erase the above note)
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Interfaces CSC 171 FALL 2004 LECTURE 14. Project 1 review public class Rational { private int numerator, denominator; public Rational(int numerator, int.
Exercise 1 Suppose C is a class that implements interfaces I and J. Which of the following Requires a type cast? C c = ……? I i = …..? J j = …..? c =
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
CS-1010 Dr. Mark L. Hornick 1 Selection Statements and conditional expressions.
Introduction to Programming with Java, for Beginners “Has a” Relationship.
1 ADTs, Collection, Iterable/Iterator Interfaces Collections and the Java Collections API The Collection Interface and its Hierarchy The Iterable and Iterator.
Understanding class definitions Looking inside classes.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Java Classes Using Java Classes Introduction to UML.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
The Java Programming Language
DOMAIN MODE: ASSOCIATIONS, MULTIPLICITY AND ATTRIBUTE-TEXT NOTATION SYS466.
A Singleton Puzzle: What is Printed? 1 public class Elvis { public static final Elvis INSTANCE = new Elvis(); private final int beltSize; private static.
Topic 5 Introduction to UML Diagrams. 1-2 Objectives To introduce UML Diagrams A diagrammatic way of showing the relationships among classes This will.
Domain Model—Part 3: Associations, Multiplicity and Attribute- Text Notation.
1 Collection, Iterable, and Iterator Interfaces The Collection Interface and its Hierarchy The Iterable and Iterator Interfaces For-each Loops with Iterable.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Lab 1 Logbook ADT. OVERVIEW A monthly logbook consists of a set of entries, one for each day of the month.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
A: A: double “4” A: “34” 4.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
1 Iterator Pattern (A Behavioral Pattern) Prepared by: Neha Tomar.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Catalog of Refactoring
יסודות מדעי המחשב – תרגול 6
A Review or Brief Introduction
Interfaces.
Syntax & Semantics UML - Java
Coding #1 if(!(index < 0 || index >= list.size( )-1))
RADE new features via JAVA
Generic array list and casting C&K s7.7
CLASS DEFINITION (> 1 CONSTRUCTOR)
Review Operation Bingo
Understanding class definitions
null, true, and false are also reserved.
TO COMPLETE THE FOLLOWING:
Introduction to Java Programming
Interfaces and Constructors
searching Concept: Linear search Binary search
AP Java Warm-up Boolean Array.
Unit 3 - The while Loop - Extending the Vic class - Examples
UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public.
UML Class Example Sales - name: string - monthlyProfit : double[] public class Sales{ private String name; private double[] monthlyProfit; public.
Recursive GCD Demo public class Euclid {
class PrintOnetoTen { public static void main(String args[]) {
Understanding class definitions
Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.
Recursive Objects Singly Linked Lists.
Unified Modeling Language (UML)
Question 1a) What is printed by the following Java program? int s;
Software Design Lecture : 39.
Methods/Functions.
Implementation Model: Mapping Designs to Code
Encapsulation.
Presentation transcript:

UML & Programming Martin Fowler

Content Class Diagrams to Java Code Interaction Diagrams

Class diagrams for Order

Specification Perspective class Order{ public Order (Customer customer); public Date getReceived(); public void setReceived(Date arg); public String getNumber(); public Customer getCustmoer(); public void setCustomer(Customer arg); public Enumeration getOrderLines(); public void addOrderLines(OrderLine arg); public void removeOrderLine(OrderLine arg); public void price(); } class OrderLine{ public OrderLine(int quantity, Product product); public int getQuantity(); public Money getPrice(); public Product getProduct();

Implementation Perspective class Order{ public Order(Customer customer); private Customer _customer; private Vector _orderLines; private Date _recevied; private String _number; public void price(); } class OrderLine{ public OrderLine(int quantity, Product product); private int _quantity; private Money _price; private Product _product;

Constraints

Implementing a Constraint class Order{ boolean isValid{ if (getCustomer.getCreditRating.equals(CreditRating.poor())) return isPrepaid(); else return true; } void assertInvariant(){ if(IS_DEBUGGING) if(!isValid()) throw new RuntimeExcetption( “Order Object not valid”);