Re: Array Symbol Suggestion
| From: | David Hutto | Date: | Thu, 13 Jan 2011 18:07:00 +0000 |
| Subject: | Re: Array Symbol Suggestion | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310737@lists.php.net to get a copy of this message | ||
On Thu, Jan 13, 2011 at 12:59 PM, David Harkness
<david.h@highgearmedia.com> wrote:
> On Thu, Jan 13, 2011 at 2:23 AM, Richard Quadling <rquadling@gmail.com>wrote:
>
>> The Hungarian Notation [1] was what I was taught all those years ago
>> when I learnt standard C programming.
>
>
> I learned it early on as well, and I never really liked it. Instead of
> $iFish I would prefer a more descriptive name such as $fishCount.
What info did you get on hook for the client?
Sure, it's
> a little longer to type, but it tells you what that number measures. In
> today's world of objects and loosely-typed languages, a descriptive variable
> name can be more important than a symbol or notation to hint at the type.
>
> As for arrays, I always name the variable plural. And if it maps keys to
> values instead of holding a list of items, I will typically name it
> $foosByBar, e.g. $customersById. From that name I *know* it's array
> already--no need for a prefix or special symbol.
>
> $oPlayer, $sName, $iWidth...what's the point? The context in which the
> variable is used can provide more meaning. If you stick to short
> functions/methods that do one specific thing, you'll be able to tell that
> $player is an object, $name is a string, and $width is an integer.
>
> I highly recommend the book Clean Code: A Handbook of Agile
> Software Craftsmanship by Robert C. Martin. [1] It has a lot of great advice
> on keeping your code easy to understand, test, and maintain.
>
> David
>
> [1]
>
> http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
>
--
Sometimes...my mama...says I get over excited about technology.