[opencms-dev] Why two CmsResourceBroker's?

Anders Fugmann anders.fugmann at framfab.dk
Tue Jul 18 11:13:44 CEST 2000


Hi again.

I can see that the classes in the two names packages will change and
begin to differ more and more as specific code for the database enters
the classes. But as I see it, this still introduces some maintainability
problems. 
Some methods in the classes are not dependent of the actual database, or
at least some functionality can be share by all database
implementations. 
Looking into CmsResourceBroker, the method 'validFileName' and
'fileSystemChanged' has IMHO nothing to do with the specific database
implementation (or CMS database-driver). The latter one, might (besides
counting changes and eventually do some logging) might need to do some
database specific handling as well as do some general stuff. There may
be other methods that also are 'general' for all database
implementations. 

Another point looking in general at the code - I need to get this
clarified:
Is it accepted to use exception as accepted states (opposed to error
states).
for example looking at CmsResourceBroker.validFileName(String), it
throws an exception, if the given filname is not accepted - would it not
be nicer to return a boolean instead. IMHO an exception means that an
unexpected error occurred, but it seems that
CmsResourceBroker.validFileName(String) does indeed check for this
error, and therefore the program does not enter an unexpected error
state at this point.

Also I see that exceptions are used to to break out of loops. I do not
see this as 'nice programming' to catch a NullPointerException, just
because EOF is reached, when reading a file. EOF is IMHO not an
unexpected error state, and should not be treated as such.

I ask all these questions, because I'm on the edge of writing some code
to the OpenCMS project, and it would be nice to know what programming
guidelines are to be followed. Also if I'm allowed to post patches,
which removed some exceptions in order to make cleaner code, and to
maintain the philosophy of exceptions being an unexpected error state.

Kind regards 
Anders Fugmann
Nebual team developer.
  
"Schouten, Andreas" wrote:
> 
> Hi,
> 
> > Looking af the new version 4.1.31, it strikes me that all classes
> > in package com.opencms.file.genericsql and
> > com.opencms.file.mySql seems
> > to be identical,
> > except from changes in date, revision, etc. (ok, in I_CmsQuerys, four
> > line of code has been changed.)
> 
> Yes, you are right. But meanwhile the two packages are more different. With
> this access-packages it is possible to fit the needs for different
> databases.
> 
> >
> > Would it not be more in the object oriented way to only have
> > one class,
> > and then extend it, for the sake of maintainability and overview?
> >
> > The reason that i ask, is that I want to make log all changes in the
> > Virtual filesystem, but now i need to write the same code
> > twice, which i
> > hate to do :-)
> >
> > btw. 'com.opencms.file.mySql' does not follow the java naming
> > standard,
> > in which no capital letter are to occur in packagenames.
> 
> We will fix that mistake ASAP.
> 
> Regards,
> 
> Andreas Schouten

-- 
. . . . . . . . . . . . F r a m f a b   A / S . . . . . . . . . . . . .
Anders Fugmann                                 Livjægergade 17A, 2.sal.
Systems Developer                              DK-2100 København Ø.
E-mail: anders.fugmann at framfab.dk              Telefon: +45 39 17 48 48
Direkte: +45 39 17 48 38                       http://www.framfab.dk
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .



More information about the opencms-dev mailing list