About design, code and how to make them better.

суббота, 20 февраля 2010 г.

CSLA – First impression

I’ve spent a day learning CSLA framework and I would like to share my impression. Of course, first question is “What is it for?”. Following wikipedia

Component-based Scalable Logical Architecture (CSLA) is a software framework created by Rockford Lhotka that provides a standard way to create robust object oriented programs using business objects. Business objects are objects that abstract business entities in an object oriented program.

Definitions like this make me confused because essentially it says nothing.  For example, DataObjects.NET have nothing to do with CSLA but also fits the definition. So, I would like to give another one: CSLA is a framework to make  objects which are smart enough to provide binding, undo-redo, validation and at the same time simple enough to be serializable. These objects should be organized in a hierarchical structure matching specific use case.

If I understand things right, then basic scenario is following:

  1. Create UI Form.
  2. Create CSLA objects with Data and Logic this Form needs.
  3. Bind Form fields to CSLA object properties.
  4. Implement logic to fill and persist CSLA objects.

In my opinion concept is very good and it is exactly the way I would like to work with Data. Realization is also OK: It is not complex, it does not use black magic like code generation or aspect oriented tricks (AFAIK), it is easy to plug to your project (just one assembly reference).

One thing I DO NOT like about CSLA is that it uses STATIC methods to transport data, which means that you can not fully control data transport. Though it should not be a problem for most scenarios, from design point of view it looks ugly. It is like if SqlConnection’s ConnectionString property were static.

1 коммент.: