Objects by Design Forums Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Calendar Find other members Frequently Asked Questions Search Home  
Objects by Design Forums : Powered by vBulletin version 2.3.5 Objects by Design Forums > Main Forums > Object-Oriented Design and Patterns > Looking for a solution to an OOD problem
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
jasongr
Junior Member

Registered: Oct 2004
Location:
Posts: 2

Looking for a solution to an OOD problem

I am facing the following problem:

Imagine the need to support a system of skins. Each skin should know how to render a specific entity. A skin could have the following abstract functions:

- renderButton
- renderTable
- renderHeader
and so on.

The output of these functions should be HTML which provides a concrete implementation based on the skin.

We could have a 'wood' skin which renders its button in a brownish color, a metal looking skin, and so on.

The complication comes from the requirement that the skin implementation cannot be browser dependent.

There could be a Firefox implementation for each of the skins and an IE implementation and possibly a few other supported browsers.

This forms two sibling hierarchies with the Browser abstract class at the top of one and abstract Skin at the top of the other.

My question is, how can I combine these two hierarchies in a smart way so that I will be able to easily support new skins and new browsers?

I don't want to end up writing classes like: MetalIESkin, WoodFirefoxSkin and so on because this solution isn't robust.

I was thinking about having the Skin functions take a Browser object as a parameter and then use it to render themselves, but I am not sure how this helps me.

My ultimate solution should have an isolated code that knows how to render the metal button for IE (for example).

I was thinking about the Abstract factory and Prototype design patterns but I fail to take them to the next step and use them to achieve my goal

regards

Report this post to a moderator | IP: Logged

Old Post 10-14-2004 08:13 AM
jasongr is offline Click Here to See the Profile for jasongr Click here to Send jasongr a Private Message Find more posts by jasongr Add jasongr to your buddy list Edit/Delete Message Reply w/Quote
SZ
Administrator

Registered: Apr 2001
Location: New York
Posts: 492

The first question I would ask is why there should be such differences between browsers? HTML should be portable to each and it should be possible to have one class for each feature to output a generic HTML.

If there are differences between browsers, I personally would recommend XML and XSLT. Your classes could output a generic XML content stream and then you could have separate XSLT stylesheets for each browser. Each feature would be rendered by its own template in the stylesheet, maintaining encapsulation.

Report this post to a moderator | IP: Logged

Old Post 10-17-2004 01:45 AM
SZ is offline Click Here to See the Profile for SZ Click here to Send SZ a Private Message Visit SZ's homepage! Find more posts by SZ Add SZ to your buddy list Edit/Delete Message Reply w/Quote
jasongr
Junior Member

Registered: Oct 2004
Location:
Posts: 2

Sometimes the difference lies in the JavaScript code that needs to be invoked by the page.

Each skin may trigger JavaScript code and this is obviously not the same in the different browsers, although XSLT is still a good solution.

Report this post to a moderator | IP: Logged

Old Post 10-17-2004 08:05 AM
jasongr is offline Click Here to See the Profile for jasongr Click here to Send jasongr a Private Message Find more posts by jasongr Add jasongr to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 12:26 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 

< Contact Us - Objects by Design >

Powered by: vBulletin Version 2.3.5
Copyright ©2000 - 2018, Jelsoft Enterprises Limited.
Copyright 1999-2005, Objects by Design, Inc.