Comment On Truth Is How You Define It

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks. One day, while debugging some of his colleague's code, Miguel noticed that most of the conditional expressions were inelegantly formed with redundant Booleans, abuse of operators, and so on. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Truth Is How You Define It

2005-11-07 14:29 • by ferrengi
FIRST!

Re: Truth Is How You Define It

2005-11-07 14:32 • by whojoedaddy
49779 in reply to 49778
ferrengi:
FIRST!




It's funny, these normally get spam filtered, yet people still do it.



Anyways, about the wtf, maybe the guy was a philosophy major?

Re: Truth Is How You Define It

2005-11-07 14:32 • by Just another WTF
49780 in reply to 49778

ferrengi:
FIRST!


Wow... is that the first first that is actually first?

Re: Truth Is How You Define It

2005-11-07 14:34 • by ferrengi
Alex Papadimoulis:

Miguel Arguelles' company
recently hired a fresh graduate with a fairly good resume and high
academic marks. One day, while debugging some of his colleague's code,
Miguel noticed that most of the conditional expressions were
inelegantly formed with redundant Booleans, abuse of operators, and so
on.


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);


Naturally, he decided to talk to the new guy about it, explaining
that the above code could be simplified with an OR, an AND, and no
confusing $canProcess variable. His workmate shook his head, replying
with "Yes, that may be so, but you don't want to build your logic based
on the way PHP implements those."

Miguel is not so easily discouraged. "It's not just PHP. It's
for everything," he pressed on despite receiving a blank stare,
"Boolean logic? You know, the way to find truth."

He gave up when Rene Descartes Jr. replied, "Truth is how you define it."





If "Truth is how you define it", how can the programmer rely on setting
$canProcess to true or false? Maybe the definition will change and what
was once true will not be true in the future and this code will be
broken!

Re: Truth Is How You Define It

2005-11-07 14:35 • by imbusy
Boolean logic might adopt something new one day, like "FileNotFound".
You don't want to base it on todays logic, do you? Make way for the new
technologies!

Re: Truth Is How You Define It

2005-11-07 14:37 • by RevMike
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.



Please tell us what his major was!  I'd really like to restart the "CS degree is (invaluable|worthless)" flamewar from the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.

Re: Truth Is How You Define It

2005-11-07 14:40 • by sniederb
There's definitely room for improvement here. However, with respect to
another post on this site regarding good commenting, sometimes code
which isn't technically straightforward still makes sense if it
directly reflects business logic.

It might just be that with the presented code, even a business analyst
could do a code review and find an error. With the entire boolean logic
compressed as far as possible, the business analyst might fail to
understand the code.

As computer gets better and better, I tend to write more and more code
which isn't most compact technology-wise, but which very much reflects
a work flow or decision tree. This makes it much more readable and only
little slower.



Rene Descartes Jr on the other hand might need to work a bit on his understanding of truth.





Re: Truth Is How You Define It

2005-11-07 14:41 • by limelight
Alex Papadimoulis:

if ($canProcess)
{
  if ($avaiableCredit >= $ticketAmount)
    $canProcess = true;
  else
    ...
}


I love this part. We already know that $canProcess is true, but lets waste a clock cycle by setting it again.

Re: Truth Is How You Define It

2005-11-07 14:43 • by Free
49787 in reply to 49783

I would hope that any university graduate would understand that AND and/or OR are logical things and that they are implemented the same, or at least functionly the same, on Windows and Unix or Linux.


And that AND and OR are concepts older than the interweb and computers or even IBM.


 


 


 

Re: Truth Is How You Define It

2005-11-07 14:43 • by Disgruntled DBA
Does this mean we have to start programming things for every user's
individual definitions of "true", "false", and "fileNotFound"?

Re: Truth Is How You Define It

2005-11-07 14:44 • by boohiss
49789 in reply to 49783
There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


Come again? You are saying there is zero correlation? So a group of 50 year old truck drivers is just as likely to program as effectively as a group of 25 year old CS majors?

Re: Truth Is How You Define It

2005-11-07 14:44 • by Anonymoose
49790 in reply to 49781
ferrengi:
Alex Papadimoulis:

