Top Banner
UML&FM08 27 October 2008 Japan 1 Xiaoshan Li Department of Computer and Information Science Faculty of Science and Technology University of Macau, Macao, China Email: [email protected] Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, Jicong Liu and Zhiming Liu International Institute for Software Technology United Nations University (UNU/IIST)
33

Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

May 08, 2019

Download

Documents

tranminh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 1

Xiaoshan LiDepartment of Computer and Information Science

Faculty of Science and TechnologyUniversity of Macau, Macao, China

Email: [email protected]

Validation of Requirement Models by Automatic Prototyping

Joint work with Dan Li, Jicong Liu and Zhiming LiuInternational Institute for Software Technology

United Nations University (UNU/IIST)

Page 2: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 2

Motivation• Problem: Early acquired requirements are

difficult to validate.

• Solution: Prototyping is efficient and effective to expose errors in the early stages of requirements analysis and design.

• Method: Automatically generate a prototype from system requirements model(use case model and conceptual class model)

Page 3: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 3

Requirements Model1. Use Case Model

2. Conceptual Class Model

Use-case System operations

Primitive actions (in pre and post conditions)

Entity object methods (new, get, set …)

<<interface>> <<control>><<entity>>

Page 4: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 4

Method• Generate a system entity object database from the

semantics of the conceptual class model.• Generate a system interface which displays the

buttons for the use case names in use case model.• Generate a use-case handler for each use case to

handle the execution of specification of the use case.• A use case handler maps the executable parts of each

use case into a sequence of primitive actions on the system entity database.

Page 5: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 5

Architecture of Generating Prototype

Prototype Interface

Use Case Handlers Object Database

Automated Prototyping Generator

Use Case Model Conceptual Model

Prototype in Java

Requirements Model in UML with OCLinput

tool

output

Page 6: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 6

UML Requirement Model

