Value Objects

In this episode, Ben and Joe discuss value objects. You can learn more about value objects in Ruby Science, or on Martin Fowler's blog. You might also want to try you hand at our Extract Value Object exercise.
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/value-objects

hey guys, love the videos but unfortunately I donā€™t think this one did a great job of explaining value objects. The colour (Iā€™m british ;)) example was pretty confusing, especially without seeing any code examples. The really good bit of value objects (how two instances are equal) doesnā€™t get talked about until ~7mins or something. This could have been explained with some decent examples such as:

Color.new_from_rgb(255, 0, 0) == Color.new_from_hex('#ff0000') # explicit static methods to show instances are created

Describing how integers could be value objects was quite confusing too (youā€™re right, they could be) but there are plenty of better things that could have been used as an example to describe a value object: email address, currency, temperature, weight, etc.

keep up the good work! I look forward to fridays to see the latest video from you both :+1:

2 Likes

An applied example wouldā€™ve been nice. Iā€™m left kinda clueless as to how Iā€™m going to implement what was said here!

2 Likes

After watching this episode, still have no clue about how to implement value object. Iā€™d could use some code examples as well. I found some examples on this link: Value Objects Explained with Ruby - SitePoint. Maybe helpful to other people too.

1 Like

@wiserfirst thanks for sharing this link thatā€™s what I was looking for. I would also recommend the Value Objects chapter in The Rails 5 Way.

This video needs some kind of code examples to be of any practical help!

When I try to access the exerciseā€™s link, it redirects me to https://whetstone.thoughtbot.com/exercises/10 and I get an ERR_NAME_NOT_RESOLVED

Hi @duduribeiro, sorry for the trouble there. It should be linking to https://exercises.upcase.com/exercises/extract-value-object. Iā€™ve updated the show notes as well to prevent further confusion.

1 Like

Thanks so much @christoomey. It is working now.