Sunday, December 18, 2011

Biweekly roundup: more and more languages

I am a PHP developer and a student by day, but I don't want to limit my options: I'm currently experimenting with Clojure and exercising with Rails. Each new language or platform teach us something general about programming; I advise you to abandon any prejudice if you decide to dive into a new language in your practice time (which for a PHPer programming Ruby is essential.)

Here are my articles published in the last two weeks.
What I learned in the Global Day of Code Retreat is a summary of my experience at the Code Retreat in Milan during the Decembed edition.
Practical PHP Refactoring: Remove Setting Method is about guaranteeing immutability or simplifying the interface of an object by throwing away a method.
Testing and specifying JavaScript code with Jasmine is an example of usage of the popular BDD JavaScript testing framework.
Practical PHP Refactoring: Hide Method is about information hiding: limiting the scope of a method to be able to easily evolve it later.
Practical PHP Refactoring: Replace Constructor with Factory Method transforms a giant constructor into several well-named Factory Methods.
Rails from the point of view of a PHP developer is about me trying out Rails 3 (again, without prejudices).
Practical PHP Refactoring: Encapsulate Downcast (and Wrapping) is about the PHP version of downcasting: converting primitives and wrapping them in Value Objects.
jQuery plugins with jsTestDriver is an example of real world JavaScript development with TDD.

Sunday, December 04, 2011

Weekly roundup: the code retreat

Yesterday was the Global Day of Code Retreat, an event where local groups of developers get together to hone their skills. It consists of six iterations of solving a problem (simulating the Game of Life) in pairs, where at the end of each hour the code is deleted and the pairs mixed. This combination enforces a focus on the method, not on the result; and allows to try out many different approaches (outside in, bottom up, functional and object-oriented languages, using no else or primitive types, closed eyes and an hand tied behind your back...)

I will write more about the experience in Milan in the next days on DZone. Here are my articles published in the past week.
Practical PHP Refactoring: Replace Parameter with Method is about simplifying a method's argument list by eliminating premature parameterization.
Clojure for dummies: a kata is the FizzBuzz problem implemented in Clojure, a now-popular Lisp dialect.
Practical PHP Refactoring: Introduce Parameter Object is about replacing a list of parameters with a single object.
HTML5 Drag and Drop uploading outlines how this technique works, when it breaks and how you can get it in your application in a few minutes.

Thursday, December 01, 2011

XPUG Milano, November 30th

Yesterday Uberto Barbini held the second part of his Agile Day presentation at the eXtreme Programming user group in Milan. Here are the topics of the talk and the discussion, that you can also follow on the slide deck.

At the conference (video in Italian), Uberto covered only part of the presentation, so he restarted from the half presentation check:
  • many bugs are caused by shared, inconsistene state
  • the procedural paradigm doesn't care how you organize state
  • OOP encapsulates state inside objects
  • functional programming expels state from pure functions.
An example of OOP went wrong was a MyBag object which allows read and write access to any item inside. The Singleton pattern used for no reason and the absence of any form of Dependency Injection are other common pitfalls: just because a piece of code contains many classes and methods it does not mean it is object-oriented.

The Blackboard
An interesting thing came up while this non-OO code was presented to us: we cannot judge a design without knowing which is the underlying problem it solves. While changing class names simplifies a slide, the same Blackboard metaphor can be implemented with wildly different results:
  • in the case of a list of actions to perform, it couples the actions in a certain order; the first or second action populates the blackboard for the other ones and cannot be moved.
  • in a distributed scenario, it decouples different processes from knowing the rest of the system, and allows new configurations.
Yet the scenarios are identical if not for the names of classes and methods.
The presentation went on to compare the object-oriented and functional approach as different tools for solving different problems: they are not always in competition, but code can contain a mix of both according to the problem at hand. For example, Uberto cited simulations as a really natural place for objects, and transformations of data into different formats (XML, JSON) as a call for pure functions.
This reminded me of the Expression Problem and of how new requirements favor either the functional or object-oriented solution.

Rebecca's book
I'm not sure I will understand the Centralized/Dispersed/Delegate control comparisons before reading Rebecca Wirfs-Brock's book on design, but an issue that came up is that this kind of books is disappearing, despite being very handy in teaching design. Today we see many technical books which teach how to code in Java or Clojure or Ruby, but not book on how to model and solve problems with code.

Elegance and familiarity
A final note is Rick Hickey's (inventor of Clojure) quotation:
Elegance and familiarity are orthogonal.
Just because we see functional code as strange and different from the object-oriented approach, it does not mean it's inelegant: probably just that we are not familiar with it. It is closed against different changes than the equivalent OO solution; and a functional programmer will see our objects as inelegant too.

PHPUnit_Selenium 1.1.1 has been released

Yesterday Sebastian reviewed my PHPUnit_Selenium master branch and release a new package in the phpunit PEAR channel. You can install it along with PHPUnit easily:
$ sudo pear install phpunit/PHPUnit_Selenium
Before this release, PHPUnit_Selenium was broken when used with PHPUnit 3.6.

I'm closing several more issues and I plan to cover with tests the 2K lines of code contained in the package: currently the test coverage is terrible. After the current features are covered, we can start thinking about supporting the Selenium 2 API (based on WebDriver). In any case, I will keep backward compatibility: support for WebDriver will come with another base Testcase Class.
If you want to contribute, consider providing tests for the functionality you are using. For example, the following areas are uncovered:

  • running Selenese tests
  • all the Custom Assertion methods
  • running tests in multiple browsers.

Acceptable tests comprehend an HTML page to use as a target and the actual test, written in Selenese or using PHPUnit_SeleniumTestCase. If you want your pull request to be immediately accepted, provide a test along with the rest of the code. You can take some inspiration from the existing ones in the Tests folder, which will serve as examples.

