D
Day
In ZenTest 3.9.0's release notes
(http://blog.zenspider.com/archives/2008/01/zentest_version_390_has_been_released.html),
it says, "Cleaned out nearly every @ and use accessor methods instead.
You should too."
My first thought was, "What?" So in a blog comment, I asked about it.
Here's that (brief) exchange:
http://blog.zenspider.com/archives/2008/01/zentest_version_390_has_been_released.html#comments.
I may still get an answer there, but it occurred to me that wider
discussion might be better anyway (and he's probably on this list,
yes?). I understand, now, that there is a difference and what that
difference is (I think), but I still don't see why the latter is
better.
So... what's the advantage of changing
class Thing
attr_accessor :a
def do_something(arg)
@a = arg
end
end
to...
class Thing
attr_accessor :a
def do_something(arg)
self.a = arg
end
end
Am I missing some context that's helpful in understanding this? I'd
think that it would be more valuable for readability to keep the @var
assignment since it clues you in to the nature of the variable (vs. a
class variable, etc.) than... anything else I can come up with. I will
be the first to admit that, "anything I can come up with," is a
pitifully small set of ideas. I'm not trying to say that this idea is
bad or whatever... I'm wondering what I don't know. Thanks in advance
for illumination.
Ben
(http://blog.zenspider.com/archives/2008/01/zentest_version_390_has_been_released.html),
it says, "Cleaned out nearly every @ and use accessor methods instead.
You should too."
My first thought was, "What?" So in a blog comment, I asked about it.
Here's that (brief) exchange:
http://blog.zenspider.com/archives/2008/01/zentest_version_390_has_been_released.html#comments.
I may still get an answer there, but it occurred to me that wider
discussion might be better anyway (and he's probably on this list,
yes?). I understand, now, that there is a difference and what that
difference is (I think), but I still don't see why the latter is
better.
So... what's the advantage of changing
class Thing
attr_accessor :a
def do_something(arg)
@a = arg
end
end
to...
class Thing
attr_accessor :a
def do_something(arg)
self.a = arg
end
end
Am I missing some context that's helpful in understanding this? I'd
think that it would be more valuable for readability to keep the @var
assignment since it clues you in to the nature of the variable (vs. a
class variable, etc.) than... anything else I can come up with. I will
be the first to admit that, "anything I can come up with," is a
pitifully small set of ideas. I'm not trying to say that this idea is
bad or whatever... I'm wondering what I don't know. Thanks in advance
for illumination.
Ben