Being this "Turkey" is not being a "Developer"

They sit in the corner, take the spec sheet from their manager, check over the items and hang their head or beat it against the table. It is all too impossible.

They seek solace in the discussions with fellow developers who are in the same position, talking about their terrible colleagues and the mess that keeps befalling them.

They are not a developers. They are not someone who I would trust to code an xml document with two nodes. They are a turkeys.
Read More…

Easing Launch Stress

Talking about making change is easiest. Investing money in a large project is easy. Putting the wheels in motion to change business practices is more difficult. All these require no actual change to established practices. The system change-over is where the doubts all get to the surface and all your hard work is brought into the spotlight. The client panicked and is now look at putting all the old system bugs back into your brilliant new software. Is there anything you can do to remove or ease this stress?
Read More…

The Production Server has Bad Code, and The Bad Code is Yours

I broke something today and I asked myself "What Would Rands Do?". Five minutes before knocking off there is obviously a problem. That sinking feeling struck as soon as the words drifted across the partition. "A problem? But there can't be, I don't code in #Fail."
Read More…

Social Media and Short Attention... What was that again?

Here we are asking our kids to dedicate early life to school. To understand the world. To understand complex situations and interactions. While technology is getting simpler and interacting digitally is getting easier - the hardest lesson to learn is that digital does not translate well to real life.
Read More…

Just because your product uses Open Standards does not mean that it is an Open System

Usually I am not one to complain about software companies and their fights for supremacy in each others markets. But I do feel the need to write about my thoughts on Apple, their decisions and modus operandi. Especially on the lack of flash support and their open systems.
Read More…

CakePHP : Toggle a BitWise status field

I had a problem. I have been using BitWise status indicators for sometime now, in fact after reading Mark Story's article they have been a staple of development ever since. In my latest work there was a need to turn on or off an item from a menu. I came across this Nice Trick to toggle Model, which seemed to be perfect but because it is on or off it wasn't quite what I was looking for.

So I made this. If you'd like to use it, throw it into the AppModel. If you'd like to help make it better, leave a comment and let me know what to do...
[php]function toggleField($field, $data = null, $bitwise = true) {
$field = $this->escapeField($field);
if(empty($data['conditions'])){$data['conditions'] = null;};
if(is_array($data['conditions'])){
//ARRAY :: The user has passed a few conditions so we set that up for an insert.
foreach($data['conditions'] as $object => $property){
$data['conditions'][$this->escapeField($object)] = $property;
unset($data['conditions'][$object]);
}
$query_where = $data['conditions'];
} elseif(!empty($data['conditions']['id'])){
$query_where = array($this->escapeField() => $data['conditions']['id']);
} else {
//DEFAULT :: Where there is no conditions passed, we assume that it is updating the status with the current 'id'.
$data['conditions']['id'] = $this->id;
$query_where = array($this->escapeField() => $data['conditions']['id']);
}

if($bitwise){
$query_string = 'CASE';
$query_string .= ' WHEN '. $field .' & '. $data['switching']['On'] .' THEN ('. $field .' &~ '. $data['switching']['On'] .') | '. $data['switching']['Off'];
$query_string .= ' WHEN '. $field .' & '. $data['switching']['Off'] .' THEN ('. $field .' &~ '. $data['switching']['Off'] .') | '. $data['switching']['On'];
$query_string .= ' WHEN '. $field .' & 0 THEN '. $field .' | '. $data['switching']['On'];
$query_string .= ' ELSE 0';
$query_string .= ' END';
$query_conditions = array($field => $query_string);
} else {
$query = array($field => 'NOT ' . $field);
}
return $this->updateAll($query_conditions, $query_where);
}[/php]
Then to call it I have two ways. Firstly the easy way, where I do not need to specify fields:
[php]function live_not_live($id = null){
if(!empty($id)){
$toggle_field = $this->Category->toggleField('status', array(
'switching' => array('On' => Category::LIVE, 'Off' => Category::NOT_LIVE)
)
);
if($toggle_field){
$this->redirect($this->referer());
};
}
}[/php]
No fields are specified, so it just alters the row with the $id variable.

The next one runs based on some conditions specified to the call. In other words there are two fields that need to be set to change the status.
[php]function lock_unlock_domain($id = null){
if(!empty($id)){
$current_setting = $this->CategoryGroup->findByOurId($id, array('recursive' => -1));

$toggle_field = $this->CategoryGroup->toggleField('status', array(
'conditions' => array('our_id' => $current_setting['CategoryGroup']['our_id'], 'whm_id' => $current_setting['CategoryGroup']['whm_id']),
'switching' => array('On' => Category::LIVE, 'Off' => Category::NOT_LIVE)
)
);
if($toggle_field){
$this->redirect($this->referer());
};
}
}[/php]
And thats it. Status changed in keeping with the Fat Models, Skinny Controllers theory. I am happy with how