Sunday, October 31, 2010

Weekly roundup: returned from PBC 2010

I've just come back (in yesterday's evening) from Barcelona and the wonderful PHP Barcelona 2010 conference.
I was the only guy talking about testing and design for testability there - as Enrico noted during the return trip, the Spanish community is different from the Italian one in interests and offerings. At phpDay 2010 in Italy, half of the schedule was centered on Agile practices, while technical topics were the real heart of this conference.
Thus, many thanks to the organizers, which worked really hard to provide a smooth experience to us, and to the 400 attendees that followed as many talks as possible. It has been nice having a so passionated audience, with people even sitting on the floor when all the seats were already filled.
My slides for the talk Architecture and testability are available for downloading or online consultation.

Anyway, just because I travelled this week it does not mean I stopped writing. Here are my articles published from the last roundup.
Practical PHP Testing Patterns: Scripted Test
INVEST in user stories
Practical PHP Testing Patterns: Data-Driven Test
Primitive Obsession

Saturday, October 23, 2010

Weekly roundup: preparing for PHP Barcelona

I'm preparing for the PHP Barcelona Conference 2010, which will take place on October 29th and 30th. If you are reading this blog and are attending the conference, it will be nice to meet you there.
My talk is titled Architecture and testability and was originally given in Italian at phpDay 2010. It will take place on October 29th, at 16:30 in the assertTrue room.

Here are my articles for this week on Web Builder Zone. We have ended the series on PHP patterns and started a new one, dedicated to the pattern we use every day in testing. Test code has the same, if not greater, dignity of the production code it exercises.
Practical PHP Patterns: Record Set
The must-know of color theory
Practical PHP Testing Patterns: Recorded Test
The unknown acronym: GRASP

Saturday, October 16, 2010

Weekly roundup: university time

I have completed my first standard week in a Master's program at Politecnico di Milano. Well it's not really a week, since it is composed of four days, but I work full time on Friday. The topics of the Data Engineering specialization are quite interesting, comprehending courses such as image processing (how a program acts on multimedia files to modify them), multimedia information retrieval (how to query a large collection of images, videos or songs), computer vision (how a computer can recognize objects in an image), and so on. There's also some classic stuff like advanced databases and web development.

You don't have to worry about my time shortage however: here's are my four original articles published this week, as happened every other Saturday.
Practical PHP Patterns: Plugin
Paint on a canvas like Van Gogh, a primer on HTML 5 <canvas> element.
Practical PHP Patterns: Service Stub, a classic integration testing solution to keep in your toolbox.
You don't have to always stare at a screen, which describes how to substitute LCD with ebook readers for most of your tasks, even reading blog articles.

Saturday, October 09, 2010

Weekly roundup: working remotely

My experiences in working remotely lately have been great. I connected with a more than 300-kilometer distant enterprise and work with Skype and Teamviewer as if we were in the same room. After the initial hassle of setting up the microphone and the applications, I could converse and reason productively with my colleagues (we were for one month physically in the same office) for hours, without any voice latency (for talking overseas, this may be different: talking with people in the US has been more difficult for me).

Here are my articles for the last two weeks on Web Builder Zone.
PHPUnit 3.5: easier asserting and mocking, which describes the new features of this release (including my MockBuilder).
CSS refactoring
Practical PHP Patterns: Value Object, a timely article while the community is discussing on Value Objects in PHP and how they should be implemented.
What we don't need in object-oriented programming, a controversial article that spawned a long discussion with many insults between OOP purists and "we have to get things done" guys.
The PHP paradigms poll results: OOP wins - did someone have any doubts?
Practical PHP Patterns: Money
What you need to know about your version control system, one of the most popular posts on DZone this week.
Practical PHP Patterns: Special Case

Thursday, September 30, 2010

Monkey patching in PHP

Don't do this! It's only curiosity that drove me to try.
A monkey patch is a way to extend or modify the runtime code of dynamic languages (e.g. Smalltalk, JavaScript, Objective-C, Ruby, Perl, Python, Groovy, etc.) without altering the original source code. -- Wikipedia
Till tried to do some monkey patching a while ago, using PHP namespaces. Basically, if you use a PHP function inside a namespace, the original function will be called if an override is not defined. In the example, calling strlen() inside of a namespace would refer to the NamespaceName\strlen() function, and if it not exists, it would fall back to PHP's native one.
The problem was that you actually have to namespace the original code. It would not be monkey patching anymore: if I could modify that code, I would simply change the function calls.
For example, we may want to monkey patch the following code:
<?php
$str = 'mystring';

echo "This should eight, but it's not: " . strlen($str) . "\n"; // 6

So what do we do? Basically, this evil black magic:
<?php
namespace monkeypatching;
function strlen()
{
    return 6;
}

$code = file_get_contents('monkeypatched.php');
$code  = 'namespace monkeypatching; ?> ' . $code;
echo $code;
eval($code);
which prints out:
This should eight, but it's not: 6
Of course this infringes every single SOLID and software engineering principle. Again, don't code like this, we are not in Ruby.
In general, methods and functions definitions are part of the mandatory global state of an application, and so once the loading phase has finished they should be immutable. This is done at the loading time, so it may be acceptable. But also dangerous: it's the poor man's version of polymorphism.

Wednesday, September 29, 2010

Grouply and connect with me

I have been receiving several emails with contact requests on Grouply.
I registered there, but Grouply required then my Yahoo! username and password to work, which I'll never enter on a 3rd party application (it's a very evil and dangerous habit.) If only they used OAuth or OpenID... (is the latter dead?)

I actually do not follow many mailing lists in this period, apart from zf-contributor. So if you want to connect with me, I'm on Twitter, and you will be sure that I read tweet where I am mentioned every day.
I do not use Facebook instead - except for people that I have already met out of the Internet (conferences, work, university). This blog and Twitter are really the best ways to chat for me.

Tuesday, September 28, 2010

Find the intruder

 1. We can connect the set-top box to the tv first, and when it goes online it will bypass the Scart signal to override both the Vcr and the Dvd player. For switching between those two instead, we'll use this Scart switch.
2. This MySQL database, which is populated by the turnstile at entrance of the school when students enter the building the first time, should be synchronized with the custome e-school software. We can easily make a PHP script which is run daily and selects the right rows and inserts them in the right place.
3. We cannot fix the ship's engines in time, and the shields cannot survive the lava flow, under which we will be trapped, for long. But we can to use the impending explosion itself as our ticket out: the volcano's cataclysm will launch us, and by using the shields for some instants, we can engage the hyperdrive for a split second to get them into orbit, where we can be saved.
4. You can boot from the Ubuntu 10.04 live cd and get a running system from here, then check if your modem is working. You'll install it over the disk with Windows XP, which is now too slow to use, only if there are no connectivity problems. Besides that, you can also install Ubuntu and leave an empty partition for reinstalling Windows on it later."
Now detect which ones are real engineers quotes (mine, actually) and which comes from Stargate Atlantis. After a summer marathon of three series I started sound like Rodney McKay when explaining engineering topics to naive people.
I guess that's why we (engineers) are almost always sci-fi aficionados: in science fiction engineers save lives and travel between galaxies in every episode, while we are limited to build some indeed very useful web application. :)

Featured post

A map metaphor for architectural diagrams

It is a (two-dimension) representation of a pipe. The map is not the territory , but in software engineering terms they are models of it....

Popular posts