Thursday, December 30, 2010

Results of my 2010 New Year's resolution

My last new year's resolution of January 5th, 2010 had three main goals. Let's see how it all played out.

First goal was maintaining my blog, with an estimate of 285 posts for the year 2010. You can see that on this website there are not so many articles, but the fact is that I moved my technical writing at DZone. On, the Web Builder Zone of the site, I write 4 articles a week that I regularly link from here.
The counter is currently at 178 articles on DZone plus 140 here (the majority before the switch); some of them are link posts and they should not be counted in the statistics. We can say however that the first goal was more or less accomplished.

The second goal was obtaining my Bachelor's degree in Computer Engineering at Politecnico di Milano, plus its mandatory English language certification. I exceeded exceptations and score 111/120 on my TOEFL exam and graduates with a final mark of 110 cum laude, which is the maximum grade in Italy. We can say this goal has been accomplished.

The third goal has not been met instead. I was aiming to continue development on a personal project, NakedPhp, and reach a stable release. However, two things got in the way. First, I started working on my thesis in February, and stopped working in PHP to code in Java and JavaScript for quite some time, until graduation in July. The day after graduation, I received a work offer from Allbus, where I still work part-time today.
Thus, I hadn't have any free time for open source coding this year, apart from my MockBuilder contribution to PHPUnit. I however still write a lot, and I hope my tutorials and articles make up for the time spent from other people on open source tools like Doctrine 2 that I use every day. I have failed this goal.

Tomorrow I think I'll write a new-new year's resolution. It's quite interesting to go back after an year, and see what you still value, and which assumptions are changed about what you should be doing in your life.

Saturday, December 25, 2010

Weekly roundup: Xmas edition

It's Chistmas today and I hope you will have a nice day with your families in case you observe this holiday, without having to think about work and other commitments. To distract you from these issues, here are my articles published this week on DZone.

Practical PHP Testing Patterns: Test Discovery
Sitting on the couch
Practical PHP Testing Patterns: Test Discovery
What cooking can teach to a software developer

Saturday, December 18, 2010

Weekly roundup: switching to Chrome

It seems that my co-workers have infected me and I'm now using Google Chrome (actually Chromium, via the Ubuntu repositories) instead of the old-fashioned Firefox 3. I can't help it, it's far too fast and Firefox cannot keep up with it: I started with the Chrome for a Cause extension and I found out that it was probably a marketing stunt to push people to try Chrome, hoping that it would the better performance with respect to the other browsers will convince the average user to stay. At least on me, it worked.

Here are my original articles, published this week on DZone.
Practical PHP Testing Patterns: Test Runner
Technical Investment, or quality vs. time
Practical PHP Testing Patterns: Testcase Object
Real-life closures examples ...for real

Sunday, December 12, 2010

Weekly roundup: going 64-bit

I finally have installed Ubuntu 10.04 in its 64-bit version on my work/home machine. After the usual initial tuning - uninstalling a lot of packages and installing back my favourite ones previously saved with Synaptic - it seems to work well. I had a 32 bit processor until May of this year, when the old box broke down; I started using (K)Ubuntu amd64 in the office in Siena and I see now no reason to going back: Dropbox, Teamviewer and Skype are examples of non-standard applications which now support the amd64 architecture.

Here are my articles published this week on DZone.
Practical PHP Testing Patterns: Assertion Message - explains how and when to write a custom message for assertions.
Double Dispatch: the next best thing with respect to Dependency Injection explores a little known technique for achieving collaboration between objects.
Practical PHP Testing Patterns: Testcase Class
Zend_Locale for the win shows a little bit of localization goodness built in Zend Framework.

Sunday, December 05, 2010

Weekly roundup: snowing and snowing

It's been snowing in Italy for several days this week. Working remotely however meant that it has almost no effect on my day-to-day activities, only on my presence at the university. Being able to work from home, when you can, may result in substantial money and time savings.

Here are my original articles published this week.
Practical PHP Testing Patterns: Four Phase Test - Arrange, Act, sssert, and Teardown.
Date and time in PHP 5, which shows you how to use the PHP native class DateTime.
Practical PHP Testing Patterns: Assertion Method
Zend_Validate for the win walks you through Zend_Validate out-of-the-box utilities and chains of validators.

Sunday, November 28, 2010

Weekly roundup: Matlab is ugly

I'm working more and more with Matlab for some university projects. If you want to know why PHP is successful, you can look at Matlab for a similar scenario.
PHP sometimes requires an ugly syntax and many inconsistencies, but it has so many extensions and batteries-included features (datetime extension, shipped database drivers) that you can get things done very easily.
Matlab it's the same on the engineering's scale: it's probably the only language designed by someone who does not know that arrays are universally accessed by square brackets [] and not by parentheses (). However, it has so many built-in goodness that you can rectify an image with 10 lines of code, if you know what you're doing.

Here are my original articles published this week on DZone.
Practical PHP Testing Patterns: Layer Test
Zend_Glossary, an hands-on glossary about the terms used in Zend Framework, like filter, validator, boostrap, etc.
Practical PHP Testing Patterns: Test Method
Meaningless docblocks considered harmful, which explains why you should not misuse your docblocks.

