EMF + Xtend = BOEM

Builder Of EMF Models

Why Boem

Migration project

  • Old: Rational Rose
  • Old: UML Stereotyped language (without specs) (> 15 years)
  • Big: ~1.5M semantic elements
  • Complex: Split into 1700+ ressources with cyclic references
  • Complex: Business rules for validation and reference scopes

Lesson learned: WE NEED TESTS!!

  • Need efficiency: We are going to write a lot of tests
  • Need flexibility: Metamodel constantly evolving
  • Need readability: We need to maintain them in the long term
  • Need fun: Team needs to use fun tech to maintain interest in the project

What is Boem

  • Xtend language
    • Easy to read
    • Compliant with java
  • Simple EMF model builder
    • Fast to write & easy to read
    • Compiling => Fail fast
    • Maintainable
  • Flat learning curve
  • Used in industrial project
  • Lightweight (< 500 lines of code)
  • Inspired by: EclipseCon France 2016 talk by Max Bureck

Set up

Download from here

Add a dependency to fr.ibp.odv.boem.lib

Extra required dependencies (XTend)

  • com.google.guava
  • org.eclipse.xtext.xbase.lib
  • org.eclipse.xtend.lib
  • org.eclipse.xtend.lib.macro

Create a XTend class with a Boem factory


											extension BoemFactory factory = new BoemFactory(YourMM.eINSTANCE)
												

Import helpers

									import static extension fr.ibp.odv.boem.lib.Boems.*
										
You are ready to go!

Concepts

How to create objects

fr.ibp.odv.boem.tests.uml.UmlCreateObject

How to create trees & resources

fr.ibp.odv.boem.tests.uml.UmlBuildTreeTest

How to access object

fr.ibp.odv.boem.tests.uml.UmlObjectAccessTest

Settings references

How to add multiple objects

fr.ibp.odv.boem.tests.uml.UmlSettingReferences.testMultipleAdd()

Settings references

How to set single reference

fr.ibp.odv.boem.tests.uml.UmlSettingReferences.testSingleSet()

Settings references

How to use ids

fr.ibp.odv.boem.tests.uml.UmlSettingReferences.testUsingIds()

Settings references

Defining an implicit id provider


extension BoemFactory factory = new BoemFactory(UMLPackage.eINSTANCE) //
.registerIdProvider([
	if (it instanceof NamedElement) {
		return it.name
	}
	return null
])
																			

Settings references

How to use implicit ids

fr.ibp.odv.boem.tests.uml.UMLImplicitIds

How to update a model

fr.ibp.odv.boem.tests.uml.UmlUpdate

Demo

What's next

  • Boem serialization from existing models
  • Improving Xtend editor
    • Enum completion
    • Code folding lambda (done in Xtend Editor >=2.13)
  • Sirius Boem integration: Sessions and Representations
  • Any uncovered requirement? Ask or contribute on Github

Thanks for you attention. Any question?

Thanks also to Nicolas Peransin and Laurent Latil