RE: Re: Function size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




-----Original Message-----
From: Paul M Foster [mailto:paulf@xxxxxxxxxxxxxxxxx] 
Sent: Wednesday, May 30, 2012 10:54 AM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  Re: Function size

On Wed, May 30, 2012 at 04:31:12PM +0200, Sebastian Krebs wrote:


[snip]

> 
> If the functions were named properly you don't have to follow every 
> execution path to the deepest deep. Or do you reading PHPs C-source, 
> just because a wild "substr()" appeared? When you see a method
"loadFromFile()"
> and the IDE tells you, that it expects a $filename as parameter, why 
> should you jump there just to make sure, that the method loads 
> something from a file by the filename given as first parameter?

Here's why, and I've seen this happen a *lot*. The function may be properly
named, but have side effects. Or the guy who named the function
*thought* it was properly named, but was wrong. For example, he may have
named the function "loadFromFile()", and the function does in fact do that.
What the name doesn't tell you is that it then erases the file from which it
pulled. Oops! No, you're correct, the function is *not* properly named in
that case. But the guy who wrote it thought it was.
And before I look at the internals of the function, I don't know whether
it's properly named or not. Worse, the side effects may not show up until
later, and then with disasterous results. Imagine assuming everything's
okay, patching your code into the system, and finding out that it's been
hacking up the customer's filesystem for the last three weeks. All because
you didn't check to see what that other function was
*actually* doing.

Rule: NEVER assume you know what a function is doing by looking at its name.
ALWAYS satisfy yourself that you know what a function is doing by
*looking* at what it's doing.

Paul

--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
----------------------------------------------------------------------------
-------------------------------

That is WHY you put Function Definitions / Relations 


Rick.







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux