Skip to content

2.4 Coding style

Kjell edited this page May 7, 2019 · 7 revisions

In general, try to stick with the style you find in existing files. Fritzing follows the Qt Coding style in most cases, but some differ.

Whitespaces

The Fritzing source code has a mix of 4-spaces and tabs. To render properly, set you tab width to 4. For example, to set the tab with in git diffs: git config --global core.pager 'less -x1,5'

Preferably configure your editor to use spaces instead of tabs, but do not reformat whole files.

Curly braces

Use curly braces for single line if or for statements. For example if ( condition) { if ( other ) { a += 1; } }

This is not in line with qt style, but we think it is important to distinct from if ( condition) a = 1; if ( other) a += 1;

Especially since we have a mix of 4 spaces and tabs.

Line width is 120

It is ok to occasionally use 120 columns before braking a line, so you are not forced to split calls like varWithToLongName->callToMethodWithAnotherLongName(justThisParameter, andAnotherOne)

This is not an invite to create deeply nested conditional clauses!

Qt coding style

For everything else, please see Qt Coding Style Qt Coding Conventions

If in doubt, don't hesitate to ask.