CSLA compatibility using a MVP/MVVM design pattern?

CSLA compatibility using a MVP/MVVM design pattern?

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

bill2010 posted on Wednesday, December 23, 2009

Just curious... how does CSLA play when using a MVP or MVVM design pattern? Is there a good fit here?

RockfordLhotka replied on Wednesday, December 23, 2009

CSLA .NET works great with any of the "M" patterns, since it is all about helping you create a great Model.

The only catch you might discover is that some (many?) implementations of the "M" patterns assume an anemic or limited Model implementation. Specifically they are often based around the idea that the Model is composed of DTO or dumb Entity objects.

CSLA .NET is all about creating a very rich Model, where the objects encapsulate actual behavior (business, validation and authorization rules) and are not just dumb data containers.

Due to this you may discover that some assumptions made by some "M" pattern implementations don't work real well. I view this as a problem with the pattern implementations, based on that terrible assumption that the Model should be lame...

CSLA .NET 3.8 introduced a whole bunch of cool features specifically focused on MVVM for Silverlight and WPF. The ViewModelBase class is probably universally useful. The Execute and InvokeMethod components are useful if you want to implement the pattern without adopting one of the larger MVVM UI frameworks.

CSLA .NET 3.8 also introduced a CslaModelBinder class to smooth the one outstanding issue with using ASP.NET MVC with the cool Controller "data binding" capabilities. This is optional, but addresses some issues that come up if you use MVC 2 and DataAnnotations attributes and Controller data binding together.

Obviously other UI frameworks may have their own idiosyncracies, but generally speaking I think any quality UI framework will have enough extensibility points to work very nicely with a Model created using CSLA .NET.

bill2010 replied on Thursday, December 24, 2009

Wow, Rocky. Your framework ROCKS! I'm really impressed.

Copyright (c) Marimer LLC