Monday, November 22, 2010

Paamayim Nekudotayim

I think that few will get it, but I am confident in the geekness of my readers (probably Italian are at an advantage here.)

Sunday, November 21, 2010

Weekly roundup: Agile Day insights

You always learn something new at conferences. The most valuable insight I got from the Italian Agile Day, held last friday in Genoa, was:
Building construction as a metaphor for software development is a frequent misunderstanding. In construction, you have an architect for the design phase and hundreds of workers for the actual construction. In software, the deliverable of the design phase is the source code, and the construction consists in an automated build. Therefore, you have no workers, and everyone is an architect. -- from the keynote of Paolo Perrotta
By the way, here are the articles I wrote last week, before heading for Agile Day.
Practical PHP Testing Patterns: Shared Fixture
Zend Application demystified
Practical PHP Testing Patterns: Back Door Manipulation
The best tools for writing UML diagrams

Thursday, November 18, 2010

Italian Agile Day 2010

Tomorrow I'm going to Italian Agile Day in Genoa. It is not a long trip, but I will wake up at 5 am.
If you want to chat, code or insult buzzword-obsessed professors together, look for me there.
Twitter stream: #iad2010

Monday, November 15, 2010

The PHPUnit Refcard is out

My PHPUnit Refcard is now available for download. Hope you enjoy it.

Do you occasionally forget the syntax for creating Mocks and Stubs in PHPUnit? Or wonder how a command line option work? Or if there is an assertion that may be perfect for the test you're writing? Then this Refcard can help you.

The Refcard is a PDF cheatsheet of 6 pages, which interleaves code samples with explaining test and sample outputs. Getting to know PHPUnit to use it at its full potential will be a little easier now. :)

Sunday, November 14, 2010

Weekly roundup: Refcard upcoming

It seems that my Refcard will be published tomorrow (November 15th). Follow to get a promptly update on publishing.

Refcardz are 6-page cheat sheet which you can use as a reference while programming.
For example, my team printed various copies of the Git Refcard when starting out with this tool. My Refcard instead is related to a popular testing harness.

Here are my original articles for this week.
Practical PHP Testing Patterns: Standard Fixture describes the concentration of fixture creation code in a single place, which eliminates duplication but may result in overgeneralization.
The Dark Side of Lean discusses Toyota's mindset, with the hope that Lean software development is different enough from it to avoid copying the Japanese work values. Which are: live to work.
Practical PHP Testing Patterns: Fresh Fixture describes the creation of new fixtures for each different test to run.
It's just like putting LEGO bricks together... Or not? in which the validity of LEGO bricks as a software metapho is discussed.

Sunday, November 07, 2010

Weekly roundup: TEDx edition

Yesterday I attended TEDxLakeComo, historically the first TEDx Italian event now in its second edition. TEDx is a spin-off of the TED global conference: a program of independently organized events which respect the spirit of TED: ideas worth spreading.
I think the power of TED and TEDx is in its wide variety of topics and speakers, that maintain are however connected in a single thread (at least in this edition). In a single day I attended talks about cloning, robotics, climate change, pandemics, and the free market. The world problems - energy, pollution, climate, economics -  are all more interrelated than I thought.

Here are my original articles for this week, published on Web Builder Zone.
Practical PHP Testing Patterns: Test Automation Framework
5 features of PHP that seem hacks, but save your life
From Doctrine 1 to Doctrine 2
Practical PHP Testing Patterns: Minimal Fixture

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:
$str = 'mystring';

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

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

$code = file_get_contents('monkeypatched.php');
$code  = 'namespace monkeypatching; ?> ' . $code;
echo $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. :)

Monday, September 27, 2010

Speaking at PHP Barcelona 2010

I'll be presenting my talk Architecture and testability in its English version at the PHP Barcelona Conference. I gave the Italian version of this presentation at phpDay in May.

This is the abstract:
Testing a web application may seem an hard task, but nowadays it is a fundamental part of the development process that ensures the application does not experience regressions, and it is free to grow incrementally. My point is that testability is a property which is desiderable not only for the ease of building an automated test suite, but also for the positive effects on the overall architecture that maintaining an application testable at the unit level produces. For example, being able to test a class in isolation is a sign of enough decoupling of it from the other collaborators, while keeping a limit on test cases length forces the production classes to be cohesive in functionalities.
The treated topics range from Dependency Injection to the Law of Demeter to the inherent evil Singletons and static classes. I'm a practical guy, so I will show you code; but not so much that it isn't readable.
This is an occasion for everyone who wanted to see my talk at phpDay, but wasn't there, to get a nice wrap-up about why making your code testable improves its design.
By the way, the conference will take place on the 29th and 30th of October, and a two-day ticket costs only 60€, of which I receive nothing. Hope to see you in Barcelona. :)

Saturday, September 25, 2010

Mentioned in Clean code talk

