QML style guide

Dmitry A. Ashkadov dmitry.ashkadov at rosalab.ru
Wed Nov 7 08:26:10 UTC 2012


Hello, Aaron!

1. If usage of item consist of only one property that is set, then may it be placed on one line?

Example: 

ScriptAction { script: targetItem.smooth = false }

PlasmaCore.SvgItem {
... // blablabla
svg: PlasmaCore.Svg { imagePath: "path" }
... // blablabla
}

2. Maybe is it better to fix the aliases like PlasmaCore, PlasmaExtras, PlasmaComponents ... for a consistency? 


----- Исходное сообщение -----
От: "Aaron J. Seigo" <aseigo at kde.org>
Кому: plasma-devel at kde.org
Отправленные: Вторник, 30 Октябрь 2012 г 0:42:18
Тема: QML style guide

hi..

we have a style guide for our C++ code: the kdelibs style, which was mostly 
borrowed from Qt. unfortunately for us there was no QML guide we could 
similarly abscond with.

and it shows.

summary -> i've started putting together a QML style guide draft and would 
like your input and to bring it completion in a collaboration with all of you 
who are writing QML for Plasma. to that end, i've started a wiki page here:

	http://community.kde.org/Plasma/QMLStyle

nothing is set in stone. let's make it great.

tl;dr version ->

in the early Plasma QML days things were often just proofs of concepts or 
written under tight deadlines with few people working on them. that and we 
didn't have a style guide to, well,  guide us. the result is that there is 
only one consistency: inconsistency.

within the same QML component (e.g. plasmoids) things aren't consistent; even 
inside the *same files* things are inconsistent. we can do better than this, 
and we should want to for the same reason we have a C++ coding style.

it makes maintenance easier. it is easier to read code not written by you as 
you don't have to go through the step of becoming familiar with a random 
coding style but know exactly where to look for any given part of the code.

i get frustrated seeing "if (foo==bar)" on one line and then "if( foo == bar 
)" a few lines later. it says we are not paying attention to what we write, 
but are just throwing up code. it is a sign of a lack of care and attention to 
detail. ime, discipline filters upwards.

but frustration is just an annoyance. losing time because Component.onComplete 
if found in some utterly random spot in the QML or having to scan the whole 
QML item block because properties are defined/set throughout: between 
functions, after other items, at the top, near the bottom.. i've seen it all 
in our QML unfortunately.

i know we are capable of producing consistent code. we do it with our C++ 
output.

starting today, i will be rejecting patches and if necessary fixing style 
slopiness complete with appropriately critical commit log messages CC'd to 
this list so everyone notices.

but i'd rather we just cleaned up our QML act by paying attention to the 
details and creating beautiful, consistent code and cleaning up the messy bed 
we've made for ourselves as we go ... fair?

-- 
Aaron J. Seigo
_______________________________________________
Plasma-devel mailing list
Plasma-devel at kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


More information about the Plasma-devel mailing list