[Chicago-talk] design opinions

Jim Thomason thomasoniii at gmail.com
Thu Aug 12 14:15:33 CDT 2004

> Not sure if this is relevant, but when conditionals start bugging you a
> lot it might be time to start thinking about polymorphism [1]. Or not...
> //Ed

I already went through my polymorphic re-factoring pass on that
script. :-) The current procedural (non-machine-based) script is ~84
lines. The original one that I ripped up was 168 lines. Moved a lot of
the additional security checking out of it into a slightly more
complex superclass and a listing of configuration information. So I
got rid of a lot of the things like:

if ($user->can_delete($object)) {

and replaced it with simple:


where the delete method internally looks up configuration information
and does the delete if the user can is allowed. No, it wasn't just a
matter of moving the conditional into the method, don't worry.

But, even though the wheels already did spin in my head with ways to
subclass all of my objects out the yinyang to create polymorphically
subclassed state machines, that's not an avenue that I'm going to


More information about the Chicago-talk mailing list