ReadOnly and Editable classes.

ReadOnly and Editable classes.

Old forum URL:

Lokesh posted on Friday, January 18, 2013

Hi there,

I am new to this CSLA framework, so please correct me if I am wrong.

I have grid which only shows the data from database. No edit, insert, delete operations are performed on it.

Now my question is, Why am I told to use Read-only classes to bind the grid whereas I can do it using editable classes also ? What performance difference does it make ?

JonnyBee replied on Friday, January 18, 2013

Editable classes have a larger footprint in memory and transfer, support n-level undo and change tracking.

Why would use these if there is no editing involved? Use ReadOnly classes where there is no editing involved. 


Lokesh replied on Friday, January 18, 2013

Thanks for your quick reply.

Yes, there is no editing involved in the grid.

But what if I use editable classes instead? Anyways only " Get" properties of the class will be used, no "Set".  The Object won't be getting dirty.

So why not use the editable classes?

"Editable classes have a larger footprint in memory and transfer, support n-level undo and change tracking." Could please explain this ?

I just want to know that, if I use the editable classes, will it affect the performance of the application? If yes, How ??




JonnyBee replied on Saturday, January 19, 2013

The editable classes uses more memory and support n-leve undo and editing via IEditableObject which will create snapshots in memory. 

DataGridView in f.ex WindowsForms will by default support editing. 

ReadOnly classes in the framework exists for a purpose - to use less memory and have a smaller size when serialized. So while you _may_ use onlyeditable classes - I would find it very confusing if you used editable base classes for readonly list objects. 

As an example - editable base classes will always have a Save / SaveAsync method om them - readonly classes do not.  BusinessBase also has other properties like BrokenRules. So anyone - other than yourself - who starts using your classes would easily get confused on the responsibility of the class. 

Lokesh replied on Monday, January 21, 2013

Thanks a lot for your reply and explanation. Now I am clear with the use of Editable and Read-only classes.

Thanks. Smile 


Copyright (c) Marimer LLC