Re: Should function argument be changed in function body?
- From: "Mark" <sober@xxxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 18:14:35 GMT
"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
.
- Follow-Ups:
- Re: Should function argument be changed in function body?
- From: CBFalconer
- Re: Should function argument be changed in function body?
- References:
- Should function argument be changed in function body?
- From: Morgan Cheng
- Re: Should function argument be changed in function body?
- From: CBFalconer
- Re: Should function argument be changed in function body?
- From: Tim Rentsch
- Re: Should function argument be changed in function body?
- From: CBFalconer
- Re: Should function argument be changed in function body?
- From: Tim Rentsch
- Re: Should function argument be changed in function body?
- From: CBFalconer
- Should function argument be changed in function body?
- Prev by Date: Re: why is it so ?
- Next by Date: Re: why is it so ?
- Previous by thread: Re: Should function argument be changed in function body?
- Next by thread: Re: Should function argument be changed in function body?
- Index(es):
Relevant Pages
|