There is an undocumented, experimental feature in this release: call PHPUnit_Extensions_SeleniumTestCase::shareSession(true) in your bootstrap and the browser session will be shared between tests; a new session will be restarted only after non successful tests.
 It will be up to you to reset the state of the browser to perform new tests, and will leave the browser windows open after the end of the run: it's called experimental for a reason.

Sunday, November 27, 2011

Weekly roundup: PHPUnit_Selenium

I am now the maintainer of PHPUnit_Selenium, the PHP library for writing PHPUnit test cases that make use of Selenium RC to drive a real browser (usually to perform end-to-end tests). PHPUnit will continue shipping the library, and PHPUnit_Extensions_SeleniumTestCase will continue to be compatible with the Api in the manual.
Right now, you should use PHPUnit_Selenium in tandem with Selenium 2. Selenium 2 integrates WebDriver (not supported yet from PHP code) and implements the old Selenium RC Api, so it will continue to work and be maintained. If you encounter a backward compatibility break, open an issue.
PHPUnit_Selenium was not maintained and was broken in PHPUnit 3.6; with the next release, it will resume working. I'm integrating all sort of pull requests initiated during 2011, so if you want to contribute or to merge back one of your forks, you will be welcome!

Here are my original articles published this week.
Practical PHP Refactoring: Replace Parameter with Explicit Methods explains how to break up a method into a few, finer-grained ones.
Setting up a LAMP box with Puppet is an how to on writing Puppet manifests for provisioning packages and services like Apache, PHP and MySql in a machine (instead of writing long scripts containing apt-get, yum and /etc/init.d/ calls).
Practical PHP Refactoring: Preserve Whole Object explains how to pass an entire object to a method instead of extracting its state and passing a series of variables.
PhoneGap: native applications written in HTML is a review of a mobile application frameworks which promises to wrap your Ajax-based applications into an Android or iOS one.

Sunday, November 20, 2011

Weekly roundup: Italian Agile Day

Yesterday I followed via streaming the 8th edition of the Italian Agile Day, since I was unable to go to Rome for the event. If you speak Italian, stay tuned as many talks have been recorded and will be published (the event does not seek profit.)
Of course I missed the networking dimension of such a big event, but at least I enjoyed some talks on methodology while I am mostly a technical person. Look for the bottleneck!

Here are my original articles published this week on DZone.
Practical PHP Refactoring: Separate Query from Modifier is about respecting the Command/Query Separation principle.
Selenium 2 from PHP code explains which options you have right now for accessing the Selenium 2 (WebDriver) Api from a PHP script.
Practical PHP Refactoring: Parameterize Method explains how to unify different versions of a method in a single one with more parameters.
Creating a virtual server with Vagrant: a practical walkthrough is an howto for making Vagrant build a virtual machine with your OS and software of choice, instead of creating that machine and go through the installation process of an .iso image yourself.

Sunday, November 13, 2011

Weekly roundup: universal software development rules

This week, Kevin Schroeder from Zend collected responses to his tweet asking what are the universal software development rules. My take, cited there, is that there not many universal practices that you can follow. There are many conflicting metrics to measure the quality of a software piece, and their relative importance depends on the domain in which we are in.
For example, in development of embedded systems (which do not even run on general purpose microprocessors), many "clean code" practices like Don't Repeat Yourself and Keep It Simple Stupid are subverted. We may replicate the code for an operation to parallelize it and lower the response time of the system; we may micro-optimize operators and substitute multiplications with binary shifts. Power, energy and cost of a circuit come into play more than expressiveness of the code...

These are my original articles published this week on DZone.
Practical PHP Refactoring: Add Parameter is about adding an explicit parameter to a method instead of trying to look it up in a singleton or in some other place by itself.
Eventual consistency is everywhere in the real world contains a few examples of how eventual consistency (popularized in the programming world by NoSQL solutions) make many businesses work.
Practical PHP Refactoring: Remove Parameter is about simplifying a method by removing a parameter which is not needed anymore.
Web applications with the Play framework is a primer for the usage of a clean alternative to bloated enterprise Java stacks. And it supports Scala, too.

Sunday, November 06, 2011

Weekly roundup: a short Pomodoro presentation

Here is my Pomodoro Technique short presentation held at phpDay 2011 in Verona. It's not the same as the full one at PHP Barcelona, but it contains some frequently asked questions about Pomodoros along with some handy tricks.
Remember that English is not my native language. :)

Giorgio Sironi - An year of pomodoros - phpday2011 from GrUSP on Vimeo.

Here are also my original articles published this week on DZone.
Practical PHP Refactoring: Introduce Assertion is about the ancient usage of assertions, when they were embedded in production code instead of being segregated in an external test suite.
PHP on a Java application server is our experience with Quercus for running a PHP application on Resin. TL;DR: not really working.
Practical PHP Refactoring: Rename Method is about making method calls easier to follow: when a method's name is really explanatory you don't have to read into its body to understand what it does.
Using a virtual machine to play with multiple versions of PHP is a tutorial on setting up a VirtualBox machine with PHP 5.4 (the newest unstable version).

Sunday, October 30, 2011

Weekly roundup: the Pomodoro Technique in Barcelona

Here are the slides of my talk The Pomodoro Technique at PHP Barcelona last Friday. If you have found it interesting, remember to rate the talk on I'd like to thank all the staff (who also gave away a Pomodoro Technique Illustrated book) and the audience, which was very interested and involved in the topic.

Here are my original articles that I published this week before the conference.

