Create safe, sturdy code by modeling domain attributes as rich value objects.
Are you familiar with the "missing stair" metaphor? Wikipedia describes it as: a person within a social group who many people know is untrustworthy or otherwise has to be "managed", but whom the group chooses to work around, by trying to quietly warn others of their behaviour, rather than deal with them and their behaviour openly
The metaphor is derived from the idea of a missing stair on a staircase, which people simply warn new visitors about, instead of repairing.
An enormous amount of production application code contains its own "missing stair". Software's missing stair is quantities and other business-domain values that are represented using primitive datatypes such as Strings and Integers. These datatypes don't enforce the natural business domain constraints on the values they represent. Instead, everyone who works on the code has to "just know" to apply business rules to them.
For instance: software for a doctor's office might have a
patient_height field, maintained as a raw integer. It makes no sense for a patient's height to be a negative number... but there's nothing about the value type that enforces this constraint.
These kinds of missing stairs in the domain model can lead to bugs. Sometimes, as you'll find out in the first episode of this course, those bugs can be disastrous.
Valued Ruby is all about fixing missing stairs, by leveraging the language to model quantities just as richly as we model complex domain concepts like
Order. In the process, we'll dive deeply into immutability, identity, comparisons, implicit and explicit conversions, as well as some of the 3rd-party libraries that can help us create robust value types.
The running example for this course is classes for representing physical measurement, like Feet and Meters. But the techniques you'll learn here will help you model all kinds of rich domain values in Ruby.
Prerequisites: This course is part of the Ruby for Graceful App Development garden tour, which you can follow from beginning to end for maximum coverage of domain modeling concepts.
There was a problem reporting this post.
Please confirm you want to block this member.
You will no longer be able to:
Please allow a few minutes for this process to complete.