RE: [PEAR-DEV] New XSLT class for PEAR
| From: | Stuart Herbert | Date: | Mon, 24 Feb 2003 17:36:31 +0000 |
| Subject: | RE: [PEAR-DEV] New XSLT class for PEAR | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13781@lists.php.net to get a copy of this message | ||
> I'm not very comfortable with OO yet, could you explain what
> you mean ?
>
> Arnaud.
I'll have a go. Flames to /dev/null please ;-)
A stateful object is basically an object with memory. An object where you
get/set values that are stored within the object. This is fine (imho) when
your object is encapsulating a piece of data - such as a string, a file, a
XML document, and so on. Can't really have it any other way.
On the other hand, another type of object is one that *does* something to
datatypes. A XSLT Processor is an excellent example. The processor takes
two (sometimes three ;-) inputs - XML, XSLT, and an optional set of
parameters - does something - and produces an output. You'd expect to be
able to use and re-use the processor over and over again. This type of
object (imho) has no need whatsoever to be stateful. I'd go as far as
saying that it's poor quality engineering.
The reason I'm not comfortable with objects being unnecessary stateful has
to do with quality. Stateful code - of any description - is
non-deterministic, and more prone to bugs. This is especially true over
time when many engineers work on the code. Non-stateful code, on the other
hand, is deterministic. Same input - same output. You can write unit tests
that are more simple, and require less maintenance over time. Given that
any comprehensive set of unit tests will take up between 30% and 50% of
total development time, that's very important ;-)
That's what I mean.
Best regards,
Stu
--