Are you using SmartInt16, SmartInt32, SmartFloat, SmartBool, etc?

Are you using SmartInt16, SmartInt32, SmartFloat, SmartBool, etc?

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


david.wendelken posted on Thursday, August 09, 2007

Out of curiosity, are you using any of the various Smart* classes available in the CslaContrib project? 

(SmartInt16, SmartInt32, SmartInt64, SmartDecimal, SmartFloat, SmartBool, etc.)

If not, why not?

ajj3085 replied on Thursday, August 09, 2007

I'm not, mainly because I did my own before I found that those existed.

ozitraveller replied on Thursday, August 09, 2007

I'm still relatively new to csla, so I'm not sure how to merge it in.

david.wendelken replied on Thursday, August 09, 2007

It's pretty easy to do.  They are in their own project, CslaSrd.
Just add the CslaSrd project into your Csla solution and compile it, then include it in your own applications the same way you include Csla.

Instead of SafeDataReader, you use SmartSafeDataReader.

There are some other classes in CslaSrd that are worth looking at too.

triplea replied on Friday, August 10, 2007

I am using the smart classes. Simple concept but since somebody else kindly wrote and provided the classes why not use them :-) Didn't have time to check other stuff on offer in the CslaSrd project (I did play around with the codegen templates in the CslaContrib bundle though which are a great starting point) but sure there are some more interesting stuff.

dmccrory replied on Friday, August 10, 2007

At the risk of extending the thread....what are the main benefits of using them?

triplea replied on Friday, August 10, 2007

Well pretty much the same reason you use SmartDate (if you do), which is a way of dealing with primitive types (e.g. int, bool etc) effectively on both the UI and database level. So e.g. you have a property called Age which can be null. SmartInt32 allows you to display the corresponding textbox as being empty on the UI plus store null when the time comes to update your database. There is more to it but that's my main use. Using nullable types (e.g. int? ) doesn't work very well.

david.wendelken replied on Friday, August 10, 2007

triplea:
Well pretty much the same reason you use SmartDate (if you do), which is a way of dealing with primitive types (e.g. int, bool etc) effectively on both the UI and database level. So e.g. you have a property called Age which can be null. SmartInt32 allows you to display the corresponding textbox as being empty on the UI plus store null when the time comes to update your database. There is more to it but that's my main use. Using nullable types (e.g. int? ) doesn't work very well.

The other benefit of the smart* classes is that they understand that an "empty" variable means different things in different contexts.  Let's take an object that has an EffectiveDate and an ObsoleteDate property in it.

Exactly what does an empty ObsoleteDate mean?  An empty date could mean the same as a database NULL, i.e., "I don't know what the ObsoleteDate is."  Or, an empty ObsoleteDate could mean "This object is valid and remains so until the end of time (at least until I change the ObsoleteDate to some other value)."   Ditto for the EffectiveDate, except in a different time direction.

The SmartClasses understand that concept and make it very easy to implement.

 

david.wendelken replied on Friday, August 10, 2007

dmccrory:

At the risk of extending the thread....what are the main benefits of using them?

Hope the preceding message answered why the other Smart* classes are handy to use. 

Another contributor put in an ObjectListView class which is really easy to use.  It provides a sorted and filtered view of a business object collection that binds to front-end controls very nicely.

 

JoeFallon1 replied on Monday, August 13, 2007

I use the ObjectListView all over the place. It is very well written.

It handles multi-property sorting which is extremely useful in some situations.

Filtering is very easy too.

I wrote a couple of Helper methods to make it easy to fetch one of these from all of my web pages.

Highly recommended.

Joe

 

Copyright (c) Marimer LLC