qmlbook / qt6book

The Qt 6 Book - A book about QML
https://www.qt.io/product/qt6/qml-book
Other
351 stars 112 forks source link

ch06: inconsistent property/function naming #89

Closed mitchcurtis closed 3 years ago

mitchcurtis commented 3 years ago

docs/ch06-controls/src/interface-document-window/DocumentWindow.qml has a bunch of properties that start with "_", and one function.

The latter seems to be inconsistent, as the other functions don't have the prefix.

For the former, we should probably decide whether or not we want to encourage the "_ means private" convention or not.

mitchcurtis commented 3 years ago

@Inkane, what do you think? Will we have language features that allow making properties private? Is it worth using the _ prefix?

Inkane commented 3 years ago

Will we have a language feature? Yes, but not in 6.2, and who knows when it actually lands. Though I can't say I like the "_" convention; if you really want some notion of privacy, I'd rather use a pattern like

// MyItem.qml
import QtQuick

Item {
   property int publicProperty
   QtObject {
      id: priv
      property bool myPrivateProperty
    }
}

even though it has a certain amount of overhead.

e8johan commented 3 years ago

I take it that we should drop the _ prefix for now, and then introduce the language feature going forward. does that make sense?

mitchcurtis commented 3 years ago

That's what I would vote for.