Miguel Arguelles' company
recently hired a fresh graduate with a fairly good resume and high
academic marks. One day, while debugging some of his colleague's code,
Miguel noticed that most of the conditional expressions were
inelegantly formed with redundant Booleans, abuse of operators, and so
on.


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);


Naturally, he decided to talk to the new guy about it, explaining
that the above code could be simplified with an OR, an AND, and no
confusing $canProcess variable. His workmate shook his head, replying
with "Yes, that may be so, but you don't want to build your logic based
on the way PHP implements those."

Miguel is not so easily discouraged. "It's not just PHP. It's
for everything," he pressed on despite receiving a blank stare,
"Boolean logic? You know, the way to find truth."

He gave up when Rene Descartes Jr. replied, "Truth is how you define it."





If "Truth is how you define it", how can the programmer rely on setting
$canProcess to true or false? Maybe the definition will change and what
was once true will not be true in the future and this code will be
broken!




Clearly, the programmer does not depend on setting $canProcess to true or false... it is uninitialized!

I suppose the programmer's code may be 'inelegant', but saying that
$canProcess is confusing?  What else could it possibly mean?



New addition to Rogthefrog's database of typical responses,



INSERT TypicalResponses VALUES("All hail the ternary operator, which would make that code easier to read!");

INSERT TypicalResponses VALUES("The Ternary operator, contrary to it's
intent, actually makes the code more difficult to read!");







Re: Truth Is How You Define It

2005-11-07 14:46 • by sammybaby

He gave up when Rene Descartes Jr. replied, "Truth is how you define it."


Man, that is just way too deep for a Monday.


Now I need some pi.


[pi]

Re: Truth Is How You Define It

2005-11-07 14:47 • by RevMike
49792 in reply to 49786
limelight:
Alex Papadimoulis:

if ($canProcess)
{
  if ($avaiableCredit >= $ticketAmount)
    $canProcess = true;
  else
    ...
}


I love this part. We already know that $canProcess is true, but lets waste a clock cycle by setting it again.


I actually have two amusing (to me) comments:

1) Maybe he though that boolean values are like bits in a dram, they need to be rewritten ocassionally.

2) Maybe he was concerned that another thread might alter $canProcess while he was in the middle of this call.

Re: Truth Is How You Define It

2005-11-07 14:47 • by kipthegreat
Alex Papadimoulis:


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);







if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)

  ProcessTransaction($ticketId);

else

  RejectTransaction($ticketId);






Now do I get the big bucks for tripling productivity?

Re: Truth Is How You Define It

2005-11-07 14:48 • by l
Well, PHP has it's way of DWIM-ing whatever you do into the Wrong Thing, so I can half understand the guy.

Re: Truth Is How You Define It

2005-11-07 14:50 • by kipthegreat
Alex Papadimoulis:

Naturally, he decided to talk to the
new guy about it, explaining that the above code could be simplified
with an OR, an AND, and no confusing $canProcess variable. His workmate
shook his head, replying with "Yes, that may be so, but you don't want
to build your logic based on the way PHP implements those."





Maybe he was a VB programmer, and didn't know that pretty much every
other language out there short-circuits their boolean operators?? 
..maybe??

Re: Truth Is How You Define It

2005-11-07 14:53 • by limelight
49797 in reply to 49792
RevMike:
limelight:
Alex Papadimoulis:

if ($canProcess)
{
  if ($avaiableCredit >= $ticketAmount)
    $canProcess = true;
  else
    ...
}


I love this part. We already know that $canProcess is true, but lets waste a clock cycle by setting it again.



I actually have two amusing (to me) comments:

1) Maybe he though that boolean values are like bits in a dram, they need to be rewritten ocassionally.

2) Maybe he was concerned that another thread might alter $canProcess while he was in the middle of this call.


1) Definitely amusing


2) Scary

Re: Truth Is How You Define It

2005-11-07 14:56 • by Anonymoose
49798 in reply to 49793
kipthegreat:
Alex Papadimoulis:


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);







if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)

  ProcessTransaction($ticketId);

