From Zero To Launch - Part III: Reusable Web Controls
18 05 2008This is the third post in a series of entries that I am using to describe the architecture used in my most recent social networking project. While some of the architecture is omitted from these discussions, I would like to share some of the tricks that my team used to decrease development time and meet the rough and ambitious deadlines that were placed upon us. This entry will continue the discussion on web controls with an emphasis on distinguishing between server and user controls.
During the domain modeling phase of the application, we noticed that Comments were utilized by several different areas of the application:
The first piece of the application to utilize the control was the User profile. As mentioned in the previous post, we constructed useful server controls to facilitate a consistent layout throughout the application. Using one of these controls, the LayoutModule, we constructed what we referred to as a CommentContainer to display comments.
As we expanded the functionality of the control, we realized we needed/wanted two things:
- AJAX comment posting, deleting
- Pagination
In order to allow for this functionality, we needed to abstract out the functionality that was required using a variation of the Bridge pattern:
Note: The CommentProvider is an extension of a generic EntityProvider that is used to define the general functionality shared by all of the controls that utilize this pattern.
After the CommentContainer and CommentProvider were finalized, adding comment functionality for additional pages was a piece of cake and the code is very easy to maintain.


May 19th, 2008 at 12:18 pm
What component maintained responsibility for determining the type of Provider to use? Were you basing that on the page you were looking at or some other piece of knowledge?
May 19th, 2008 at 12:31 pm
We allowed the pages themselves to determine the appropriate provider. The providers themselves maintain pagination information (required for the LoadEntities override) so the pages needed to pass that information into the appropriate setters or constructors.
An example would be:
commentContainer.CommentProvider = new UserProfileCommentProvider(_queryUser, _pageIndex, AppConfiguration.CommentsPerPage);May 21st, 2008 at 6:13 pm
[...] Next up: Reusable user controls [...]