Closed pjotrp closed 11 years ago
Maybe, args hash should be replaced with specific Structs. The Struct could be responsible of verification of parameters, so you could separate the logic of the method from the parameter checking.
Ahh! This is a common issue. "When is it appropriate to check arguments and when not?"
Don't check arguments when:
Do check arguments when:
I think generally the appropriate exception to raise is ArgumentError
. Sometimes it's something else, like a FileError
. Try to find similar examples elsewhere in Ruby code, especially ruby-core.
A few rounds of refactoring have been done and this issue can be closed.
I have a problem reading this code. I presume symbols like :round are JSON tags and you are setting properties after validation. Is there no more elegant and clear way that this code can work?
Maybe you should be using a proper parser/lexer to do this stuff. I mean, if Vega is much larger, this is going to be problematic.