Announcements § Quiz 04 opens today, and it is due on December 1. It is an assignment about EMF (described at the end of this lecture) § Quiz 05 opens today, and it is due on December 1. Questions about Software Design
Grades § 5 Quizzes (25%), therefore 5% each § 6 Assignments (25%), therefore 4.16% each. Notice that Assignment 4.1 was replaced by 4.2 § Midterm Exam (25%). Grades are posted. You need Lockdown Browser to access. § Final Exam (25%).
Final Exam § Final Exam is comprehensive § Take a look to the review done in lecture 15 § Additionally, a) Software design, i.e., class diagrams, coding, match code and design b) Design Smells, i.e., is this a correct design (y/n) ? c) Software Architecture and Architecture Patterns d) Model-Driven Development and EMF
Schedule § Final Exam is scheduled December 1 during the lecture time … Me and many other students who take SER 531 and SER 540 along with CSE 564 have all 3 of our exams on 1st of December I will send a survey. But since we announce it (October 13) to be December 1, it could probably stay that way, unless unanimously request to change. I will let you know as soon as everyone answer the survey
Generator Model § Create a generator model. This allows to configure properties for the code generation that are not part of the model itself. § Generate a maximum of four different plugins for a defined model: 1. Model plugin contains all entities, packages and factories to create instances of the model. 2. Edit plugin contains providers to display a model in a UI. For example, the providers offer a label for every model element, which can be used to display an entity showing an icon and a name. 3. Editor plugin is a generated example editor to create and modify instances of a model. 4. Test plugin contains templates to write tests cases for a model.
Step 3 :: Generate Code § Right click the model folder in the project then § New → Other… → EMF Generator Model → Next § and enter myModel.genmodel as the file name. § Select Ecore model as the model importer. § select Browse Workspace… and select our previously created myModel.ecore
Step 3 :: Generate Code § Based on the generator model, we can now generate the source code. § EMF allows you to generate 4 different plugins. § To generate the plugins, right-click on the root node of the genmodel and select the plugin. For our tutorial, please select “generate all”.
§ For each class in your model, there is a corresponding generated § Java interface § Java implementation class § For each package, there is a § XXXPackage interface and implementation class § XXXFactory interface and implementation class
§ These are singletons, to access the instances use § XXXPackage.eINSTANCE § XXXFactory.eINSTANCE § Use the Factory to create instances of your model classes, e.g: TaskList t = ExampleFactory.eINSTANCE.createTaskList(); § Use the Package to access the meta-model definition, e.g: EClass c = ExamplePackage.eINSTANCE.getTaskList(); List attrs = c.getEAttributes();
Why is This Better than Writing POJOs? § plain old Java object (POJO) § We have generated over 1,000 LOC, § Even very simple code is considered to be worth $1 per LOC. So, $1,000 just by clicking some buttons
Test Cases § Generated test class for all the entities of your model. § Add methods starting with “test” to create single test cases. § Run test cases with a right-click on the test class then. “Debug As” => “JUnit Test”. In this context, test cases are very simple way of exploring and using the API of the generated classes.
Test Cases § Use the MyModelFactory to create a Course and a Student public class CourseTest extends TestCase { // original code... public void testCourseStudentReference() { Course course = MyModelFactory.eINSTANCE.createCourse(); Student s1 = MyModelFactory.eINSTANCE.createStudent(); course.getStudents().add(s1); assertEquals(course.getStudents().get(0), s1); } }
Quiz 04 UML Class Diagram 1. Define the Model in EMF (take a screen shoot) 2. Generate Code (take a screen shoot) 3. Use the Code to Create a Class Diagram (only the Model package but include both interfaces and implementations). It will be bigger and more complex that the one provided 1. Create a test case to create (using the factory) one instance of each class EMF (take a screen shoot) 2. Run it (take a screen shoot)