Semantics are definitely important, but it's also good if technically your code follows your intentions. I definitely used const members in a way where they were semantically correct, but I didn't consider the technical implications.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In my opinion, when you create a class
Foo
, there is a broader question than "should memberbar
beconst
or more?".This broader question = "is
Foo
a value object or not?"If
Foo
is in fact3DCoordinate
, thenFoo
should be copyable and its members datax
, `y
andz
should not beconst
.If
Foo
isBankAccount
, then it should be impossible to copy an object and its members datanumber
andowner
should beconst
.For me, the question "
const
or not?' has to be answered based on semantic first, not on "technical details" :)Semantics are definitely important, but it's also good if technically your code follows your intentions. I definitely used const members in a way where they were semantically correct, but I didn't consider the technical implications.