Hello,
I’m working on a community site which will allow members to register and interact with other members.
Members will be able to have a buddy list to which they can add and remove other members. In addition, members will also be able to view the list, but not update an individual “buddy”
Visitors will be able to see the member’s profile, which includes their bio along with the first 5 buddies in their buddy list. Clicking on “View All” will take them to the entire list of buddies.
I am not sure how to set up the buddy list to accomplish the above requirements.
Thinking about it a little more I have another "solution"
Would I be able to have a Read Only Collection, say, BuddyList (based on ProjectList) which would take a memberID as the criteria then the Fetch method would read all of the member's buddies from the DB and load each BuddyInfo (based on ProjectInfo)? This part would be used when a visitor clicks on "View All"
This same class would have a Shared method that would take a DataReader, supplied by the parent class (Member) and loop through it creating the BuddyInfo objects. This would be used when the a visitor is viewing a member profile. The member class could pull up it's information, along with that of it's children collections and have each child collection load it's children.
Finally, I would create a Buddy class (similar to the Project class) which would be used to add and remove a buddy from the list. From the example in the book, this class would implement the add, delete and Exists methods of the data portal. Members would just select the buddy they want to remove from the list (readonly) and then I would be able to tell the Buddy Class to delete itself based on the ID of the selected buddy.
Please let me know what you think of this approach.
Thank you,
- Andy
Here is the object model of the last approach I was talking about.
Let me know,
- Andy
Ok, ok, I went back and re-read some sections of the book and I believe what I want are called "Switchable Objects" (Page 391 in the vb book).
My concern now is that Rocky mentions that using this method "indicates a flawed object model,.. but there are exeptions."
The reason I am using this approach is for performance on the web. Sometimes I need the member class to load the child buddy list (calling one sproc which gets the member info, plus the list info), and other times I want the buddy list to load itself.
Please let me know if this approach makes sense how I'm using it, or if I should rethink my design and not use switchable objects.
It's a little scary using such a unique approach (which could mean my approach is flawed) specially since this is the first project in which I use CSLA.
Please let me know if this makes sense for situation.
Thank you,
- Andy
Andy,
Without getting into the reasons why using switchable objects could hint at design issues, I'd like to propose that you create two separate buddy list classes. For example, you could create one buddy list class that is to be loaded from it's parent which would make it a child collection of the member obejct. The other buddy list class could be a "root collection" able to load itself with information directly from the database.
Dustin
Andy,
All of my experience with CSLA and most of my experience with .Net is in the WinForms environment. Hopefully somebody else can chime in here with an answer that is suitable for the web.
Dustin
Copyright (c) Marimer LLC