Sep 012008
This was my first experiment in Domain Driven Development. The entire user interaction model was modeled in xtUML (iUMLlite was the IDE) and the code was translated by hand to the PHP code at the rate of over 1000 lines of code per day.
Development statistics;
- Requirements – 7 days
- Design -3 days
- Development – 3 days
- ~3000 lines of PHP code
- ~ 300 lines of MySQL
Running sites;
A few details on how I implemented state machines in PHP
Signal handling
switch ($_SESSION['state']) {
case 'Main':
if ($_POST['signal']=='attributes') {$_SESSION['state']='Attributes';}
break;
case 'Attributes':
if ($_POST['signal']=='add_attribute') {$_SESSION['state']='AddAttribute';}
if ($_POST['signal']=='delete_attribute') {$_SESSION['state']='DeleteAttribute';}
if ($_POST['signal']=='cancel_attribute') {$_SESSION['state']='Main';}
if ($_POST['signal']=='strip_clean') {$_SESSION['state']='StripClean';}
if ($_POST['signal']=='resize_images') {$_SESSION['state']='ResizeImages';}
if ($_POST['signal']=='includes_attribute') {$_SESSION['state']='IncludesAttribute';}
break;
case 'AddAttribute': break;
case 'DeleteAttribute': break;
case 'StripClean': break;
case 'ResizeImages':
if ($_POST['signal']=='cancel') {$_SESSION['state']='Main';}
break;
case 'IncludesAttribute':
if ($_POST['signal']=='exit') {$_SESSION['state']='Main';}
break;
default : $_SESSION['state']='Main';
break;
}
Body
case 'ViewPage':
if (isset($_POST['attribute_Item_ID'])) {
$attribute_Item_ID = $_POST['attribute_Item_ID'];
} else {
if (isset($_SESSION['attribute_Item_ID'])) {
$attribute_Item_ID = $_SESSION['attribute_Item_ID'];
unset ($_SESSION['attribute_Item_ID']);
}
}
$url_page_id=$attribute_Item_ID;
$Attributes[] = array('name' => 'Item_ID', 'value' => $attribute_Item_ID);
$webpage = getPage($site_prefix, $attribute_Item_ID);
$Attributes[] = array('name' => 'State', 'value' => $webpage['State']);
$Attributes[] = array('name' => 'Parent_ID', 'value' => $webpage['Parent_ID']);
$row[] = buildForm($site_IconDir, 'Back', 'cancel');
$row[] = buildAttributeForm($site_IconDir, 'Edit', 'edit_page',$Attributes);
$webpage['Content'] = buildHorozontalTable($row).$webpage['Content'];
unset($Attributes);
break;

