Is Business Rule Serialize ?

Is Business Rule Serialize ?

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


st3fanus posted on Tuesday, December 06, 2011

Hi all,

 

I have a question about Business Rule / validation Declaration and Location ?

1.  read from http://www.lhotka.net/weblog/CSLA4BusinessRulesSubsystem.aspx ,

     I read that a business rule is declare as a private class on Business Object, that location is a regulation or just guide ? ( what are the considerations needed to declare a Rule ? as a nested class or as independent class so that it can be used by another object ? )

2. If I declare as independent class, is it needed a Serialize attribute ? for moving across tiers / layers ? and Why ?

 

Could anyone explain me around this concept , anything suggestion is welcome :)

 

thanks a lot

 

 

JonnyBee replied on Wednesday, December 07, 2011

1. General rules should be independent class and BO specific rules is often better placed inside the actual business object.

2. Rules does not have to be serializable.

BrokenRule (builtin class in Csla used in BrokenRulesCollection) is serializable so it can move between tiers just like any other child list in a business object.

A rule instance is registered for all instance of a given business object type. As such - the rule should be considered a "singelton" and can not contain any poperties that are specific for the code in Execute method.

Copyright (c) Marimer LLC