Re: Should function argument be changed in function body?



"CBFalconer" <cbfalconer@xxxxxxxxx> wrote in message
news:42E10005.2603CDB8@xxxxxxxxxxxx
> Tim Rentsch wrote:
>> CBFalconer <cbfalconer@xxxxxxxxx> writes:
>>> Tim Rentsch wrote:
>>>>
> ... snip ...
>>>>
>>>> 1. Is the function body small (under 10 lines, say)?
>>>> 2. Is the code simple, and clearly and obviously correct?
>>>> 3. Is the code highly unlikely to have to change in the
>>>> foreseeable future?
>>>>
>>>> If the answers to any of the questions is NO, then it's almost
>>>> certainly better to follow the guideline and not modify any of
>>>> the parameter variables.
>>>
>>> And I would say a better guide is to make the answers be YES.
>>
>> Do you mean to say that every function body that you write is
>> under 10 lines, simple and clearly/obviously correct (including
>> to other readers), and highly unlikely to have to change in the
>> foreseeable future?
>
> I don't always succeed, but yes, those are objectives. :-) You
> will have to judge the "including to others" portion yourself.
> Feel free to root around in:
>
> <http://cbfalconer.home.att.net/download/>

uncmntc.zip - (picked at random)
>>>> 1. Is the function body small (under 10 lines, say)?
All with the exception of main.

>>>> 2. Is the code simple, and clearly and obviously correct?
Simple? Definitely. Clearly and obviously correct? No.
It was actually pretty obvious that it would not work properly :-)

As for style... PICK ONE!
I can understand why one puts the constant first in if statements
(in case you accidentally put = in place of == blah blah blah...
must be too hard to just look at the damn code when you type it!)
but you go 'both ways' on back to back lines! (74/75)

>>>> 3. Is the code highly unlikely to have to change in the
>>>> foreseeable future?
That depends on whether or not you choose to fix your bugs...
What would your utility do if it encountered a line such as:
printf("What\\" /* embedded string */ "%s joke!\n", /* doh */ "a
/*#(K1N5");

Oh, it will strip something alright, but probably not what you'd expect ;)

Regards,
Mark



.



Relevant Pages

  • Re: Mage Tanks, onoes!
    ... <SNIP> ... > Great guide. ... Hate to hear about what happened, there is a HUGE difference between solo ... but dont discount us as glorified healbots ...
    (alt.games.warcraft)
  • Re: MP arrested. Police interfere in politics
    ... Service guidelines on what to do if you found something you were not ... happy with - an internal whistleblower's guide? ... Any chance that it was because he wasn't really public spirited and ...
    (uk.legal)
  • Re: MP arrested. Police interfere in politics
    ... Service guidelines on what to do if you found something you were not ... happy with - an internal whistleblower's guide? ... Any chance that it was because he wasn't really public spirited and ...
    (uk.legal)
  • Re: MP arrested. Police interfere in politics
    ... Service guidelines on what to do if you found something you were not ... happy with - an internal whistleblower's guide? ... Any chance that it was because he wasn't really public spirited and ...
    (uk.legal)
  • Re: invalid single quote
    ... Tim Rentsch writes: ... Obviously Tim was looking for a portable solution. ... >> Interested readers may enjoy seeing if they can find a ...
    (comp.lang.c)