The Shipping Container as Object Oriented Code (Previously posted Dec 2006)
The Shipping Container as Object Oriented Code
From the perspective of my daily work, as a web developer, the parallels between shipping containers and object oriented programming are obvious; a standardised design for the shipping of goods across different modes transportation (which interestingly took hold because not only was it standardised, but also it was open - given freely to the ISO standards organisation), which is turned into many many instances of the design (or class), and which is extended in many different ways (inheritance).
<?php // object oriented presentation of the shipping container: class shippingcontainer { public $height; public $width; public $length; private $contents; function __construct( $height, $width, $length ) { $this->height = $height; $this->width = $width; $this->length = $length; } function storeGoods( $goods ) { $volume = $this->height * $this->width * $this->length; if ($goods->volume > $volume || isset($contents)) { return false; } else { $this->contents = $goods->contents; return true; } } function unloadGoods() { if (!isset($this->contents)) { return false; } else { $goods = $this->contents; unset($this->contents); return $goods; } } } class politicalmeaning extends shippingcontainer { public $meaning; function __construct( $height, $width, $length ) { $parent::__construct( $height, $width, $length ); $meaning = array(); } function addMeaning( $new_meaning ) { $meaning[] = $new_meaning; } } ?>