Re: Re: Switch - Case Statement Questions
| From: | tamouse mailing lists | Date: | Sat, 17 Nov 2012 21:42:43 +0000 |
| Subject: | Re: Re: Switch - Case Statement Questions | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319728@lists.php.net to get a copy of this message | ||
On Sat, Nov 17, 2012 at 3:13 PM, Sebastian Krebs <krebs.seb@gmail.com> wrote:
> 2012/11/17 Andrew Ballard <aballard@gmail.com>
>
>> On Nov 16, 2012 10:24 PM, "tamouse mailing lists" <tamouse.lists@gmail.com>
>> wrote:
>> > Just a tad obscure for someone coming along
>> > later
>>
>> Without knowing the intent of the code, it could be a headache to maintain.
>>
> Interesting, that you see 5 lines of code and assume, that nobody will ever
> get the intent of this code ;) Of course the context is missing. I guess,
> that "$count" is something like "remaining days", or such, because
> "7" and
> "14" look like "one week" and "two weeks", respectively. Thus I
> wouldn't
> name the variable "$count" [1], but "$remainingDays" and voila: Context is
> back and so is the intent :)
This was actually the thrust of my remark about obscurity. I could
easily see how the refactored algorithm worked from the original
code's algorithm. What was obscure was exactly the variable name
$count, i.e., the meaning of the data driving the algorithm. When you
know the actual meaning of data being used, the obscurity goes away.
Hence: useful variable names.
Again, well done, Seb.