TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

How About a Custom Class Designer?

If I'm going to ever use DataSets in my app, which isn't very often, I'm going to use typed-DataSets. I really like the typed-DataSet designer in Visual Studio and I've been using it since VS2002. It gives you a nice way to create an XSD that dictates how to handle null values and lots of other cool stuff. Not only that, typed-DataSets are wonderful as far as having features such as IsSomeColumnNull() methods being generated for you. DataSets are first-class citizens in Visual Studio, no doubt. But why aren't custom classes? How cool would it be to be able to use the same kind of designer but be able to set the output type as a custom class! I'm talking specifically for creating data transfer objects (DTOs). Sure, you can use xsd.exe on the command line to create a class, but what if I don't want all of the serialization attributes, or want to customize the name of the private fields that get generated, etc. It would be nice to be able to customize xsd.exe. There could be a minimalist approach where you can use the designer to create an XSD by hand, or drag-drop tables or stored procs from Server Explorer to generate a class with properties. Optionally there could be a feature to mark properties as “dirty” or raise events when they are modified. Personally, I think it should be an IDE feature and custom classes should be just as important to Visual Studio as DataSets. Many of us do this by hand or use a tool such as CodeSmith instead. By hand you end up developing a DTO class with properties w/ private fields corresponding to query results. Writing the code to mark the properties as “dirty” and then writing the code to fill each object with data using a DataReader.

Perhaps this is just left as an “exercise for the reader (errrrr customer).” I'm considering tweaking an existing idea I found on Paulo Reichert's blog to make this happen in the immediate future. XSD type to CLR type sounds like a winner to me.


Digg!

posted on Friday, December 02, 2005 11:48 AM

Feedback

No comments posted yet.