Entry tags:
Hey you coders
These questions aren't language-specific; consider the questions as pseudocode. Pretend that the underscores are actually studlyCaps if you'd like.
Also, don't worry about return values of the mutators, which is a separate question.
[Poll #875101]
Also, don't worry about return values of the mutators, which is a separate question.
[Poll #875101]
no subject
I have an intrinsic dislike -- learned from LISP, where this caused a bug that took about a week to track down -- of having method names that look like variable names.
(no subject)
(no subject)
you can grep "set_foo()" easier than "foo"
(no subject)
(no subject)
no subject
(no subject)
no subject
no subject
Although what I really prefer is object.foo and object.foo = new value, but we'll have to wait for Perl 6 to really do that properly.
(no subject)
(no subject)
(no subject)
(no subject)
no subject
(foo object)
and(setf (foo object) new-foo-value)
, which I've also started to use in Scheme dialects that have extensibleset!
(like Swindle). But since Scheme is a Lisp1 instead of a Lisp2, it does sometimes get in the way when you want to have a variable with the same name as an accessor function. I haven't decided yet if this matters enough.(no subject)
no subject
I'd say 'overloading is overrated' but there are times when it's really handy. I'll just say 'overloading is easily abused'.
no subject
The get/set style in any form is to be vastly perferred. As someone else here pointed out, it can be searched on more easily, and that alone is sufficient reason to prefer it to foo() foo(new foo).
I neither know nor care about Java, as Perl and Python are my preferred scripting languages, but in C++ most of the libs I use, and the coding standards I adhere to in most of my professional work, and the code my xml-driven code generator writes (now available in a new and better incarnation), all use some variant of the get/set style.
Software development is hard, and it became very clear in the 90's, if not before, that conciseness is not in general a virtue, even in algorithmic code. Reminding people, especially the poor (usually junior) maintenance coders, what code is doing in multiple ways is a best practice.
For commericial development of application code that will be maintained over many years, there is really no alternative to get/set, preferably in the getX/setX form rather than with underscores, which are ugly and hard to read (but that's an unjustifiable personal preference, unlike the superiority of get/set.)
no subject