I have been mentioned in the Clean code talk by @avalanche123 as a source of informations, and with this quote:
"Refactoring is a natural part of coding. You don't explain to management why you need to write while and for loops" -- source
Since I tweeted this phrase in quotes ("), we can assume it is not an original work of mine. I guess I heard it in some presentation, probably of Uncle Bob. What kept me from including the source on Twitter was the 140 character limit.

My Master's Degree specialization is in Data Engineering, and finding quotes in videos is one of the common task for multimedia search engines we study and research on. Maybe one day we will be able to find this phrase's source video with a single click, in the same way as we google a term today.

Weekly roundup: back from Siena

Original articles
Here are my article for this week on Web Builder Zone.
How to set up the Pomodoro Technique in your office, which introduces the Pomodoro Technique as a tool for time management even for teams and not only for freelancers.
Practical PHP Patterns: Layer Supertype, which talks about the common practice of extracting superclass, which is not always beneficial as it seems at a first glance.
Why a Pomodoro helps you getting in the zone answers the common questions on getting in the zone while using the Pomodoro Technique.
Practical PHP Patterns: Registry, which presents the Registry as implemented by Zend Framework 1.x and its inherent issues.

Siena, the city of Palio
After four weeks as a Software Architect in Siena, I'm back ready to begin my new university courses. I'll continue working for Allbus remotely for some hours a week.
The experience has been quite interesting, as it was essentially what I am used to do on an open source project, applied to a commercial one. This is another benefit of contributing to open source: it prepares you for the challenges of your work.
Besides that, living in Siena for some weeks was delightful, because of the city's beauty and population density. Walking to work instead of driving a car was particularly unusual.

Saturday, September 18, 2010

Weekly roundup: reaching the conceptual contours

This week at Allbus we have been extracting methods, interfaces and classes all the time. We are hitting the point when the refactoring is paying off and we can finally remove old, duplicated and ugly code, never called in our new routines.
Never stop refactoring and eliminating duplication. The answer to How many lines of code have you written today? should be something like -100.

Here are the articles for this week on Web Builder Zone.
Is graceful degradation dead?, which discusses the issues in accessibility of popular websites and enteprise applications.
Practical PHP Patterns: Mapper, which introduces the sibling pattern of Gateway.
Practical PHP Patterns: Separated Interface is about the management of dependencies by careful placement of interfaces.
From Subversion to Git in a morning describes how we did the migration, comprehending svn:externals conversion to submodules, in a few hours.

Saturday, September 11, 2010

Weekly roundup: new academic year

After a vacation on Tuscany's beaches where I was totally disconnected from the Internet and work-related topics, I'm ready to start a brand new year, first with two weeks of consulting business in Siena and then with the Master's Degree program at Politecnico di Milano. I will also attend the Alta Scuola Politecnica program, an additional set of courses for the students selected in the top 7.5% ones of every ordinary course.

While I was away, some original articles of mine have been published, and they are listed here.
Selenium is not a panacea, which outlines the common issues encountered while using Selenium for acceptance testing of complex JavaScript-intensive applications.
Practical PHP Patterns: Database Session State, which discusses the storage of session data into a database compared with the more common solutions of using cookies or the server's memory.
Practical PHP Patterns: Gateway, which is a basic pattern for consuming an external resource in an object-oriented, testable way.
What paradigm should PHP applications embrace? is a poll which compares procedural, object-oriented and functional PHP functionalities. Feel free to express your vote.

Sunday, September 05, 2010

Weekly roundup: vacation time

I'm leaving again in Tuscany next week, but this time for vacation on the Tirrenian Sea. You'll continue to see my articles published on Web Builder Zone anyway.

Here are my original articles for this week.
The different kinds of testing. You know, all those buzzwords such as functional, unit, acceptance, integration testing have a precise meaning.
Practical PHP Patterns: Client Session State, an explanation on how to persist information on the client via cookies, forms or URLs.
Practical PHP Patterns: Server Session State, which you can contrast with the earlier post on Client Session State.
How to build a Kanban board, a practical tutorial with photographies.

Image credits.

Saturday, August 28, 2010

Weekly roundup: consulting in Siena

It has been a busy week in Siena, where I am doing consulting on web development topics. The most effective task in my work has been repairing the test suite of a PHP project and optimizing it for running in 1/5 of the original time.
On the whole, Siena is a beautiful city, with nearly no factories nearby and small enough for me to walk to my workplace through the historical part of city.

Here are my original articles for this week on DZone.
Practical PHP Patterns: Coarse Grained Lock
The wonders of the input tag in HTML 5
Practical PHP Patterns: Implicit Lock
NetBeans vs. Vim for PHP development

Sunday, August 22, 2010

Weekly roundup: double edition, packing for Siena

Last week I got caught in the Google search vs. Oracle joke and I couldn't do a roundup, so this one spans two weeks' worth of posts.
Anyway, I will be in Siena for the next weeks, for software consulting business.

Here are my articles written in the last two weeks.
WebML: overcoming UML for web applications
Practical PHP Patterns: Remote Facade
The buzzword glossary, a dictionary for frequently used generic words such as model, domain, role...
Practical PHP Patterns: Data Transfer Object
The shortest guide to character sets you'll ever read, which is fully exaplained by its title.
Practical PHP Patterns: Optimistic Offline Lock
Native jQuery animations, which shows what you can do with the jquery.js file only.
Practical PHP Patterns: Pessimistic Offline Lock

Friday, August 20, 2010

PHPUnit MockBuilder in master branch

A quick note: my MockBuilder class has been integrated by Sebastian Bergmann in the master branch of phpunit. The name MockBuilder reflects the nature of this addition, a Builder pattern for the mock objects, more than the original MockSpecification does.
He said it should be included in PHPUnit 3.5, the next minor version. I'll soon add some documentation by forking the phpunit-documentation repository.

Wednesday, August 18, 2010

Refactoring PHPUnit's getMock()

Not an actual refactoring, but at least the introduction of a layer of indirection, a Parameter object, called PHPUnit_Framework_MockSpecification. I have already written the patch in a branch of my github repository. They are actually two independent patches, since PHPUnit core and the mocking component are in two separate repositories:
All functionalities were Test-Driven Developed.

Use cases
The current API of getMock(), the Facade for the mocking library, actually prescribes 7 parameters. Most of them are optional, like in use case (a):
But if you want to specify an uncommon parameter, you have to include the previous ones, and hunt around for their default values, praying that you will get them right and insert the boolean or empty values in the correct order, like in (b):
return $this->getMock('MyClass', array(), array(), '', false);
In some cases (c):
$this->getMock('MyClass', array(), array(), '', true, true, false);
A Specification objectBuilder pattern, which I intend to propose as a feature request after getting some feedback from the community, will aid some of these use cases. For example a) remains the same: there is no need to complicate the API here.
For case b):
For case c):