Practical PHP Refactoring: Replace Conditional with Polymorphism is the cornerstore of the elimination of conditionals.
Getting started with Selenium 2 is a primer for the usage of WebDriver, only with the official Java bindings for now.
Practical PHP Refactoring: Introduce Null Object explains the creation of an object dedicated to special cases.
I've had enough of running Scala in a terminal, let's try with a web application is the first step in my quest to develop for the web in Scala.

Sunday, October 23, 2011

Weekly roundup: going to Barcelona

I'm leaving for Barcelona on Thursday afternoon for the PHP Barcelona 2011 conference and I will hold my talk on the Pomodoro Technique on Friday morning. Feel free to ping me if you will be there, I like to discuss about the themes treated in my writings. :)

These are my original articles published this week on DZone.
Practical PHP Refactoring: Remove Control Flag is about refactoring from a boolean variable to statements like break and continue.
A look at Dart from the eyes of an OO programmer is my opinion on Dart.
Practical PHP Refactoring: Replace Nested Conditionals with Guard Clauses explains how to simplify a complex conditional before starting to extract objects.
Tell, Don't Ask in the case of a web service is a practical case of changing a design from a getter-based style to a Tell Don't Ask one.

Sunday, October 16, 2011

Weekly roundup: hardware design vs. Continuous Integration

I'm taking a course in ubiquitous computing where we are studying hardware design. It's interesting how a common methodology reminds me of waterfall - each phase from the behavioral specification to the logical synthesis (where you decide how many and, or and not to use) contains a thorough verification step.
The reason is simple - the last phase, the actual production of a custom integrated circuit is very costly (hundreds of thousands of Euros). So iterating a design including this phase is not possible at all.
In software, it's a bit different. We can afford a dedicated server that builds our application dozens of time each day.

Here are my original articles published this week on DZone.
Practical PHP Refactoring: Consolidate Conditional Expression is about extracting code from conditionals and applying polymorphism when possible.
What I have learned at DDD Day is about my experience at a conference on enterprise software, mostly oriented to .NET.
Practical PHP Refactoring: Consolidate Duplicate Conditional Fragments is about avoiding duplication even in ifs.
OAuth in headless applications explains how to access Facebook, LinkedIn and other Apis when the user can't continuously authorize your application.

Tuesday, October 11, 2011

DDD Day slides

Here are my slides (if you can call them slides) for the DDD Day of Saturday in Bologna. The audio+slides playback will be available in the next weeks.
Note that the talk was oriented to an audience who knows what Domain-Driven Design is, but hasn't really worked with PHP yet (Java and C# developers).

Sunday, October 09, 2011

Weekly roundup: DDD Day

From this photo, you almost cannot see that I was rasmussed by Greg Young
I've returned from the DDD Day, the Italian conference on Domain-Driven Design. I learned some concrete tips ad techniques in spite of the event being oriented to .NET and frequented by C# and Java programmers.
In fact, as Alberto Brandolini said in the morning, DDD is also about the method, not really about the technology; and the differences in technology between imperative object-oriented languages such as C# and PHP are not so high.

Here are my original articles published this week on DZone.
Practical PHP Refactoring: Replace Subclass with Fields is about the inverse move of refactoring from type codes.
The Goal of software development is an exposition of Goldratt's work applied to software development.
Practical PHP Refactoring: Decompose Conditional is the first article about dealing with ifs and possibly targeting polymorphism.
Temporal correlation in Git repositories contains the code for discovering which classes usually change together in the history of your codebase.

Sunday, October 02, 2011

Bi-weekly roundup: DDD in PHP

I'm wrapping up my presentation for the DDD Day in Bologna and beginning rehearsals. Since I am involved in the project as a software architect, I will talk mostly about the technical side (it's DDD in PHP, not DDD in transportation and rental companies.) Wit respect to Java and C#, we will take a look at the differences in the language, in the platform where they are run and in the Domain Model.
See you in Bologna on October 8th.

Here are my original articles published in the last two weeks.
First week
Practical PHP Refactoring: Replace Record with Data Class is about substituting data structures provided by the language or libraries with an object coded on your own.
Practical Google+ Api is a guide to get you up and running in coding for an application using Google+ as a data source.
Practical PHP Refactoring: Replace Type Code with Class is about substituting a field value with a new object.
Phar: PHP libraries included with a single file is self-explanatory: Phar is the equivalent of Jar for the PHP world.
Second week
Practical PHP Refactoring: Replace Type Code with Subclasses expands on the type code miniseries, by adding subclasses to the one containing the problematic field.
Cross-Site Request Forgery explained is my take on this security issue, providing three ways documented in the literature to avoid it.
Practical PHP Refactoring: Replace Type Code with State or Strategy is the third option for eliminating a type code: transforming its values in a hierarchy of State objects.
Pretotyping: a complete example describes my experience with Who Disagrees With Me? and all the data I collected, which suggests a very focused audience but a descending trend.

Friday, September 23, 2011

Who disagrees with me? Fourth and final issue

I've just sent the fourth edition of the Who disagrees with me? newsletter, a pretotype for an aggregator of challenging links aimed to burst the filter bubble and confirmation bias. If that sounds obscure, consider as an example picking a PHP programmer like me and showing him where Ruby (or Java, or JavaScript) beats its preferred language. Ignoring the fact does not make the PHP programmer any better...
With this fourth edition I conclude the experiment of the newsletter and start thinking about a web application; I will take a look at analytics and subscriptions/unsubscriptions to see what has been the level of interest in the last weeks to see if the idea can be pursue further.
Please your opinions and criticism about Who disagrees with me? and these four issues in the comments.

Sunday, September 18, 2011

Weekly roundup: speaking at DDD Day

On October 8th I will speak at DDD Day in Bologna, an Italian event for Domain-Driven Design practitioners. The topic of the talk is DDD in PHP: which part of the approach changes with the programming language and platform, and which stay the same.
The abstract (in Italian, as for the talk) follows.
Cosa cambia nell'applicare Domain-Driven Design quando si passa da un linguaggio fortemente tipato e compilato come C# o Java ad uno dinamico e interpretato come PHP? Ci sono differenze ancora più subdole: il tempo di residenza degli oggetti in memoria è molto diverso, così come il livello di sviluppo degli ORM; per non parlare della differenza di mentalità fra gli sviluppatori, abituati a siti pubblici invece che a domini (applicativi) aziendali. Passare ad un linguaggio veramente diverso ci fa capire quali sono le parti di DDD che importano solo dal punto di vista tecnico (che quindi possiamo trascurare), e quali sono invece i concetti che non cambiano mai.
Here are also the links to my articles published this week on DZone.
Practical PHP Refactoring: Encapsulate Field
Backbone.js: MVC in JavaScript
Practical PHP Refactoring: Encapsulate Collection
Web typography in 2011

Friday, September 16, 2011

Who disagrees with me? Third issue

I've just sent to subscribers the third issue of Who disagrees with me?, the newsletter providing a weekly article guaranteed to challenge the assumptions of your preferred programming language. There are still 5 different editions - PHP, Ruby, C/C++, Java and JavaScript.
Last week I got a feedback on Google+ about subscribing to multiple Preferred technologies. It would definitely be handy, but I can't change the setting now without losing the data from already subscribing people. It's something to keep in mind in case this becomes something more than a newsletter.
Who disagrees with me subscription

Sunday, September 11, 2011

Weekly roundup: ergonomics

I've been using a mouse not at the same height as my keyboard for years: it took different pains and a transition to Vim (where the mouse is useless) to realize that the ergonomics of my main workstation was not excellent.
OSHA (I trust the US government on these issues more than the Chinese one) has a checklist for checking your own work desk, along with links to further explanations and pictures of good and bad setups.

While you're checking and avoiding a Carpal Tunnel Syndrome, take also a look at my original articles published this week on DZone.
Practical PHP Refactoring: Change Bidirectional Association to Unidirectional
All the Git hooks you need
Practical PHP Refactoring: Replace Magic Number with Symbolic Constant
Future JavaScript, today: Google's Traceur

Friday, September 09, 2011

Who disagrees with me? Second issue

