Hacker News new | ask | show | jobs
by autarch 4995 days ago
Looking at the examples it's really hard to know if this stuff was copied. How else would you write this sort of stuff? This seems like really simple, straightforward code.

A lot of it seems to be about creating a hash based on a well-defined data type. Is there some other way of doing this that makes sense in Ruby?

Similarly, he points out similar variable names. If you have a variable containing an API key what do you call this besides "api_key"?

Maybe these are just poorly chosen examples, but if these are the best evidence the author has I don't think there's grounds for flipping out quite yet.

2 comments

IMHO, the unnecessary require statement is a fairly solid evidence.

And programming is like English writing, no one will actually produce the same code. You can try by yourself

A few things stand out as distinctive in terms of Ruby style. For example, for self.send "#{sym}=", val, I'd much prefer to see send :"#{sym}=", val. And "sym" is a poor choice of variable name semantically when it's really referring to an attribute name.

If I were writing this, I'd probably have a single hash that defines the SOAP names and internal names then dynamically create those accessors and dynamically create the hash in to_hash rather than have repetition. DRY and all that. So there are other ways to go about it.

There's not a great deal to go on, of course, but the chance of two independent Rubyists stumbling across an identical solution syntax-wise is far from high (though is not minuscule, either.)

Valid point. When I first looked at the code I knew the initialize code was fairly common, but then I noticed the unnecessary require. I started to explore a bit more and noticed that the style changes from the copied code[1]. They also place their require statements immediately after module declaration[1]. Not to mention the use of single quotes vs double quotes.

1 - https://github.com/donnen/TaxCloud/blob/b036594969f045660a79...