State of development
I have currently implemented support for 6/7 of the getMock parameters in the MockSpecification object (only the autoload-related parameter is missing). This solution is an instance of the Builder pattern (I need a new name for MockSpecification, which started out as a parameter object but then acquired a getMock() method for a faster access to the created object).
Once the mock is created, it behaves exactly like an ordinary mock: MockSpecification calls getMock() internally.
This would be a totally backward compatible change, since it only adds a new way to creating a mock.

What I want from you
Any feedback, from glitches in the code to better names for the API methods and the class itself. I guess PHPUnit_Framework_Mock_MockBuilder can be the right name. Once tidied up the code, I'll open a ticket for a feature request on PHPUnit's trac asking to assess it and merge in the master repository.

Monday, August 16, 2010

The Flattr model

Following examples from Germany, I have integrated the Flattr buttons in this blog. I also reduced the only ad, an AdSense banner, to a small box on the right.

Basically Flattr is a micropayment system:
  • Users charge their account via Paypal or other means.
  • They flattr really amazing blog entries or useful articles they found on the Internet, when they want to repay the authors for their time and effort.
  • At the end of every month a small, configurable amount of money (like 2 or 10 €) is set aside. This is divided between all the flattered articles the user has selected.
Fixed expense, almost no barrier to micropayment once registered to Flattr (Paypal has fees that render donating something like € 0.10 impossible). We'll see how this work out.
If you also want to be flattered, try set up the system on your blog too.

Sunday, August 15, 2010

A public response to Gene Quinn on the "Google removed Oracle" forgery

