Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • writing classes for OrgUnit, Person and Role and providing get, set, add and remove methods for manipulating accessing and mutator the structure of OrgUnit, Person and Role instances
  • implementing validation for attributes like name (no digits or special characters) and date of birth (no employee is 200 years old), as well as structural validation, e.g. every OrgUnit must have a Person with a leader Role
  • ensuring consistency, e.g. that if a Person belongs to an OrgUnit, both objects refer to each other, and if a Person is removed from an OrgUnit, none of them refer to the other
  • supporting the UI by making the domain objects observable, i.e. provide a mechanism to listen for changes
  • selecting form elements based on attribute types and multiplicity
  • triggering appropriate validation during editing
  • persisting the data, perhaps in a file using XML or JSON format, or in a database

The accessor and mutator methods are trivial, once you know the attribute and association names and multiplicity. The validation code is domain specific, but how it is used by the UI isn't. Consistency of such opposite relations is difficult to code, but always follow the same patterns. Observability is trivial usage of coding patterns. Form element selection is rule-based, with a few options pr. type. Serializing (saving) and parsing (loading) data is a systematic and well-understood process.

We see that only part of the code is domain-specific, but it will be entangled with other code. When writing code by hand, you combine domain-specific and knowledge of coding conventions and patterns.

The idea behind EMF, and model-driven development in general, is to separate the domain knowledge from the coding knowledge. The domain knowledge is captured in a domain model, while the coding knowledge (conventions, patterns, architecture, ...) is part of the framework and tools, using a combination of code generation and generic and so-called reflective code. This relieves the developer from a lot of tedious work, but requires stronger modelling skills and an understanding of how the framework utilizes the model. Once mastered, it provides opportunities for developing with greater agility, efficiency and quality. 

Learning the basics of the Eclipse Modeling Framework (EMF).

...