jgs CSE 564 Software Design Lecture 24: Model-Driven Development II Dr. Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
jgs 564 00000100 § 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
jgs 564 00000100 § 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();
jgs 564 00000100 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
jgs 564 00000100 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.
jgs 564 00000100 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); } }
jgs 564 00000100 Assignment UML Class Diagram 1. Define the Model in EMF (take a screen shoot) 2. Use the Code to Create a Class Diagram (only the Model and Test packages and include both interfaces and implementations). It will be bigger and more complex that the one provided 3. Create a document with the screen shoot of your model and your UML diagram. The diagram is going to be bigger and different from the one used as input! Car Engine Wheel
jgs 564 00000100 Stable Dependency Principle (SDP) § Every dependency between modules should terminate on a module whose Instability is less than or equal to the depending module's Instability. § Every dependency between modules should terminate on a module whose Abstractness is greater than or equal to the depending module's Abstractness.
jgs CSE 564 Computer Systems Fundamentals Javier Gonzalez-Sanchez [email protected] Fall 2020 Disclaimer. These slides can only be used as study material for the class CSE564 at ASU. They cannot be distributed or used for another purpose.