From isis-dev-return-2089-apmail-incubator-isis-dev-archive=incubator.apache.org@incubator.apache.org Fri Jul 15 16:30:06 2011 Return-Path: X-Original-To: apmail-incubator-isis-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-isis-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1074B6075 for ; Fri, 15 Jul 2011 16:30:06 +0000 (UTC) Received: (qmail 46416 invoked by uid 500); 15 Jul 2011 16:30:05 -0000 Delivered-To: apmail-incubator-isis-dev-archive@incubator.apache.org Received: (qmail 46365 invoked by uid 500); 15 Jul 2011 16:30:05 -0000 Mailing-List: contact isis-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: isis-dev@incubator.apache.org Delivered-To: mailing list isis-dev@incubator.apache.org Received: (qmail 46357 invoked by uid 99); 15 Jul 2011 16:30:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 16:30:04 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dkhaywood@gmail.com designates 74.125.82.175 as permitted sender) Received: from [74.125.82.175] (HELO mail-wy0-f175.google.com) (74.125.82.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 16:29:58 +0000 Received: by wyg30 with SMTP id 30so1031928wyg.6 for ; Fri, 15 Jul 2011 09:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:organization:user-agent:mime-version :to:subject:references:in-reply-to:content-type; bh=L1zp298+mRirEbzIp2XGJ6ZsIVFVfpfAscArDrjpcxU=; b=E7ySb6bxGCbRXwK0/ubc2yuBhr0Zw+vBPKy6G1u0nyDaBFm1mrbiPP+sxpXrlKECQs vLXfnV+am1L85wB9uoXJ2JREX5vXQPrXlc67R6/0EJyzIfjvYzXd8kQFBCoMDHREcY8v qnwYHIOVou+F2Zbnfkrh0DTeaiBQLWGw2bPmM= Received: by 10.216.37.78 with SMTP id x56mr3240570wea.27.1310747377081; Fri, 15 Jul 2011 09:29:37 -0700 (PDT) Received: from [10.111.36.89] ([89.191.33.254]) by mx.google.com with ESMTPS id m46sm380287weq.29.2011.07.15.09.29.35 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 09:29:35 -0700 (PDT) Message-ID: <4E206AF0.10206@gmail.com> Date: Fri, 15 Jul 2011 17:29:36 +0100 From: Dan Haywood Reply-To: dan@haywood-associates.co.uk Organization: Haywood Associates Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.18) Gecko/20110616 Lightning/1.0b2 Thunderbird/3.1.11 MIME-Version: 1.0 To: isis-dev@incubator.apache.org Subject: Re: Problem with non-support of Collections as arguments. References: <4E1EC3BB.28399.82FBE7@kevin.kmz.co.za>, <96D14106-820D-4C08-946E-32C0C59F4EF8@cs.man.ac.uk> <4E200A0E.5272.35ACB2@kevin.kmz.co.za> In-Reply-To: <4E200A0E.5272.35ACB2@kevin.kmz.co.za> Content-Type: multipart/mixed; boundary="------------080004070209070707030502" --------------080004070209070707030502 Content-Type: multipart/alternative; boundary="------------030707020807090101010301" --------------030707020807090101010301 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Just catching up on this thread, interesting stuff you guys have been talking about. In general I'm not a fan of code generation, and indeed wrote a paper a long while back [1] criticising its latest incarnation at the time, namely MDA. The problem of allowing the generated code to be extended to add in imperative behaviour remains difficult, especially on the Java platform. Using the template/hook pattern and subclassing is probably the best option; but it's still horrid. I guess you could look at Lombok project too, though, and hook into the compile pipeline [2]. That'd be academically interesting. For what it's worth, I reckon that .NET is a much better platform for code gen, because it supports partial classes. And, if it was me writing your paper, I'd look at writing a DSL in Boo, and target it at Isis' twin, Naked Objects MVC [3]. Cheers Dan [1] http://www.theserverside.com/news/1365166/MDA-Nice-idea-shame-about-the [2] http://projectlombok.org/ [3] http://nakedobjects.net/ On 15/07/2011 10:36, Kevin Meyer - KMZ wrote: > Hi Iain, > > On 15 Jul 2011 at 1:37, Iain Flynn wrote: > >> On 14 Jul 2011, at 11:23, Kevin Meyer - KMZ wrote: >>> Look at dishevelled: >>> http://www.dishevelled.org/codegen/ >>> >> Done some experimenting and I'm quite impressed! I've done some >> tinkering with one of the Mutable templates and I've managed to >> remove constructors from generated classes (I prefer using >> repositories, and it likes to throw Collections in as parameters) >> and have Collections be eagerly initialised, preventing the >> possibility of null pointers. > Sure - the template based mechanism seems to imply that it'll be > highly configurable. > >> I do have a couple of concerns (can't see a way to declare a class >> as abstract, no support for adding your own methods without them >> getting overwritten upon re-generation) but I'm liking this so far >> and will definitely bring it up with my supervisor when we meet >> early next week. > For abstract support, I presume you should easily be able to either > extend dishevelled's source to support "abstract" as a class type > modifier, or just edit the class templates, or both. > > For losing changes with regeneration, one of the code-generators that > I was readin about yesterday supported the concept of "user comment > blocks" that bracketed user-code. If a user comment block was > present, it'd preserve code between the open and close markers when > it regenerated the code. > > Otherwise, you just add your user code to an extended (sub?)class of > the generated code: > Class UserExtensions extends GeneratedBase { > public boolean hideCustomer(){ > ... > } > } > > where GeneratedBase is the generated code and has the Customer > property (with getters/setters, etc). > > >> As for advantages, I think adding in referential integrity to >> associates (using the mutual registration pattern) and implementing >> a way to add validate methods to operations could be useful for >> generating classes for Isis, and I believe both should be doable. > This reminds me: I have an open JIRA ticket for modifying the Isis > Eclipse templates regarding the mutual registration pattern [1]. > > If you're planning on actually implementing a full parent/child mutual > registration pattern, please let me know how you do so. The current > Isis Eclipse code templates are, AFAIAC, broken (see [1]) - but I've not > proposed a fix as I have not used a child collection that retains a copy > of the parent, or deferred to the parent for addition/deletion. > > I'll patch the templates as required for your purposes. > >> Thank you so much for introducing me to this! > You're welcome. > > For what it's worth, I did find a few other tools that supported code > generation from UML (e.g. ArgoUML [with Eclipse plugin], etc), but I > assumed you wanted to keep to a text-based solution. > > Regards, > Kevin > > > [1] https://issues.apache.org/jira/browse/ISIS-9 > --------------030707020807090101010301 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Just catching up on this thread, interesting stuff you guys have been talking about.

