Hi
I am just investigating CSLA and am quite impressed.
One of the things that bothers me though is the redundant code necessary in the business object property set/get. (eg CanRead, CanWrite, PropertyChanged) Is it possible to use classes instead of base types as the properties and still have them bound to the db and UI?
My reasoning is that that will allow you to have much smarter business objects. SmartDates are in the same mindspace. In the example I seen (dnrTv), the BO uses a SmartDate internally but exposes a string property to manage the UI set/get of the date. Seems to me that you would then need to expose another property to handle get/set as a date. Would it not be better to have a DateProperty class that exposes a Value that is of type date and has a UIString that handles conversion to/from strings? The CanRead/CanWrite/PropertyChanged logic would only need to be implemented in the DateProperty class and not in every BO that uses it. There is of course a whole whack of other intelligence that the DateProperty class could implement.
Code generators are sometimes suggested but they just allow one to generate more redundant code faster and would clutter up the BO namespace with DateAsUIString and DateAsDate properties.
You are right, it would be nicer to expose the properties as a more complex type that could not only provide the property value, but also metadata and other functions around that property.
Unfortunately, data binding doesn't work with that model. So following that model means abandoning data binding - or coming up with some abstraction layer that would sit between data binding and your objects.
I have had some luck implementing ICustomTypeDescriptor, PropertyDescriptor, ITypedList (and soon IBindignList). It seems to work okay at run time but I have having little luck at design time (ASP.NET). Am not sure if I want to keep persuing this angle or give up and use vanilla business objects.
Ken
RockfordLhotka:You are right, it would be nicer to expose the properties as a more complex type that could not only provide the property value, but also metadata and other functions around that property.
Unfortunately, data binding doesn't work with that model. So following that model means abandoning data binding - or coming up with some abstraction layer that would sit between data binding and your objects.
When I say “data binding” I mean across Windows
Forms, Web Forms and WFP. Since CSLA supports all the UI technologies, anything
I build into the framework needs (in my view) to support all of those options.
I don’t think they all support dot-notation for binding, at least if you
want to use the designers.
Rocky
Copyright (c) Marimer LLC