Afficher un message
Vieux 13/04/2008, 17h35   #11
Richard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to be a better C programmer?

CBFalconer <cbfalconer@yahoo.com> writes:

> John Bode wrote:
>>

> ... snip ...
>>
>> Ultimately, practice is the only way to significantly improve your
>> skills. It's good to look at what other people have done to get a
>> feel for good style and practice, but until you've pounded out
>> thousands of lines of code for yourself, you may not understand
>> *why* the code was written that way. You have to make mistakes,
>> and go through the effort of fixing those mistakes, to appreciate
>> the lessons that other people's code provides.

>
> One of the advantages of having been at this for a while is that
> you learn what your common mistakes are, and can arrange to
> orgamize the code to automatically detect them. A couple of simple
> tricks are:
>
> 1. Make similary functions have similar parameter lists.


Whatever that means. I think it needs explaining.

> 2. Organize statements so that error will show up.
>
> As an example of 2 consider "if (2 = x) ...". Placing the constant
> first means that using a single = sign (the fault) is automatically
> compiler detected.


I personally find that form to be ugly and at odds with the great
majority of code out there. "=" and "==" does happen but very rarely
with any half competent C programmer.
  Réponse avec citation
 
Page generated in 0,05107 seconds with 9 queries