My quick debunking of Google Briefly Punishes Oracle by Removal from Google Search has been retweeted a lot and even linked from Tech Crunch.
I can't reply on all the different web sites where Gene Quinn, the author, is "sticking to his guns" (I learnt a new English expression today) and say that we are all wrong.
So I'll summed up my thoughts here, with a response to one of his typical comments. The comment is nearly identical to one posted by him on his own article (particularly the bits about typing oracle instead of using a link and the screenshot as a proof), so we can assume it's authentic.
It is Tech Crunch, not me, that has been duped. 
Unfortunately, someone at Tech Crunch knows what Unicode is. You probably don't.
You can believe what you want, but I was not provided a link. I watched someone type “oracle” into Google search and this was what was produced. 
This does not imply anything - I can configure a keyboard to produce homograph cyrillyc characters when I press keys like a and o. Everyone who has ever installed a wrong keyboard driver knows that the characters printed on the keyboard are not electronically hardcoded and depend on a software configuration.
I requested a screen shot. So those, whoever they are (including Tech Crunch) that are claiming this is false are incorrect. Those saying I was sent a link with an intentionally malformed search term are likewise wrong.
This does not imply anything, again. Holy crap, Batman, you are an attorney, do you bring screenshots in court? I can easily make one by simply saving the page and modify the HTML source.
Furthermore, the provided screenshot shows exactly links to pages which contain the fabricated query, like Those pages are the only shown just because they were the only ones containing the oracle word spelled with 4/6 as Cyrillic characters. By now, the same query will include all the articles which talk about this story.
This is the freezed version of his article in case he decided to take the image down (basically this is a screenshot made by a trusted third party, And this is the freezed version of his screenshot:
If you try visiting the links, you will be brought to pages containing the fabricated query.
If Tech Crunch has any journalistic standards they would remove this post which offers nothing but speculation passed off as fact. My guess is that if and when Oracle makes this an issue during their litigation Tech Crunch will be printing a retraction. So, you have been warned. I am sticking 100% behind the report because it is true.
This is only FUD. You are expected to publish an amendment to your article, basing on the evidence about your own screenshot linking to a forgered query which explains everything. You may want to know that when you publish links in an image, people can actually following them by typing their URLs in the location bar of browsers.
Next step, you'll treaten me to take down my blog?

Saturday, August 14, 2010

Google never removed Oracle from its index

Some folks have been reporting a strange behavior assumed by Google after the lawsuit filed by Oracle against Android and Google: it supposedly removed pages, and all the pages that talk about Oracle, from its search index. Even the wikipedia page on the Delphic oracle.
I initially retweeted the news and explained that it was a trick shortly after.
It would have been a low shot, really. I don't think it's even possible to remove that large set of results on all the datacenters of Google in a short time frame.

What really happened
Someone made up this query:оrаcІе
Initially the result page was empty (Your search - ... - did not match any documents).  Then people began tweeting and sharing the query and Google started showing up them as the unique results:

So how did they do it?
At first I thought someone used a capital i (I) to substitute the L of Oracle, but Google is smart and would perform a case-insensitive search in this case:

Nevertheless, the difference between capital i and lowercase L is not so visible in Google's font.
But, if you try to paste the link or save the page and go over it with hexedit, you'll notice this:
This is clearly the sign that someone has inserted non-ASCII characters in the query.
The character table for Unicode/UTF-8 says that we have, in sequence:
This combination of characters is very unlikely to be found in actual documents. In fact, at first it did not produce results. Furthermore, in Google's font of choice, Arial, the difference between these letters and their latin counterparts (if there is any) is again not clear to the naked eye. It makes sense to reuse glyphs that are actually the same in ordinary printed text.
And finally, the forgery replaces the majority of the latin letters, because replacing only one or two would lead to a Did you mean: oracle notice.

Mystery solved
So UTF-8 struck again, and some of us were fooled by a ingenious, well-forgered Google query. Technically this is called an homograph attack.
The potential of UTF-8 as a dangerous mean of fooling users is great - imagine if non-latin URLs will become a reality. Fortunately, the ICANN and major browsers have been working on a solution, but we as web developers should be aware of the problem too.

Thursday, August 12, 2010

Get an ebook reader

Only if you enjoy reading books, of course.

I recently ordered a Bebook Neo, the European equivalent of the Amazon Kindle. It arrived from the Netherlands in two business days (there is no custom between European Union countries). It has wi-fi and an headphones jack if you want to listen to music, but these features do not interest me. I want to tell you about the reading experience.

As a programmer and engineer, I read a lot of books, on various subjects:
  • technical ones (Kent Beck, Martin Fowler, Uncle Bob...)
  • managerial ones (Peopleware, Agile Estimating and Planning)
  • science fiction (Asimov, Dune, Philip K. Dick...)
  • fiction (Zen and the art of motorcycle maintenance)
  • personal development (Getting things done)
  • cooking (well...)
For some of these books, I don't even know if an Italian version exist. Instead, ebooks (mostly in PDF format) are ideal to get them in their original English edition. For example, Packt Publishing sent me a PDF copy of some of their books for review in less than a minute from my registration.
Furthermore, there are other publications available in electronic format only, like DZone Refcards and free ebooks from SitePoint.

The only problem with reading ebooks is the device you use to read them. My Asus EeePC 701 (the first netbook in the market segment) is good for writing articles, and skimming blog posts, or for a bit of PHP programming by SSHing into my home machine. But for reading extensively, LCD screens will kill us.

First, there is backlight. You know when, as a child, you were told not to stare at the Sun? Here is the same mechanism, on a smaller scale. Direct light is sent from the LCD screen to your eyes, and over the minutes or the hours staring at it becomes not very beneficial for the eyes. Besides the protracted direct lighting, the LCD screen has a very different light intensity from the surrounding environment (from objects which do not emit own light, of course), which causes eyes to strain to continuously adapt between the screen and the rest of the world:

When reading a good book, I usually get in a flow state and do not make 5-minutes pauses, which sound innatural and break the natural page turn rhythm I am accustomed to since I was 6.
With an LCD, the brighter the environment, the less you see on the screen (outdoor you can't see anything, especially with modern glossy displays). With a e-ink screen like Kindle's or Nook's Bebook's ones, you have to actually provide external light to read. This is an advantage for e-ink devices, since you can easily provide light when it's needed, like you do for paper books. I do so with an abat-jour over my bed. On the contrary, it's quite difficult to obscure the sun if you want to read outdoors with an LCD screen.
As any library affectionate can tell you, an LCD-based device is not an ebook reader, period. Forget about iPads - those can make for wonderful trays for Martini glasses like my CD drive does, not for readers that do not cause headaches.

Second, there is the user experience. I used Evince, the Ubuntu equivalent. The ebook reader software is specialized and offers a simpler interface. Zooming have several acceptable levels and text is automatically reflowed to fit the pages. There's no fine tuning of the horizontal scrolling bar to have all the text visible at the same time, nor continuos adjustment of the vertical one; only two buttons to go to the next or previous page.

Third, there is battery life. I haven't still recharged my Bebook after the initial unpacking day more than a week ago. It basically consumes energy only for its idle cycle and during page turns. Requiring no own lighting mechanism, when you're reading a page it is essentially not consuming. Its charge is estimated to last between 4,000 and 7,000 page turns. In comparison, for my netbook I have a choice between attaching a cable to the nearest power outlet or using a half-kilogram battery.

Fourth, there is size and weight convenience: the internal memory of Bebook Neo is 512 MB and a book commonly occupies from 1 to 10 MB of storage space. This particular device has an SD card slot that you can use to expand the memory further: with 8-16GB of SD cards, you have practically infinite memory (unless you own the Library of Congress). You're helping the environment at the same time - I bet the material used for manufacturing an ebook reader and the energy it used during its lifecycle are a more efficient choice over printed books. If there are doubts, maybe we can recharge readers with solar panels. :)

Fifth, there is the absence of distractions. On my netbook, I'm one click away from opening my mailbox or twitter account. In the latest versions of Ubuntu, new messages from instant messenger buddies shows up as notifications (in some also Twitter mentions), and I have to close Pidgin or Empathy.

Sixth, it is very trendy. No one I know in Italy has an ebook reader. When people brag with their iPhones you can peacefully continue reading your favorite book and ignore them. :)

The downside of the solution is only its cost. A device from the Bebook series costs between 250 and 350 Euros. If you live in the US, the Kindle and the Nook are available and cost much less. Take into account custom duties if you decide to buy from another country.

These costs are comparable or inferior to those of netbooks, but ebook readers are much more specific devices. However, if you read a lot, embracing an ebook reader will give you all the advantages above.

Sunday, August 08, 2010

Weekly roundup: cooking

I dedicated my weekend to cooking pastries and meringues for the girlfriend returning from Sardinia. Software engineers are good chefs when they give their best effort in the kitchen, probably due to attention to the detail, dosages and practices (like using leftover egg whites for making meringues, which is a best practice of the domain.)

Here are my original articles published this week on the Web Builder Zone.

PHP inclusions on include(), include_once(), require(), readfile(), autoloading and so on.
Practical PHP Patterns: Application Controller
10 HTML tags which are not used as often as they deserve, which gained 12,000 views (and counting) at this time.
Practical PHP Patterns: Visitor, a pattern which was skipped in the original Gang of Four series on this blog.

Tuesday, August 03, 2010

Munchkin, learning Test-Driven Development in PHP

Mészáros Márton and other PHP coders have started a Test-Driven Development project centered on showing the methodology to new adopters in a green field. The goal of the project, named Munchkin, is creating a feed aggregator - like Google Reader - from scratch.

The authors will post a series of articles about their development process along the way. If you want to follow a step-by-step guide to implementing an Agile project with TDD in PHP, follow them.

Monday, August 02, 2010

We're not superheroes

I was reading bits of Coders at work, a book of interviews to famous programmers. I didn't like it very much: here's why.

The first thing I noticed is that many questions are biographical. I do not care about knowing if Ken Thompson, which built Unix, worked on a PDP-10 or a PDP-11 or a PDP-7. By the way, I do not even know how those things look like: I was born in 1988.

Besides that, this kind of books tells you how to live like a superhero coder, but most of us just aren't (me too).
Thompson could work out the design of software in his mind for a month before starting coding, I can't (or I can waste less time by writing something in code).
Knuth could design and code LaTeX in pencil and write for six months before do any testing. I can't (or I can, but I would be much more efficient with a quick feedback loop like Test-Driven Development's one.)
Zawinski could pick up rolls of duct tape and make Netscape work in six months (picking up also a lot of technical debt and vanishing from the market in the following years). I prefer working software over comprehensive documentation but not over sustainable development.