else

  RejectTransaction($ticketId);






Now do I get the big bucks for tripling productivity?




What are you talking about?  You have just caused the number of
CPU instructions per line to go way up (and doing away with a few
redundant operations, as well), meaning a decrease in the number of source lines processed per second!



Sincerely,






Re: Truth Is How You Define It

2005-11-07 15:00 • by ZeoS
49799 in reply to 49793
kipthegreat:
Alex Papadimoulis:


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);







if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)

  ProcessTransaction($ticketId);

else

  RejectTransaction($ticketId);






Now do I get the big bucks for tripling productivity?




You should've used the thernary operator :D

(($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)?ProcessTransaction($ticketId):RejectTransaction($ticketId);







BTW: he has forgotten to check if
ticketAmount is null.

Re: Truth Is How You Define It

2005-11-07 15:00 • by mjan
49800 in reply to 49789
Anonymous:
Come again? You are saying there is zero correlation? So a group of 50 year old truck drivers is just as likely to program as effectively as a group of 25 year old CS majors?


Well, given that a group of 50 year old truck drivers will probably not be convinced that they know everything right off the bat like your average CS grad, yes.

Re: Truth Is How You Define It

2005-11-07 15:01 • by ferrengi
49801 in reply to 49792
RevMike:
limelight:
Alex Papadimoulis:

if ($canProcess)
{
  if ($avaiableCredit >= $ticketAmount)
    $canProcess = true;
  else
    ...
}


I love this part. We already know that $canProcess is true, but lets waste a clock cycle by setting it again.


I actually have two amusing (to me) comments:

1) Maybe he though that boolean values are like bits in a dram, they need to be rewritten ocassionally.

2) Maybe he was concerned that another thread might alter $canProcess while he was in the middle of this call.




My theory is that he needed to check this condition and set $canProcess
= false in the else portion. At that point he felt that he had to put something in the if portion of the statement so he chose to set $canProcess = true again.

Of course he could've just done

if ($availableCredit < $ticketAmount)

    $canProcess = false;



But since he is quite confused as it is and really not comfortable with
these boolean operators, he either did not know how to do this or was
worried that the truth might change on him.



- Dan

Re: Truth Is How You Define It

2005-11-07 15:03 • by RevMike
49802 in reply to 49789
Anonymous:
There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


Come again? You are saying there is zero correlation? So a group of 50 year old truck drivers is just as likely to program as effectively as a group of 25 year old CS majors?


I'm not saying that at all, and if you think so maybe you should read a little more carefully.  You imply that I said that a group of truck drivers would correlate just just as closely as CS graduate in the skill of programming effectively.  I said no such thing.

I'll defend my statement by working backward form the result.  Think of the programmers you've worked with who you would judge effective.  How many have CS degrees?  How many have other related degrees such as IS, MIS, SE, etc?  How many have math, science, or engineering degrees not directly related to computing?  How many have Arts or Humanities degrees? (I've found lots of music degrees)  How many have vocational certificates?  How many managed to get their first job then make their way on experience?

You may be the exception, but I have found from my experience and talking to many peers that the CS people are actually in the minority and that maybe only 50% of the good people have any sort of computing degree.  If CS (and related computing) degrees were really an indicator of programmer skill, wouldn't that ratio be much higher?

Programming is a skill that is more likely to be learned from self-directed education and experience than any other route.

Re: Truth Is How You Define It

2005-11-07 15:03 • by christoofar
49803 in reply to 49789
Anonymous:
There is no correlation, positive or
negative, between having a CS degree and being able to program
effectively.

Come again? You are saying there is zero correlation? So a group
of 50 year old truck drivers is just as likely to program as
effectively as a group of 25 year old CS majors?




I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.



She knew Boolean logic [AND] lap dances!

Re: Truth Is How You Define It

2005-11-07 15:04 • by dabocla
This hurts my eyes.  *2 minute rant and rave*

Ah - that felt good.

Re: Truth Is How You Define It

2005-11-07 15:05 • by JohnO
49805 in reply to 49783
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really like to restart the "CS degree is (invaluable|worthless)" flamewar from the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I thought that was the guys from Purdue are stupid flamewar.

Re: Truth Is How You Define It

2005-11-07 15:10 • by JohnO
49806 in reply to 49803

christoofar:
Anonymous:
There is no correlation, positive or negative, between having a CS degree and being able to program effectively.
Come again? You are saying there is zero correlation? So a group of 50 year old truck drivers is just as likely to program as effectively as a group of 25 year old CS majors?


I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.

She knew Boolean logic [AND] lap dances!


Are you sure that her lapdancing skills didn't bias your evaluation of her Boolen logic skills?

Re: Truth Is How You Define It

2005-11-07 15:10 • by RevMike
49807 in reply to 49803
christoofar:


I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.



She knew Boolean logic [AND] lap dances!


I would guess that talented bookkeeper or accountant  would have a decent chance at being able to program.  They already have some understanding about how to build a process that transforms information by some set of rules, aka an alogrithm.  So the key is to teach them our methods of expressing that process.

I'm not saying it would be a trivial transition, but I'd bet it is very doable.

Re: Truth Is How You Define It

2005-11-07 15:11 • by giannis
I wonder if Miguel Arguelles had shown Rene Descartes Jr. the right implementation, which is:
if ($ticketAmount < 1000 && 
$avaiableCredit >= $ticketAmount &&
$hasOverride)
ProcessTransaction($ticketId);
else
RejectTransaction($ticketId);




Then what would his answer be?

Re: Truth Is How You Define It

2005-11-07 15:15 • by Jeff S
49809 in reply to 49805

Perhaps, he meant he didn't want to know the PHP spec on operator precedence -- you know, which is evaluated first, the AND or the OR.  Some languages do it different than others, I believe -- I don't know that there is  universal rule like * comes before +. 


All of us expert programmers here at TDWTF know, of course, that you use parens to explicitly indicate this whenever you combine AND and OR's in a boolean expression, and thus you never have an issue .... 


... so, maybe he was aware of the operator precedence issue, didn't know the spec for PHP, and he didn't know how to use parens to work around it?


(grasping at straws as to what the heck he might have been thinking)

Re: Truth Is How You Define It

2005-11-07 15:16 • by A Wizard A True Star
49810 in reply to 49806
JohnO:

Are you sure that her lapdancing skills didn't bias your evaluation of her Boolen logic skills?



The boolean is randomly set to true or false, so there can be no bias.


 

Re: Truth Is How You Define It

2005-11-07 15:17 • by JohnO
49811 in reply to 49783
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really like to restart the "CS degree is (invaluable|worthless)" flamewar from the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I disagree.  If you had two people with 0 coding experience (aside from their degree-related work), one with a C.S. degree the other w/o, all other things being equal, I'll take the C.S. grad every time.

Re: Truth Is How You Define It

2005-11-07 15:18 • by mrsticks1982
49812 in reply to 49793
kipthegreat:
Alex Papadimoulis:


if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
{
if ($avaiableCredit >= $ticketAmount)
$canProcess = true;
else
$canProcess = false;
}
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);







if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)

  ProcessTransaction($ticketId);

else

  RejectTransaction($ticketId);






Now do I get the big bucks for tripling productivity?




No, because you reduce the lines of code,



more lines means you make more money

Re: Truth Is How You Define It

2005-11-07 15:18 • by Xepol
49813 in reply to 49803

christoofar:

I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.

She knew Boolean logic [AND] lap dances!


That could be a very handy mix of skills when it comes time for a tax audit, but I suspect that your refund would all be in singles.


Seriously, however, this looks the work of a true beginner.  He has thought his way through the logic, and seems to have it all mapped out so it works.  He does not, however, seem to have a grasp on the finesse we have all developed over the years.  The only WTF I can see is why this is here?  Deriding an beginner's CORRECT, albeit in-efficent, logic is a little tacky to say the least.


Everyone has to start somewhere, and let's face it.  The code works, it just doesn't work elegantly.  I doubt anyone here can claim that their last project had the polish of their current project, and I would lay serious money that everyone's first projects would be an embaressment to them now.


