Prefer an object over a hash, whenever the keys are significant

In general, any time you're working with a hash that has specific keys
(e.g. accessed with a literal), you've likely got an object wanting to
get out, even if it's just a struct with no other methods. The biggest
upside is more meaningful errors if you have a typo, since the default
behavior of a hash is to return nil. Cases where you don't care about
specific keys (e.g. using a hash to memoize a single argument method)
are fine.
I had originally specified it further, to point out the common indicator of
this particular case, but people seemed to want to generalize it.
On Sep 24, 2014 12:23 PM, "Elliot Winkler" <notifications@github.com> wrote:

> In best-practices/README.md:
>
> > @@ -41,6 +41,8 @@ Ruby
> >    multiple models.
> >  * Prefer `private` when indicating scope. Use `protected` only with comparison
> >    methods like `def ==(other)`, `def <(other)`, and `def >(other)`.
> > +* Prefer (named) value objects over plain arrays and hashes to hold
> > +  domain-specific data.
>
> Yeah, I would agree with that. [image: :-1:] unless we can specify this
> further.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/thoughtbot/guides/pull/231/files#r17990057>.
>