When to use PropertyInfo in CSLA 3.5?

When to use PropertyInfo in CSLA 3.5?

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


jasonlaw posted on Wednesday, May 14, 2008

Hi, may I know when to use PropertyInfo and what is the benefit in CSLA 3.5?

Thanks in advance.

Jason Law

ajj3085 replied on Wednesday, May 14, 2008

The benefit is that your property setters and getters become just one line, and you won't be able to forget things like not calling PropertyHasChanged and you won't have to worry about misspelling the name of the property.  You hardcode the string property name once, instead of three times per getter / setter.

Also, when used to declare child BO properties (like lists or other BOs), you won't need to override IsDirty / IsValid on the root object, or wire property changed / list changed event listeners; a ChildManager will do all this work for you. 

In short, you gain a lot of code reduction, I believe Rocky estimates about a 30-40% code reduction over the old style of handling properties.  You write less code, which means that you have less chance to forget something (which is mostly boiler-plate code anyway).

Copyright (c) Marimer LLC