Hi Andy,
We're using managed properties in our read-only classes.
Doing a quick look at the Csla's ReadOnlyBase shows a FieldManager there.
Chris
I suggest always using RegisterProperty() and the GetProperty(), etc. helpers.
Whether you use a private backing field or managed backing field is a different question. Private backing fields are faster, but require a tiny bit more code. Managed backing fields require less code, but are slower.
Managed backing fields work automatically with CSLA Light. Private backing fields require that you write OnGetState() and OnSetState() methods to serialize/deserialize the values of those fields (just like in VB6) because reflection isn't workable in Silverlight (or medium trust in general).
Personally, I default to using managed backing fields for all objects, and only switch to private backing fields if I find performance to be an issue (which honestly hasn't happened yet in any real work).
It will ultimately use a mix of private backing fields and
managed backing fields – so I can demonstrate both.
Rocky
From: ajj3085
[mailto:cslanet@lhotka.net]
Sent: Thursday, July 24, 2008 7:36 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Managed properties for BusinessBase objects
only?
I guess I'm missing something; I thought you had to use
managed fields to use RegisterProperty and GetProperty.
So will (has) the PTracker sample have it's read only BOs changed to use
RegisterProperty and GetProperty?
Hey Rocky, quick question.
You've said that managed fields are slightly slower when not using private backing.
How much slower? Have you run benchmarks or is it more of a "it's slower just by nature of design" but not exactly quantified at this point?
Thanks!
It depends on the situation (how many fields, are you in tight
loops, etc), but it can be about 15-20% slower or so.
It has been a while since I did the testing – I was doing
mass loading of objects with random data. If I recall correctly, it was loading
around 10,000 objects per second with managed fields, and 12,000 with private
backing fields – but this is totally from memory.
But it is slower by nature of design. Managed backing fields are
stored in a data structure (array) rather than a private field, so there’s
an array lookup to get/set the value rather than directly manipulating a single
field.
Rocky
From: skagen00
[mailto:cslanet@lhotka.net]
Sent: Thursday, July 24, 2008 8:56 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: Managed properties for BusinessBase objects
only?
Hey Rocky, quick question.
You've said that managed fields are slightly slower when not using private
backing.
How much slower? Have you run benchmarks or is it more of a "it's
slower just by nature of design" but not exactly quantified at this point?
Thanks!
ReadOnlyBase should provide GetProperty(), ReadProperty() and
LoadProperty() methods – the only one it doesn’t implement is
SetProperty().
Rocky
From: sixeyes
[mailto:cslanet@lhotka.net]
Sent: Saturday, August 02, 2008 6:55 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Managed properties for BusinessBase objects
only?
I'm new to CSLA. I'm using CSLA 3.5 and have been working
with classes derived from ReadOnlyBase.
I've probably missed something but I found there was no LoadProperty in
ReadOnlyBase and so as far as I could see the only way to use RegisterProperty
etc in ROB was to use a private backing field.
Is there any way to use managed fields in ROB classes?
Iain
Copyright (c) Marimer LLC