Up Yours Truly

A fairy tale about software development

Posts Tagged ‘PHP

Guaranteed Execution

leave a comment »

Dear Reader. Today is the opening of the Best Practices section and I am proud to introduce to you the first Design Pattern that was recently discovered by one of my beloved colleagues. Without further ado, here it is:

Pattern Name and Classification:
Guaranteed Execution

Discovered by: Willy Benton

Level of Complexity: Intermediate

Intent: Provides a fail safe way of executing a code block with 100% certainty.

Also Known As: Surefire Block, 100% Execution, Execute It For Real

Motivation (Forces): Imagine you have a code block that plays a very important role in your application. You wouldn’t want that block to be accidentally skipped by the compiler or interpreter, or by CPU in run time. You have to take precautions. Guaranteed Execution is the best practice in such occasions.

Applicability: Can be used in any programming language which supports If / Else constraints. Although, we suggest extensive use of Guaranteed Execution design pattern in PHP, Perl and Ruby to make sure your mission critical applications will work as expected.


Guaranteed Execution Design Pattern


Compiler / Interpreter / CPU – a thing that processes the code (the author is not quite sure which one is it).
Critical Code Block – a block of code which MUST be executed by any means necessary.
The Lure – If / Else statement that attracts the attention of Compiler / Interpreter / CPU therefore lures it into execution of the Critical Code Block.

Collaboration: Either compiler, interpreter or CPU is doing it’s usual daily job – computing and stuff. One of them notices The Lure – an If / Else statement, and says “Shit, this must be important, I’d better go execute it”. If / Else statement traps the Compiler / Interpreter / CPU and forces it to execute the Critical Code Block. Job well done!

Consequences: Your mission critical application will work as expected. No trade offs or side effects whatsoever as If / Else statements work really fast (“I am sure If / Else statements work as fast as your eye blinks” – W. Benton).

Implementation: The implementation is straightforward. It should get clear after reading the Sample Code.

Sample Code:

<!-- the usual HTML here -->


//Compiler / Interpreter / CPU hidden here somewhere

$a = 1;
$b = 2;

//The Lure
if (!is_empty($a + $b / 10032)) {
    //Critical Code Block
    $application_safe = true;
    $critical = "executed";
} else {
    //Critical Code Block
    $application_safe = true;
    $critical = "executed";

<!-- back to the usual HTML here -->

Known Uses: Number of mission critical applications of SHIT Inc. that cannot be disclosed.

Related Patterns: Soon to come (wait for the updates).


Written by Ken Benchmark Jr.

January 27, 2008 at 9:16 am

Willy Benton – Senior Web specialist, designer and programmer

with one comment

Willy BentonWilly is special. Not in the “Special Olympics” kind of way, simply special. He’s got awesome talent of programming HTML with Macromedia Dreamweaver IDE. Many were amazed of how innovative he gets when it comes to programming web pages. Willy has worked in SHIT for years, he is one of the oldest and most respected developers around. I’m absolutely sure he is one of the key members behind W3C, though Willy denies it as he is a decent, unspoiled person that refuses to accept his great achievements.

On the personal side, he’s got truly immense sense of humor which he tends to express by emailing funny pictures and YouTube links to colleagues all day long. Have I mentioned that he is the most stylish software developer I met? Great hairdo, fancy outfit – any woman in our company would die for him.

Despite of Willy’s gorgeous looks, all his achievements are the result of his knowledge and wisdom. He recently realized that his wizardry of HTML programming has reached the limit of perfection therefore he moved to a next level – the wonderful land of PHP. Nobody has a doubt that he will soon overcome the best specialists of this beautiful programming language. SHIT Inc. should start worrying about Zend taking him over as a core PHP internals developer.

Some of Willy’s award-winning methodologies will be secretly revealed under “Best Practices” section which will appear on this blog really soon, so stay tuned! A great tribute of his upcoming PHP development success must go to his weapon of choice – Macromedia Dreamweaver:

The Dreamweaver

When asked a question “Willy, what inspires you the most?”, he mysterious grins and says “I think it’s Chuck.”.

Written by Ken Benchmark Jr.

January 25, 2008 at 11:14 am