Code Generation

Code Generation

Old forum URL: forums.lhotka.net/forums/t/198.aspx


cds posted on Thursday, May 25, 2006

Hi Guys

This is my first post, though I've been reading for a few weeks...

I'm very enthused about CSLA.NET, but am just trying a few experiments with some real stuff now - thinking about converting/upgrading an existing application to CSLA.NET.

I'm intested in knowing what people use for code generation, if anything. I'm thinking that there's a huge amount of code to write for things like property accessors, etc. if it all has to be written by hand (and especially so when converting an existing app!)

Do you use a code generator, and more importantly, what is the "source" of the generation? From what I can see, I want my business object classes to model my domain and not the way my relational database is structured - so ideally I'd be using some UML model of my classes as input to a code generator, and not my database schema. Or maybe I'm imagining something that doesn't actually exist (but would make an awesome productivity tool if it did!)

I'm most interested in using CSLA.NET with an ORM (LLBLGen is my current tool) but I'm leery of making my business object classes mirror the database (which is exactly what LLBLGen tries to provide) - I really want to get away from that and be able to model my objects according to their behaviour rather than their data structure.

Interestingly there are some guys who've put together a combination of LLBLGen and CSLA.NET - known as JCL - however, from looking at it I'm wary that they've hacked CSLA.NET to use the LLBLGen generated classes as the base classes - the business object classes inherit from the LLBLGen classes and this then ties the business object design to the database. Not what I want...

Thanks in advance for any enlightenment.

Craig

pfeds replied on Thursday, May 25, 2006

Hi Craig,

Have a look at CodeSmith.  There are already CSLA templates that can be used to create your classes.  All you really need to do is state what properties you want and then fill in the data access code.

I've never been a fan of code generation, but I have to say this is a good tool and produces clean code (you define the template to do produce what you want).

xal replied on Thursday, May 25, 2006

I've been working on a tool called CSLAGen for quite some time now.
You can read more about it in Chris' site (http://www.onelittlevictory.com/) in the tips / tricks section. That site will also give you a lot of information!
This tool does get data from your db, but it's very flexible. You can generate your objects based on table(s), view(s) or a stored procedure.
There are some features that are still missing, but it is generating valid code (that I'm using at the office) for Csla and Active Objects. (Only VB for now.)

Andrés

Steven replied on Thursday, May 25, 2006

Is CSLAGen updated for CSLA 2 ?

cds replied on Thursday, May 25, 2006

Hi Andres

From the quick look I've taken as your CSLAGen, it looks like what I was imagining. Certainly sounds promising. Are you working on a version for 2.0 of CSLA?

The other track I'm going down is that my company has previously purchased a tool called Enterprise Architect which is a UML modelling tool. We've really only scratched the surface of it previously but the version we have supports MDA and being able to transform a UML model, through templates, into something else. At this stage, I'm thinking that if I wrote some templates for CSLA.NET this would give me what I'm looking for.

Craig

cds replied on Thursday, May 25, 2006

Hi Andres

I looked at Chris' site in the tips/tricks section, then went to SourceForge to download the project, but it's not the same version as Chris's page refers to. Where do I get the version his tutorial is for?

Thanks,

Craig

P.S. I went to www.cslagen.com but it comes up with some ASP.NET configuration error :Smile [:)]

xal replied on Friday, May 26, 2006

Hi Craig,
www.cslagen.com has nothing to do with the project.
The sourceforge page is outdated at the moment, but I'm hoping to integrate everything back there in a not too distant future.

Cslagen only supports vb for 2.0 (at least for now). There are still some missing features (that should be integrated soon).
Btw, I'm looking for contributors for porting changes to C# templates... Anyone interested drop me a line.
Also, the ones interested in testing cslagen at it's current state, send me your email address and I'll add you to the group. I think at this stage it's ready for a wider testing, although, you should expect bugs and you should definitely use it only for testing purposes.

Andrés

xal replied on Friday, May 26, 2006

Sorry, after re-reading my post i realize it looks like 1.x is not supported but it is. It is supported for vb and c#.

Andrés

cds replied on Friday, May 26, 2006

Hi Andres

I'm certainly keen on getting my hands on this, and would like to be able to contribute.

Craig

 

BasharLulu replied on Sunday, June 18, 2006

Hey Craig,

I'm one of the people who've compiled the JCL Framework, and I'd like to inform you that on an upcoming version of the framework, we will be doing exactly what you asked for: allow the users to create objects based on behaviour and NOT data.

If you read the blogs on the JCL website www.jclframework.net you'll see what I mean.

Bashar

Copyright (c) Marimer LLC