Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

Changes between Version 10 and Version 11 of StyleGuide


Ignore:
Timestamp:
Feb 28, 2014, 7:31:35 AM (10 years ago)
Author:
MarkDoliner
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StyleGuide

    v10 v11  
    8686
    8787
    88 == Variable Declarations ==
     88== Variables ==
    8989 * Prefer declaring each variable on its own line. This makes diffs easier to read and reduces churn. It also makes the code more clear when one variable is given an initial value but another is not.
    9090 * Use const for variables that don't need to change or be deallocated.
     91 * Avoid assigning variables in conditions unless it leads to simpler logic, e.g.:
     92{{{
     93#!c
     94/* Don't do this: */
     95if ((written = write(fd, buf, len)) < len) {
     96        ...
     97}
     98
     99/* Do this -- it's easier to read and leads to
     100 * cleaner diffs when things change: */
     101written = write(fd, buf, len);
     102if (written < len) {
     103        ...
     104}
     105
     106/* But this if often ok, because the alternative might be unwieldy: */
     107while (has_next = get_next()) {
     108        ...
     109}
     110}}}
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!