[chbot] !!!!!!!! Choc fish challenge 2 !!!!!!!!!
hamster
hamster at snap.net.nz
Thu Aug 4 02:14:27 BST 2011
Best summed up in Book 5 of the Tao of Programming
(http://www.canonical.org/~kragen/tao-of-programming.html)
Thus spake the master programmer:
``A well-written program is its own heaven; a poorly-written program is
its own hell.''
And:
Thus spake the master programmer:
``Though a program be but three lines long, someday it will have to be
maintained.''
On Thu, 4 Aug 2011 11:01:35 +1200, Richard Jones <rjtp at ihug.co.nz> wrote:
> On Thu, Aug 4, 2011 at 9:43 AM, Charles Manning
> <manningc2 at actrix.gen.nz>wrote:
>
>> On Thursday 04 August 2011 08:53:48 Andre Renaud wrote:
>> > On 03/08/11 22:13, Volker Kuhlmann wrote:
>> > > On Wed 03 Aug 2011 11:40:03 NZST +1200, Charles Manning wrote:
>> > >> In my books there is also a very hot place reserved for those who
>> write
>> > >> things like
>> > >> while((*x++ = *y++)){}
>> > >
>> > > You can't really compare this with previous examples. This one is
>> > > much
>> > > different because it is undefined, unpredictable and therefore
>> > > useless
>> > > and much worse. Your choc fish challenge was defined in its
behaviour
>> > > and predictable, although extremely bad programming and a
convoluted
>> way
>> > > to say while(1); .
>> >
>> > I don't think this is undefined - isn't this a simple implementation
of
>> > strcpy (assuming x & y are char *)? It will continue around until it
>> > assigns a 0 pointer, at which point it will stop. It would be
undefined
>> > if you had *x++ = *x++.
>> >
>>
>> Exactly my reason why this is a bad code.
>>
>> The algorithm is hidden and non obvious.
>>
>> I'd far rather someone wrote:
>>
>> while((*x = *y)) {
>> x++;
>> y++;
>> }
>>
>> I agree.
>
> Expert coders can produce functional write only code, professionals
> including the open source community should produce maintainable code.
>
> Use the source code show the intent. Let the compiler do the
optimisation.
>
> If this was off topic, it certainly generated plenty of interest!
>
> Richard
More information about the Chchrobotics
mailing list