RE: [PHP] Classes - Dumb question
| From: | Jay Blanchard | Date: | Fri, 12 Oct 2007 14:03:41 +0000 |
| Subject: | RE: [PHP] Classes - Dumb question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263146@lists.php.net to get a copy of this message | ||
[snip]
Yes, but I could do that procedurally from within the customer
function by simply adding a customer type (needed regardless) and
using a switch to direct and collect the additional data needed.
....
In either case, I still have to write more code to accommodate
scaling. And, if I have more customer types, then it's a simple
matter to add more customer functions and addition case statements to
the initial customer function. I don't see the benefit in using a
class. At this point, it just looks like a different way of doing
things.
[/snip]
No doubt. (are you by chance continuing the other argument, re: interfaces?), but you have to break
open the original tested function, add code to it, test it, etc. Every time you add a new case you
have to break open the existing function to add that case. After a while, say if you need to drop a
customer type you would have to (not really, you can leave it there and never exercise the case)
break open the original code and delete the un-used code. Any way that you slice it the original
customer function becomes more and more like spaghetti every day. Documentation for the function has
to change each time as well.
With a class you can inherit all of the base class functionality into a new customer type. You do
not have to break open the base class to add a case, you just have to create an extension class.
Documentation is unique to each class.