Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

DotNetNuke UserMembership class (as well as some others) hasObjectHydrated property as a flag is object loaded or not.

In my opinion implementation of this pattern is fragile and not reliable.

Get  Membership Property of  UserInfo tries to load data from UserMembership, which is not good, because Get (read-only) property should not change state of the object.
It can cause different behavior in Debug and Release modes, if any code like Debug.WriteLine(ObjUser.Membership.Email) will be used.

Also assigning any of UserMembership properties (e.g. Email) sets has ObjectHydrated flag to true, even if other properties are not filled.

I've noticed a few times that FillUserMembership wasn't called when expected and properties of UserMembership were null, even if ObjectHydrated flag was true.It caused exceptions, that are not reproducible.

I've noticed that DNN support has reports about the issue(see here and here)

Posted on Wednesday, March 15, 2006 6:16 AM DotNetNuke | Back to top


Comments on this post: ObjectHydrated pattern in DotNetNuke UserInfo is not good

# re: ObjectHydrated pattern in DotNetNuke UserInfo is not good
Requesting Gravatar...
IMHO – You might simply be misunderstanding the use of ObjectHydrated, not that the pattern is necessarily bad.

If my understanding is correct, ObjectHydrated follows a different pattern the the “is Dirty” type of property often found in O/R objects.

With OH it appears that you either have an empty object (created but with no fields set) or an object with SOME value set.

An isDirty pattern would take a different approach in that in a given state (filled or unfilled) an object is dirty with ANY change (from an empty state to a filled state to a changed state), so that you can determine if some sort of a persist needs to occur. Very useful but, quite possibly, not what the DNN architects were shooting for.

As for the exceptions, I wonder if the FillUserMembership doesn't get called either because of caching or because the debug user hasn't attempted authentication? Do you know what the exceptions were or what they were related to? Can you check your DNN log as it should be there?

Just my $.02 and thanks for the post.
Left by Hal Lesesne on Mar 15, 2006 7:14 AM

# re: ObjectHydrated pattern in DotNetNuke UserInfo is not good
Requesting Gravatar...
Hal,
Thank you for clarification. My understanding was that ObjectHydrated means that not SOME, but ALL values for consistent object state are set. E.g if email is set, but username doesn't, UserInfo object is not completed, can't be saved and is not fully Hydrated.
Left by Michael Freidgeim on Mar 15, 2006 12:05 PM

# re: ObjectHydrated pattern in DotNetNuke UserInfo is not good
Requesting Gravatar...
i will made to now i cann;t get user info by code in dnn :(
Left by almny on May 17, 2009 9:45 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net