system modelling - ut

31
System Modelling Lecture 25.10.2011

Upload: others

Post on 06-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

System Modelling

Lecture 25.10.2011

Lecture Objectives

● GUI design with Story-Driven Modelling● Class Diagram to Code (revistited)● Automatic Code Generation● Intro to project Mancala game: 35pts

Wireframes or Mockups

3/31

Wireframes or Mockups● Often created manually on paper

● For customer it is difficult to differentiate GUI elements of editor from the designed application

● Often GUI is refined together with customer who is often missing design app. skills

● Designers vs Developers● Usability vs code complexity

4/31

1. Karli, Bobby, and Olga agree to have a pot luck barbeque, but want to share the cost evenly. On the day of the barbeque, Karli brings his notebook running the Group Register application. He assumes that Bobby and Olga will bring enough for them all, so he does not bring any food items. After starting the application it shows the initial screen of the application with no entries.

This step mentions that we have an application with an initial screen

2. Karli adds himself, Bobby, and Olga to the list of participants

This step mentions a list of participants. Therefore we need a list showing the names of the participants. But how we will actually get the participants into the list?

6/31

A B

C

a) Just editing the table*This requires complex handling of a single dummy line in the end of the table and might pose some diculties in programming

b) Having some fields and an add button underneath to enter one person at a time

c) An add button on top which creates an empty line, which is editable

* Combined idea from a) and b) but still needs more programming than b)

Lets say that customer agreed decision b)

8/31

3. Bobby shows up and brings some beer for 12 EUR. Karli enters that Bobby brought beer for 12 EUR into the system. Olga brings bread for 4.50 EUR and salad for 3.00 EUR. Karli enters the items for Bobby and Karli to the system.

● From this step, we can derive that we need something to store bought items, the person who bought it, and the price of each.

● This also suggests to use some kind of table with the columns person name, item description, and price.

– Also here, we could discuss different options to fill in the values like in the last step, but also here we will settle on the option of adding some entry fields and an add button. This could be done in a different window, but we will put it in the same to make all information visible at all

9/31

10/31

4. The food items sum up to 19.50 EUR. Therefore, the share of each participants equals to 6.50 EUR. As Karli has not spent any money for food items, he has to pay the full share of 6.50 EUR. As Bobby has already spent 12 EUR, he has to receive back 5.50 EUR. Olga has spent 7.50, so she has to receive 1 EUR back.

● So far we have not taken into account that we want to also see the amounts of the balance each participant has to pay to the register. – We could now either add a button to compute the

balance and show a different window with the results or we could also show the balance all the time in the participant's list.

● Let us assume that our potential customer prefers the version seeing the balance all the time. – We therefore add a column Amounts.

12/31

Refining the Storyboard● Further playing with these wireframes might

lead to some further requirements and ideas● Will it be possible to remove items from the list?

– How exactly?● Will it be possible to edit the names of the

participants?● Client might discover that he needs to be able to

adjust the price of the food items.● ...

13/31

Revisited: Class Diagram to Code

public class Student {

}

public class Student {

}

14/31

Revisited: Class Diagram to Code

public class Student {

private String name ;

public void setName (String name){ this.name = name; }

public String getName ( ){ return name ; }}

public class Student {

private String name ;

public void setName (String name){ this.name = name; }

public String getName ( ){ return name ; }}

15/31

Revisited: Class Diagram to Code

public class Student {

private String name ;

public void setName (String name){ if (name == null) { throw new IllegalArgumentException("Student.name must not be null!"); } this.name = name; } ...}

public class Student {

private String name ;

public void setName (String name){ if (name == null) { throw new IllegalArgumentException("Student.name must not be null!"); } this.name = name; } ...}

16/31

public class Student {

private University university;

public void setUniversity (University university) { this.university = university; }

public University getUniversity() { return university; } ...}

public class Student {

private University university;

public void setUniversity (University university) { this.university = university; }

public University getUniversity() { return university; } ...}

17/31

import java.util.HashSet;public class Course { private HashSet<Student> students = new HashSet<Student>( ); public void addStudent (Student student){ students.add (student) ; } public void removeStudent (Student student) { students.remove (student) ; } public HashSet<Student> getStudents ( ){ return students; }}

