3 ms·
Languages are based on widely understood conventions. If it looks like I'm writing to or from a variable, then let that be what happens, because that's how 98%
by maxklein 16y ago
Languages are based on widely understood conventions. If it looks like I'm writing to or from a variable, then let that be what happens, because that's how 98% of programmers will understand it to be.
Don't just change it, because the change seems "cleaner". You are breaking convention in a major way, and this will surely lead to worse code in the future.
- raganwald 16y agoYes, but if a language provides a mechanism whereby what look in other languages like property accessors can actually be implemented as method calls, then in that language, 98% of programmers ought to--like true scotsmen--expect that it might be a variable and then again it might be a method call. Case in point: In Ruby, foo.bar and foo.bar= are never property accessors, it's just that sometimes there exists code such that foo.bar returns @bar and foo.bar= sets @bar.
- viraptor 16y agoIf you're talking about a narrow view of what new compsci (with a poor programme) person might know (== only java) - yes, these are understood conventions, although even that is not completely true. Counter-examples: python properties, ruby (=, ? and normal methods), C# properties (and events), probably any message-passing language (via 'name' or ('name', 'newvalue')), lots of other languages mentioned in other comments here... How is not using setValue, getValue "breaking converntion in a major way" then? Java, PHP, Javascript and some others do it that way. This is their convention - true. But it's far from "an OOP convention" - mainly since OOP doesn't define the syntax in any way - just some properties of the environment.