MDE Exercises

This article provides a number of exercises which enable you to test your knowledge on MDE, EMF and Epsilon.

Exercise 1

Create Ecore metamodels and exemplar models for the following scenarios:
  1. All school rooms have a buzzer triggered by a central clock to signal the end of the school day.
  2. Political parties, such as the Labour Party, the Conservative party, and the Liberal Democrat party, have both voters and supporters.
  3. An undirected graph consists of a set of vertices and a set of edges. Edges connect pairs of vertices.
  4. A football league has a set of teams, where each team has a manager and a set of players. A player is a forward, defender, or goalkeeper. The manager cannot be a player.
  5. A student is awarded a prize. Each prize is donated by at least one sponsor, e.g., IBM. A prize may be jointly awarded. Each student must write a letter thanking the sponsors of their prize

Exercise 2

Consider the class diagram below.
  • Rewrite the class diagram above as an Ecore metamodel and create a sample model that conforms to it
  • Write the following EVL constraints
    1. In the context of class Student, write a constraint stating that a student takes up to 6 modules
    2. In the context of class Grade, write a constraint stating that the mark must always be non-negative.
    3. In the context of Module, write a constraint stating that every student must have a unique name.
    4. In the context of Student, write a constraint that states that the grades for the modules taken by a student must be identical to the grades that the student knows about directly

Exercise 3

The Office Management System (OMS) is used to manage the rooms available to a company. It keeps track of who is assigned to occupy a room, along with their position in the company. It facilitates providing newly hired employees with offices, and assists employees who are to move from one office to another. Employees have positions, an office (offices are never shared), and know when they started work at the company and when they ended their employment. The OMS keeps track of all employees and rooms. Rooms are either occupied or unoccupied.
With the OMS, it is possible to:
  1. hire a new employee and assign them to a room
  2. fire an employee and remove them from their office
  3. move an employee from one room to another, unoccupied room
  4. calculate the set of rooms that are unoccupied (useful for planning)
With this scenario in mind you need to do the following:
  • Write an Ecore metamodel for the system above
  • Write the body of the following EOL operations that implement 1-4 above
    1. operation Employee hire() { ... }
    2. operation Employee fire() { ... }
    3. operation Employee move(to:Room) { ... }
    4. operation Company getFreeRooms() : Sequence(Room) { ... }

Exercise 4

Create GMF editors for the metamodels you have written in Exercises 1,2 and 3 using EuGENia.