I've just sent to subscribers the second issue of Who disagrees with me?, the newsletter providing a weekly article guaranteed to challenge the assumptions of your preferred programming language.
After two weeks and a half from the launch of the pretotype, the newsletter has grown to 5 of the 6 technologies available: there is a C, Java, JavaScript, PHP and Ruby edition.
I plan to prepare two more issues for the coming weeks before wrapping up the experiment. The result would be either the start of a new website or the end of the service, depending on user response (that's you!).
Who disagrees with me subscription

Tuesday, September 06, 2011

Automatically assign constructor parameters to private properties

In Scala, a JVM language, constructor parameters become private fields of the class, by default:
class Person(age:Int) {
  def grow() = {
    age += 1
I find it handy, as I always use private properties which are the target of dependency injection, in particular constructor injection.
Here's how to emulate this functionality in PHP, with great hacks. I post this code here so it won't be lost in the interwebs.

Sunday, September 04, 2011

Weekly roundup: speaking at PBC 2011

There is no official schedule yet, but speakers are beginning to confirm their presence to PHP Barcelona 2011. I will be there, with my talk on the Pomodoro Technique, a time management tool inspired by eXtreme Programming/Agile methodologies and widely diffused also outside of the software development field.
I also have seen confirming Juozas Kaziukenas, Stephan Hochdörfer, and Marcelo Duarte from iBuildings. See you all in October in Barcelona!

Meanwhile, here are my original articles published this week on DZone.
Practical PHP Refactoring: Duplicate Observed Data is a refactoring associated with moving fields from the presentation layer to the domain one, in the cases where their values take part to the execution of some logic, like validation or a change in state.
There's no reason not to switch to DocBlox is an overview of an Api documentation generator for PHP 5.3, which together with phpdox will replace the older phpDocumentor, not maintained anymore.
Practical PHP Refactoring: Change Unidirectional Association to Bidirectional targets the transformation of a pointer between two objects in a bidirectional reference, where each object can navigate the graph towards the other.
Offline web applications: a working example is, in fact, a working example of an HTML5 application that you can load in the browser once and then use forever after severing the connection with the server, or closing and reopening the browser. The goal of course, is to make a comparison with native mobile applications.

Friday, September 02, 2011

Who disagrees with me? First issue

I've just sent to subscribers the first issue of Who disagrees with me?, a service providing a weekly link to an article guaranteed to challenge your thinking.
For example, readers who have subscribed to the PHP edition (selecting PHP as their preferred technology) are getting an article describing an advanced feature of Ruby that PHP lacks by construction.

If you want to jump on board, subscribe. I am pretotyping this service by selecting links manually: if there is a recurring interest in the list, I will transform it into a website covering other areas too (economics, or maybe music).
Who disagrees with me subscription

Wednesday, August 31, 2011

Between Pomodoros

In the Pomodoro Technique, work is timeboxed into interval of 25 minutes. Between two Pomodoros, there is always a small break which lasts up to 5' minutes: here's what I (try as much as possible to) do during the breaks.

A note: this list is valid for short breaks, while they won't fill longer breaks like a 15' one.
  • 10 pushups: easy, fast, move your arms and legs after a long period on the chair. Or 10 squats, 10 exercises; you get the idea...
  • Refill my water glass from other rooms.
  • Check lighting and temperature to make sure there is no glare on the screen, or the windows do not need adjustment.
  • Adjust the chair and the position of the screen or the keyboard. 
  • Go to the bathroom, also for washing teeth or my face.
  • Unpack my bag.
  • Check phone for urgent messages (only urgent ones).
  • Get up and walk around a bit. Sitting too much tires me.
Here's what I don't do:
  • Engage in mental activity, like explicitly solving problems. Although I find that often since my hands cannot use the keyboard my brain starts to work on autopilot on the last Pomodoro's topic.
  • Browse the web. I try to rest my eyes and focus.

Monday, August 29, 2011

Pretotyping Who disagrees with me?

I am pretotyping a new web site, Who disagrees with me?, in order to find out if the basic idea behind the service is viable or if there is no interest at all.
Who disagrees with me subscription

The idea
A filter bubble is a controversial concept developed by Internet activist Eli Pariser in his book by the same name to describe a phenomenon in which Internet search queries selectively guess what information a user would like to see based on the user's past search history and, as a result, searches tend to play back information which agrees with the user's past viewpoint. According to Pariser, users get less exposure to conflicting viewpoints and are isolated intellectually in their own informational bubble.  --
I have refined my RSS reader, Twitter and Google+ accounts so much that I never encounter something that challenge my views. For example, I get PHP-related content all day; but I am learning much from reading 7 languages in 7 weeks and being exposed to Ruby or Prolog. I suggest to view the short TED talk (9') from Pariser for a longer explanation of the phenomenon and its issues.
While this filtering is definitely useful for singling out an appropriate slice of the Internet cake, it menaces growth as I always threading on the same subjects. Most of the new content I see comes from personal blog and accounts, which are by definition free to link to links they find interesting.

When building a web service an engineer typically starts from designign a data or object model, or from the algorithm that will find challenging links by starting from a set of references. And it must be an adaptive algorithm, that improves as the user gives out more information on his preferred technology, economic policy, or music.
But that's not what to start from: coding the perfect algorithm won't suffice if there is no one interested in using it. Pretotyping consists in narrowing down the scope of a product (like in an MVP) and even faking the existence of the product in order to check the market viability. Will people be interested in reading a challenging newsfeed, or they will prefer conservative filters and I will waste my time buying a domain name and coding?
I want to validate my idea by spending the minimum amount of time and money.

In my case
Instead of a continuous feed of information like for Facebook or Twitter, I limited the pretotype of the service to a single, weekly e-mail containing links. I also limited the category to a single choice: preferred technology.
I started preparing a subscription form with Google Docs, but I switched to MailChimp, a newsletter service, due to the support for verification emails.
I'm using a mixture of two pretotyping strategies described in the book: the Mechanical Turk and the Re-label; they are viable thanks to the very limited scope of this trial. The Mechanical Turk means I will write the weekly emails by hand, not select links with an automated algorithm. Re-label means I'm using an existing service (MailChimp) to take care of the subcription part.
What I'm saving here? The time to build a complex algorithm and a website with a 2nd level domain and an authentication system to store user preferences.
My metrics will be the initial subscription level compared to the number of view and links this post get, and the returning users of the service (people who do not unsubscribe in a month, for example.) MailChimp is adequate for measuring both, while Google Analytics will count the unique views this post get.

What will happen?
The two extremes of the spectrum are:
  • no one submits the form. The service is a crappy idea, because everyone wants to read interesting articles and not from other fields. In this case I have saved my time and I have discovered the idea was not really valid with an expense of just 4 Pomodoros (2 hours, with the time spent writing this post included) and no monetary investment. If it fails, it's normal: most of new ideas fail.
  • I get a good amount of subscription, which do not quit from the newsletter for more than a month (let's say 4 issues). In this case I can move to coding and build a real prototype.
Stay tuned, and share this post with friends if you think they are interested...
Who disagrees with me subscription

Sunday, August 28, 2011

Weekly roundup: pretotyping

I've read the pretotyping free book in one sit: I first came into contact with the concept, while watching a presentation of Patrick Copeland on innovation. At the same time I'm reading the Blue Ocean Strategy, and all this inspirational content has made me thinking about pretotyping a web application related to language learning in the next week.

But I also continue to write on DZone. Here are my new posts.
Practical PHP Refactoring: Change Reference to Value
Edge Side Includes with Varnish in 10 minutes
Practical PHP Refactoring: Replace Array with Object
Raphaël: cross-browser drawings

Sunday, August 21, 2011

Holidays roundup: 2 weeks of PHP and client side

While I was away, my editor continued publishing my articles on DZone. In the last period I am trying not to focus too much on PHP but also on client side technologies; in this case, CoffeeScript and SASS, but usually JavaScript.

Here are my original articles.

First week
Practical PHP Refactoring: Introduce Local Extension is a technique for adding behavior to a class whose source code is not available for modification.
CoffeeScript: a TDD example is an introduction to CoffeeScript that explains how to work with Test-Driven Development in this JavaScript abstraction.
Practical PHP Refactoring: Self Encapsulate Field is about hiding fields even inside a class.
The fastest browser poll: results shows which browser is considered the fastest by developers who read DZone.

Second week
Practical PHP Refactoring: Replace Data Value with Object is about the introduction of a class in place of a scalar value.
Object Calisthenics is an exercise to improve object-oriented design basic skills. My results and code are attached.
Practical PHP Refactoring: Change Value to Reference is about changing the lifecycle of an object from a simple value to a unique object.
Syntactically Awesome Stylesheets is an introduction to SASS, a language that compiles to CSS.

Sunday, August 07, 2011

Weekly roundup: Barcelona

I'm returning to Barcelona, this time for vacation in the nearby Calella. I'm also submitting proposals for PHP Barcelona 2011, and I hope to be selected for the conference in October. Last year's audience was really active in questions during my talk Architecture and testability and large in number.

Here are my original articles published this week. Even while I will be on vacation, my editor will continue to publish my articles.
Practical PHP Refactoring: Remove Middle Man
PHP 5.4 features poll: the results
Practical PHP Refactoring: Introduce Foreign Method
Assetic: JavaScript and CSS files management

Sunday, July 31, 2011

Biweekly roundup: The Goal

What is the goal of a business organization? To make money, or in a software development sense to provide value.
More precisely, in the case of a software development team, to deliver as many features as possible (throughput) while minimizing the developers time (operational expenses) and the amount of Work-In-Progress features which are stuck inside the development or testing phase without having been deployed (inventory).
The Goal: A Process of Ongoing ImprovementI'm reading The Goal by Eli Goldratt (and apparently I am the only one at ASP), the book that introduced the Theory of Constraints and transformed these goals into a process for improving production. It's really fashionary these days to transport industry-related concepts into software development. :)
The lesson I am learning so far is that targeting the wrong metrics, like the amount of time worked by each person, is not what moves us towards The Goal. Code coverage is one of our tools, but if our software never gets deployed it is the most useless of metrics.

While I'm finishing the book, please enjoy my articles published in the last two weeks.
First week
Practical PHP Refactoring: Move Field is about moving private members between nearby objects.
What new feature in PHP 5.4 is the most important to you? is a poll on the release candidates of PHP 5.4
Practical PHP Refactoring: Extract Class is one of the most underused tools for isolating logic.
Phantom JS: an alternative to Selenium is an headless browser we experimented for end-to-end testing of web applications.

Second week
Which browser do you consider the fastest? is a poll on current browser speeds.
Symfony 2 from the eyes of a ZFer is my first date with the new framework.
Practical PHP Refactoring: Inline Class is about Extract Class performed in the opposite direction.
Practical PHP Refactoring: Hide Delegate tells us one of the ways to follow the Law of Demeter.

Tuesday, July 19, 2011

Hardware metaphors

Computer metaphors do not always work well in real world.

Here's an example of a metaphor that produces good results when transported in life: RAM vs. permanent storage. Each productivity system (e.g. Getting Things Done) worth its salt recognizes that our brains have limited RAM and we cannot keep in mind too many things at once. But we can use what is called an exocortex - an extension to our brain to augment our capabilities - namely, the Internet, but even a sheet of paper where to write our calculations, or diagrams.
One of the uses of the exocortex is storage: a simple paper notepad that is always with you will be able to function as an hard disk, and your brain RAM will be freed and available for other purposes. The point is not only to avoid forgetting an idea or a TODO, but to avoid worrying about forgetting at all.

Here's an example which doesn't work. Real time notifications are more and more embedded in our system; the sources of input are instant messaging system like email and Twitter. Technology does wonder: compare snail mail to an email being delivered in seconds.
Yet we find ourselves avoiding the wonderful technology of real time communications: interruptions are considered a menace for our flow and our Pomodoros. In order to get large batches, I visit GMail only few times a day, and I'm working on lowering this number; I avoid any kind of GMail or Twitter applet in my panel (although they may work for managers: I'm talking about creative work as put in danger by interruptions).
Polling is often a waste of CPU cycles for computers, and in fact they are built from the ground up on an event-based model: hardware interrupts. Yet the model fails miserably when, due to the inability of humans to multitask like a machine.

Sunday, July 17, 2011

Weekly roundup: Uncle Bob's inspiration

From Robert Martin's pragmatic podcast:
Certainly employers will coem to you and say "Geez, you're doing such a good job programming, let's have you not program. You should go in management where you can make the real money." And of course that happen to me as well, but I could never take my fingers off the keyboard [...] even while running a company, I still write code and I write it a lot.

Here are my articles published during this week.
Practical PHP Refactoring: Substitute Algorithm is about changing an algorithm without impacting the rest of the codebase.
HATEOAS, the scary acronym is a list of metaphors for understanding this REST concept.
Practical PHP Refactoring: Move Method is one of the first larger-scale refactoring we can make to PHP (and non-PHP) code.
Unit testing JavaScript code when Ajax gets in the way describes isolation techniques for, well, testing JavaScript code.

Sunday, July 10, 2011

Weekly roundup: PHP.TO.START

I'm packing up some gear (and some dinner) for my trip to Torino for the PHP.TO.START. The path from Porta Nuova station to the event is in the most central area of the city, so I'll take a walk in the morning; maybe I'll try the metro for the return trip, which (unlike the Milan one) is very modern and completely automatic.

Here are my original articles published during this week.
Practical PHP Refactoring: Remove Assignments to Parameters is a small scale refactoring to ensure the values of parameters remain invariants of a method.
Testing JavaScript when the DOM gets in the way uses jsTestDriver for testing JavaScript code which manipulated divs, inputs and other HTML elements.
Practical PHP Refactoring: Replace Method with Method Object describes how to extract a too complex method as an object of its own.
The era of Object-Document Mapping is a snapshot of the current Doctrine tools for mapping PHP objects to a NoSQL database.

Friday, July 08, 2011

PHP.TO.START - July 11th

I will be in Torino on Monday for PHP.TO.START, a day-long event oriented to PHP businesses and university students. The event would be in Italian and has been created by Indigeni Digitali and
Who wants to work with EJBs if you can work with PHP? :)

Subscription is mandatory and closes on Sunday. I will make the trip with the 8:00 AM Freccia Rossa if you're coming from Milan.

Thursday, July 07, 2011

The ultimate web 2.0 note-taking tool

It's always with you, because it fits in your pocket. You don't have strange synchronization processes which would eventually overwrite something. It does not require an Internet connection, so it works everywhere free of charge. It does not force you into a textual form or anything, you're free to draw mind maps or graphs.
And it is web 2.0, if you buy it on eBay (not suggested due to shipping costs).

No seriously, leave out the web 2.0 part. The fact is that the information I keep in this notepad has a cycle that goes from written to discarded of some days at maximum: I write on it Google queries I should make, ideas and exercises got from books that I should explore, or titles of articles to write.
Since I do not have to keep these information around for long, there are no disadvantages with respect to a digital form. I'll never write an article on it, but for my reminders works pretty well.

Sunday, July 03, 2011

Weekly roundup: Agcom

It seems that Italian regulators understand just enough of the Internet to craft meaningless measures. The recent proposal for arbitrary removal (without the intervention of a judge) of content from Italian websites would extend the YouTube doctrine to all Italian websites: after a suspect violation of copyright, the related pages have to be cautionarily deleted (or the website's ip and domain name be blocked, if you're wondering how); after a controversy, maybe someday you'll get your content back. Maybe.
This regulation is either a a) copyright protection gone bad or b) a censorship act. In the former case, is like sending SWAT teams to expropriate children tapes, because they may contain copied songs (or they may not; but we'll confiscate them just in case.) In the latter, it's just a way to take down everyone that does not lick the government's ass and transforming the Internet in Mediaset. I don't know which is worse.
To make an international comparison, we are on the level of absurdity of the DMCA, although this issue is not related to DRM systems; the DRM system here is simply blocking Internet addresses.

By the way, here are my articles published this week (unless some prankster says I have infringed his trademark on the Self-Initializing Fakes term and they are taken down):
A week without Flash
Practical PHP Refactoring: Introduce Explaining Variable
Self-Initializing Fakes in PHP
Practical PHP Refactoring: Split Temporary Variable

Image of the Students for Free Culture movement.

Sunday, June 26, 2011

Bi-weekly roundup: Practical PHP Refactoring

I didn't have much time last Sunday, so here's a roundup of my articles that cover the two weeks just passed.

In the first week, I started a new Practical PHP Refactoring series, as suggested by @_odino_ as a continuation from the Practical PHP Testing Patterns one.  The level of interest is comparable between the two series, so I feel it will go on.
Practical PHP Refactoring: Extract Method is one of the basic tools of the code surgeon.
Parallelism for dummies explains how parallelism affects our programmer lives at various levels, from multi-core processors to clusters of servers.
Practical PHP Refactoring: Inline Method is the simmetrical refactoring.
Automated code reviews for PHP is an introduction to PHP quality assurance tools that you can include in your build.

In the second week, 
Practical PHP Refactoring: Inline Temp is about eliminating unnecessary abstractions.
Monitoring on Unix from scratch is an overview of the tools for logging CPU, memory and I/O utilization bundled on Linux and similar systems.
Practical PHP Refactoring: Replace Temp with Query is about keeping methods short by extracting the calculation of variables into other methods.
I don't know how to test this makes the point on the importance of learning testing skills, and gives you lots of tips from my experience on web applications.

Image courtesy of Ildar Sagdejev.

Sunday, June 12, 2011

Weekly roundup: referendum day

Today (and tomorrow) Italian get the chance to vote in a referendum on nuclear power, water privatization and whether politicians can go on trial. #IoHoVotato (I have voted) was a worldwide trending topic this morning on Twitter.
For the referendum to be valid, more than 50% of the citizens must vote. If you are Italian, you have the chance to do so up to the 15 of Monday.

To cheer you up after you return from the voting booth, here is the list of my article published this week on DZone.

Practical PHP Testing Patterns: Generated Value is the last pattern for prodiving expected and input values in tests.
On commits and commit messages is an analysis on commit ACID properties and on the lost art writing messages.
Practical PHP Testing Patterns: Dummy Object is a specialization of the Test Double pattern.
The Victorian Internet, and the Victorian social networks tells the story of an invention that predates the Internet and had a similar, and probably greater, social impact.

Sunday, June 05, 2011

Weekly roundup: a new Practical series

We're getting to the end of the Practical PHP Testing Patterns series, which followed the Practical PHP Patterns one in exploring by-the-book patterns (by the Gang of Four, Fowler and Meszaros) in their application to PHP code. It all started with the Practical PHP Testing ebook, with a simple tenet: working code sample at the end of each chapter/article.

Since these series have gained the trust of many readers, I'm thinking about a new Practical-branded series. The format has worked pretty well: one small topic treated from theory to code sample, twice a week; the level of views is constant and that tells me there is interest.
So what would you like to see after our joruney in design, enteprise application architecture and testing patterns?

Meanwhile, here are my articles published this week on DZone.
Practical PHP Testing Patterns: Literal Value is the simplest pattern for dealing with example values in tests.
The Kindle is ready for programmers is a review of the Kindle from a programmer's point of view. Some people told me that this article addresses their doubts regarding using a Kindle for technical books.
Practical PHP Testing Patterns: Derived Value describes the practice of generating input or expected values for your tests on-the-fly.
PHPSpec: BDD for your classes is a review of PHPSpec and its approach to Behavior-Driven Development in the small.

Thursday, June 02, 2011

Choosing pronounceable names

It's not a w, it's an omega. If you have a background in engineering like me, you are familiar with the Greek alphabet. Learning how to pronounce these letters while reading a book helps your studies: you don't have to wonder what this symbol is every time you encounter it, nor you have issues in explaining to other people what you mean (the angular velocity w... wait, what?).

Fortunately Greek letters aren't used in programming due to lack of ubiquitous Unicode support and difficulty of entering them with a standard keyboard. Yet when it comes the time to variable names, I find $pwd and $stdGrpType everywhere.

These names are difficult to read, understand and must be spelled out for discussion, leading to phrases such as pea double v dee and es tee dee gee ar pea type. Let's do a favor to the psychopatics who will end up maintaining our code and choose $password and $standardGroupType instead.

Sunday, May 29, 2011

Weekly roundup: back from Bardonecchia

I have returned from an Alta Scuola Politecnica one-week event organized by (UX|service|strategic|product) designers, and although I had some reserves at first I enjoyed the startup game where we had to craft an experiment to test the viability of a service idea, using only existing technologies (no fancy web application allowed). This approach is reminescent of Google's Pretotyping Manifesto, so it struck the right chord in me.

Anyway, while I was away my four weekly articles have been published by my editor.
Practical PHP Testing Patterns: Humble Object shows you how to deal with untestable controllers and other framework-based objects.
How to bomb a technical talk is about what I have learned from my first foreign, professional conference.
Practical PHP Testing Patterns: Test Hook is a measure of last resort.
The eXtreme Programming Values are not just a marketing tool.

Monday, May 23, 2011

DPC 2011 slides

Here are my slides for the Testing in isolation tutorial. A link is included pointing to the Git repository, this time with tags. :)

