Code Explainers

Code explainers tagged #value-object

java
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Currency;
 

A safe Money value type in Java

immutability bigdecimal value-object
Intermediate 10 steps
php
<?php
 
namespace App\Support;
 

Recursively finding files with SPL iterators in PHP

recursion iterators filesystem
Intermediate 7 steps
php
<?php
 
namespace App\Http\Requests;
 

A validated date-range value object in PHP

value-object validation immutability
Intermediate 7 steps
ruby
require "phonelib"
 
class PhoneNumber
  class InvalidNumber < StandardError; end

Wrapping phone parsing in a Ruby value object

value-object memoization validation
Intermediate 7 steps
ruby
class SemanticVersion
  include Comparable
 
  attr_reader :major, :minor, :patch, :prerelease

Comparable semantic versions in Ruby

comparable parsing operator-overloading
Intermediate 8 steps
ruby
class Money
  include Comparable
 
  CURRENCY_SYMBOLS = { usd: "$", eur: "€", gbp: "£" }.freeze

Building an immutable Money value object in Ruby

value-object immutability comparable
Intermediate 8 steps