What does Rocky use for code generation?

What does Rocky use for code generation?

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


zythra posted on Thursday, June 29, 2006

Code generation is a common topic in the forum with many people using many different generators, from CodeSmith, CSLAGen, to personally rolled generators.  I'm curious, what does Rocky use?  I find it hard to believe that Rocky (Magenic) would code everything by hand, especially being a fairly sizable consulting company, not to mention the fact that the book mentions generating code as well as there being portions of the framework that cater to generators.

I've assumed (maybe I shouldn't) that Rocky/Magenic uses a proprietary, in-house generator.

Anyway, just a curiosity a friend of mine and I have wondered about.

:-)

Brian Criswell replied on Thursday, June 29, 2006

Rocky has mentioned in the past that Magenic has a purpose-built code generator.

zythra replied on Thursday, June 29, 2006

What is "purpose-built"?

Brian Criswell replied on Thursday, June 29, 2006

Built for the purpose of generating applications that use CSLA.  At least that is how I understood it.

zythra replied on Thursday, June 29, 2006

Gotcha.  I think that's probably what most people are after in the forums; a generator that generates applications that use CSLA.  If he uses something properietary I assume Magenic probably keeps it close to their heart to give them an edge, if not, I'd be interested in it.  :-)

skagen00 replied on Thursday, June 29, 2006

