Working on Code Generation

Working on Code Generation

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


GlennP posted on Saturday, August 01, 2009

Ok... maybe I'm a little obsessive compulsive, but I need to be complete. I'm a bit obsessed with code generation out of the database objects, and I'm getting ready to start including the CSLA.NET framework into it. (VB and C#)

My current templates are very good at generating the Stored Procs for Insert, Update and Delte, Effective Dated rows, Many to many relationships, views of currently effective dated rows, table generation scripts, extended properties, Foreign key constraints, etc...

Does anyone out here have a list of "Got-ya's" I should watch for when creating my own templates?

Thanks much.

Glenn

richardb replied on Sunday, August 02, 2009

Not sure if you mean generating business objects from the database design or just the data access / DTO parts but you probably want your business objects to model your Use-Cases rather than the database table design.

Apologies if I have mis-interpreted your post.

Some of your business objects may well mirror the table design of course, and so generating them can get you reasonably far down the road.



GlennP replied on Sunday, August 02, 2009

I've come a bit of the way down the road on this so far, but my goal is to get as far as I can through the process based on the Database design. When you're in 3rd normal form, you can infer quite a lot about the DTO(s) and even some of the Business Objects. I plan to have a windows app that you can use to generate the basic business objects, and then interactively add basic business rules, the data related ones.
(eg. Inserted date is before Deleted date, or Last_Name.MaxLength = 30)

What will come out of the process at the end is either a C# or VB project containing the basic classes, a database project containing all of the SQL scripts required for Data Access, and a few simple administrative windows and ASP.NET forms for database maintenance.

Admittedly, I try to use the data layer to closely model an OOD, but there are limits. For the most part, a lot of business rules are related to the shape and structure of data. What I'd like to get this down to is having to only implement the custom behaviors and non-data-related business rules to finish the Business Layer. Hopefully the config file will accomplish anything else I intend.

bniemyjski replied on Thursday, August 13, 2009

Hello,

Have you checked out our CSLA Templates? We are about to release Version 1.1(in SVN) which includes VB.NET templates and new Authorization rules. You can download 1.0 and check out a completely working PetShop Sample Application here. Also we have a video located here.

There seems to be a lot of people out here working on templates. I wish that people would check out and extend our templates as they are a really complete solution that is easy to customize and extend.

Thanks
-Blake Niemyjski

Copyright (c) Marimer LLC