NMFCode / NMF

This repository contains the entire code for the .NET Modeling Framework
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

What is the different between EMF and NMF? #19

Closed chansey97 closed 6 years ago

chansey97 commented 7 years ago

I'm looking for library which like EMF in .NET platform. (Unfortunately, the EMF4NET is dead. ) Is NMF another EMF port on C# ? or Equavalent tool? What is the different between EMF and NMF? Could I think of EcoreInterop is a wrapper of Ecore in NMF? For example: EPackage ePackage= EcoreInterop.LoadPackageFromFile("myModel.ecore"); var eFactoryInstance = package.EFactoryInstance;

Can I treat ePackage and eFactoryInstance as if they were in EMF? But I can't find "create(EClass eClass)" method in EFactory, how to create new instance in NMF?

Best regards.

georghinkel commented 7 years ago

Hi and thanks for your interest in NMF.

I would rather describe NMF as a complete new development inspired by EMF rather than a port of it. That is, the general idea is the same, but the details are very different.

The complete answer what NMF is, is available as a publicly accessible technical report: http://nbn-resolving.org/urn:nbn:de:swb:90-537082. There is also a YouTube video that explains how to get started with NMF: https://youtu.be/NIMYuwTltVs

In short, NMF is able to generate C# code for a given metamodel. Unlike EMF, generating the code is actually a must in NMF, so dynamic instances are not supported. Using EcoreInterop, this metamodel may either be an Ecore metamodel, or a metamodel of NMF's own meta-metamodel NMeta. Using the latter has the advantage that you also get support for stereotypes, refinements and deep modeling. However, NMF is not only about model representation, but also about model processing. So next to standard C# and the generated model API, you also have two model transformation languages (one unidirectional without change propagation and another one with support for both) and a powerful incrementalization system.

To answer your confusion about the code example you provided: The LoadPackageFromFilefunction is a shortcut to load an Ecore package from a file. What you get is that EPackage, but not in a representation that you know from EMF, but in the NMF representation. This means that things like factories do not exist. Rather, you simply create instances of metaclasses using the default constructor of the implementation class. In case this is not generic enough, you can use the standard .NET reflection API to create an instance. Any class that has been generated to code has a runtime stereotype called MappedType from which you can query the implementation class (but not the interface, yet).

Best regards,

Georg

georghinkel commented 7 years ago

I hope that answers your main questions. In case you need further help, do not hestitate to ask.