So we're not superheroes: test suites, source control, Continuos Integration are our bat-gadgets which enable us to deliver software while working for a living and not living for work, like Ken Thompson and his 28-hour days or Bill Gates and his nights at school programming. Let the people with the superpowers shoot webs all night long, while we go back to Wayne Manor and throw a party. At least Batman hasn't a day job: poor's Peter Parker must live a miserable life.

Saturday, July 31, 2010

Weekly roundup: vacations

I'm programming vacations, looking for a beach in Italy to go in September. Taking a break after a long period of working overtime due to university courses will be important to recoup energy.
You may have noticed I have returned publishing original articles also to this personal blog thanks to the free time I have now.

Here are the articles of mine published elsewhere on the web during this week.

Firebug is beautiful
Practical PHP Patterns: Transform View
A Dojo primer
Practical PHP Patterns: Two Step View

PHP 5.3.3 and 5.2.14 are out

Wednesday, July 28, 2010

Missing the point (OOP in scripting languages)

Yesterday I came across a question: Do Web-Scripting Languages Really Need OOP?
Here's my answer: only if you want to do more than an Hello World script (which is paradoxically how old school programmers measure the utility of a language.)
I'll express some of my thoughts without compromises, which will be up to you.

The author is equilibrated, as he saw the design simplifications that object-oriented programming introduces. However:
But our main point is that use of PHP constructs for OOP is a very “tradeoffy” and pragmatic decision, which we have often seen made more on the basis of religion or fashion. If you are comfy with OO, this kind of syntax is there for you; and if you work in a group that has decided to write in that style, you may want to let the majority rule. If you decide not to go OO, however, be strong—we urge you not to be swayed by the moral-superiority arguments you may hear from people who disdain your five-line procedural script in favor of their ten-line OO script that does exactly the same task.
This is not about 5 lines vs. 10 lines. If your projects are that long, go ahead. But hasn't the fact that every PHP framework is object-oriented told you something? The web is evolving from displaying documents to executing applications in the browser. The complexity will only increase in the future. When do you encounter 5-line script anymore?

