Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I use EMF?

I've read some tutorials about EMF and I still wonder why I should use it.

Until now, I was generating my POJOs from XSD schema + JXC, or by hand.

As far as I understand EMF it can be useful to define some complex relationships between the classes (one-to-many, etc...). But is that all? Isn't it more complicated to generate the code with EMF? Doesn't it add some extra-dependencies?

like image 975
Pierre Avatar asked Apr 01 '11 17:04

Pierre


People also ask

What are the benefits of EMF?

These include nerve regeneration, wound healing, graft behavior, diabetes, and myocardial and cerebral ischemia (heart attack and stroke), among other conditions. Preliminary data even suggest possible benefits in controlling malignancy.

Why do we need EMF protection?

There may be an association between increased EMF exposure and health conditions such as breast cancer, Alzheimer's disease, infertility, cardiovascular ailments and possibilities of miscarriage. Thus, it is important that today's electrical devices are shielded and not radiating harmful emissions into the environment.

Where is EMF used in real life?

In daily life everybody is, to a greater or lesser degree, exposed to electromagnetic fields. Examples are the fields produced by kitchen appliances, radio transmitters and mobile phones.

What does EMF do to your brain?

It was reported that EMF exposure was associated with neurological diseases such as Alzheimer's disease that is increasing the level of amyloid beta, a risk factor, in the brain. Long-term EMF exposure may result in Alzheimer disease like symptoms due to enhancing oxidative stress (Jiang et al., 2013).


2 Answers

In general terms one could say that using emf provides several benefits at runtime.

On a first stage you'll notice that the ecore classes (and the emf runtime) offer what you might need from your POJOs in your application. There's no further coding needed in a lot of areas whereas you would need to code a lot by hand when using plain POJOs:

  • You get a full blown notification system (no PropertyChange coding any more). It even offers notifications for changes that occur further down in you instance-tree (attach listener to x, get notified of changes in y which is referenced by x).
  • values are unsettable (actually a very common need: you need to know about 3 states of a value: it is set, it is set to null or it was not touched).
  • bi-directional references: X references Y and vice-versa. Remove the reference to Y in X, the opposite reference is removed, too.
  • XML, XMI (etc.) serialisation support out-of-the-box.
  • lazy loading: you can partition your model and have certain parts loading lazyly only.
  • etc.

Extensions to EMF even offer far more:

  • EMF Query or EMF Path add advanced query capabilities to collect pojo instances for given criterias
  • CDO allows you to code 3-tier applications without any further hand-coding. CDO adds Database persistency and remote notification (sessions, transactions, versioning, branching, etc.)
  • Xtext adds serialization to custom DSLs (define your own serialization format/dialect)
  • etc.

You could actually argue that EMF/Ecore offers a standard for POJO and a whole ecosystem grew around it that actually offers what you would code by hand in a classic approach.

To be honest, the downside of EMF is that you get tied to the Ecore runtime which is very fine if you code Eclipse based rich clients but may become an issue if you are on the server.

like image 90
adietisheim Avatar answered Sep 22 '22 07:09

adietisheim


IF your only interest is generation of POJOs, then I agree that there are many alternatives out there to achive the same you can do with EMF.

However, Java generation was just the first application of EMF. Now there are a huge number of EMF-based Eclipse plug-ins that give your for free a lot of functionalities to manipulate (query, validate, transform,...) your EMF models.

See the Eclipse Modeling Project for a list of official Eclipse projects on EMF.

Also, take a look at Acceleo to see the flexibility of their template-based generation approach from EMF models (for Java, PHP,...).

like image 34
Jordi Cabot Avatar answered Sep 23 '22 07:09

Jordi Cabot