Re: Generation of DAO code
- New member here,
Very interesting to see all the links to code generation for the
persistence and domain object tiers.. I'm just wondering how far it
could go. For example the NETtiers stuff seems to create the domain
objects based upon the RDBMS schema... would it be possible to
generate basic business logic and presentation stuff too based upon
I realise that theres always going to be handcoding of specific rules
and the presentation may require some alterations, but I'm just
wondering from a practical point how far code generation from the
lower tier can go?
I seem to recall reading a technique called "Naked Objects" that
created everything based upon the domain objects and then moving
these objects physically around on the screen and creating
relationships generated code.. but I don't know about it in detail.
Also, from a different point of view, I'm wondering where AOP could
fit into this. Does it make sense to modularise crosscutting
concerns vertically across the tiers? I can see where AOP fits
horizontally within the tiers for things like persistence, security,
logging and so on, but the crosscutting distributed nature of
enterprise systems brings up some interesting angles for AOP.
For example does it make sense to think of Customer table, Customer
objects, Customer DAO, Customer business logic and Customer
presentation as a single aspect of the system? Would certainly fit
with the idea of features, product lines and so on.
Just thinking out aloud.. ;-)
> > --- In agileDatabases@yahoogroups.com, "Scott W. Ambler" <swa@>
> >>I maintain a list of links to such frameworks, some of which workas
> > you suggest and some of which generate SQL on the fly.framework
> > You are missing a few I believe:
> > Gentle.Net: http://www.mertner.com/confluence/display/Gentle/Home
> > NetTiers: http://www.nettiers.com/
> > And a new one that I'm just now checking out, basically works like
> > Rails, but for .NET, and I guess without MVC:
> > SubSonic, formerly known as ActionPack: http://wekeroad.com/blogs/
> > I'm _pretty_ sure that the NetTiers guys built most of their
> > modelled off of your papers / books, but I haven't kept up withthem
> > in the past year.
> > D
> > Yahoo! Groups Links
> Very interesting to see all the links to code generation for theSomewhat. With Gentle, and the MyGeneration templates (or the
> persistence and domain object tiers.. I'm just wondering how far it
> could go. For example the NETtiers stuff seems to create the domain
> objects based upon the RDBMS schema... would it be possible to
> generate basic business logic and presentation stuff too based upon
> the schema?
Gentle.CodeGeneration assembly that I've added to it recently) you can
generate all of the CRUD access, along with the loading routines for
all of the relationships. So, if a User can belong to zero or more
Groups, you simply type "User.Groups" to get access to a List. (And
can databind them very quickly to front-end controls.)
On top of that, I've been working on a framework that complements
Gentle blatantly called Gentle.Rails, which can be found in the Gentle
subversion repository. It has a long way to go, and "real work" keeps
getting in the way of finishing it, but it's basic premise is to
abstract all of the Web or Win form to data layer code. So, instead
of running through a set of properties on your object and saying
"assign this object's value to this webcontrol, and properly format
it" you simply say:
IRails rails = RailsFactory.Load(this.Form);
rails.FillControls(user, group, [any other objects...]);
And it searches through each control, looks at its ID and attempts to
map it to a property. So, if you have a User First Name field, you
would call the textbox "UserFirstName" and then it would get the value
of the property from the User object and populate it into the control
When the user then fills in the form and posts it back, you would then
rails.FillObjects(user, group, etc);
and it maps the values back. You can then call the Persist method,
added by Gentle, to store the results back to the database.
Like I said it has a lot of work that needs done. Date fields are
particularly troublesome right now, because often you want to display
a date, not a date/time to the user and so on. (Basically, it takes
the mapping far too literally sometimes.) Plus, I've been trying very
hard NOT to have to make the end user use a special set of "Gentle
Controls" to do basic stuff, a like specialized GentleTextBox or
GentleDropDownList. I'm starting to think though that perhaps it
would be good to create these controls for more advanced features
because basing everything off of a single ID field is getting troublesome.
You asked about screen generation - I don't generate any "scaffolds"
yet, like Ruby on Rails does, because that seems a lot less useful. 9
times out of 10, I don't just want a basic screen with all of the
fields for the object on it - and would probably spend more time
ripping out the fields that I didn't need, and repurposing them.
However, I HAVE been thinking about autogenerating server side user
controls for customized GridViews and maybe others...
So to answer your question - yes its out there, Ruby on Rails does it
now - but I'm not sure how much "real" work goes into making it work
the way you want. And I haven't seen anything that does it on .NET
except what I've done on Gentle.Rails. (But I'd like to hear about it
if others are working on it.)