-
Notifications
You must be signed in to change notification settings - Fork 545
Improve clarity/usage of Package dimensions #434
Comments
I think the use of measured is great here. And, if desired, I'm going to add an extension module to number classes (opt-in) that will make this far less verbose (e.g., |
Absolutely, I'm on board with a less verbose version, but not before having something clear. An express way of implementing the above could be: package = ActiveShipping::Package.new(20.grams, [15, 14, 13].cm)
package.length # => #<Measured::Length: 15.0 cm> Extending |
We're talking in That being said, We should 100% remove |
@jonathankwok @kmcphillips Removing this from the 2.0 milestone. We're using Measured everywhere now, but leaving these signatures the same for 2.0. |
Problem
If you weren't aware of the implementation, what do you think are the details of this package?
What is the
20
?What is the dimensional ordering of
13x14x15
? Hint: It's not LWH.Even if you add
units: :imperial
, it doesn't explain what units you're using, just the system the units would be in. Is it inches? Feet? Furlongs? Fathoms?Also, retrieving the length is not as easy as you would think.
No, you would have to do this:
Or is it
[0]
? Who can remember. Why isn't itpackage.length
? Why does it return aFixnum
and not aQuantified
? Why are we using Quantified?Possible solution
Now, what if we changed it to be more verbose?
Zero chance of confusion. In addition, uses the
measured
gem, which is what we want in #427. It's more lines/typing, but it eliminates all areas of uncertainty. And when you're shipping something, certainty is key.CC: @kmcphillips @thegedge
The text was updated successfully, but these errors were encountered: