CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

ReadOnly and Editable classes.

rated by 0 users
Answered (Verified) This post has 1 verified answer | 4 Replies | 1 Follower

Not Ranked
3 Posts
Lokesh posted on Fri, Jan 18 2013 12:24 AM

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 ?

Answered (Verified) Verified Answer

Top 10 Contributor
1,772 Posts
Verified by Lokesh

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. 

Jonny Bekkum, Norway CslaContrib Coordinator

All Replies

Top 10 Contributor
1,772 Posts
Suggested by JonnyBee

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. 

 

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
3 Posts
Lokesh replied on Fri, Jan 18 2013 11:19 PM

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 ??

 

Thanks,

Lokesh.

Top 10 Contributor
1,772 Posts
Verified by Lokesh

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. 

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
3 Posts
Lokesh replied on Mon, Jan 21 2013 12:53 AM

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

Thanks. Smile 

 

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems