Re: Had an interview
- From: Andrey Tarasevich <andreytarasevich@xxxxxxxxxxx>
- Date: Fri, 02 May 2008 11:23:13 -0700
andrew.nesterov@xxxxxxxxxxxx wrote:
...
Once I've read a following joke in a programming errs and traps book:
Implement a block that inputs either 1 or 2 and outputs the opposite:
1 -> 2, 2 -> 1
The author continue with three hypotetical solutions:
1. A programming class instructor:
if ( x == 1) x = 2;
if ( x == 2) x = 1;
I don't know why you call it "solution", since it's obviously incorrect.
2. A programmer:
if ( x == 1) x = 2;
else if ( x == 2) x = 1;
That would be a beginner/inexperienced programmer.
A "programmer" would most likely opt for the '?:' operator in this case.
3. A mathematitian:
x = 3 - x;
In reality that would the solution for a _good_ programmer.
--
Best regards,
Andrey Tarasevich
.
- Follow-Ups:
- Re: Had an interview
- From: CBFalconer
- Re: Had an interview
- From: Spehro Pefhany
- Re: Had an interview
- From: Lanarcam
- Re: Had an interview
- Prev by Date: Re: ADC/DAC combination with serial interface
- Next by Date: Re: Microcontroller USB interface chip
- Previous by thread: Re: Had an interview
- Next by thread: Re: Had an interview
- Index(es):
Relevant Pages
|