What worries me are some of the comments:
However, in the PHP community there are very strong tendencies to cargo cult programming. Private methods and attributes make sense in Java, from where the idea was copied, but it adds little structural integrity in scripting languages (that's why Python eschewed them). But still, many PHP coders consider it "right OOP" to mark as many attributes as private as possible; neverminding that it only shadows underdesigned interfaces.
Private properties are available for encapsulation, not for structural integrity. I mark items as private so that I can change them in the future while only looking at the source code of their own class, and never worrying about external dependencies.
The likewise silly namespace\syntax also gets quite overused already. Deeply nested namespaces make sense in Java, but add little of the pleaded name conflict protection in PHP. It's just another syntax construct that gets used purposeless because it's hip. 
Namespaces are good because they remove duplication: you refer to the full class name (which can be quite long, such as Zend_Controller_Action_Helper or Zend_View_Helper_Url) only one time, at the top of your source file.

I'll give you one single reason to switch from procedural to object-oriented programming: seams.
In plain old structured programming, functions refer to other hardcoded functions, in a rigid graph. In OOP, object are (should be) wired at runtime, during their creation phase. It's this mechanism that makes practices like unit testing and polymorphism possible.

Monday, July 26, 2010

From static class to real object, and then from inheritance to composition

I'm refactoring Scisr, an automated command line refactoring tool, because it uses static classes as collaborators for the various Operation objects (Rename File, Rename Class, ...). In my refactoring, the static classes are becoming objects one at the time, and I inject those objects into the Operation ones.

Because of the quantity of collaborators, I am at the point where constructors are taking 5-6-7 arguments. But by no means this is a failure of Dependency Injection.

Using static classes means hiding the dependencies under the carpet, because you'll never know which objects access a static class from the signature of its constructor or of its setters. You must dig and look for :: operators (in PHP; in Java, for [A-Z]{1}[a-z]+\. or something like that; I'm glad Rasmus used a different operator for calling static methods).

Thus this refactoring uncovered a new code smell: the Operation objects have too much dependencies. Probably this is because common functionalities were refactored in abstract base classes instead of intermediate objects. This solution has great limitations, because the collaborators of an abstract class still must pass from the subclass constructor.
Furthermore, abstract base classes are not orthogonal: you can only inherit from one of them. Different functionalities end up in the same superclass only for convenience and not for cohesion.
The next step will be changing the design from this:
to this:
Possibly with more than one Collaborator, one for each use case where a subset of the old collaborators Db... were injected together. With this solution I hope to eliminate the explosion of the constructors of Operation classes.

Saturday, July 24, 2010

Weekly roundup: graduation week

Here are my original articles published elsewhere this week, between refining slides and receiving my scroll.

Practical PHP Patterns: Front Controller
JSP are more than templates
Practical PHP Patterns: Template View
Exceptional JavaScript

PHPDOCX: generating Word documents from PHP
ORMs and relational databases: powerful tools or dumb ideas?

I am Bachelor of Science and here's my thesis

Some updates on what's been going on here.
July 22th was the graduation day for the Bachelor's programs of Politecnico di Milano. I gave my presentation on my thesis project -  a multimedia search engine for musical videos which annotates songs with parameters like language, artist, lyrics and predominant emotion.

Video walkthrough (1:43)

Creative Commons LicenseMy thesis is now also available under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. It is in Italian, because the policy of Politecnico di Milano is to keep discussions in Italian for the Bachelor's programs (while many Master's programs are entirely taught and managed in English). The thesis contains many examples on Test-Driven Development and build automation, describing my experience with tools like JUnit, HttpUnit, Selenium, Ant, Equinox & OSGi.

Saturday, July 17, 2010

Weekly roundup: talk preparation

My next talk will be at graduation day on July 22th, in the Como campus of Politecnico di Milano. My long run towards the bachelor's degree is coming to and end and I still have to think about what to do with all the free time I'll gain now (apart working and open source).

Here are my original articles for this week.

Practical PHP Patterns: Repository
Web applications as enterprise software
Practical PHP Patterns: Page Controller
The absolute minimum you'll ever have to know about session persistence on the web

Ext4Yii, bridging PHP and JavaScript frameworks together

Sunday, July 11, 2010

Weekly roundup: returning to a personal project

This week I made some commits to a personal project of mine, NakedPhp, which aims to produce an implementation of the Naked Objects pattern (direct manipulation of domain objects via a generated user interface). It's quite nice to see that I was able to resume coding immediately thanks to the project's test suite, which covers both the acceptance and the unit levels. Tests are one of the best example of documentation you can maintain without hassle.

Here are my original articles for the past week.
Practical PHP Patterns: Metadata Mapping
Software engineering in the rail system
Practical PHP Patterns: Query Object
How to be a worse programmer, which has gained 17,000 views at the time of this writing.

Saturday, July 03, 2010

Weekly roundup: towards the PHP world

