By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,589 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,589 IT Pros & Developers. It's quick & easy.

Somewhat advanced OO design question

P: n/a
Hoping to get some ideas from more experienced hands regarding the best way
to use object-oriented design to assist my development of a content
management system destined for multiple devices. Imagine this class
structure:

clsContentData [interface to complex database.]
clsPages [abstraction of pages, not sure whether I need this
or not]
clsClientDiscover
clsRender [this class brings us to the crux of my question]

Imagine also that you're working with a language that supports a full OO
featureset. You want to design a class structure so that "pages" can be
built for all existing devices and can also be built for future
presentational technologies.

I'm wondering what the good OO design is here. My insight is limited by the
fact that I've only recently started working with languages that support
full OOP.

An amateur tack is to make a Jack-of-All-Trades "render" class with a
bazillion one-shot methods:

objRender.RenderMyUweekArticlePageForHtml
objRender.RenderMyNewsReleaseWithThe2004DesignForB lackberry
objRender.RenderMyNewsReleaseWithThe2004DesignForT ext

.... etc. This approach sucks.

Another possibility is to shift the complexity to clsPages, which would hold
declarative XML descriptions/ page templates, and then have a bunch of
methods on clsRender for rendering those pieces using different
presentational technologies:

objRender.RenderNavbar
objRender.RenderBody

Ideally use of the class involves two abstractions:

+ Hiding the specific page/content type in question. So we can call
".RenderNavbar" instead of ".RenderNewsreleaseNavbar" (a specific
implementation of navbar)

+ Hiding the device type. We can call ".RenderNewsRelease" rather than
".RenderNewsReleaseForBlackberry", confident that the render method will
interact appropriately with clsClientDiscover to determine what the clients
capabilities are and send the right page.

What's the right OO structure here? I'll be using ASP.NET with C# or VB.NET.
Yet another possiblity is that I might take advantage of some intrinsic part
of ASP.NET (e.g. user controls, server controls) to manage some aspects of
the complexity, but I don't know offhand if that's the cleanest or best
approach.

General question. Any insights gratefully accepted. I'll be going to TechEd,
so if you know of sessions I should be paying particular attention to,
please let me know.

Thanks.

Ken Fine
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Short answer -- look into "Strategy pattern"

http://www.dofactory.com/Patterns/PatternStrategy.aspx

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
<ke*****@u.washington.edu> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hoping to get some ideas from more experienced hands regarding the best
way to use object-oriented design to assist my development of a content
management system destined for multiple devices. Imagine this class
structure:

clsContentData [interface to complex database.]
clsPages [abstraction of pages, not sure whether I need this
or not]
clsClientDiscover
clsRender [this class brings us to the crux of my question]

Imagine also that you're working with a language that supports a full OO
featureset. You want to design a class structure so that "pages" can be
built for all existing devices and can also be built for future
presentational technologies.

I'm wondering what the good OO design is here. My insight is limited by
the fact that I've only recently started working with languages that
support full OOP.

An amateur tack is to make a Jack-of-All-Trades "render" class with a
bazillion one-shot methods:

objRender.RenderMyUweekArticlePageForHtml
objRender.RenderMyNewsReleaseWithThe2004DesignForB lackberry
objRender.RenderMyNewsReleaseWithThe2004DesignForT ext

... etc. This approach sucks.

Another possibility is to shift the complexity to clsPages, which would
hold declarative XML descriptions/ page templates, and then have a bunch
of methods on clsRender for rendering those pieces using different
presentational technologies:

objRender.RenderNavbar
objRender.RenderBody

Ideally use of the class involves two abstractions:

+ Hiding the specific page/content type in question. So we can call
".RenderNavbar" instead of ".RenderNewsreleaseNavbar" (a specific
implementation of navbar)

+ Hiding the device type. We can call ".RenderNewsRelease" rather than
".RenderNewsReleaseForBlackberry", confident that the render method will
interact appropriately with clsClientDiscover to determine what the
clients capabilities are and send the right page.

What's the right OO structure here? I'll be using ASP.NET with C# or
VB.NET. Yet another possiblity is that I might take advantage of some
intrinsic part of ASP.NET (e.g. user controls, server controls) to manage
some aspects of the complexity, but I don't know offhand if that's the
cleanest or best approach.

General question. Any insights gratefully accepted. I'll be going to
TechEd, so if you know of sessions I should be paying particular attention
to, please let me know.

Thanks.

Ken Fine

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.