operation: p(x) ` R(x, x’) =def p(x) ) R(x, x’)

Requirements Model = (UCM, CCM)

UCM (Use Case Model) & CCM (Conceptual Class Model)

A step of a use case (system operation) is specified as a contract with a pair of pre and post conditions.

Page 7: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 7

Use Case Diagram of Library System

Page 8: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 8

Conceptual Class Diagram of Library

Page 9: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 9

Conceptual Class Model of Library

CN = { User, Copy, Publication, Reservation, Loan}

Attr(User) = {<cid: String>, <copyNum: Integer>}

Attr(Copy)={<cid:String>, <available: Boolean>}

AN={CopyOf:<Copy, Publication>,

Takes: <User, Loan>,

Borrows:<Loan, Publication>,

Makes:<User, Reservation>,

Reserves:<Reservation, Publication>,

IsHeldFor: <User, Reservation>}

Page 10: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 10

Formal Specification of LendCopyLendCopy = def pvar copy: Copy, user: User

pre: copy ∈ Copy /\ copy.available = true /\

user ∈ User /\ user.copyNum <10

post: 9 loan: Loan. (loan not ∈ Loan)

/\ Loan’=Loan ∪ { loan }

/\ Borrows’=Borrows ∪ {<loan, copy>}

/\ Takes’ = Takes ∪{<user, loan>}

/\ copy.available’= false

/\ user.copyNum’=user.copyNum+1

Page 11: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 11

Pre & Post State Object Diagrams of LendCopy

user: User

copy: Copy

user: User

copy: Copy

loan:Loan<user, loan>

<loan, copy>

pre-state post-state

LendCopy

(copy,user)

Page 12: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 12

OCL Specification of LendCopy

context Usecase::LendCopy(user:User,copy:Copy) :Loan

pre: User ->includes(user) and user.copyNum < 10and Copy ->includes(copy) and copy.available = true

post: user.copyNum = user.copyNum@pre + 1 and copy.available = false and result.oclIsNew() and result.Borrows = copy and result.Takes = user

Page 13: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 13

Generate Executable Prototype• Prototyping of requirements analysis should

demonstrate the important functional effects of each use case in terms of atomic state changes rather than the detailed algorithms for internal object interactions.

• Primitive actions are create an object or a link, remove an object or a link, check andset object attributes.

Page 14: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 14

Find Objects and Links in Pre & Post Conditions• preobject = {user, copy, copy.available= ture,

user.copyNum < 10 } , • prelink = ∅ , • postobject = {user, copy ,loan, copy.available’=false,

user.copyNum’=user.copyNum+1, }, • postlink = {<user, loan> , <loan, copy>} -------------------------------------------------------------------------• createobject = postobject – preobject ={loan}• checkattributes ={c.available= ture, u.copyNum < 10 }• removeobject = preobject – postobject = ∅• createolink = postlink–prelink = {<user, loan> , <loan, copy>} • removelink = prelink – postlink = ∅• setattributes = {copy.available’=false,

user.copyNum’=user.copyNum+1}

Page 15: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 15

Algorithm of Source Code Generation 1. Check existing objects of preobject set in pre-state.

2. Check existing links of prelink set in pre-state.

3. Check conditions about attributes of objects in preobject.

4. Create objects of createobject set in post-state.

5. Create links of createlink set in post-state.

6. Set attributes to force the conditions satisfied in postobjectset.

7. Remove links of removelink set in post-state.

8. Remove objects of removeobject set in post-state.

Page 16: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 16

Rules for Transforming OCL Expressions to Primitive Actions

Context Usercase:: AddCopy(copy:Copy, pub:Publication)Pre: Publication->includes(pub)

and Copy->excludes(copy)Post: copyoclIsNew() and copy.available=true

and copy.CopyOf=pub

Ten rules can be used to transform OCL expression fragments in AST to primitive actions.

Page 17: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 17

Precondition AST of AddCopy

Page 18: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 18

Postcondition AST of AddCopy

Page 19: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 19

Primitive Actions of AddCopy

1. FindObject(pub, Publication)2. FindNoObject(copy, Copy);3. CreateObject(copy, Copy);4. SetAttr(copy, available, true);5. CreateLink(CopyOf, copy, pub)

Page 20: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 20

Interface of Prototype Generator Tool

Page 21: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 21

OCL Pre and Post Conditions

Page 22: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 22

System Invariants in OCL

Page 23: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 23

Code Generation of the Prototype

Page 24: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 24

Compile and Run Prototype

Page 25: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 25

Generated Prototype Interface of Library

Page 26: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 26

Prototyping Use Case LendCopy

Page 27: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 27

System State

Page 28: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 28

Check Invariants on System State

Page 29: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 29

Check Multiplicity on System State

Page 30: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 30

Executable Problem of Post Conditions

• A complex equation satisfaction in post conditions may not be executable in the implicit style such as

F(x,y, x’,y’)=0 /\ G(x,y,x’,y’)=0

• They will be left for further refinement into the explicit style such as

x’=f(x,y) /\ y’=g(x,y)

Page 31: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 31

Conclusion1. The key idea is to map a use case defined on the

CCM in pre and post conditions to a set of executable primitive actions.

2. We developed the prototype generation and analysis: AutoPA3.0, which can accept the requirements model produced from UML CASE tool with OCL formal specification.

3. Requirements can be validated by the generated prototype.

4. System invariants and multiplicities can be checked dynamically on system state.

Page 32: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 32

Future WorkWe hope

• to apply the tool to more case studies and practical applications.

• to extend the functionality of tool to support test case generation and automated testing like the USE tool.

• to generate Java code from design sequence diagrams for non-executable parts in requirements.

• to put online for the public.

Page 33: Validation of Requirement Models by Automatic Prototyping · Validation of Requirement Models by Automatic Prototyping Joint work with Dan Li, ... input tool output.

UML&FM08 27 October 2008 Japan 33

Thank you!

Question?