Book a Demo

Author Topic: Persistence - Ongoing "Model-first" approach?  (Read 3827 times)

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Persistence - Ongoing "Model-first" approach?
« on: March 22, 2010, 10:13:52 pm »
Now I know how to generate C# classes and appropriate DDL file from a Project independent Model (http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1268749612).

But how to keep the EA modeled business objects in sync best with a persistence framework like LINQ? LINQ for example uses it's own design tool, but I already have my EA model.

I would be happy if someoe could give me some recommendations on working with persistence frameworks and Enterprise Architect designed classes. The main questions for me are at the moment:

How to avoid having 2 models to maintain (change management general)?
Which frameworks can be recommended by EA users?


Thanx
Tom

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Persistence - Ongoing "Model-first" approach?
« Reply #1 on: March 22, 2010, 10:51:55 pm »
Quote
How to avoid having 2 models to maintain (change management general)?
Hi Tom,

Though I didn't use this in practice so far, I think this is the "kind of intelligence" that somehow needs to be "thrown" to the PIM -> PSM  transformation process itself. The transformation templates can be edited and adapted for your specific PSM(s) needs, very similar as done with code generation templates. This approach could also use certain stereotypes created from your own (or appropriate UML-based standard) profiles to do "special" transformations, identifying " high level" packages and classes in the PIM. These would be things like "Data Transport Layers", "Query engines" (like LINQ, which I think would be a good choice BTW), aso.

Hope I could get you a grip. Other "MDA formalists" may give you different opinions than mine. As mentioned I'm not really experienced with such process, but that's how I can imagine, it could successfully work, without too much (organizational and maintenance) overhead.

VBR
Günther

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Persistence - Ongoing "Model-first"
« Reply #2 on: March 23, 2010, 06:21:56 pm »
I'm sure the MDA purists would say the PIM is the master and everything is generated from it so when change happens you only maintain the PIM and re-generated everything. So in theory you only need to maintain one model, the PIM. However, you know what they say about theory and practice. In theory they are the same but in practice they are different.

Here is a thought for LINQ - you could write you own MDA to create your LINQ model and code from the DDL Model. A kind of two phase MDA process. You would need to identify the common LINQ pattens you would want to use in your application first. You may like to look at LINQ examples to identify the patterns you think would be most useful (See http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx).

I did an PIM->DDL->Stored Procedures (two phase) MDA transformation a few years back on a project that worked quite well and saved a truck load of time.

Afraid EA doesn't support Persistence Frameworks out of the box other than EJB - you have to do the customization yourself.

If your looking for other persistence frameworks as alternatives then consider NHibernate or IBATIS. Unfortunately using any of these with EA means you need to do some customization to EA.

Here is an opportunity for the EA community to contribute to the success of EA by creating MDA scripts to support persistence frameworks such as LINQ. We could upload them to the EA community site
http://community.sparxsystems.com/

Well there is my 2 cents worth.
« Last Edit: March 23, 2010, 06:22:46 pm by phenzell »
Happy to help
:)

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Persistence - Ongoing "Model-first"
« Reply #3 on: March 24, 2010, 01:06:51 am »
I think sunshine is on the right way and a bit more concrete about the homegrown MDA you can use to specify the Query/CRUD engine part.
For the product I was working with my last employer we had special tools that were able to generate code for SQL stored procedures, DDL, C# Mapping (table) code aso., for about 90% of the standard CRUD stuff we needed. Wasn't UML based, I couldn't convince me or my bosses of appropriate UML usage would make sense in our environment. Hmm but I didn't knew EA that time, only MS-Visio and that thingey was consuming more time than it was likely to save (especially when you tried to roundtrip generated code from your models).
At least what always somehow made troubles where that missing 10% that were outside the straightforward standard stuff (e.g. specially "mirrored" change-history tables for certain (business)-critical data, customized data & behaviour, special purpose data mining, performance & scalability tweaks, etc.). I'm afraid those will be left by any transformation(s) from a "master model" in a very similar way. This stuff was "lovingly" handcrafted code (of all kinds SPL, windrops-script, xslt, C# and a bunch more).

Just another 0.02 EUR upon sunshine's
Günther

pocketom

  • EA User
  • **
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Persistence - Ongoing "Model-first"
« Reply #4 on: March 24, 2010, 10:40:32 pm »
Yes, that makes absolutely sense. Extending EA by sharing MDA scripts would be a great thing!

After having a bad experience with ADO.NET Entity, I try NHibernate now. It looks good on first sight, and flexible because no specific design tool is nedded. Now I created a new transformation language "C# NHibernate" in the template editor and copied everything from the default C# template. Let's see how to get these annotations above classes and operations.

EDIT: I found that there is a class modifier "Persistence". Does anybody know how I catch that with the intermediary language? So I wouldn't need to duplicate the C# template and it would be more convinient to have a IF clause for persistence...
« Last Edit: March 24, 2010, 11:12:55 pm by pocketom »