NYCPHP Meetup

NYPHP.org

[nycphp-talk] why does setcookie fail?????

Chris Shiflett shiflett at php.net
Sun Sep 7 14:27:07 EDT 2003


--- Adam Maccabee Trachtenberg <adam at trachtenberg.com> wrote:
> But seriously, my suggestion is whenever you're getting frustrated
> to take a deep breath, a five minute break, then come back and put
> together a step-by-step list of what you're trying to
> accomplish. Once you're armed with a list, you can then verify that
> each step is getting the correct input and providing the correct
> output. Often times, merely the process of figuring this out will
> trigger what you should do to fix the bug.

This is great advice. The setcookie line of questioning perfectly illustrates
why erroneous assumptions can make simple problems into very complex ones.

For example, consider this calculation:

(25 * 4) * 10

There are basically three pieces of data here that are combined together in two
operations to produce the final output. Now, consider this question:

Does anyone know WHY I can multiply 100 by 10 and get 1250??? See if you can
explain THAT one!!!

After scores of messages back and forth, it is realized that the error was that
the following calculation was actually being performed:

(25 * 5) * 10

So, if the question asked had been why 5 was being returned by something
instead of 4, the answer would have been much easier (and less misleading).

Breaking things down is essential to solving problems. This should have been
the first test to prove the assumption wrong:

100 * 10

This would have given 1000, not 1250, so the erroneous assumption should never
even be mentioned in the question. A little effort up front can save a lot of
time for everyone.

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/



More information about the talk mailing list