|
Posted by gosha bine on 07/08/07 02:12
pangea33 wrote:
> My post got longer and longer as my thoughts came together on this
> subject. The gist of my claim is that you shouldn't build something as
> FRAGILE as a function that breaks if there are argument variations,
> when you can simply build a more robust function in the first place.
If something is going to fail, let it fail. The sooner it fails, the
more chances to discover and fix the bug.
> An unchanging set of arguments
> makes sense when you're working with a small codebase, but sometimes
> one might want to call a function from multiple locations that have
> different requirements.
In a large project it's more likely that you use OOP rather than bare
functions. In OOP, when you need to modify existing functionality, you
extend or aggregate, but not rewrite it.
> There are two options here. You can create your function with a static
> set of arguments that fails when it is called with missing parameters,
> then counter with the retort that the dude who called it was a "bad programmer."
Yes, someone who calls a function with wrong arguments is a bad (or
simply careless) programmer.
> This is totally useless when your production sites are
> throwing unnecessary errors.
You do test your software before it goes production, don't you?
>
> When I need to expand the capabilities of an existing function to
> support new requirements, I simply have to make a modification to the
> UDF rather than to all existing code.
Again, the decent use of OOP might help here. When you need a new
feature, just extend the baseclass, and if your classes are properly
decoupled, this change won't affect the rest of the program.
>
> Any "professional" programmer who relies on the vast repository of
> *documentation* present in most projects in industry is either an
> idealistic novice, or EXTREMELY fortunate for the places they've
> worked.
>
That's the point where I tend to agree with you. Documentation should
document behaviour, not syntax. The best documentation for the syntax is
the source itself.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
[Back to original message]
|