Presentation is loading. Please wait.

Presentation is loading. Please wait.

Syntax & Semantics UML - Java

Similar presentations


Presentation on theme: "Syntax & Semantics UML - Java"— Presentation transcript:

1 Syntax & Semantics UML - Java

2 Syntax Java has textual 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 correctly structured document or fragment in that language.” Java has textual syntax. The If-sentence bellow is syntactically correct: First code word if followed by token ( , etc. … int age = 10; if (age >70){ System.out.println(“Can be retired!"); } else { System.out.println("Can not be retired!"); }

3 UML Has a Vusuall Syntax (and also a textual one)
If sentence in an activity diagram: [age>70] Print: «Can be retired!» age = 10 [else] Print: «Can not be retired!»

4 Semantics The study of meanings. Used to differentiate the meaning of an instruction from its format. int age = 10; if (age >70){ System.out.println(“Can be retired!"); } else { System.out.println("Can not be retired!"); } Semantics of the if-sentence: If the boolean expression evaluates to true then execute what is between { and }... Here the symbol function as a merge (i.e., not an if) [age>70] Print: «Can be retired!» age= 10 [else] Print: «Can not be retired!» The samantics of a branch is the «same as» the if sentence.

5 Code Generation Semantics of UML constructions expressed with Java expressions
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; }

6 MagicDraw: UML  Java public class PatientFile{
private java.util.List<PatientRecord> contains;... 7/2/2018

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

8 This was problematic in MagicDraw
This was problematic in MagicDraw. Did some reverse engineering to get this in place... package Journal.controller; import Journal.model.PatientFile; public class JournalApp { private java.util.List<PatientFile> patientFiles; public static void main( String[] args ){ }

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

10 Software Engineering Ref. :


Download ppt "Syntax & Semantics UML - Java"

Similar presentations


Ads by Google