Skills and polish develop over time from a solid foundation.  This guy obviously has a solid basis for his logic, so wtf are we trying to hold him up to ridicule?  Just because he hasn't developed polish yet?


Sad.  Everyone go back and look at your first few projects and then rethink running down this code.

Re: Truth Is How You Define It

2005-11-07 15:19 • by DrJames
49814 in reply to 49793

kipthegreat:


if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)
  ProcessTransaction($ticketId);
else
  RejectTransaction($ticketId);



Now do I get the big bucks for tripling productivity?


If by productivity you mean performance, I'd put the hasOverride check first as it most likely is a cached variable and would save you the ticks of calculating the validation checks

Re: Truth Is How You Define It

2005-11-07 15:19 • by JohnO
49815 in reply to 49810
A Wizard A True Star:
JohnO:

Are you sure that her lapdancing skills didn't bias your evaluation of her Boolen logic skills?



The boolean is randomly set to true or false, so there can be no bias.



Either Christoofar is bisexual or I don't understand your reply.

Re: Truth Is How You Define It

2005-11-07 15:20 • by giannis
49816 in reply to 49808
Anonymous:
I wonder if Miguel Arguelles had shown Rene Descartes Jr. the right implementation, which is:
if ($ticketAmount < 1000 && 
$availableCredit >= $ticketAmount &&
$hasOverride)
ProcessTransaction($ticketId);
else
RejectTransaction($ticketId);




Then what would his answer be?




Something's wrong with the design editor, it messed up my pre code, and where's the preview button? and why that captcha doesn't work right? wtf did the developers of this forum were smoking when they wrote it?

Re: Truth Is How You Define It

2005-11-07 15:20 • by mrsticks1982
49817 in reply to 49811
JohnO:
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really
like to restart the "CS degree is (invaluable|worthless)" flamewar from
the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I disagree.  If you had two people with 0 coding experience
(aside from their degree-related work), one with a C.S. degree the
other w/o, all other things being equal, I'll take the C.S. grad every
time.





On paper the CS grad will have, or at least should, a better
understanding of what is required to make a program but give them two
weeks time and it may not matter.

Re: Truth Is How You Define It

2005-11-07 15:23 • by Swede
49818 in reply to 49808
Following up on the CS flame war... Did you know that up here in Sweden anyone who majors in Usability automatically can title themselves Usability Experts? Oh, dear...

Re: Truth Is How You Define It

2005-11-07 15:24 • by DrJames
49819 in reply to 49813
Xepol:

christoofar:

I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.

She knew Boolean logic [AND] lap dances!


That could be a very handy mix of skills when it comes time for a tax audit, but I suspect that your refund would all be in singles.


Seriously, however, this looks the work of a true beginner.  He has thought his way through the logic, and seems to have it all mapped out so it works.  He does not, however, seem to have a grasp on the finesse we have all developed over the years.  The only WTF I can see is why this is here?  Deriding an beginner's CORRECT, albeit in-efficent, logic is a little tacky to say the least.


Everyone has to start somewhere, and let's face it.  The code works, it just doesn't work elegantly.  I doubt anyone here can claim that their last project had the polish of their current project, and I would lay serious money that everyone's first projects would be an embaressment to them now.


Skills and polish develop over time from a solid foundation.  This guy obviously has a solid basis for his logic, so wtf are we trying to hold him up to ridicule?  Just because he hasn't developed polish yet?


Sad.  Everyone go back and look at your first few projects and then rethink running down this code.



 


I agree that we've all probably written some crappy code not understanding the fundamentals at some point, but I think the WTF here is not necessarily the code (as it could be a JR dev) but that when approached the dev did not listen to a more senior dev's suggestion.  He should have been more interested in what the senior dev had to say, maybe go home and read up on it a bit more and thereby increase his understanding and efficiency as a dev.  Just firing back with a stupid retort is a sign that this dev will never become a good dev.

Re: Truth Is How You Define It

2005-11-07 15:27 • by RevMike
49820 in reply to 49811
JohnO:
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really like to restart the "CS degree is (invaluable|worthless)" flamewar from the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I disagree.  If you had two people with 0 coding experience (aside from their degree-related work), one with a C.S. degree the other w/o, all other things being equal, I'll take the C.S. grad every time.



