Wednesday, January 07, 2009 Register    Login
Instructions

In order to add new threads or reply to existing posts, you have to be logged-in. If you are not registered yet, you need to register first, and then login with your personal credentials.

   

CslaFactory Forums
 
  Forum  Discussions  General  Modeling Behavior
Previous Previous
 
Next Disabled
New Post 11/10/2008 2:51 AM
  kdubious
2 posts
No Ranking


Modeling Behavior 

I assume all of us here, having read Rocky's book and adopted his model, believe him when he says that Business Objects should model Behavior, not Data.  Can someone explain something to me about this tool?  I can't get my brain to see how you'll allow me to accomplish this task.  Code generation is trivial for lists and editable roots, so I may just be missing the boat by viewing the examples. I'm more concerned about the cases where a database table doesn't neatly match the properties of my objects.

Can someone point me to an 'Advanced' tutorial, or would it be best for me to pose a few scenarios, and allow you to tell me how you would infer the appropriate DB model? 

Also, what if I already have my database?

I love the idea of using the VS DSL Tools to work with the model, but I think it is going to be hard to adopt unless it can work in both directions.  By that, I mean having the ability to create the Database Schema when appropriate, and allowing the developer to create models 'Based On' the database as well.

Kevin

 

 
New Post 11/10/2008 9:51 AM
  Marcel
49 posts
No Ranking


Re: Modeling Behavior 
Modified By Marcel  on 11/10/2008 8:21:16 PM)

Hi Kevin,

CslaFactory is meant to help you concentrate on the business logic instead of loosing time writing the same structural code over and over again. There are lots of good tools that support you by generating code from database tables and they are very useful, especially if you have an existing database and want to apply CLSA.net on it.

Unfortunately, if you try to generate proper relations from a database, you might fail to do so sooner than later. From the table stucture you can not tell the difference between an aggregation and a composition and you can hardly figure out self-references. What about validation rules? How do you generate them from a table structure? And authorization rules? As CslaFactory is based on a DSL designed for CSLA.net. you can easily model all of this and generate the code. Imagine that you may have multiple versions of a model. This is very helpful if you want to serve multiple customers with different naming conventions or if you just want to track your versions. These are just some of the main reasons to use a model-based code generator instead of a database-driven tool, but if I still did not manage to get you back on track, please do not hesitate to drop a line.

Even if you already have an existing database, you should be able to use CslaFactory in most cases. You would have to model the entities of your existing database before generating the code, but as I just mentioned beforehand, this is good, because you can model relations, and validation rules and so on. This surely is hard work for large databases. We already received requests for an importer tool that reads an existing database structure and initially creates the model from it. Although not planned yet, it would not be too hard to provide such a tool, I guess.

Marcel

 
New Post 11/19/2008 4:09 PM
  kdubious
2 posts
No Ranking


Re: Modeling Behavior 

Thanks, Marcel.  I do agree that if you run a tool against a relational database, and let it create classes that are 1:1 with your tables, you'll be in trouble. (Although, that approach often works just fine in simple content management systems for websites, for example).  I'm just not so sure that the reverse approach works completely, either.  In other words, I don't know that you can completely infer an accurate and performant database model from a DSL model built to serve as a class diagram.  One issue is that any changes that need to be made to the DB structure after generation would somehow need to be managed and tracked along with the project(s) as well. Another issue is that versioning and multi-developer use of this system is going to be difficult. (I'm thinking about source control here)

I really think to make this thing go from useful to brilliant, it needs to be 2-directional.  One would need to be able to map properties in their objects to fields in the database.  There is a great tool for CSLA that's been around for a while.  It pulls in the database model, and lets you create CSLA objects by selecting fields from tables, views, or sproc result sets.  It has support for Authorization, Business Rules, Lazy Loading, Active Objects (an excellent implementation of the observer pattern), and more. It even navigates the relationships in the DB to generate the CRUD sprocs. [CSLAGen - http://groups.google.com/group/CslaGenerator

I'm not promoting them, just suggesting that the tool is incredibly useful, as yours will likely be.  Why is it not Brilliant? No visual model.

You are left with a list of objects, and no way to see the relationship between any of them.  Of course, those relationships are there.  You use the property grid to select objects that are child properties of other objects, for example.  There is just not a visual aid. So while it can let you build the entire behavior focused BO Library from an existing, well designed, purely relational database, it can be very difficult to see the big picture.

Just food for thought.  V2 maybe.

Best wishes on rolling out something soon!

Kevin

 
Previous Previous
 
Next Disabled
  Forum  Discussions  General  Modeling Behavior
   

UsersOnline
Membership Membership:
Latest New User Latest: Essin
New Today New Today: 3
New Yesterday New Yesterday: 4
User Count Overall: 722

People Online People Online:
Visitors Visitors: 3
Members Members: 1
Total Total: 4

Online Now Online Now:
01: pberggreen