RICKS OO Problem:
I'm porting my old Content Management System to c#. The old CMS was
com/dll/script based and was bleugh.
I'm modularising functionality as much as possible. The first section I'm
rebuilding is the image library system.
This generates HTML that displays thumbnails and a main image. When you
click on the thumbnail, the associated image is displayed.
The database comprises of three tables. tblimage, tblthumbnails and
tblcategory,
I have a base class called Image, with classes thumbnail and picture
deriving from this. The base class has member properties such as filename,
width, height etc. It implements an interface Ifetchsavedelete which defines
three member functions that interact with the database. Thumbnail and
Picture overload some of this functionality (for example a picture has
description and therefore the fetch member function must also extract this
info from the database). They also contain functionality specific to each
type of image.
An additional class Navigation builds HTML. For example it instantiates a
Picture object and generates HTML based on the Picture objects member
properties. For example it creates <img src="name" alt="description"
height="500" width="500"/> etc . A Navigation object is instantiated by the
page controller which streams the HTML to the client browser. This is all
fine. Data access is minimal etc
At this point the Navigation class is completetly independent of the data
layer. This is good.
This Navigation Class must also generate HTML that displays a number of
thumbnails.
At this point things get messy.
A thumbnail object based on the thumbnail class represents one thumbnail.
Since there are multiple thumbnails to be displayed (these are determined
based upon the category of image i.e. gig photos) the navigation object must
determine which thumbnails should be displayed. This requires that it
converse with the database and return a recordset of thumbnail ids. It must
then instantantiate each thumbnail object for each id. It can then return
through the thumbnail object its filename, size etc. This must be done for
each thumbnail. Since the database is accessed by each thumbnail object this
is very inefficient.
Alternatively I can ignore the thumbnail object in the navigation class and
just get all the required data directly through the data layer.
This to me seems to negate the point of oo.
Can any body suggest a solution?