That is part of the problem - a CS grad with zero coding experience.  Back in the previous flamewar, someone mentioned working with a CS grad who couldn't program.  The non-coding CS grad explained that they did all their coding projects in teams, and he always elected to do the documentation.

Seriously, though.  Say you had a CS grad and an EE grad both coming in just out of school.  The CS grad did well in school.  The EE grad did well in his course of study and brings in a small portfolio of programming projects which he did over several years in his spare time, all of which seem to be of good quality.  Who do you pick?

Re: Truth Is How You Define It

2005-11-07 15:28 • by ZeoS
49821 in reply to 49814
DrJames:

kipthegreat:


if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)
  ProcessTransaction($ticketId);
else
  RejectTransaction($ticketId);



Now do I get the big bucks for tripling productivity?


If by productivity you mean performance, I'd put the hasOverride
check first as it most likely is a cached variable and would save you
the ticks of calculating the validation checks





I thought the same first, but what if 99% of the times hasOverride is false?

Re: Truth Is How You Define It

2005-11-07 15:30 • by RevMike
49822 in reply to 49814
DrJames:

kipthegreat:


if (($ticketAmount < 1000  &&  $availableCredit >= $ticketAmount)  ||  $hasOverride)
  ProcessTransaction($ticketId);
else
  RejectTransaction($ticketId);



Now do I get the big bucks for tripling productivity?


If by productivity you mean performance, I'd put the hasOverride check first as it most likely is a cached variable and would save you the ticks of calculating the validation checks



On the other hand, I'd assume that an override is a rare occurance.  Why evaluate it first in an OR expression when it will rarely be true.  Better to let it only be evaluated if the first part fails.

Re: Truth Is How You Define It

2005-11-07 15:31 • by Jeff S
49823 in reply to 49813
Xepol:

christoofar:

I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.

She knew Boolean logic [AND] lap dances!


That could be a very handy mix of skills when it comes time for a tax audit, but I suspect that your refund would all be in singles.


Seriously, however, this looks the work of a true beginner.  He has thought his way through the logic, and seems to have it all mapped out so it works.  He does not, however, seem to have a grasp on the finesse we have all developed over the years.  The only WTF I can see is why this is here?  Deriding an beginner's CORRECT, albeit in-efficent, logic is a little tacky to say the least.


Everyone has to start somewhere, and let's face it.  The code works, it just doesn't work elegantly.  I doubt anyone here can claim that their last project had the polish of their current project, and I would lay serious money that everyone's first projects would be an embaressment to them now.


Skills and polish develop over time from a solid foundation.  This guy obviously has a solid basis for his logic, so wtf are we trying to hold him up to ridicule?  Just because he hasn't developed polish yet?


Sad.  Everyone go back and look at your first few projects and then rethink running down this code.



I would agree.  A classic "WTF" is something so convoluted, so crazy, so twisted that a sane person can barely comprehend it.  Oh, and often you do literally say to yourself "WTF" ...


This might not be good code, but it's not a WTF.  I guess it's OK for a Monday.  There is a key difference between a "WTF!" and code that could simply be made shorter/optimized/tweaked.

Re: Truth Is How You Define It

2005-11-07 15:32 • by ferrengi
49824 in reply to 49813
Xepol:

christoofar:

I worked with an ex-stripper in Texas who could code very well, she only had a BBA and a lot of years as a bookkeeper.

She knew Boolean logic [AND] lap dances!


That could be a very handy mix of skills when it comes time for a
tax audit, but I suspect that your refund would all be in singles.


Seriously, however, this looks the work of a true beginner.  He
has thought his way through the logic, and seems to have it all mapped
out so it works.  He does not, however, seem to have a grasp on
the finesse we have all developed over the years.  The only WTF I
can see is why this is here?  Deriding an beginner's CORRECT,
albeit in-efficent, logic is a little tacky to say the least.


Everyone has to start somewhere, and let's face it.  The code
works, it just doesn't work elegantly.  I doubt anyone here can
claim that their last project had the polish of their current project,
and I would lay serious money that everyone's first projects would be
an embaressment to them now.


