Composition vs. Inheritance: How to Choose?

Steven Lowe piece on Composition vs. Inheritance is a must read. Just to wet your appetite, let me quote the opening paragraph:

In the beginning, there was no inheritance and no composition, only code. And the code was unwieldy, repetitive, blocky, unhappy, verbose, and tired. Copy and Paste were the primary mechanisms of code reuse. Procedures and functions were rare, newfangled gadgets viewed with suspicion. Calling a procedure was expensive! Separating pieces of code from the main logic caused confusion! It was a Dark Time.

Fattura Elettronica Open Source: Web Service PA

this post is about an all-Italian open source release, so it’s going to be in Italian

Il progetto Fattura Elettronica Open Source si è arricchito di un nuovo strumento: Web Services. Il namespace FatturaElettronicaPA.WebServices raccoglie una serie di client C# che consentono di consultare i Web Service per la Fattura Elettronica messi a disposizione dalla Pubblica Amministrazione.

Sono disegnati in maniera da esporre tutti la stessa interfaccia ed essere al tempo stesso semplici e leggeri. Al momento lavorano in modalità sincrona ma l’obiettivo è di renderli tutti asincroni.

Come usare i Web Service

Prendiamo per esempio il Web Service che consente di convalidare un Codice Univoco di Fatturazione e recuperare le informazioni relative all’ufficio:

var ws = new CodiceUnivocoFatturazioneWebService()

// Authorization Id ricevuto dall'ente.
ws.AuthId = "<auth Id>";
// Codice univoco dell'ufficio che ci interessa
ws.CodiceUfficio = "KN3VNW";

if (ws.Ufficio == null) return;

// "Ravenna"

Molto semplice. Gli altri WebService (sono sette in tutto) operano secondo lo stesso schema. Ricordo che per l’utilizzo dei Web Services della Pubblica Amministrazione è necessario richiedere una specifica autorizzazione. L’Authorization Id è gratuito ed il rilascio è immediato, ma bisogna compilare un apposito questionario.


FatturaElettronicaPA.WebServices è su NuGet quindi tutto quel che serve è eseguire:

PM> Install-Package FatturaElettronicaPA.WebServices

dalla Package Console, oppure usare il comando equivalente in Visual Studio.

La libreria è una portable class library e gira senza modifiche sui seguenti ambienti: .NET Framework 4.0 e superiori; Xamarin.iOS; Xamarin.Android; Windows Phone 8; Windows Store apps (Windows 8); Silverlight 5.0. Enjoy!

If you want to get in touch, I am @nicolaiarocci on Twitter.

On my trip to Microsoft Build 2015

Last week I was in San Francisco for Build 2015, the annual conference event held by Microsoft and aimed toward software and web developers. Overall it has been a great experience. I especially enjoyed the opportunity to speak with Microsoft executives, Program Managers and developers about the new stuff they are cooking up and, in general, about that New Microsoft we all have been experiencing as of late (I have a guest post on MSDN Italy on that topic).

In this week TecHeroes episode I am interviewed along with my buddy Matteo Collina. At about 1m 20s in the episode Matteo and I share a few considerations on Open Source projects and technologies that really caught our attention at the conference, and of course on Microsoft in general. It is all in Italian by the way.

Talk Python To Me Podcast Episode #1:
EVE RESTful APIs for Humans

I was lucky enough be the first guest for the shiny new Talk Python To Me Podcast hosted by Michael Kennedy. In this episode we talk about Eve an my other open source releases, which gives us an excuse to touch on a variety of topics such as Polyglot Programming, New Microsoft and the .NET evolution, MongoDB and the Open Source eco-system as seen from the point of view of an old fart who has been spending most of his career in closed systems.

Talk Python To Me: Eve

Michael has a great lineup ready for the next episodes, so make sure you subscribe to his show. It is also available on iTunes.

If you want to get in touch, I am @nicolaiarocci on Twitter.

New Releases for Cerberus and Eve

Yesterday Cerberus 0.8.1 was released with a few little fixes, one of them being more a new feature than a fix really: sub-document fields can now be set as field dependencies by using a ‘dotted’ notation.

So, suppose we set the following validation schema:

schema = {
  'test_field': {
    'dependencies': [
  'a_dict': {
    'type': 'dict',
      'schema': {
        'foo': {'type': 'string'},
        'bar': {'type': 'string'}

Then, we can validate a document like this:

>>> v = Validator(schema)
>>> document = {
      'test_field': 'foobar', 
      'a_dict': {'foo': 'foo'}

>>> v.validate(document, schema)

>>> v.errors
{'test_field': "field '' is required"}

This release will not work with Eve 0.5.2 or less so if you want to use Cerberus 0.8.1 with Eve make sure you upgrade to Eve 0.5.3, released today. By the way, yesterday we hit 2K stargazers and 70 contributors on the Eve repository, quite the milestone!

If you want to get in touch, I am @nicolaiarocci on Twitter.

Attention is a Resource

Today, the New York Times’ SundayReview features a great column by Matthew B. Crawford: The Cost of Paying Attention.

Attention is a resource; a person has only so much of it […] What if we saw attention in the same way that we saw air or water, as a valuable resource that we hold in common? Perhaps, if we could envision an “attentional commons,” then we could figure out how to protect it.