Continuing the discussion from Coding Standards:
Does anyone know, why many use the prefix m for properties? Why not p?
Continuing the discussion from Coding Standards:
Does anyone know, why many use the prefix m for properties? Why not p?
I don’t know, as I don’t do it.
I, and probably many others, use the prefix m to indicate that it’s a private property or methode.
It has nothing to do with “private” but of course you can do as you please.
The m prefix is usually used for COMPUTED properties with a getter and setter method, where the property serves as a place to store the value (as methods have no storage capacity).
Think of it as “method property”.
Eg. imagine you have a class DNA with properties
sequence as String
sequenceLength as Integer
sequenceWeight as Double
Every time the sequence changes you want to automatically recalculate the sequenceLength and the sequenceWeight.
So you add a computed property and name it sequence. It has a Get and a Set method - but where does it store it’s value? That’s where you need a property for the methods:
Public Property mSequence As String
And in the Get and Set methods you have:
Public Property Sequence As String
Get
return mSequence
End Get
Set(value as String)
mSequence = value
SequenceLength = Len(value)
SequenceWeight = WeightOf(value)
End Set
End Property
‘m’ quite often means member property.
‘_m’ quite often means private member property. Prefixing with an underscore appears to be reserved in Xojo so we add an underscore as the last character.
‘p’ quite often means parameter.
As Keving stated, prefix differentiators like m, p, k are usually member of the class, parameter of the function/method, constant definition. It’s not exactly a standard (you must), but a known style (you may, sometimes should).
Thank you all for the valuable explanations!
I thought m was for module which became classes with oop
better
Private Property mSequence As String
True