I need to have state management on a 2 dimensional array of decimal values with a variable number of rows and columns. I need full Csla state tracking on every decimal value in the array and I'm having a hard time coming up with an efficient way to accomplish this. Any suggestions you have will be received with appreciation.
I'll ask for this, but honestly it may not end up helping much...
If you could give us some more context to your problem space, we might be able to suggest a solution.
Having said that, I wouldn't hold my breath. I don't see a way to manage the array in any kind of efficient manner within CSLA, especially as a single unit. Breaking each element out isn't efficient, but fits more into the CSLA model - until you add in the variableness factor. CSLA doesn't really do well with that kind of dynamic situation - at least not right out of the box.
Essentially you're trying to add CSLA functionality to a DataTable, which to my knowledge hasn't really been done. In fact, you may get more of what you want by using a DataTable...
But again, a bit more information about what you're trying to do may help.
I suspect that you are probably correct but thought I'd take a shot on the forum to see if anyone had suggestions.
What I'm trying to accomplish is tracking an unknown number of value series indexed by a single date series (imagine a spread sheet with a date column and several value columns). A DataTable isn't a viable option because one UI I'm working with is Silverlight which has no DataTable.
Well... I can actually think of a way to make it work, though I'm not sure how efficient it would be, nor would it be easy to work into in a XAML-based UI.
(This would also be helpful if this array is a sparse array, which I have a hunch it may be...)
You could implement a simple node class with pointers, and essentially create a linked list to define your array. That could fit relatively neatly into one of the CSLA collection classes, and then you'd get your change tracking on each node. From an efficiency perspective, that's about the best I can come up with, and if you don't have a lot of rules (business or otherwise), the overall structure size might not be that bad.
If you wanted to make it a little simpler to conceptualize, you could build a child/grandchild list, with the children being your date and the grandchildren being the series values for each date. It's a variation on implementing a sparse array, and could also work relatively well.
The UI, though, is a problem. XAML data-binding isn't really built to do work with something like that. So you'd have to build a ViewModel to turn that into something that looks like a spreadsheet, but still maintains the appropriate link back to the true data element (presuming that's your UI metaphor.) And that's where you're going to run into overhead, as you basically can't take advantage of a lot of the built-in UI infrastructure for CSLA - you have to re-implement that UI code, probably delegating back to your CSLA nodes. The level you have to go to depends on what your UI needs are, but it's likely not non-trivial. The second structure (the child/grandchild structure) might make that easier, but I still think you'd end up re-implementing a fair amount of code.
All of this assumes you want to rely on XAML data-binding, but if you set that aside, then you gain some flexibility - at the cost of a potentially heavy code base to write behind your SL usercontrol. That's a step I'd seriously think about before implementing; do not underestimate the amount of additional code you might have to write.
Copyright (c) Marimer LLC