Syntax Semantics UML Java Jan Pettersen Nytun page

  • Slides: 10
Download presentation
Syntax & Semantics UML - Java Jan Pettersen Nytun, page no. 1

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

Syntax From Wikipedia, the free encyclopedia: “…the syntax of a computer language is the

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!"); } Jan Pettersen Nytun, UIA, page 2

UML Has a Vusuall Syntax (and also a textual one) If sentence in an

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

Semantics The study of meanings. Used to differentiate the meaning of an instruction from

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 }. . . [age>70] age= 10 [else] Print: «Can be retired!» Here the symbol function as a merge (i. e. , not an if) Print: «Can not be retired!» The samantics of a branch is the «same as» the if sentence. Jan Pettersen Nytun, UIA, page 4

Code Generation Semantics of UML constructions expressed with Java expressions package Journal. model; public

Code Generation Semantics of UML constructions expressed with Java expressions package Journal. model; public class Person { private String first. Name; private String last. Name; } package Journal. model; public class Patient extends Person{ private Patient. File has; } package Journal. model; public class Patient. File{ private java. util. List<Patient. Record> contains; private Patient concerns; } Jan Pettersen Nytun, UIA, page 5

Magic. Draw: UML Java public class Patient. File{ private java. util. List<Patient. Record> contains;

Magic. Draw: UML Java public class Patient. File{ private java. util. List<Patient. Record> contains; . . . Introduction to Object-oriented Software Development, J. Pettersen Nytun page no. 6, 3/3/2021

Operations Method public class Person { private String first. Name; private String last. Name;

Operations Method public class Person { private String first. Name; private String last. Name; public String get. Name( ){ return null; } public void set. Name( String name ){ } } Jan Pettersen Nytun, UIA, page 7

This was problematic in Magic. Draw. Did some reverse engineering to get this in

This was problematic in Magic. Draw. Did some reverse engineering to get this in place. . . package Journal. controller; import Journal. model. Patient. File; public class Journal. App { private java. util. List<Patient. File> patient. Files; public static void main( String[] args ){ } } Jan Pettersen Nytun, UIA, page 8

Magic. Draw - I Meny velg: Tools/Generate Code/Java Jan Pettersen Nytun, UIA, page 9

Magic. Draw - I Meny velg: Tools/Generate Code/Java Jan Pettersen Nytun, UIA, page 9

Software Engineering Ref. : http: //developeriq. in/articles/2013/dec/24/the-myth-of-software-reengineering/ Jan Pettersen Nytun, UIA, page 10

Software Engineering Ref. : http: //developeriq. in/articles/2013/dec/24/the-myth-of-software-reengineering/ Jan Pettersen Nytun, UIA, page 10