Hi again,
Sorry for the barrage of questions... I'm just trying to understand
the details of the code a little better.
What's the difference in usage between 'eval' and 'exec' in the
loader classes? Are either of these overridden ever?
In most cases, 'exec' seems to invoke 'eval' except in the
'LayoutLoader' and 'PageLoader'. 'eval' builds the page by invoking
the abstract method 'build' directly. For the the 'layout' and 'page'
cases, 'exec' builds the page directly by invoking the abstract
method 'build'.
I suggest the following changes, which I'll be happy to make once I
learn more details:
1. Rename 'eval' and 'exec' to more descriptive names. If they're not
used independently, merge them into a single method.
2. Make PageLoader and LayoutLoader follow the model of the other classes.
3. Perhaps move all of this into a parent class which implements the
duplicated code in one place.
4. Instead of invoking 'build' directly, invoke another method like
'do_build' which invokes 'build'. I try to make abstract methods only
invoked from INSIDE a particular class. This allows the class to
change calling context of the abstract method easily.
For instance, if we wanted to do something before 'build' was
invoked, we would have a hard time doing it seems most screens and
actions directly override the 'build' method and it is invoked
directly in other parts of the code. It might make sense to hide the
'build' method and make clients of the class invoke 'do_build'
instead. Then if we want to invoke another method along with 'build'
each time a build is requested, it is very easy to encapsulate this
into the 'do_build' method. This is a tough explanation, so here's
some code which demo's the problem:
abstract class Screen
{
abstract void build();
}
class BigScreen extends Screen
{
void build();
}
class SmallScreen extends Screen
{
void build();
}
someFunction...
{
Screen s = getBigOrSmallScreen();
s.build();
}
Now lets say that we want to extend the 'build' method to log the
time of each 'build' invocation.
We could put the code in each of the 'build' methods... but this
would have a lot of duplicated code.
We could put the code in the invocation of 'build' [in someFunction
in the code above]... but this would also be duplicated and difficult
to maintain.
So, if instead we did the following:
abstract class Screen
{
void do_build()
{
build();
}
private abstract build();
}
class BigScreen extends Screen
{
void build();
}
class SmallScreen extends Screen
{
void build();
}
someFunction...
{
Screen s = getBigOrSmallScreen();
s.do_build();
}
It is very easy to add the code (to the 'do_build' method).
Also, one other note: I wouldn't necessarily name the methods
'do_build' and such. I would think renaming the abstract method
'build' to 'buildScreen' or whatever was appropriate for the class it
was in would be the best way to go. Then 'build' could be used by the
loader...
Again I apologize for the barrage of questions... Just trying to get
to the point where I can make useful changes to the code.
Chris Meyer
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]