Hi guys,
I'm want to write a class for validating xml files, but I'm not sure about the pattern the class shall have.
what I have so far:
a class that's doing XSLT transformation:
in the load() method I check the XML files for validaty too, but that's taking too long (4 - 10s) so I decided to do the validation only when the files were recently changed. which leaves me with the task of storing the last validation results.
Now the problem.
in every call of this class I need the validation file to be checked if I have to do validation or not (basicly if the last successful validation is after the last modified time). I'd like to create a class (or an instance of a class) that holds the complete validation results (better than reading the file each time).
But which pattern should that class be? I thought of either singleton or registry pattern.
singleton
+ file reading while instantiation
– more (complex) code
registry
+ less code
+ can be deserialized (as a whole)
– needs external initialization
what do you think about that? or do you have a better idea than I?
thanks
I'm want to write a class for validating xml files, but I'm not sure about the pattern the class shall have.
what I have so far:
a class that's doing XSLT transformation:
Code:
class XSLTransform
{
__construct() // checking if files are loaded from file or string
load() // loading XML & XSL files/strings
process() // doing transformation
checkResult() // well...
}
Now the problem.
in every call of this class I need the validation file to be checked if I have to do validation or not (basicly if the last successful validation is after the last modified time). I'd like to create a class (or an instance of a class) that holds the complete validation results (better than reading the file each time).
But which pattern should that class be? I thought of either singleton or registry pattern.
singleton
+ file reading while instantiation
– more (complex) code
registry
+ less code
+ can be deserialized (as a whole)
– needs external initialization
what do you think about that? or do you have a better idea than I?
thanks
Comment