These are the slides for the Domain-Driven Design talk (similar to the phpDay 2011 version). Link to the Git repository is included too.

Sunday, May 22, 2011

Weekly roundup: back from DPC 2011

I am back home from Amsterdam, after having attended the Dutch PHP Conference 2011 and having presented my tutorial on isolation of tests and a talk on Domain-Driven Design.
Which, in a different way from the phpDay 2011 version, was liked by some attendees and also widely criticized by many. Thanks to the many attendees who took the time to give feedback on, as it's difficult for a speaker to find out the problematic areas which he has to focus on (more on that in the next days). I commonly express myself with writing and addressing a crowd is very different in many aspects.

While I was at the conference, these original articles were published on DZone.
Practical PHP Testing Patterns: Dependency Injection
The 4 rules of simple design
Practical PHP Testing Patterns: Dependency Lookup
Git backups, and no, it's not just about pushing

Wednesday, May 18, 2011

Packing for DPC 2011

I'm leaving in the afternoon from Milano Linate to Amsterdam in order to participate to the Dutch PHP Conference.

I will present:

See you at #dpc11!

Sunday, May 15, 2011

Weekly roundup: back from phpDay 2011

Yesterday's evening I arrived home from the phpDay, and I have lots of things to share with you.

First of all, the slides of my two presentations.

