syntax semantics
play

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


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

  2. 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 a 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

  3. Syntax Example EBNF is an example of a language for making a formal description of 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 optional {} {} means repetit ition zero or or more tim times Jan Pettersen Nytun, UIA, page 3

  4. UML Has a Visual Syntax (and also a textual one) A class is represented with the help of a rectangle: If sentence in an activity diagram: [age>70] Print: «Can be age = 10 retired!» [else] Print: «Can not be retired!» Jan Pettersen Nytun, UIA, page 4

  5. Semantics 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 Jan Pettersen Nytun, UIA, page 5

  6. 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 in english: If the boolean expression evaluates to true then execute what is between the following { and }... Here the symbol function as a merge (i.e., not an if) [age>70] Print: «Can age= 10 be retired!» [else] Print: «Can not be retired!» The samantics of a branch is the «same as» the if sentence. Jan Pettersen Nytun, UIA, page 6

  7. 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; } Jan Pettersen Nytun, UIA, page 7

  8. MagicDraw: UML  Java public class PatientFile { private java.util.List<PatientRecord> contains;... 8/3/2016 Introduction to Object-oriented Software Development, J.Pettersen Nytun page no. 8,

  9. Operations  Method public class Person { private String firstName; private String lastName; public String getName( ){ return null; } public void setName( String name ){ } } Jan Pettersen Nytun, UIA, page 9

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

  11. MagicDraw - I Meny velg: Tools/Generate Code/Java Jan Pettersen Nytun, UIA, page 11

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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend