lkml.org 
[lkml]   [2003]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] coding style addendum
Richard B. Johnson wrote:
> On Mon, 10 Mar 2003, Luben Tuikov wrote:
>
>
>>Someone may find this helpful and descriptive of how kernel code
>>should be developed.
>
> [SNIPPED...]
>
>
>>+ Make sure every module/subroutine hides something.
>
>
> This is not correct. Well known example:
>
> #include <math.h>
>
> double hypot(double x, double y) {
> return sqrt((x * x) + (y * y));
> }
>
> This subroutine hides nothing. It receives input parameters

It does hide something. It hides *the implementation* of
the function hypot().

In effect, elsewhere in your code you could have the explicit
... = sqrt((x * x) + (y * y));
or,
... = hypot(x, y);

It's just eliminating (code) redundancy and duplication.

I.e. this addendum was meant on a more abstract/logical ground, thus the
name of the chapter.

[cut]
> locally stored and therefore not hidden. Your rule would require
> the replication of three floating-point variables NotGood(tm).

This isn't really my rule. I didn't invent or came up with anything
new here.

Documentation/CodingStyle is remarkably similar to most of what
you'd find in [1], and those rules are more or less from that
same book.

Actually, the whole point of my posting the patch is the last rule,
since well thought out data representation makes or breaks the code.

References:
[1] ``The Elements of Programming Style'' by Kernighan
and Plauger, 2nd ed, 1988, McGraw-Hill.

--
Luben


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:33    [from the cache]
©2003-2011 Jasper Spaans