And then, four of my articles published this week.
Practical PHP Testing Patterns: Table Truncation Teardown shows the first option for resetting a relational database between tests: deleting everything from the tables but maintaining the schema for speed.
PHP UML generation from a live object graph shows you a bit of code I written in order to generate an Uml class diagram from a group of instantiated PHP objects.
Practical PHP Testing Patterns: Transaction Rollback Teardown shows you another option for resetting a database in tests: rolling back a transaction.
Bleeding edge JavaScript for object orientation contains the new features which will be available in the generation of browsers containing Firefox 4 and Internet Explorer 9.

Wednesday, May 11, 2011

Interview on Voices of the Elephpant

There is an interview with me, recorded with Cal Evans, on the Voices of the Elephpant podcast. You can enjoy my Italian accent and my random pronunciation of injection. :)

Inside: design for testability, the Shower Methodology, test maintainability.

Sunday, May 08, 2011

Weekly roundup: month of conferences

I'm finishing up my talks and tutorials for this year's phpDay and the Dutch PHP Conference. Here is the list of my speeches.

An year of Pomodoros
Pursuing Domain-Driven Design practices in PHP

Isolation for your tests, 3 hour tutorial
Pursuing Domain-Driven Design practices in PHP

I'm planning to submit to ZendCon...

Meanwhile, here are my articles published this week.
Practical PHP Testing Patterns: Database Sandbox
Classical inheritance in JavaScript
Practical PHP Testing Patterns: Stored Procedure Test
A Mockery review

