当前位置 > 首页 > Asp.net

Object Hydrator fills your objects with random data...on purpose!

2009-9-15 1:50:00来源:Asp.net

First off...long time since I've last written...yeah I guess frequent blogging isn't my thing.

But I wanted to post this to solicit feedback from the community about something I've been thinking about lately.

Call it DDD, BDD, TDD or a bananna there is a lot of merit in approaching a new application, from an angle other than the database and how you're going to persist the data.  If you've been building applications long enough, you know that data access (in any form) is one of the most repetitive and code heavy features of your application.  I called it a feature because it really is...and with all features, you're smart to delay the building of the feature until last responsible moment.  This allows you to garner the maximum knowledge of said feature.

What if we could build 'working' applications, that demonstrates the solution to the particular business challenge we are trying to solve...*without* a database at all.  Well at least until it makes sense to.

Rob Conery's SubSonic has a fantastic feature called the SimpleRepository.  This allows you to save any object into a database without having previously created a table and without having done the alphabetical gymnastics of mapping said object to the database.  It just saves it.  This mimic's closely the concept of the object centric database functionality of db4O etc...  I think it's brilliant but what if we could delay that decision even longer still.

What if we could design our object, and pass it through a ''generator" that returned us that object filled with data that mimicked real world data.  What if it could return a collection of these objects?  Theoretically we could be repositories that acted like databases, but since we hadn't yet commited to a database structure we have the flexibility of tweaking those objects at will.

What we end up with is an interface and business objects that behave like they should, that demonstrate the intent of the application without having to commit to a persistence strategy until nearly the end of the project.

I didn't have any luck finding this out there already...so to that end I started Object Hydrator...it's free and up on CodePlex in source form.  It will allow you to create data filled objects during runtime. I think it could have a lot promise when it comes to TDD and DDD/BDD/R2-D2.  It currently works with two methods...you can add attributes to your object's properties, or you can use a mapping collection.

So if it interests you, feel free to go check it out and look at the tests to see it in action.  It's still a veritable infant, so keep that in mind, but please let me know what you think about its usefulness and the code itself.