import java.util.HashSet;public class Course { private HashSet<Student> students = new HashSet<Student>( ); public void addStudent (Student student){ students.add (student) ; } public void removeStudent (Student student) { students.remove (student) ; } public HashSet<Student> getStudents ( ){ return students; }}

18/31

Courses course = . . . ;...course.getStudents ( ).clear ( ) ;course.getStudents ( ).add (new EvilStudent ( ) ) ;

// now all student references are gone// now all student references are gone// possible parameter check of addStudent ( ) is skipped!// possible parameter check of addStudent ( ) is skipped!

Courses course = . . . ;...course.getStudents ( ).clear ( ) ;course.getStudents ( ).add (new EvilStudent ( ) ) ;

// now all student references are gone// now all student references are gone// possible parameter check of addStudent ( ) is skipped!// possible parameter check of addStudent ( ) is skipped!

19/31

import java.util.Collections;import java.util.HashSet;import java.util.Set;public class Course{ private Set<Student> students = new HashSet<Student> ( ); public boolean addStudent (Student student){ return students.add (student); } public boolean removeStudent (Student student){ return students.remove (student) ; }

public Set<Student> getStudents ( ){ // don't expose the concrete container class return Collections.unmodifiableSet (students) ; } public int sizeOfStudents ( ){ return students.size ( ); }}

import java.util.Collections;import java.util.HashSet;import java.util.Set;public class Course{ private Set<Student> students = new HashSet<Student> ( ); public boolean addStudent (Student student){ return students.add (student); } public boolean removeStudent (Student student){ return students.remove (student) ; }

public Set<Student> getStudents ( ){ // don't expose the concrete container class return Collections.unmodifiableSet (students) ; } public int sizeOfStudents ( ){ return students.size ( ); }}

20/31

public class LectureHall {

private Course course;

public void setCourse (Course course){ if (this.course != course ){ Course oldValue = this.course; this.course = course; if (oldValue != null) { oldValue.setLectureHall(null); } if (course != null) { course.setLectureHall(this); } } }...

public class LectureHall {

private Course course;

public void setCourse (Course course){ if (this.course != course ){ Course oldValue = this.course; this.course = course; if (oldValue != null) { oldValue.setLectureHall(null); } if (course != null) { course.setLectureHall(this); } } }...

21/31

public class Course {

private LectureHall lectureHall;

public void setLectureHall (LectureHall lectureHall){ if (this.lectureHall != lectureHall ){ LectureHall oldValue = this.lectureHall; this.lectureHall = lectureHall; if (oldValue != null) { oldValue.setCourse(null); } if (lectureHall != null) { course.setCourse(this); } } }...

public class Course {

private LectureHall lectureHall;

public void setLectureHall (LectureHall lectureHall){ if (this.lectureHall != lectureHall ){ LectureHall oldValue = this.lectureHall; this.lectureHall = lectureHall; if (oldValue != null) { oldValue.setCourse(null); } if (lectureHall != null) { course.setCourse(this); } } }...

22/31

Same for the Course class

UML Lab Demo

Choosing the Right Container Class

24/31

● java.util.Set● java.util.HashSet● java.util.TreeSet

Choosing the Right Container Class● java.util.Set

● java.util.HashSet● java.util.TreeSet

● java.util.List● java.util.ArrayList● java.util.LinkedList● java.util.Vector

25/31

Choosing the Right Container Class● java.util.Set

● java.util.HashSet● java.util.TreeSet

● java.util.List● java.util.ArrayList● java.util.LinkedList● java.util.Vector

● java.util.Map

26/31

SDM Method Discussion

Course Project● Develop a multiplayer version of the game

Mancala in this course as course project using Story-Driven Modelling method

● You can see an example implementation● Wikipedia has a compact description

28/31

Taken from: http://www.gamesfromeverywhere.com.au/blog/wp-content/uploads/2010/05/maths-kids-mancala.jpg

Project DocumentationThe project report you will have to hand in has to consist of: ● A guide through your project (and repository)● Your project plan (scheduler, requirements, aims..)● Project log (progress) ● User manual● Storyboard(as detailed as possible and reasonable)

● Also simulate customer discussion, try to find 3-5 features you missed before● Video of discussion will be considered as a bonus

30/31

Project Presentation● The deadline for the assignment is 13.11 (23:59)

● Separate session on course project presentations is on 15.11● Talk about solved/not solved problems● How you organized the work● Some notes about the SDM method● Application demo

31/31