← Back to team overview

kicad-developers team mailing list archive

Re: Bugfix for plotting

 

Manveru wrote:

<< snipped >>

> But, you should always avoid the following:
> int *ptr, val;
> as it always leads to misunderstandings. Most coding standard mention
> about this.
> 
> The way how pointers are marked in C is somewhat confusing, in other
> hand the same operator marks pointer declaration and pointer dereference
> - that seemed logical to language authors.
> 
> I saw advice to declare only one variable at a time in many places, so
> programmer should avoid constructs like:
> int a,b,c;
> But lot of people argues that such style creates lot of source code
> lines and takes too much time to type.
> 
> I am curious what Dick is thinking about it.

I can't speak for Dick, but I can say from experience that declaring C
variables this way can hide complexity. It tends to mask the total
number of variables that are being used in any given function or method.
Putting variables in line with the code also suffers from the same
problem. I make it a point to declare variables at the beginning of my
functions. Remember, the human brain (even highly developed ones) can
safely handle 7-10 pieces of information before becoming confused.
There have been plenty of studies that validate this. I try to use this
as a warning that my code is becoming too complex and try to figure out
ways to simplify things. This tends to make debugging easier. But more
importantly, I may have to revisit my code six months from now and try
to remember what it was that I was attempting to do. It is even more
important when coding for a project where many other developers are
trying to figure how your code works.

Wayne

> 
> --
> M.
> 
> 
>


 




References