Next week I will hopefully be able to return to PHP, after having taken my last exam of the bachelor program at Politecnico di Milano next Monday, and waiting for the graduation day on July 22th.
My thesis is complete, as it needs only an abstract and a cover. I will probably publish it in the future, as it contains a good panoramic of acceptance-functional-integration-unit test practices (in Italian).
In the meantime, I continue writing as planned for DZone. Here are my original articles published this week.

Practical PHP Patterns: Concrete Table Inheritance
Web services in Java
Practical PHP Patterns: Inheritance Mapping
Web MVC in Java (without frameworks)

Saturday, June 26, 2010

Weekly roundup: Chansonnier is ready

This week I've completed the last user story (search term highlighting) on Chansonnier, my thesis-related project on multimedia search. Now I'm reviewing my thesis document with the goal of graduating in July and return to the PHP world.

Here are my original articles for this week.

Practical PHP Patterns: Single Table Inheritance
Lower your bar in Test-Driven Development
Practical PHP Patterns: Class Table Inheritance
The refactoring breakthrough on a CoffeeMachine, a post which gained little attention but that presents my approach to Test-Driven Development and refactoring on a little sample project from the ground up. If you wanna see how I work with TDD, this post also points to the related repository on github.

Open source life style

Saturday, June 19, 2010

Weekly roundup: getting to the end of my thesis

I almost finished the application which my thesis is a report on, and I'm getting to the end of writing it. I will probably publish it after graduation if I will be allowed to (not know what is the university policy), if only for the many testing insights for Java (OSGi) and web applications that I have inserted here.

Anyway, here are my original articles for this week.
Practical PHP Patterns: Embedded Value
Testing web applications with Selenium
Practical PHP Patterns: Serialized LOB
Client applications with Ajax Solr: JavaScript vs. servlets

Sunday, June 13, 2010

Yet another weekly roundup

With my thesis due for July and five exams in this month, I've had very little time. Fortunately, I have four original articles for you every week at DZone.

Practical PHP Patterns: Association Table
Death by buzzwords: The design viewpoint expresses the logical components and their structural relationships... My head explodes.
Practical PHP Patterns: Dependent Mapping
Getting to know Solr, Lucene done right

Sunday, June 06, 2010

Weekly roundup: new development box

After the death of my 512-megabytes-of-Sdram box, finally a replacement arrived that allows me to run Eclipse for Java development without issues (4 GB of DDR, dual core processor, motherboard from NASA).
Fortunately, Zend Framework 2 git repository has been created this week, so that I can still have some fun with vim and phpunit from the command line.

There are my original articles for the past week (all on DZone).
Practical PHP Patterns: Identity Field
OSGi and servlets can work together
Practical PHP Patterns: Foreign Key Mapping
CSS3 pseudo-classes

Saturday, May 29, 2010

Weekly roundup: giving back to Zend Framework

I've proposed myself for becoming the Zend_Debug maintainer for the 2.x iteration of Zend Framework. Actually it is composed by a single class, but since I don't know how much time I will have available in the next months I feel I can start from here, and alleviate a bit the workload of the most busy maintainers.
If you want to help too, join the zf-contributor mailing list.

Here are my articles for this week.
Practical PHP Patterns: Identity Map
Writing user stories for web applications
Practical PHP Patterns: Lazy Loading
Yahoo! Query Language

Thursday, May 27, 2010

What to do on weekends

At least, what I do on weekends in relation to software development, university and all my work-related projects and tasks. Feel free to add comments about your lifestyle and what you think of work-life balance: I think I finally found an equilibrium after all these years, without feeling guilty in my free time.

What I do on the weekend (when I have time)
When I have time because weekend is meant for resting, going out, drinking, partying... Still, you sometimes find yourself waking up at 10 AM on Sunday morning or find a free hour before going to a football game. How will this hour be spent?
I usually read books, monstly non-fiction, and articles from feed aggregator that built up until Saturday or Sunday.
I experiment sometimes, or start writing drafts for new articles. And I plan the goals and the required work for the upcoming week.

What I don't do in the weekend
I don't write code in the weekend: I know that even when I feel inspired writing code on Sunday, it would drain my energies for the subsequent week. There is a famous icon of the open source programmer that writes code in his free time, but free time shouldn't be oppressed by a todo list by definition. I schedule my contributions in the workweek, when I can establish a rhythm in my work and process also non-exciting programming tasks.
I never publish original content (something other than a link roundup) for the same reason. Brainstorming or writing a rough draft is simple when you have the inspiration and you want to capture some thoughts, but actually publishing it implies a polishing process (proofreading, formatting, editing...) that is boring to do when you're supposed to rest the mind.
A nice addition to this list now that I have embraced the Pomodoro technique: I never timebox on the weekend. This exclusion of free time from pomodoros is explicitly stated by the inventor of the technique.

As a sidenote, I never check email on purpose after a predetermined hour even in the workdays,or at least try to: now that I'm expecting feedback from eBay sellers I infringe the rule, unfortunately.
Since you wouldn't want to craft an answer to some complex question or start a new project following a late evening email, just don't check the inbox: reading such emails now will only result in worrying over the night. Having a different e-mail for work and life will be useful...

Image from Wikimedia Commons.