CSLA & identity map

CSLA & identity map

Old forum URL: forums.lhotka.net/forums/t/10313.aspx


Zillo posted on Thursday, April 28, 2011

Hello,

does CSLA include any kind of identity map? (http://martinfowler.com/eaaCatalog/identityMap.html).To me it seems, it doesn't. For what reason there's no use of an identity map?

Thanks for CSLA and for new insights.

 

Zillo

 

JonnyBee replied on Thursday, April 28, 2011

CSLA is for creating BusinessObjects and implements several patterns including Mobile Objects. CSLA is NOT a Data Acess Layer.

IdentityMap is implemented in f.ex EntitiyFramwork and Linq2Sql.

Quote from Martin Fowler:
"An Identity Map keeps a record of all objects that have been read from the database in a single business transaction. Whenever you want an object, you check the Identity Map first to see if you already have it.:"

 

tmg4340 replied on Thursday, April 28, 2011

No, CSLA does not include the concept of an identity map.  While this was possible in older versions, for several versions now CSLA has not supported the concept of logical equality, which is key to making an identity map work (especially in n-tier environments).  This is because Microsoft changed things with WPF, and as such no longer supports logical equality in XAML databinding scenarios.

HTH

- Scott

Zillo replied on Friday, April 29, 2011

Normal 0 21 false false false DE X-NONE X-NONE

Hello Jonny, hello Scott,

I’m quite new to this whole topic and now I’m tryring to merge your answers in my mind.

Both of you said CSLA itself does not include an identity map. Jonny said the function of an identity map is provided by f.ex EntitiyFramwork and Linq2Sql. In contrast Scott quoted an identity map is no longer included in CLSA since WPF doesn’t support the concept of logical identity. It sounds like that there isn’t any identity map at all, neither in business layer nor in data access layer. How do these answers fit together?

After reading some chapters of Lhotkas C# Business Objects 2008, it seems to me, CSLA doesn’t provide functions of an identity map. E.g. at p. 158 you can read: “Note: It’s important to understand that the updated root object returned to the UI is a new object. The UI must update its references to use this new object in lieu of the original root object.”

My main concern is to find out the pros and cons of using an identity map. So after reading your posts, I’d like to know, how do Windows Forms support the concept of logical identity (in Jonnys post it sounds like that’s a difference between Windows Forms and WPF, isn’t it)? Why doesn’t WPF support this concept?

Do know any useful sources of information beside Fowlers Patterns of EEA, Evans Domain Driven Design and Lhotkas C# BO 2008?

Thank you

Zillo

tmg4340 replied on Friday, April 29, 2011

I think you may have misunderstood what I was saying.  I wasn't saying that CSLA used to include an identity map and now no longer does.  What I was saying was that CSLA used to have support for building an identity map of CSLA business objects.  However, with the way WPF (and I believe Silverlight) handles object equality, that concept won't really work anymore, and so the methods in CSLA that support the concept of logical equality (a necessary concept for an identity map to really work) have been deprecated.

Whether it's a good idea to create identity maps for your business objects is a different question.  Given the way CSLA works, identity maps don't really get you much, and ultimately would probably complicate things more than they help.  Saving a CSLA object results in a new instance, so any identity map would have to be updated with that instance, as well as all your other instance references in your app.  So the map isn't really going to save you all that much, even in a basic client/server scenario (and it would be even less useful in an n-tier scenario).

Jonny is right that identity maps are more often found in data-access layers or ORM tools.  CSLA is neither of those.

As for why Microsoft changed the game when WPF came along, I don't know.  It was something Rocky specifically brought up on this forum when working on upgrading CSLA to support WPF.  I presume he saw some documentation stating that, and possibly the reasons why, but I if so I am not sure what it was or where it is.  I'm guessing that it had to do with how XAML databinding works vis-a-vis Windows Forms databinding.

The books you listed would probably be the best sources I know of, though when you start talking about OOD you are going to get wildly varying opinions based on who you talk to.  Rocky has made some suggestions over the years on the forum, and while the titles he mentioned don't come to mind, you should be able to search the forum posts and find them.

HTH

- Scott

Zillo replied on Tuesday, May 03, 2011

Thank you for making things clearer.

Copyright (c) Marimer LLC