It's called FBOA - Foundation Business Object Accelerator - you're able to leverage it if you co-develop with Magenic if I understand correctly. (You can find it on Magenic's site - the mention of it that is)

I do wonder if it actually utilizes one of the code gen options out there.

ajj3085 replied on Thursday, June 29, 2006

Just out of curiosity, what do you generate your BOs from?  I have a generator for my DAL which examines the tables in the database, but for business objects?


skagen00 replied on Thursday, June 29, 2006

Me? I don't code gen, myself. Not yet anyways.

(Call me crazy but I don't really know how much I'd benefit - the stuff that's easily replicatable via code generators takes very little time to type and snippets kick butt anyways. Though I can see how something for the DAL could be definitely useful)

I highly recommend using snippets for anyone not already doing so.

Here is an article about creating your own snippets:

http://aspnet.4guysfromrolla.com/articles/122105-1.aspx#postadlink 

And Rocky has some in the Csla code - csla20cs\Snippets

 

 

Brian Criswell replied on Thursday, June 29, 2006

To me, snippets are like one-off generation, they give you a tremendous boost, but you are then stuck with whatever you made.  One thing I have realised over the last year is how powerful regeneration is.  The ability to fix all occurrences of a bug or adding a piece of functionality to all the objects in a few seconds was fairly shocking the first few times I did it.

RockfordLhotka replied on Thursday, June 29, 2006

Yes, Magenic has a code generator called FBOG. Actually two of them, neither based on a custom generation engine. The first one was for CSLA 1.x and uses the code DOM, the second is for 2.0 and uses straight text output to escape the limitations of the code DOM.

These generators are built with the intent of augmenting Magenic's consultants as they work on projects, and the generator stays behind with the client when our consultants leave. But my point is that they aren't designed for "casual use" like CodeSmith; meaning no docs, a UI that lacks polish, etc. The tools aren't designed to compete with other code-generators, but rather to allow Magenic to compete with lower-cost consulting firms.

Which is a really long-winded way of heading off the next question, which is whether I can make FBOG available. I can't. Magenic owns it, not me, and they provide it as part of their consulting services only.

What I've been working on, off and on, is trying to come up with a new language for describing objects. Perhaps I'm on a fool's errand, but I look at the amount of code required to write an object, even with CSLA, and I think it is ridiculous. If you go through your code and identify only the lines of code that perform actual business functions - that have actual business value - you'll find that it is perhaps 4%. The rest of the lines of code are mandated by C# or VB or ADO.NET or Windows Forms or Web Forms or whatever. All "plumbing", and none of it valuable to the business need.

How does this tie into code-gen? A compiler is merely a fancy code generator. If I can come up with a more concise language to describe business objects (at least CSLA business objects), then I can code-gen CIL directly by creating a compiler for my language.

Thus far though, I have not been happy with any results Sad [:(]

zythra replied on Thursday, June 29, 2006

Thanks for the reply Rocky.

This has been an interesting thread, if anything it has given me a little more insight as to what others are attempting to do.

Currently all of my code is generated, well, obviously not all, but everything that is redundant and can be reasonably generated  The company I work for uses their own proprietary framework along with their own proprietary generator.  It all works very well and I really like it, but I can't use it outside of projects for them, sort of like FBOG and Magenic.

All of my side work has been NHibernate using a generator I wrote that is entirely table driven (which I hate doing).  It uses NVelocity templates.

Another gentleman and I have been working on a generator for CSLA and as soon as we feel it is ready, then I will be doing all of my contract work with generated CSLA code.  Our new generator uses XSLT templates and is coming along quite well.  My friend has done all of the work so far and he's done a great job.

Anyway, it's good to hear other ideas and to hear what you are using Rocky.

Dustin :-)

ajj3085 replied on Friday, June 30, 2006

It would seem that a code generator would could raise, say a Visio document, and is aware of Csla would be a good way to generate code.  Has anyone gone down this path?

Andy

Brian Criswell replied on Friday, June 30, 2006

From my experience a couple years ago, the Visio object model seemed to be a mess, and it was difficult to get information out of it.  Maybe that has changed in recent releases though.

ajj3085 replied on Friday, June 30, 2006

It didn't have to necessarly be Visio, although I think newer releases include some kind of built in code generator.  I haven't played with it though..

Andy

Tom Cooley replied on Friday, June 30, 2006

I've always thought that a UML-driven approach makes the most sense. Something like a Visio model or some other tool. I've not used Rational or any of the other high-end suites but I would imagine that some form of code-gen exists in these tools. So far, I have not found anything within my price range.

So, I have been using CodeSmith. My company has not yet switched to .Net 2 (coming soon) so I'm using the templates originally created by Matt Altadonna but then ported to C# by Ricky Supit. I've made a lot of changes to these templates to help reduce the amount of code changes needed, but I still feel they fall considerably short. One of primary issues for me is that they are only driven by tables. We all use (or should use) stored procedures to interact with a database and the result sets these stored procedures often do not structurally match the root table with which they interact. There are often joins to replace/augment foreign key values and multiple result sets and such and this is where table-driven code gen just falls apart.

When Ricky recently released his templates for CSLA 2, this feature was still not there. However, because he had completely rewritten the templates, he made it much, much easier to add this support than would have been possible with templates for CSLA 1. I offered to add that support and it is now available.

For business objects whose responsibility it is to maintain data (and many of them fall into this category), code gen makes sense. For me anyway, now that I can do this from stored procedures, my work load is getting a little easier. In fact, I am generating much of the code for my CSLA 1 business objects using the CSLA 2 templates. It's by no means a perfect system as I generate the same class from both sets of templates and then mash them together through cut/paste. But it still beats the alternative of hand-coding all the repetative portions of a class.

Tom

RockfordLhotka replied on Friday, June 30, 2006

Not to be overly contrary, but I very much dislike the UML approach :)
 
The reason is that UML tends to lead people down a data-centric design. The UML class diagram is terribly close, in concept, to a database ER diagram, and so most people tend to treat UML class diagrams like ER diagrams - normalizing data, etc. Very bad.
 
Of course, UML doesn't _force_ this to happen. You can fight against it with strong personal discipline and lots of experience doing behavioral/responsibility driven design. But it requires effort and experience, and the vast majority of OO designers end up falling into the data-centric pit.
 
Additionally, UML class diagrams don't convey behavior. There's no semantic meaning there. So to do real code generation with UML you must do at least two diagrams for every class (class, activity) and usually others as well. UML does have 11 diagrams, and to completely describe a system you need to do all of them...
 
Remember that the "L" stands for language. And it is a very complex language, because it is allowing you to express very complex concepts. To do a real code generator based on UML, you are effectively agreeing to build a compiler that merges all 11 diagrams into a single set of output.
 
Obviously you can gain benefit by just generating output from a class diagram - but that is, I think, woefully inadequate in the bigger picture. That doesn't even get you as far as most of the other CSLA gen tools, because they include all that database metadata, that a class diagram doesn't have.
 
Rocky


From: Tom Cooley [mailto:cslanet@lhotka.net]
Sent: Friday, June 30, 2006 8:53 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] What does Rocky use for code generation?

I've always thought that a UML-driven approach makes the most sense. Something like a Visio model or some other tool. I've not used Rational or any of the other high-end suites but I would imagine that some form of code-gen exists in these tools. So far, I have not found anything within my price range.

david.wendelken replied on Friday, June 30, 2006

RockfordLhotka:
... the vast majority of OO designers end up falling into the data-centric pit.  ...
 
No offense meant, but that statement had me falling out of my chair laughing!
 
Why?
 
Because for the last 20 years, it's been my experience that the vast majority of Entity-Relationship designers end up falling into the behavior modeling pit!
 
Maybe they should all exchange job responsibilities and we could all be happier with the designs we get saddled with.
 
 

RockfordLhotka replied on Friday, June 30, 2006

Hehe :)
 
Perhaps the reality is that everyone ends up in a "neither here nor there" no man's land in the middle. Where entities reflect too much behavior, but still reflect data. And where objects reflect too little behavior, and too much data...
 
But if I caused laughter then I am glad - when ever possible all this should be fun :)
 
Rocky


From: david.wendelken [mailto:cslanet@lhotka.net]
Sent: Friday, June 30, 2006 11:55 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: What does Rocky use for code generation?

RockfordLhotka:
... the vast majority of OO designers end up falling into the data-centric pit.  ...
 
No offense meant, but that statement had me falling out of my chair laughing!
 
Why?
 
Because for the last 20 years, it's been my experience that the vast majority of Entity-Relationship designers end up falling into the behavior modeling pit!
 
Maybe they should all exchange job responsibilities and we could all be happier with the designs we get saddled with.
 

HarvDotNet replied on Saturday, July 01, 2006

I have been using Code Generation for some time.
This has always been a home grown method
I started by generating for CSLA for VB6 and then moved to CSLA 1.x

Right now, I am generating pretty much all of the classes, (parent, child collection, and child), name value lists, etc. I also generate all the stored procedures and a basic MDI child form and dialogs with all the fields on the forms.

The stored procedures that I generate also include corporate standards for generating audit information etc.

So the home grown code generation approach works very well, BUT....

My concern is that code generation seems to be missing the behaviour aspect of OO and I am wondering how you can get that from meta data or ER diagrams.



Harvey Sather




david.wendelken replied on Monday, July 03, 2006

HarvDotNet:


So the home grown code generation approach works very well, BUT....

My concern is that code generation seems to be missing the behaviour aspect of OO and I am wondering how you can get that from meta data or ER diagrams.

You can only take automated code generation from an ERD a certain distance, and then that's it.

(It's farther than many people think, particularly if you supplement it with a behaviour-oriented meta-model that contains keywords or phrases to watch out for in the entity, attribute or relationship names.)

For example, I once wrote a program that would deduce candidate business rules from a data model.  Example: rules like start<something> or begin<something> needs to be less than or equal to end<something>.   I identified quite a few commonly recurring business rule patterns and would load the candidate rules into a meta-structure (where I could approve/disapprove them).  Other candidate rules would include a no-overlapping records rule: identified by a table that contained a multi-column primary or unique key, where the leading portion of the key was an foreign key to the parent table and the trailing columns contained a start<something> or begin<something> kind of column name.   Basically, the rule finder was a specification generator.  From there, a code generator build the data access layer with its associated validation logic.  (No complaints about where the code was - I wasn't using OO languages then. :)

With a little extra data stored about the relationships and a meta-data keyword repository, it's fairly straightforward to deduce which entities need to be maintained from the same screen.  For example, Invoice Header and Invoice Line Item will often be maintained together, whereas Invoice Header and Invoice Type will not.  That can be deduced because although all three entities share the same root word (Invoice) and would be connected via a chain of one-to-many relationships - Invoice Type contains a word that denotes a category or grouping of meta-data about Invoices, whereas Invoice Header does not.  (It could be tuned by placing a <put them together> or <split them apart> code in the relationship meta-data.) I would pull these candidate maintenance screen data elements out of a data model via a utility program and put them into a meta-model that defined the screens' purpose and data usages.    From there, further automated transformations (supplemented with manual enhancements and special hand-coded business logic) would turn them into code.

Now that I'm in the .Net world instead of the Oracle Forms world, I'm having to re-build my repository and code generation infrastructure.   I'm looking for some good xml or relational meta-models that are already in use for holding object specifications - or I'll roll my own if need be.

(Feel free to point me in the right direction!)

 I'm planning on adapting the techniques I used to mine an ERD to build candidate OO business object and maintenance/review screen specifications.  From there, I'll supplement the meta-model by hand and by utility, then generate the code.  CodeSmith looks to be an affordable way to short-circuit some of that work. :)

The key for me is to find my sea-legs with OO-based design.  The CSLA book and forum have really helped me get a better grip on good OO design, and that will help guide me in building my new specification generators.

JCardina replied on Friday, June 24, 2011

Rocky is dead on in his reply in my experience.

In my opinion if you rely heavily on code generation you are either ignorant of any usability or user experience concerns or are just too lazy to care.

Light use to automate repetitive areas of code that don't face the user is a different story but no great, modern, task oriented app was ever or ever will be generated entirely from a database schema.

 

 

Ashraf Ali replied on Friday, June 24, 2011

In my opinion your answer shows a lot more ignorance than my question did. It's public forum not a 'court" to decide who is lazy or igonrant.

if you dont have a professional answer you dont have to reply to my questions, you can keep your 'high' opinions to yourself. I can start using all kinds of words too but I won't, its just not mature.

JCardina replied on Friday, June 24, 2011

Sorry Ashraf, I did not in any way intend an insult.  I used the word ignorant in the dictionary sense.  I apologize if you were offended and stick by my remarks. 

I do not mind being called ignorant, I readily admit I'm ignorant on many things and that there is nothing wrong with being ignorant, it's when you think you know it all that you are in trouble. :)

If you knew my background and the long complicated route I came to that point of view and the direct correlation between the roof over my head and how easy my software is to use to my end users you would perhaps respect my opinion a little more but I won't waste time trying to convince any one, time will do that inevitably for those that care about the end user and correct task oriented user interface design.

Again I apologize if you felt insulted, I did not mean to direct an insult at you, I do freely admit to directing any insult to the concept of code generation in general, unless it's used extremely sparingly in the correct situation.

 

Ashraf Ali replied on Friday, June 24, 2011

No hard feelings, although this is an old thread but I got interested in it because of Rocky's reply (given below)

Yes, Magenic has a code generator called FBOG. Actually two of them, neither based on a custom generation engine. The first one was for CSLA 1.x and uses the code DOM, the second is for 2.0 and uses straight text output to escape the limitations of the code DOM.

These generators are built with the intent of augmenting Magenic's consultants as they work on projects, and the generator stays behind with the client when our consultants leave. But my point is that they aren't designed for "casual use" like CodeSmith; meaning no docs, a UI that lacks polish, etc. The tools aren't designed to compete with other code-generators, but rather to allow Magenic to compete with lower-cost consulting firms.

Which is a really long-winded way of heading off the next question, which is whether I can make FBOG available. I can't. Magenic owns it, not me, and they provide it as part of their consulting services only.

What I've been working on, off and on, is trying to come up with a new language for describing objects. Perhaps I'm on a fool's errand, but I look at the amount of code required to write an object, even with CSLA, and I think it is ridiculous. If you go through your code and identify only the lines of code that perform actual business functions - that have actual business value - you'll find that it is perhaps 4%. The rest of the lines of code are mandated by C# or VB or ADO.NET or Windows Forms or Web Forms or whatever. All "plumbing", and none of it valuable to the business need.

How does this tie into code-gen? A compiler is merely a fancy code generator. If I can come up with a more concise language to describe business objects (at least CSLA business objects), then I can code-gen CIL directly by creating a compiler for my language.

Thus far though, I have not been happy with any results Sad <img src=" />

 

 

JCardina, In my opinion CRUD code generation is not helpful but like Rocky mentioned above there may be some oppurtunities for code generation.

have a good weekend!

tiago replied on Friday, June 24, 2011

Ashraf Ali

JCardina, In my opinion CRUD code generation is not helpful but like Rocky mentioned above there may be some oppurtunities for code generation.

have a good weekend!

Why don't you give a try to CslaGenFork? There is a fresh Nightly Build 2011.06.23

Ashraf Ali replied on Thursday, June 23, 2011

Ok , I am really interested in knowin what happend to the code generation tool Rocky was trying to build Smile

RockfordLhotka replied on Thursday, June 23, 2011

I didn't pursue that option. There are some really good code generators out there, several of which include templates for (or directly target) CSLA .NET.

I'd much rather foster a code generation ecosystem around CSLA than attempt to become a competitor to those generators. I think that's better for CSLA and for the community as a whole.

Ashraf Ali replied on Friday, June 24, 2011

I am sorry I don't follow what does a "code generation ecosystem" mean? Big Smile, I do like the sound of it.

No offense meant please, I think I just like the term.

Brian Criswell replied on Thursday, June 29, 2006

For the past year I have been developing a metadata creation application that uses CSLA business objects at its core.  You can define your business objects with their properties, authorization rules, lookups, and child objects and define how they map onto a data source.

CodeSmith is used as the actual generator because it allows me to drop the business objects assembly in the Addins directory.  Rather than having to use the CodeSmith database object model, my templates can then load the same source file that the application uses and use my business objects to generate the classes, stored procedures, tables, etc.

Recently though, I have wondered about the various DAL generators and how I could incorporate them.  Does anyone have any suggestions for DAL generators as well as giving an idea of how they work and what they give you?  Currently, my generator can load all children, grandchildren, etc. of an object in a single stored procedure hit, and I wonder how I could get similar concepts out of a property DAL.

Copyright (c) Marimer LLC