L
Logan Capaldo
--Apple-Mail-2-713170932
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
I don't believe it is any more descriptive than the current
situation. I think that whenever possible, you are right code should
be self-describing, but I don't think abstract methods are self-
describing.
I think that in ruby this already _is_ self describing:
module Enumerable
...
def map(&block)
results = []
each { |x| results << block.call(x) }
results
end
end
Looking at this a programmer using this api will say, ok I need to
provide an each method,
and it needs to take a block. That's what the code tells him. If he
doesn't read the code, and attempts to use Enumerable, he will get an
exception. This exception will tell him what method his object
doesn't implement that enumerable relies upon. This exception may be
a NoMethodError, or a NotImplementedError. Either way though he has
to go back to the code or docs to see what is expected. Implementing
an each that doesn't take a block or an each that takes more or less
arguments than its expected too is just as bad as or worse than no
each at all. I digress though, because what it really comes down to
is that your abstract_method should be a comment or an rdoc
directive. It really, really should. There is no reason to write code
that does effectively nothing. Your abstract method (irrespective of
abstract methods in other languages) is a documentation tool, and
that's where it should be implemented. You say "consider
readability", so do I. What is more readable, a comment telling me I
need to have an each method to include Enumerable, possibly even
explaining why, or a a call to a class method named abstract _method?
Now admittedly I can guess what that means, but I still have to find
out to be sure. Especially since it looks like its doing something. A
comment can be just as short as your method call, doesn't introduce
any new code and it IS part of the code, unless you read your code
with all the comments stripped out. You keep saying code should be
descriptive, I don't believe this adds to the descriptiveness. Which
is why I would not want this in the core ruby. It doesn't add anything.
--Apple-Mail-2-713170932--
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed
What you say is right. I agree with your opinion.
My point is that program code should be descriptive and
it should be prime documentation than comment or api doc.
Abstract method helps this.
I don't believe it is any more descriptive than the current
situation. I think that whenever possible, you are right code should
be self-describing, but I don't think abstract methods are self-
describing.
I think that in ruby this already _is_ self describing:
module Enumerable
...
def map(&block)
results = []
each { |x| results << block.call(x) }
results
end
end
Looking at this a programmer using this api will say, ok I need to
provide an each method,
and it needs to take a block. That's what the code tells him. If he
doesn't read the code, and attempts to use Enumerable, he will get an
exception. This exception will tell him what method his object
doesn't implement that enumerable relies upon. This exception may be
a NoMethodError, or a NotImplementedError. Either way though he has
to go back to the code or docs to see what is expected. Implementing
an each that doesn't take a block or an each that takes more or less
arguments than its expected too is just as bad as or worse than no
each at all. I digress though, because what it really comes down to
is that your abstract_method should be a comment or an rdoc
directive. It really, really should. There is no reason to write code
that does effectively nothing. Your abstract method (irrespective of
abstract methods in other languages) is a documentation tool, and
that's where it should be implemented. You say "consider
readability", so do I. What is more readable, a comment telling me I
need to have an each method to include Enumerable, possibly even
explaining why, or a a call to a class method named abstract _method?
Now admittedly I can guess what that means, but I still have to find
out to be sure. Especially since it looks like its doing something. A
comment can be just as short as your method call, doesn't introduce
any new code and it IS part of the code, unless you read your code
with all the comments stripped out. You keep saying code should be
descriptive, I don't believe this adds to the descriptiveness. Which
is why I would not want this in the core ruby. It doesn't add anything.
--Apple-Mail-2-713170932--