Skills and polish develop over time from a solid foundation. 
This guy obviously has a solid basis for his logic, so wtf are we
trying to hold him up to ridicule?  Just because he hasn't
developed polish yet?


Sad.  Everyone go back and look at your first few projects and then rethink running down this code.





To me, the funniest thing is not the code but the conversation the Miguel had with the programmer after he debugged the code.

The programmer's response shows a complete lack of understanding of
what boolean operators are and how to use them. Even worse, he has not
learned from his mistake and will probably write some code that does
not work correctly before he figures this stuff out.

A programmer's first few projects don't have to be elegant and my
almost certainly were not. But you'd think that someone with a CS
degree would have some understanding of boolean operators and how to
use them. Either that or the programmer is outsmarting himself by not
wanting to build his program "based on the way PHP implements those"
[boolean operators].



Either way, it is a pretty funny WTF.



- Dan

Re: Truth Is How You Define It

2005-11-07 15:32 • by emurphy
Ow.  This approach is valid if you have some procedural foo in the
middle that isn't amenable to being part of a compound if(), but that
clearly isn't the case here.



I'm amazed we haven't had any IsTrue() cracks yet.



Re: Truth Is How You Define It

2005-11-07 15:33 • by ZeoS
49826 in reply to 49820
RevMike:
JohnO:
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really
like to restart the "CS degree is (invaluable|worthless)" flamewar from
the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I disagree.  If you had two people with 0 coding experience
(aside from their degree-related work), one with a C.S. degree the
other w/o, all other things being equal, I'll take the C.S. grad every
time.



That is part of the problem - a CS grad with
zero coding experience.  Back in the previous flamewar, someone
mentioned working with a CS grad who couldn't program.  The
non-coding CS grad explained that they did all their coding projects in
teams, and he always elected to do the documentation.

Seriously,
though.  Say you had a CS grad and an EE grad both coming in just
out of school.  The CS grad did well in school.  The EE grad
did well in his course of study and brings in a small portfolio of
programming projects which he did over several years in his spare time,
all of which seem to be of good quality.  Who do you pick?




Just take a 30 minutes exam as a part of the interview!

Re: Truth Is How You Define It

2005-11-07 15:35 • by BK
Need to be fair.. in Smalltalk you can define true to equal "false"
(0). Of course.. it is likely for the image to crater before you get
too far.





Re: Truth Is How You Define It

2005-11-07 15:38 • by Brent Seidel
One thing that hasn't been mentioned yet (I think) is that $canProcess is uninitialised of $ticketAmount >= 1000.

It could be true, false, or fileNotFound.

Re: Truth Is How You Define It

2005-11-07 15:39 • by JohnO
49829 in reply to 49820
RevMike:
JohnO:
RevMike:
Alex Papadimoulis:

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks.




Please tell us what his major was!  I'd really like to restart the "CS degree is (invaluable|worthless)" flamewar from the "guy who doesn't know hex" topic!

Even if he wasn't a CS major, I'll start off the war anyway...

There is no correlation, positive or negative, between having a CS degree and being able to program effectively.


I disagree.  If you had two people with 0 coding experience (aside from their degree-related work), one with a C.S. degree the other w/o, all other things being equal, I'll take the C.S. grad every time.




That is part of the problem - a CS grad with zero coding experience.  Back in the previous flamewar, someone mentioned working with a CS grad who couldn't program.  The non-coding CS grad explained that they did all their coding projects in teams, and he always elected to do the documentation.

Seriously, though.  Say you had a CS grad and an EE grad both coming in just out of school.  The CS grad did well in school.  The EE grad did well in his course of study and brings in a small portfolio of programming projects which he did over several years in his spare time, all of which seem to be of good quality.  Who do you pick?


I would pick the EE grad in that scenario but all that says is experience trumps education, especially when coupled with a rigorous degree such as EE.  Don't get me wrong, I have nothing against non-C.S. grads.  I started out as one.  But a good grad from a good C.S. program actually will have learned something valuable while they were there.

« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment