Skip to content
Archive of posts filed under the CSLA category.

CSLA 4 version 4.3.0 alpha available

Rocky Lhotka published alpha version of CSLA 4.3 last week.  You can read more about the changes on his blog.  If you are using CSLA 4.X with Silverlight, please give this version a try.  If you are using an order version, 3.8.X, you can easily port the changes over to that version.  Or you can just upgrade to 4.3 Smile.

Please let me know if you have any questions.

Thanks.

Post to Twitter

How to Improve Performance of CSLA for Silverlight

CSLA for Silverlight is using MobileFormatter class to serialize and de-0serialize the data that if sent across the wire during client/server communications.  General flow of the serialization process is as follows.  Each object that implements IMobileObject is being asked by mobile formatter to serialize its data into a list of SerializationInfo objects.  That list maintains the state of each object as well as the relationships between objects.  Ultimately, the data consist of simple properties serialized into FieldData objects and relationships between objects into ChildData objects.  The formatter then is using DataContactSerializer and XML Reader/Writer combination in order to create byte arrays from object data.  These byte arrays are just XML blobs when all said and done of SerializationInfo objects.  DataContractSerializer is doing the best job it can in order to specify enough information in the XML to make it possible to reconstruct the data on the other end of the wire.  As a result, it drops hints from XML standards that specify what primate type should be used for each property value of each objects.  This results in extremely verbose XML, where each property may take additional 20-30 bytes to specify the type to be used.  On top of that, CSLA is using descriptive names inside Serialization Info object as well as generic dictionaries to store ChildData and FIeldData objects.  Turns out, serializer puts enough metadata around generic collections as well that makes them larger.

So, we took a few steps to provide some optimization around the code that should work with any version of CSLA that has MobileFormatter.  First of all, we changed DataMember and DataContract attributes to provider shorter names.  For example, instead of Value property we will just have VU in the XML.  We also created helper dictionaries instead of using generic dictionaries in order to be able to specify names for items and keys, all consisting of 2 letter instead of 4-10 letter.  Also, we eliminated XML type hints by injecting a xmlns namespace into XML header containing the root namespace of XML standards with one letter alias, which will eliminate 20-30 bytes from each serialized property.

Your particular results may vary, but we saw overall improvements of 2-50 percent depending on the objects.  Since Mobile Formatter is also used to take snapshots of objects to support Cancel button (undo) functionality, you will also see memory improvements in your Silverlight application as well.

Please read the warning message at the end of the article before you decide to use this code.

You can download attached SerializationInfo and make changes to your version of CSLA.  You will also need to find the following method in MobileFormatter

public void Serialize(XmlWriter writer, object graph)

 

and replace it with the code below:

    public void Serialize(XmlWriter writer, object graph)

    {

      List<SerializationInfo> serialized = SerializeAsDTO(graph);

 

      DataContractSerializer dc = GetDataContractSerializer();

 

      dc.WriteStartObject(writer, serialized);

      writer.WriteAttributeString("xmlns", "z", null, "http://www.w3.org/2001/XMLSchema");

      dc.WriteObjectContent(writer, serialized);

      dc.WriteEndObject(writer);

    }

 

WARNING – the byte arrays are not going to be compatible with previous CSLA version.  So, if you are serializing objects using MobileFormatter and storing them somewhere, you will not be able to de-serialize them after you make the change.

You can also download SerializationInfo file here.

 

Post to Twitter

Code Mastery Event

I participated in Code Mastery event yesterday.  The event was put on by my company Magenic as an all day free community training event.  It was all about CSLA.  The author if this widely used framework, Rocky Lhotka himself was in attendance.  He presented on two topics.  Yours truly spoke on CSLA and XAML technologies.  I talked about advantages on CSLA in XAML world, and documented big code savings that CSLA brings to the table.  I am planning to upload my project to CSLA web site in the next few days, as there have been some requests to show how to use CSLA in conjunction with Prism to build Silverlight or WPF applications.  I will blog once that happens, and you should be able to take advantage of that sample.  The sample is using an extensive technology stack, including Entity Framework Code First, CSLA, Prism for Silverlight, SQL Server.  You can download PowerPoint presentation here.

Thank you.

Here is the full agenda of the event.

1. CSLA .NET intro – Rocky Lhotka

Topic will give attendees a high level overview of CSLA as an application framework. Key moving parts of CSLA will be covered, along with answering the most important question: Why use CSLA? Roles of business objects, data portal, rules, authentication and authorization will be covered in principal.

2. Business object design – Eric Blackwell

Session will concentrate of best practices for designing business objects. Single responsibility principal and maintainability will be covered in light of using CSLA. Key aspects of good CSLA business layer will be covered in detail, including properties, rules, data portal, data access, business method and validation. Particular attention will be paid to structuring classes and relationship between classes. Designing based on use cases will be an important aspect of the session.

3. Business, validation, and authorization rules – Tim Price-Williams

This session will be a deep dive into the world or rules. Topics such as validation rules, user authentication and authorization will be covered. Distinction between validation and business rules be drawn. Important key scenarios will be covered, such as synchronous and asynchronous rules, client / server rules, object creation and save scenario from rules perspective. Custom and built-in rules be covered in detail. A pattern for typical business rule/methods will be illuminated.

4. Data portal and n-tier architecture – Rocky Lhotka

This topic will cover in details all possibilities that CSLA provides when abstracting communication channels between client and server components. Difference between local and remote data portal will be discussed. Various configuration patterns will be highlighted along with usage scenarios for each one. Multi-tier deployment as it relates to data portals will be covered, as well as using external data sources instead of CSLA data portal in client only scenarios.

5. Data access – Travis Brown

This session is all about data access technologies and how they relate to CSLA data portal access. The topic will include patterns for abstracting data access for business objects to promote maintainability. Discussion of Microsoft technologies for data access will take place as well.

6. XAML and MVVM – Sergey Barskiy

This session will concentrate on using CSLA as business layer in XAML based user interfaces. Taking Silverlight as an example, session will highlight how CSLA base classes can be used to facilitate communication between UI and business objects. Adaptability of CSLA business layer to seamlessly alter user interface based on rules be will covered. Patterns for wiring business objects for Silverlight environment will be part of the discussion.

7. ASP.NET MVC – Mitch Gordon

This session will concentrate on using CSLA as business layer in ASP.NET MVC based user interfaces. The discussion will include CSLA provided base classes that will allow developers write less code. The session will illuminate patters for maintaining authentication and authorization rules between server calls. Patterns for adapting UI based on user rights will be discussed.

Update 10/12/2011

Rocky wrote a blog post about the event that includes a link to a downloadable file with all the material enclosed.  You can find the blog post here.

Post to Twitter

Code Mastery Event

I am going participate in Code Mastery event that Magenic is sponsoring next week, on October 8th.  Code Mastery is a series of community events that my company puts out to help developers learn more about various programming topics.  The upcoming event in Atlanta is dedicated to CSLA.NETRocky Lhotka, author of CSLA will be coming to Atlanta to speak at the event.

You can register for Code Mastery here.

Our agenda consists of the following topics.

Sessions:

1. CSLA .NET intro – Rocky Lhotka

Topic will give attendees a high level overview of CSLA as an application framework. Key moving parts of CSLA will be covered, along with answering the most important question: Why use CSLA? Roles of business objects, data portal, rules, authentication and authorization will be covered in principal.

2. Business object design – Eric Blackwell

Session will concentrate of best practices for designing business objects. Single responsibility principal and maintainability will be covered in light of using CSLA. Key aspects of good CSLA business layer will be covered in detail, including properties, rules, data portal, data access, business method and validation. Particular attention will be paid to structuring classes and relationship between classes. Designing based on use cases will be an important aspect of the session.

3. Business, validation, and authorization rules – Tim Price-Williams

This session will be a deep dive into the world or rules. Topics such as validation rules, user authentication and authorization will be covered. Distinction between validation and business rules be drawn. Important key scenarios will be covered, such as synchronous and asynchronous rules, client / server rules, object creation and save scenario from rules perspective. Custom and built-in rules be covered in detail. A pattern for typical business rule/methods will be illuminated.

4. Data portal and n-tier architecture – Rocky Lhotka

This topic will cover in details all possibilities that CSLA provides when abstracting communication channels between client and server components. Difference between local and remote data portal will be discussed. Various configuration patterns will be highlighted along with usage scenarios for each one. Multi-tier deployment as it relates to data portals will be covered, as well as using external data sources instead of CSLA data portal in client only scenarios.

5. Data access – Travis Brown

This session is all about data access technologies and how they relate to CSLA data portal access. The topic will include patterns for abstracting data access for business objects to promote maintainability. Discussion of Microsoft technologies for data access will take place as well.

6. XAML and MVVM – Sergey Barskiy

This session will concentrate on using CSLA as business layer in XAML based user interfaces. Taking Silverlight as an example, session will highlight how CSLA base classes can be used to facilitate communication between UI and business objects. Adaptability of CSLA business layer to seamlessly alter user interface based on rules be will covered. Patterns for wiring business objects for Silverlight environment will be part of the discussion.

7. ASP.NET MVC – Mitch Gordon

This session will concentrate on using CSLA as business layer in ASP.NET MVC based user interfaces. The discussion will include CSLA provided base classes that will allow developers write less code. The session will illuminate patters for maintaining authentication and authorization rules between server calls. Patterns for adapting UI based on user rights will be discussed.

 

I hope to see you there.

Post to Twitter

CSLA .NET for Silverlight webcast on 11/13

Magenic is sponsoring a webcast about CSLA .NET for Silverlight on November 13. I will be doing this presentation.  I am very excited about this opportunity.  I think very highly of Silverlight/WPF technologies.  I have also being using CSLA for almost 2 years now on nearly daily basis.  As you may have noticed from other posts, I got an opportunity to work with Rocky Lhotka on CSLA for Silverlight for about three months.  I am hopeful that I can share my excitement and get people interested in CSLA for Silverlight.  I honestly believe that Silverlight can revolutionize business application development for the web, and CSLA can play a very big role in this process as the very first (to my knowledge) business framework for Silverlight.

Post to Twitter

CoDe magazine article

I have been working on CSLA for Silverlight project with Rocky Lhotka, Justin Chase, Nermin Dibek, and Mark Steinberg for about three months.  I really enjoyed this challenging and interesting work.  It has been a great opportunity for me to work with the latest technologies and great, smart and super knowledgeable people.  About a month ago Rocky invited Justin and I to help write an article for CoDe magazine on CSLA for Silverlight.  As you can imagine,  both of us jumped at this opportunity.  As Justin just informed me, the article has been published!  I am super (and I mean SUPER) excited.  Read "Using CSLA .NET for Silverlight to Build Line-of-Business Applications" article online here.

Yeay, I am a published author!

Post to Twitter