Re: Code Comprehension
- From: Logan Shaw <lshaw-usenet@xxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 14:32:56 GMT
Rob Thorpe wrote:
It's a type that works, through coercion. But it does not show the
reader what the code means clearly.
Whenever I deal with characters I always write foo[n] = '\0'; it's
three more character to type sure. But it's also documentation of what
I'm doing with the variable foo, it shows that it's a string/char
operation.
Yeah, I agree that it makes things explicit, and I don't mind typing
the extra 3 characters. But I guess to me it boils down to a judgment
call. Does the context already make it clear enough? If so, then
I might go with a bare 0 just because it is less cluttered. To me,
clutter makes things harder to read, so being explicit about things
has to be balanced against that.
Also, I don't think it's necessarily bad to use type coercion. For
instance, is this code unclear?
float f = 0.0;
The 0.0 is of type double and is coerced to a float, but I don't
have any problem at all reading that and understanding what it would
do, even though this would be more explicit:
float f = 0.0F;
- Logan
.
- References:
- Code Comprehension
- From: jj
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Rob Thorpe
- Code Comprehension
- Prev by Date: Re: how to stay updated of latest technologies
- Next by Date: Re: break/continue in loops
- Previous by thread: Re: Code Comprehension
- Next by thread: Re: Code Comprehension
- Index(es):
Relevant Pages
|