Sunday, May 01, 2011

Weekly roundup: International Workers' Day

Today is International Workers' Day, at least in most of the Western countries. It's Sunday, so we do not really have an additional day of vacation, but the spirit's the same. May your job fulfill you, as work is an undeniable part of our lives.

Here are my original articles published this week.
Practical PHP Testing Patterns: Testcase Superclass is a solution for sharing code between Testcase Classes via inheritance.
The Gang of Four patterns as everyday objects is a list of metaphors and pictures to explain the GoF design patterns meaning without a line of code.
Practical PHP Testing Patterns: Test Helper is an alternative to Testcase Superclass which favors composition over inheritance.
All you want to know about Web Storage is an essay on the Api and characteristics of Web Storage, which is a form of local storage in web browsers specified along with HTML 5.

Monday, April 25, 2011

Weekly roundup: Easter Monday edition

I'm a bit late due to various parties on Easter, but here are my original articles published during the past week.

Practical PHP Testing Patterns: Testcase Class per Feature explains how to divide tests basing on the feature they specify instead of on the class they refer to.
Linear trees with Git rebase explains what git rebase is handy for, and how it maintains a linear history of code even when managing different branches.
Practical PHP Testing Patterns: Testcase Class per Fixture is another possible division of tests, which is based upon a common initial state of the system when they are executed
Exploring TDD in JavaScript with a small kata is an execution of the FizzBuzz kata in JavaScript, with a Red-Green-Refactor cycle that executes automated tests from the command line.

Thursday, April 21, 2011

Conferences and events

This page is a reference to the conferences I have attended. It was inspired by Juozas's example.

Here's where I have been. You may have met me there: