Syntax & Semantics UML - Java Jan Pettersen Nytun, page no. 1 - - PowerPoint PPT Presentation

syntax semantics
SMART_READER_LITE
LIVE PREVIEW

Syntax & Semantics UML - Java Jan Pettersen Nytun, page no. 1 - - PowerPoint PPT Presentation

Syntax & Semantics UML - Java Jan Pettersen Nytun, page no. 1 Syntax From Wikipedia, the free encyclopedia: the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be a


slide-1
SLIDE 1

Jan Pettersen Nytun, page no. 1

Syntax & Semantics UML - Java

slide-2
SLIDE 2

Syntax

Jan Pettersen Nytun, UIA, page 2

int age = 10; if (age >70){ System.out.println(“Can be retired!"); } else { System.out.println("Can not be retired!"); }

From Wikipedia, the free encyclopedia: “…the syntax of a computer language is the set of rules that

defines the combinations of symbols that are considered to be a correctly structured document or fragment in that language.” Java has a textual syntax. The If-sentence bellow is syntactically correct: First code word if followed by token ( , etc. …

slide-3
SLIDE 3

Syntax Example

Jan Pettersen Nytun, UIA, page 3

EBNF is an example of a language for making a formal description

  • f syntax.

E.g., defining integer with help of EBNF: digit <= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer <= [ + | - ] digit { digit } | | means alt alternative [] [] means op

  • ptional

{} {} means repetit ition zero or

  • r more tim

times

slide-4
SLIDE 4

UML Has a Visual Syntax

(and also a textual one)

Jan Pettersen Nytun, UIA, page 4

If sentence in an activity diagram:

age = 10 Print: «Can be retired!» [age>70] [else] Print: «Can not be retired!»

A class is represented with the help of a rectangle:

slide-5
SLIDE 5

Semantics

Jan Pettersen Nytun, UIA, page 5

The study of meanings. Used to differentiate the meaning of an instruction from its format. Semantics "provides the rules for interpreting the syntax which do not provide the meaning directly but constrains the possible interpretations of what is declared.“[1]

[1] Euzenat, Jerome. Ontology Matching. Springer-Verlag Berlin Heidelberg, 2007, p. 36

slide-6
SLIDE 6

Jan Pettersen Nytun, UIA, page 6

age= 10

Print: «Can be retired!»

[age>70] [else] Print: «Can not be retired!»

Semantics of the if-sentence in english: If the boolean expression evaluates to true then execute what is between the following { and }...

The samantics of a branch is the «same as» the if sentence.

Here the symbol function as a merge (i.e., not an if)

int age = 10; if (age >70){ System.out.println(“Can be retired!"); } else { System.out.println("Can not be retired!"); }

slide-7
SLIDE 7

Code Generation

Semantics of UML constructions expressed with Java expressions

Jan Pettersen Nytun, UIA, page 7

package Journal.model; public class Person { private String firstName; private String lastName; } package Journal.model; public class Patient extends Person{ private PatientFile has; } package Journal.model; public class PatientFile{ private java.util.List<PatientRecord> contains; private Patient concerns; }

slide-8
SLIDE 8

8/3/2016 Introduction to Object-oriented Software Development, J.Pettersen Nytun page no. 8,

public class PatientFile{ private java.util.List<PatientRecord> contains;...

MagicDraw: UML  Java

slide-9
SLIDE 9

Operations  Method

Jan Pettersen Nytun, UIA, page 9

public class Person { private String firstName; private String lastName; public String getName( ){ return null; } public void setName( String name ){ } }

slide-10
SLIDE 10

Jan Pettersen Nytun, UIA, page 10

package Journal.controller; import Journal.model.PatientFile; public class JournalApp { private java.util.List<PatientFile> patientFiles; public static void main( String[] args ){ } }

slide-11
SLIDE 11

MagicDraw - I Meny velg: Tools/Generate Code/Java

Jan Pettersen Nytun, UIA, page 11

slide-12
SLIDE 12

Software Engineering

  • Ref. : http://developeriq.in/articles/2013/dec/24/the-myth-of-software-reengineering/

Jan Pettersen Nytun, UIA, page 12