[Ctk-developers] Libs/DICOM/Core/ctkDICOMModel.cxx : variables names with same naming as method names

Luis Ibanez luis.ibanez at kitware.com
Thu Apr 8 21:50:45 UTC 2010


I recall that at some point we discussed a
naming convention for Qt-like classes, but
I'm not sure if we arrived to a consensus.


The file:

  Libs/DICOM/Core/ctkDICOMModel.cxx

had an abundant use of local variables with
names matching some member variables and
member methods.

A notable example:

                       "index"

I just committed a fix for most of them,
but for the long run it will be great if we
agree on some naming convention.

I would vote against having a method of a C++ class
to be called "index()" for example.       :-)

a more useful name will be "getIndex()", for example,
or in this particular case, it looks like what the function
is actually doing is generating an index, so good names
could be

ctkDICOMModel::generatgeIndex ( int row, int column, const QModelIndex
& parentValue ) const

or

ctkDICOMModel::computeIndex ( int row, int column, const QModelIndex &
parentValue ) const

or

ctkDICOMModel::produceIndex ( int row, int column, const QModelIndex &
parentValue ) const


There is already another

                createIndex(int, int, Node *)


so it will be fine if we use

ctkDICOMModel::createIndex ( int row, int column, const QModelIndex &
parentValue ) const

since the signature will be different.


---


Do we have a document on coding style ?

if we do,
we probably should setup KWStyle testing
before things get out of control.



      Luis



More information about the Ctk-developers mailing list