There's a level in Hell reserved for people who write "as_string" methods that have side-effects.
... tell us the story behind this. I am boggled at how someone can think this is a good idea
Re:Please, please, please ...
dws on 2003-03-08T05:43:15
Seeing at the statute of limitations has passed...I had joined a project mid-stream, and was trying to integrate my first round of code, but it was failing on odd ways while trying to persist data. I stepped throught the whole bloody thing several times, but couldn't see what was going wrong. When I asked for help, someone pointed out that I wasn't invoking as_string() on a domain object at a particular point.
Me: But I don't need a printable representation there.Them: Well, maybe not, but that's where we cache the object GUID so that we can do [low-level stuff] to make it persist. You've gotta call as_string() there.
Me: Uh... uh... uh... why do [low-level stuff] in as_string()?!?
Them: Well, we had to do it somewhere, and everyone was already calling as_string() there anyway, so we put the code in as_string(). That way, nobody had to change their code.
Whenever I hear "that way, nobody has to change their code" a big red flag goes up.