This is a discussion on Inspiration for a Tombstone. within the PHP General forums, part of the PHP Programming Forums category; On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie <gmane@colin.guthr.ie> wrote: > Robert ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie <gmane@colin.guthr.ie> wrote:
> Robert Cummings wrote: >> >> I will never do it... it looks ugly, > > Only if you're not used to it. IMO this is how it should be taught in all > the books and guides etc. If that was the case, the other way round would be > ugly :) > >> especially when performing multiple >> if comparisons on the variable. > > Perhaps, but it's still not as ugly as a hideous error gone undetected which > accidentally deletes all your customers' data. ---snip--- I don't know about "ugly," but I agree it "feels" wrong. I feel like I'm using Yoda-speak when reading code like that: If 'yes' is you_can_read_this, 'Stop standing on me' I say. or If 0 is my_pulse then 'dead you are' should say you. :-D --Andrew |
|
|||
|
On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote:
> On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie <gmane@colin.guthr.ie> wrote: > > Robert Cummings wrote: > >> > >> I will never do it... it looks ugly, > > > > Only if you're not used to it. IMO this is how it should be taught in all > > the books and guides etc. If that was the case, the other way round would be > > ugly :) > > > >> especially when performing multiple > >> if comparisons on the variable. > > > > Perhaps, but it's still not as ugly as a hideous error gone undetected which > > accidentally deletes all your customers' data. > ---snip--- > > > I don't know about "ugly," but I agree it "feels" wrong. I feel like > I'm using Yoda-speak when reading code like that: > > If 'yes' is you_can_read_this, 'Stop standing on me' I say. > > or > > If 0 is my_pulse then 'dead you are' should say you. *lol* Exactly... just doesn't sit right. It's a good way to make sure you're not screwing up, but testing should take care of that too. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP |
|
|||
|
Robert Cummings wrote:
> On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote: >> On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie <gmane@colin.guthr.ie> wrote: >>> Robert Cummings wrote: >>>> I will never do it... it looks ugly, >>> Only if you're not used to it. IMO this is how it should be taught in all >>> the books and guides etc. If that was the case, the other way round would be >>> ugly :) >>> >>>> especially when performing multiple >>>> if comparisons on the variable. >>> Perhaps, but it's still not as ugly as a hideous error gone undetected which >>> accidentally deletes all your customers' data. >> ---snip--- >> >> >> I don't know about "ugly," but I agree it "feels" wrong. I feel like >> I'm using Yoda-speak when reading code like that: >> >> If 'yes' is you_can_read_this, 'Stop standing on me' I say. >> >> or >> >> If 0 is my_pulse then 'dead you are' should say you. > > *lol* Exactly... just doesn't sit right. > > It's a good way to make sure you're not screwing up, but testing should > take care of that too. > > Cheers, > Rob. But whoever said the flow of the English language was all that efficient? I actually prefer 'Yoda Speak'. Takes less to say more. |
|
|||
|
2008/6/28 Jim Lucas <lists@cmsws.com>:
> But whoever said the flow of the English language was all that efficient? I > actually prefer 'Yoda Speak'. Takes less to say more. > The flow of the English language was all that efficient, who ever said? 'Yoda speak' I actually prefer. Say more, takes less. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-*-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? |
|
|||
|
On Sat, 2008-06-28 at 21:19 +0300, Dotan Cohen wrote:
> 2008/6/28 Jim Lucas <lists@cmsws.com>: > > But whoever said the flow of the English language was all that efficient? I > > actually prefer 'Yoda Speak'. Takes less to say more. > > > > The flow of the English language was all that efficient, who ever > said? 'Yoda speak' I actually prefer. Say more, takes less. Don't forget the associated function of understanding... Yoda speak requires more thinking and you still understand less. Yoda speak is merely a veiled attempt to seem wise. Wisdom real requires such tricks not. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP |
|
|||
|
On Sat, Jun 28, 2008 at 1:33 PM, Jim Lucas <lists@cmsws.com> wrote:
> Robert Cummings wrote: >> >> On Sat, 2008-06-28 at 11:27 -0400, Andrew Ballard wrote: >>> >>> On Sat, Jun 28, 2008 at 9:44 AM, Colin Guthrie <gmane@colin.guthr.ie> >>> wrote: >>>> >>>> Robert Cummings wrote: >>>>> >>>>> I will never do it... it looks ugly, >>>> >>>> Only if you're not used to it. IMO this is how it should be taught in >>>> all >>>> the books and guides etc. If that was the case, the other way round >>>> would be >>>> ugly :) >>>> >>>>> especially when performing multiple >>>>> if comparisons on the variable. >>>> >>>> Perhaps, but it's still not as ugly as a hideous error gone undetected >>>> which >>>> accidentally deletes all your customers' data. >>> >>> ---snip--- >>> >>> >>> I don't know about "ugly," but I agree it "feels" wrong. I feel like >>> I'm using Yoda-speak when reading code like that: >>> >>> If 'yes' is you_can_read_this, 'Stop standing on me' I say. >>> >>> or >>> >>> If 0 is my_pulse then 'dead you are' should say you. >> >> *lol* Exactly... just doesn't sit right. >> >> It's a good way to make sure you're not screwing up, but testing should >> take care of that too. >> >> Cheers, >> Rob. > > But whoever said the flow of the English language was all that efficient? I > actually prefer 'Yoda Speak'. Takes less to say more. > Say anything about efficiency never did I. :-) I was merely commenting on a personal preference based largely on my perspective as a native speaker of (US) English. Now - if I WERE to address efficiency, I don't find "Yoda speak" to be any more efficient. It's usually the same words just in a different order. What's more that order, while quite natural for some languages, is not natural to me at all. As Bob mentioned, it requires a little extra thought for my brain to push certain phrases onto the mental stack before I can pop them off in an order that "makes sense." In programming terms, any code that requires the same amount of statements but requires more cycles to process is not what I would consider more efficient. As far as the programming practice that Colin was advocating, it is not a bad habit. And as far as the computer is concerned, the efficiency is a wash since the number of internal steps probably doesn't change much. However, it doesn't always work. (I know - no one claimed it did.) <?php if ($challenge_password_hash = $stored_password_hash) { echo 'Welcome to the club!'; } else { echo 'Stay out! This club is for members only!'; } ?> Andrew |
|
|||
|
Dotan Cohen wrote:
>> As far as the programming practice that Colin was advocating, it is >> not a bad habit. And as far as the computer is concerned, the >> efficiency is a wash since the number of internal steps probably >> doesn't change much. However, it doesn't always work. (I know - no one >> claimed it did.) >> >> <?php >> if ($challenge_password_hash = $stored_password_hash) { >> echo 'Welcome to the club!'; >> } else { >> echo 'Stay out! This club is for members only!'; >> } >> ?> >> >> Andrew >> > > In these instances you could rely on != behaviour instead of == > behaviour, like this: > > <?php > if ($challenge_password_hash != $stored_password_hash) { > echo 'Stay out! This club is for members only!'; > } else { > echo 'Welcome to the club!'; > } > ?> > > or, better yet: > > <?php > if ($challenge_password_hash != $stored_password_hash) { > echo 'Stay out! This club is for members only!'; > exit; > } > echo 'Welcome to the club!'; > // Lots of code here that just saved itself another indent in my IDE > ?> Indeed. The technique obviously only works for constants, and it wont help with variable -> variable comparisons (unless you do something really stupid like put the first expression in quotes!). Using != when possible is a good idea but I guess you have to draw the line as to moving your preferred "flow" of logic around to fit in with a technique for reducing the possibility of logical errors. Even your example above hints at another "political" minefield - Early Return or Multiple Return Points.... (s/Return/Exit/ in this case) Let's not even go there!!! Col |
|
|||
|
tedd wrote:
> Hi gang: > > For a break in our normal serious thinking, I suggested tombstone wit of: > > "Always on the edge of greatness" > > Dan offered: > > </cruelWorld> or </Dan> or > > <?php > function dan($dateOfDeath) { > return "Daniel P. Brown: 01-01-1970 - ".$dateOfDeath"; > } > die(dan('00-00-0000')); > ?> > > What would you like on your Tombstone? (<-- that's actually a > trademarked saying) > > Cheers, > > tedd Fatal error: Call to undefined function shawn() in /home/shawn/life.php on line 1 :-( |
|
|||
|
On Mon, Jun 30, 2008 at 1:31 PM, Shawn McKenzie <nospam@mckenzies.net> wrote:
> > Fatal error: Call to undefined function shawn() in /home/shawn/life.php on > line 1 I like it. ;-P -- </Daniel P. Brown> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. |
|
|||
|
2008/7/2 Daniel Brown <parasane@gmail.com>:
>> Fatal error: Call to undefined function shawn() in /home/shawn/life.php on >> line 1 > > I like it. ;-P > I think that a 500 internal service error would be more appropriate at that stage... Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-*-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? |