In general I'm not a fan of code generation, and indeed wrote a paper a long while back [1] criticising its latest incarnation at the time, namely MDA.  The problem of allowing the generated code to be extended to add in imperative behaviour remains difficult, especially on the Java platform.  Using the template/hook pattern and subclassing is probably the best option; but it's still horrid.  I guess you could look at Lombok project too, though, and hook into the compile pipeline [2].  That'd be academically interesting.

For what it's worth, I reckon that .NET is a much better platform for code gen, because it supports partial classes.  And, if it was me writing your paper, I'd look at writing a DSL in Boo, and target it at Isis' twin, Naked Objects MVC [3].

Cheers
Dan



[1] http://www.theserverside.com/news/1365166/MDA-Nice-idea-shame-about-the
[2] http://projectlombok.org/
[3] http://nakedobjects.net/


On 15/07/2011 10:36, Kevin Meyer - KMZ wrote:
Hi Iain,

On 15 Jul 2011 at 1:37, Iain Flynn wrote:

On 14 Jul 2011, at 11:23, Kevin Meyer - KMZ wrote:
Look at dishevelled:
http://www.dishevelled.org/codegen/


      

      
Done some experimenting and I'm quite impressed! I've done some
tinkering with one of the Mutable templates and I've managed to
remove constructors from generated classes (I prefer using
repositories, and it likes to throw Collections in as parameters)
and have Collections be eagerly initialised, preventing the
possibility of null pointers. 
Sure - the template based mechanism seems to imply that it'll be 
highly configurable. 

I do have a couple of concerns (can't see a way to declare a class
as abstract, no support for adding your own methods without them
getting overwritten upon re-generation) but I'm liking this so far
and will definitely bring it up with my supervisor when we meet
early next week. 
For abstract support, I presume you should easily be able to either 
extend dishevelled's source to support "abstract" as a class type 
modifier, or just edit the class templates, or both.

For losing changes with regeneration, one of the code-generators that 
I was readin about yesterday supported the concept of "user comment 
blocks" that bracketed user-code. If a user comment block was 
present, it'd preserve code between the open and close markers when 
it regenerated the code.

Otherwise, you just add your user code to an extended (sub?)class of 
the generated code: 
Class UserExtensions extends GeneratedBase {
  public boolean hideCustomer(){
   ...
  }
}

where GeneratedBase is the generated code and has the Customer 
property (with getters/setters, etc).


As for advantages, I think adding in referential integrity to
associates (using the mutual registration pattern) and implementing
a way to add validate methods to operations could be useful for
generating classes for Isis, and I believe both should be doable. 
This reminds me: I have an open JIRA ticket for modifying the Isis 
Eclipse templates regarding the mutual registration pattern [1].

If you're planning on actually implementing a full parent/child mutual 
registration pattern, please let me know how you do so. The current 
Isis Eclipse code templates are, AFAIAC, broken (see [1]) - but I've not 
proposed a fix as I have not used a child collection that retains a copy 
of the parent, or deferred to the parent for addition/deletion.

I'll patch the templates as required for your purposes.

Thank you so much for introducing me to this!
You're welcome.  

For what it's worth, I did find a few other tools that supported code 
generation from UML (e.g. ArgoUML [with Eclipse plugin], etc), but I 
assumed you wanted to keep to a text-based solution.

Regards,
Kevin


[1] https://issues.apache.org/jira/browse/ISIS-9

--------------030707020807090101010301-- --------------080004070209070707030502--