What are the BusinessBase and BusinessListBase classes in the CSLA framework?

StackOverflow https://stackoverflow.com/questions/10095184

  •  30-05-2021
  •  | 
  •  

質問

I'm learning a large legacy application written in VB.net with the CSLA framework. Many of the objects seem to inherit from BusinessBase and BusinessListBase. When I "go to definition" in Visual Studio, I see that these classes are a part of the CSLA namespace. What are these classes? What role do they play in the CSLA framework? How do they relate to other CSLA concepts like Root Object and Child Object?

役に立ちましたか?

解決

BusinessBase and BusinessListBase are the abstract base classes that all editable (i.e. not read-only) business objects inherit. Either one can be a root or a child object, depending on the business object graph. These classes are what provide the CSLA framework properties and methods on the instance classes in your application, such as IsNew, IsDirty, and Save(). The base classes also do the grunt work of communicating with the DataPortal, checking business rules that child classes define, managing the object's edit/undo level, and the like. In short, a business object inherits one of these classes in order to integrate itself with the rest of the CSLA framework. Within the confines of the CSLA framework, if a business object needs to perform a task or expose a property, these classes are where that happens.

Some of the things these classes do not do:

  • Define business properties (they do define object / life cycle management properties, such as IsNew, IsSavable, etc, but not properties to hold relevant business data)
  • Initialize business properties (again, CSLA's management properties are handled by the base classes)
  • Assign business rules (such as "customer name must have a value")
  • Talk to the database
  • Mark the object as serializable
  • Determine which foo.DataPortal_X method gets executed by calling DataPortal.Fetch<foo>(args); (that's done by the DataPortal)

BusinessListBase is for list classes, and inherits the .NET base list functionality, so a CSLA business object that's a list only needs to inherit BusinessListBase. You can add, delete, etc., objects from a BusinessListBase as you'd expect, since the object is a list.

ReadOnlyBase and ReadOnlyListBase are abstract base classes which serve the same purpose as their business counterparts, but also ensure that the objects are read only. What they provide is mostly a subset of the business bases, with a few extra constraints thrown in, such as preventing properties from implementing setters.

I suggest having a look at this question for some expedient ramp up information on CSLA.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top