Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is CSLA Framework and Its use?

Tags:

csla

What is CSLA Framework and Its use ?

like image 722
Greens Avatar asked Aug 05 '09 16:08

Greens


1 Answers

My Opinions From My Experience w/ a 1.7M LOC code base:

  1. CSLA is intended for a distributed application/database environment. This is why the basic business object is and does everything, for example it's own data persistence. An object (and everything remotely associated w/ its state) is intended to be serialized, sent to a different application and/or data server and work.
  2. If the above is not a problem you need to solve, CSLA is overkill, big time. Our development team regrets having committed to CSLA.
  3. Juggling all the CSLA balls in a complex Windowed UI is tough. We have multi-tabbed screens (which may in turn open sub-screens) that, unless you follow the "left to right, top to bottom" flow of data entry, and click save often, ends up putting and/or fetching incomplete data to/from the database; or dropping data altogether that you just entered. Yes, our original coders are at fault, but so is CSLA... It just seems that there are so many moving parts to enable, control, and coordinate CSLA features. It's like having to deal with all the dials & switches of a fighter jet when all you really need is something more like a Cessna 152.
  4. You will write lots of custom code to enable the CSLA features. For example CSLA will never be confused with object relational mapper (ORM) tools like Hibernate and Entity Framework. Our SAVE() methods are non trivial, so are the trivial ones.
  5. Encouraging the use of code generators compounds problems. We used CodeSMith to generate classes from data tables. So we end up with code that has a 1-1 correspondence of table to c# class. So you must write all the code to handle dataStore to your "real" objects.
  6. Data store/ and fetch is very inefficient w/ CSLA. Because of the Behemoth, monolithic BusinessObject-does-all-and-knows-all centric paradigm, objects end up doing a one-object-at-a-time data fetch and instantiate. Collections of composite objects significantly compound the problem. A single "get this object" always results in a cascade of separate data fetches (one or more for each individual object) to instantiate the entire inheritance & composite relationship chains. Its known as the "N+1 query problem." Oh, and fetching data ALWAYS results in a new object being created, even if we're only updating an existing one. No wonder our more complex screens are FUBAR.

It allows you to architect your application with solid object oriented principals and a good seperation of concerns.

Yes and no. Mostly no.

The BusinessObject handles it's own data storing. That is anti separation of concerns.

"It allows you..." well, yeah - so does a blank text editor screen, but does not force or encourage you like the MVC.NET framework does, for example. IMHO, CLSA provides absolutely zero benefit for ensuring that the code you develop with it follows "solid OO principles". In fact coders w/ weak OO skills (the majority, in my experience) will really stand out when using CSLA! Woe betide the maintenance programmer.

CSLA is the poster child for the solid object oriented principle favor composition over inheritance. CLSA code is untestable. Because an inherited framework BusinessObject is, does, and needs everything, all at once and every time, it's not likely that you will be able to get much test coverage. You can't get at the pieces because everything is tightly coupled.The framework is not amenable to dependency injection. It is an iron curtain of code.

Your code will be difficult to debug. Call stacks get very deep and as you get near the center of the sun so to speak, everything turns into reflection - "what *&^# methods just got called???" And you simply get lost. period.

EDIT 7 Mar 2016

What more insight can I add after the original post? Two things, perhaps:

First, It feels like CSLA has some promise. If we knew how to juggle all those moving parts together. But CSLA is so enigmatic that even things we have done right are corrupted over time. IMHO without a very strong team-wide CSLA wherewithal, any implementation is doomed. Without a vibrant "open source" of technical references, training, and community it's hopeless. In almost a decade our CSLA code, in my final analysis, is just compounding technical debt.

Second, here is a recent comment I made, below:

Our complexity often does not seem to fit in the CSLA infrastructure so we write outside of the framework. This and cheap labor results in rampant SRP violations and has me hitting brick walls managing dynamic rule application, for example. Then, CSLA parent/child infrastructure propagates composite object validation but we don't always want c/p relationships, so we write more validation and store code. So today our CSLA implementation is inconsistent & confusing. Refactoring to more-better CSLA will have profound domino effects. So after that initial injection CSLA is essentially abandoned.

end Edit

like image 61
radarbob Avatar answered Oct 10 '22 10:10

radarbob