3 ms·
Data is shorter to write and gives you automatic structural equality. You really could do the same thing with a class, but if you want something exactly like Da
by chc 4y ago
Data is shorter to write and gives you automatic structural equality. You really could do the same thing with a class, but if you want something exactly like Data, it's nice to have it built in.
- berkes 4y agoI'm a big fan of value objects. In Ruby, many of my projects have a simple baseclass, ValueObject, that is only a little simpler than Data. I love it that I can now use it from the language instead. It saves me just one class. At most five methods. But it saves me having to explain and defend this for colleagues who insist that an email is Just A String, or a price being a float (i know) has worked Just Fine. I can now point them at stdclass documentation. And it being part of std weighs far more than the opinion of that contractor that keeps on nagging about design patterns and crap.