after spending a reasonable amount of time working on my various
proposals which are all related to weblog design and customization i
have found that our object model for themes is not as well constructed
as i think it should be. the relationship between static themes and
custom weblog themes is kind of duct taped together right now and i have
some ideas on how to improve it using just a bit of refactoring.
what i'd like to do is start by redefining a Theme as "The set of
elements used to render a weblog", and use that statement to define a
more appropriate object model for themes. The idea is that the Theme
object should be *the* object which is used to access all information
about how a weblog design is defined. So instead of having the Theme
object just represent a static theme, like it does now, I'd like the
Theme object to be an interface which would have an implementation for
static (shared) themes and an implementation representing a custom
weblog theme. You then access the elements that make up the theme using
the Theme object. A Theme would contain all resources relevant to
weblog design, which currently means templates & files.
So, the updated object model would be structured basically like this ...
Theme (Interface)
|
+-- StaticTheme
|
+-- WeblogTheme
Template (Interface)
|
+-- ThemeTemplate (Interface)
| |
| +-- StaticThemeTemplate
| |
| +-- WeblogTemplate
|
|
+-- StaticTemplate (like the feed templates)
Resource (Interface)
|
+-- ThemeResource (Interface)
|
+-- StaticThemeResource
|
+-- WeblogResource
In my mind this represents a much more appropriate and structured data
model than we have right now and provides a nice object hierarchy for
proper encapsulation. This will also offer a lot more potential for
expansion as we offer more and more addons to weblog themes. A good
example is the new Widgets & Panels feature that I am developing, which
in reality is something which is a subcomponent of a weblog theme.
What exactly changes with this remodeling?
The main changes would be in the way templates and resources are
accessed. Currently the logic for looking up these items contains
duplicated logic all over the code where we do a check like ...
if(weblog is using theme)
// try getting from theme
else
// try getting directly from somewhere else
this kind of logic would be much more appropriately centralized inside
the actual Theme implementation and so accessing a template or resource
would be as simple as ...
weblog.getTheme().getDefaultTemplate();
weblog.getTheme().getTemplateByName("foo");
weblog.getTheme().getResource("path/to/resource.img");
the main places that code changes like this would be implemented would
be in the rendering code, most notably our servlets which do template
lookups by theme, and the resource servlets which do resource lookups by
theme.
anyways, before this gets too long. does anyone object to doing this?
any reasons why we shouldn't do this? or ways we could do it better?
-- Allen