Skip to main content

Coat Pattern Value Object

The CoatPattern value object represents the distinctive coloration and markings of a cat's fur. This immutable object is used for identification and description purposes throughout the system.

Core Properties

  • Base Color: Primary coat color (e.g., black, white, orange)
  • Pattern: Type of coat pattern (e.g., solid, tabby, tortoiseshell)
  • Markings: Distinctive features like spots, stripes, or patches
  • Colors: Secondary colors present in the coat

Use Cases

The CoatPattern value object is used to:

  • Describe cats consistently across the system
  • Aid in visual identification
  • Standardize terminology for coat descriptions
  • Enable matching of cats based on appearance

Implementation

Coat Pattern Value Object

File: domain/value_objects/coat_pattern.pseudo

// Coat Pattern Value Object

class CoatPattern {
// Properties
string baseColor // Primary coat color
string pattern // e.g., "solid", "tabby", "tortoiseshell", "calico", "bicolor"
string[] markings // Distinctive markings like spots, stripes
string[] colors // Secondary colors present in coat

// Constructors
constructor(string baseColor, string pattern)
constructor(string baseColor, string pattern, string[] markings, string[] colors)

// Methods
function isMatching(CoatPattern other) : boolean
function getDescription() : string
function addMarking(string marking) : CoatPattern
function addColor(string color) : CoatPattern

// Factory Methods
static function createSolid(string color) : CoatPattern
static function createTabby(string baseColor) : CoatPattern
static function createTortoiseshell() : CoatPattern
static function createCalico() : CoatPattern
static function createBicolor(string mainColor, string secondaryColor) : CoatPattern

// Classification Methods
function isPredominantly(string color) : boolean
function hasPattern(string patternType) : boolean
function hasMarking(string marking) : boolean

// Validation
function isValid() : boolean
}

Immutability and Usage

As a value object, CoatPattern is immutable. Operations like addMarking() and addColor() create and return new instances rather than modifying the existing one. This ensures consistency and prevents unexpected changes.

Factory Methods

The class provides convenient factory methods for common coat patterns:

  • createSolid() - For single-colored cats (e.g., all black)
  • createTabby() - For cats with tabby patterns
  • createTortoiseshell() - For tortoiseshell patterns
  • createCalico() - For calico patterns
  • createBicolor() - For cats with two distinct colors

Real-World Examples

From the Lime Factory colony data:

  • Dusty: Solid black coat
  • Broncho: Calico pattern with black, white, and orange coloring
  • Spot: Solid black coat with a distinctive white spot on chest
  • Nacho: Orange tabby pattern