Monday, October 20, 2014

This blog is moving

After several years using the Blogger platform I've decided to freeze this blog and move my writing efforts elsewhere. In the last few days I've tested several options, mainly looking at Wordpress running on Openshift. But I have found Wordpress a bit overkill for a simple personal blog, so I discovered Octopress.

Octopress is a framework designed by Brandon Mathis for Jekyll, the blog aware static site generator powering Github Pages. To start blogging with Jekyll, you have to write your own HTML templates, CSS, Javascripts and set up your configuration. But with Octopress All of that is already taken care of. Simply clone or fork Octopress, install dependencies and the theme, and you're set.
The main reasons for this move are:

  1. Blogger has become slow and heavy: the preview takes forever and sometimes it doesn't show up at all
  2. Octopress serves static files and can be quickly tested locally
  3. I can use Git for pushing all my changes and I can rollback easily
  4. I want to be in total control of the typography and html
  5. My main domain and blog pages are all hosted on Github

Here it is: www.maurizioturatti.com


So, goodbye Blogger.com and thank you for all the blogging fish. Welcome Jekyll and Octopress!


Thursday, October 9, 2014

The Brodzinski's estimation scale for a task

Pawel Brodzinski, lean and agile coach, suggests a good estimation scale for a task:
  • 1: 1
  • TFB: Too Fucking Big
  • NFC: No Fucking Clue
Despite the fact this could initially looks like a joke, it's actually a serious way to handle too large user stories and, from my point of view, it's very close to what has been suggested by other agile coaches like Neil Killick (My Slicing Heuristic Concept Explained), especially popular within #NoEstimates practioners.

The idea, at least at high level, is very simple: slice down your tasks until they are all more or less of the same size (1 story point), then your final estimation is just a matter of summing the total number of stories. Of course, it's easier said than done: too many misunderstand the NoEstimate practice, dismissing it as just a way to avoid the "hard work", but in reality the slicing activity forces a very accurate analysis of requirements, to be able to slim them down to a common size. The easy part is the final sum, but that's not the point.

In my opinion this method suggests that, when somebody says a user story is 5, 8 or 13 points in size, this implies a good amount of delusion, because in reality going beyond a 1, 2 or 3 size is so close to pure guessing that it is usually a waste of time. Using only a single size (one) it's even more effective, because forces a serious decomposition of tasks: if you can't achieve this level of decomposition then you should acknowledge that your requirements are not clear enough yet: drastic, but effective.

A practical approach to this kind of user stories slicing could be Gojko Adzic's hamburger method, when adding the constraint that each task composing the hamburger must be of size 1.

Many years ago I did something vaguely similar in a project: I decided that every user story had to fit into a week and every Friday was release / demo day. Not exactly continuous delivery, but I think it was even before the term "agile" was invented...





Tuesday, October 7, 2014

Extremely Bad Advice for Remote Workers

As I have a long-term experience as a remote worker, also dealing with and managing remote teams in different timezones, I am always interested in experiences on this subject. Today I stumbled upon an article on TheNextWeb: 3 radical habits of highly successful remote teams. Despite the article seems to be nice with remote workers, it actually contains what I think are some of the worst possibile anti-patterns for remote work. In summary:
  1. Total transparency about yourself with your remote team
  2. Leave your webcam on all day
  3. Replace physical space with software — lots of it
Let's rephrase the meaning:
  1. I don't care about your privacy at all, so I want to know even when you are sleeping or pooping ("For example, every Buffer employee receives a Jawbone UP wristband that tracks how you’re sleeping and shares that with the team.")
  2. I don't trust you at all, so I want to check that you are always staring at a computer screen, all day long ("This provides a persistent, passive view of your colleagues that makes you feel like you’re in the same room, working together at the same table."). So you are even required to broadcast you scratching your nose or your privates: I can only imagine the level of anxiety!
  3. Additionally, I also want to mess up with your work by asking you to install, learn an manage a lot of different software doing, more or less, the same thing ("lots of it"). So that I can annoy you from even more different angles!
I, instead, suggest the following:
  1. Hire people you trust and let them organize their daily routine and priorities
  2. Adopt few, useful, simple software like Skype, Google Hangout and Slack for communication, Google Docs and/or Confluence for shared documentation.
  3. If you want a social life go to the gym or to the pub, switching off your mobile email notifications. Get a life outside your work.
Managing a remote team like being into a modern edition of Orwell 1984? No, thanks. A remote, distributed team is not an assembly line: I suggest to move toward measuring people by the actual value they generate instead of the time they sit in front a PC.

A team made of knowledge workers must generate tangible value: if you can do that while playing tennis or having a shower, I don't really care.



Monday, September 22, 2014

The Programmer

"The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures.

Yet the program construct, unlike the poet's words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sounds, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be."
Frederick Brooks, The Mythical Man Month.


Thursday, September 4, 2014

The Java EE ecosystem keeps shrinking

Less than a year ago Oracle announced the Java EE and GlassFish Server Roadmap Update, which defined the end of commercial support for the Oracle Glassfish Server, which is (was) the fully supported release of the GlassFish Server Open Source Edition. In the last few months there has been plenty of comments about this move, some of the most remarkable are:
The motivation around this move are probably about Oracle not being keen on supporting two full app server implementations, Glassfish and Weblogic, which apparently makes sense from a commercial point of view. The problem here is that the two products are very different, and if you liked Glassfish usually hated Weblogic (but has somebody ever genuinely liked Weblogic anyway?). Glassfish is a lightweight, easy to install, fast to start, open source product, with a community around, while Weblogic is IMO one of the most bloated piece of software ever: the two products were addressing two very different Java EE markets, being Weblogic's the most lucrative one.

A reply to community's concerns, apparently from an Oracle representative:
"... GlassFish and WebLogic share quite a bit of code, and that helps with application and configuration portability between the two. So, organizations can continue to develop on GlassFish and leverage that development by deploying on WebLogic."
This is one of the most laughable sentences I have read in years: can anyone seriously think a company could develop and test in one application server but then deploy in production with another? Can anyone really assert that Glassfish and Weblogic are that similar? Just try to install both and judge yourself: you could start developing your first Glassfish application while Weblogic installer is still downloading...

Glassfish has always been a minor commercial player, but reducing the available options has never been a successful strategy for any ecosystem, and Oracle is supposed to lead this one. Below are the results of this leadership:



If you care about open source but want / need to deploy into a commercially supported Java EE app server, you now have basically only a couple of options left: RedHat's JBoss EAP and Tomtribe's TomEE. Despite both are fine options, pulling out a minor but strategic member doesn't help arresting the progressive shrinking of the Java EE ecosystem, as differentiation and competition are king.

This is a pity, because Java EE is becoming more and more lean and easy.


Wednesday, January 15, 2014

Sales are Good for You

I have just published the below presentation on Slideshare: half it's serious content, half it's just for fun.

Some of my best friends are present or former colleagues, most are developers but many of them are sales or marketing people. I was thinking about describing the often difficult relationship between software developers and sales people since many years now. Maybe I should give a talk about this, one of these days.

I am lucky I had the opportunity to work with very smart people, both on sales or IT, with the exception of some occasional moron, of course.

Hopefully you can recognize some common, funny patterns here.

Saturday, January 4, 2014

Book Review: "Real-time Web Application Development using Vert.x 2.0"

About Vert.x


I am following the evolution of the Vert.x project since its inception and I was expecting to see some books coming about the subject sooner or later. First of all, some explanation on what's Vert.x:
"Vert.x is a lightweight, high performance application platform for the JVM that's designed for modern mobile, web, and enterprise applications."
The product is 100% open source, licensed under the business friendly Apache Software License 2.0 and well documented. The project's founder and main maintainer is Tim Fox, of HornetQ fame.
Vert.x characteristics are nicely summarized in the related Wikipedia entry:
Vert.x is a polyglot event-driven application framework that runs on the Java Virtual Machine.
Similar environments written in other programming languages include Node.js for JavaScript, Twisted for Python, Perl Object Environment for Perl, libevent for C and EventMachine for Ruby.
Vert.x exposes the API currently in Java, JavaScript, Groovy, Ruby and Python.
Scala and Clojure support is on the roadmap.
The application framework includes these features:
  • Polyglot. Application components can be written in Java, JavaScript, Groovy, Ruby or Python.
  • Simple concurrency model. All code is single threaded, freeing from the hassle of multi-threaded programming.
  • Simple, asynchronous programming model for writing truly scalable non-blocking applications.
  • Distributed event bus that spans the client and server side. The event bus even penetrates into in-browser JavaScript allowing to create so-called real-time web applications.
  • Module system and public module repository, to re-use and share components.

Few days ago I decided to purchase a recent book from Packt Publishing about the subject.

The Book



Language : English
Paperback : 122 pages
Release Date : September 2013
ISBN : 1782167951
ISBN 13 : 9781782167952
Author(s) : Tero Parviainen

I bought the eBook format only and I read it in both my iPad and computer screen, especially because the narration is mainly about building a fairly complete Web application, so I wanted to read and experiment at the same time, by entering the code by hand and running it step by step.

Below I provide a short summary of the book' sections and I will write some final comments about it.

Preface


The preface introduces clearly the content and objectives of the book
"Real-Time Web Application Development using Vert.x 2.0 will show you how to build a real-time web application with Vert.x. During the course of the book, you will go from the very first "Hello, World" to publishing a fully featured application on the Internet."
The scope is to build an editor with which people can create mind maps collaboratively. So, it is neither a too trivial application, nor something too complex. A good, balanced choice, with the additional bonus of learning a few of jQuery, D3 JavaScript library and MongoDB on the road.

What the book covers 


Chapter 1, Getting Started with Vert.x, guides you through the installation of the Vert.x 2.0 platform and its prerequisites. In this chapter, you'll also write your very first Vert.x application: the web equivalent of "Hello, World".

Chapter 2, Developing a Vert.x Web Application, covers the development of a full-fledged Vert.x web application, including both the server and browser components. You will become familiar with the architecture of a typical Vert.x application.

Chapter 3, Integrating with a Database, extends the web application from the previous chapter by adding support for persisting data in a MongoDB database, using one of the available open source Vert.x modules: the MongoDB Persistor.

Chapter 4, Real-time Communication, builds on everything you've learned so far
to deliver the secret sauce: real-time communication. You will develop a real-time, collaborative, browser-based mind map editor.


Chapter 5, Polyglot Development and Modules, presents some of the polyglot features of Vert.x, as well as the development of reusable and distributable modules,
by creating a Java module that is used to save mind maps as PNG images.


Chapter 6, Deploying and Scaling Vert.x, shows how to deploy your Vert.x application on Internet, by setting up a Linux server with continuous deployment. Finally, we discuss the basics of scaling Vert.x for growing amounts of users and data. 

My comments


One might argue that the official Vert.x documentation is already quite comprehensive and this book doesn't add much, but conversely I feel this book allows for a smoother approach to learning, without the need to browse and search too much around the Web site. Maybe somebody with already a working experience with Vert.x wouldn't gain a lot of new knowledge here, at the end I feel the book is more focused on Vert.x beginners, but anyway it contains a good amount of advanced tips to make it valuable for a wide audience.

Vert.x is a polyglot framework, so one can choose among a set of popular programming languages, with even more on the move, but the code in the book is mainly Javascript, also server side. On one hand this seems to restrict a bit the potential audience, as to fully understand the source code and the logic behind the mind map application a decent knowledge of Javascript is advisable, but on the other hand this could be very appealing to node.js developers, as they could immediately compare it with Vert.x. Then, also a client-side Javascript developer can easily follow the content and learn some server-side programming. I'm not sure on my side if I would pick Javascript for developing complex server-side logic, but adopting the same language for both client and server development undoubtedly has its own advantages, as the growing popularity of node.js testifies.

What I especially like in this book is the capacity to explain "full stack" concepts in small, easy steps. You learn about Vert.x and asynchronous message exchanges via the event bus, but also some client side programming techniques in Javascript. The bridge between client and server is built using the SockJS library, which provides real-time, full duplex, client-server communication through HTML5 WebSockets and other fallback mechanisms for older browsers.

Another plus of this book resides in its two last chapters, about modules and deployment. Chapter 5 provides a clear description of distributing and managing Vert.x applications through modules, while Chapter 6 goes into the fundamental topic of real deployment and scaling of Vert.x applications. As Vert.x applications are not distributed as standard Java EE packages, these final chapters are really a bonus and I wish to see more books that include at least some basic information about development, scaling and lifecycle management.

Conclusions


The book is very well written and readable. It is balanced, as it can support both the novice and the expert developer in exploring this excellent Web framework. I can definitely recommend buying it if you want to start studying in deep Vert.x.

Note: I actually bought this book by myself and not asked to review it by Packt or anybody else, so this article reflects my own independent opinion only.

References



Thursday, June 27, 2013

Apache Maven Starter - my first, little book

Today Packt Publishing has published a little book I have written in the last few months together with Maurizio Pillitu.

The book is titled Apache Maven Starter and it's part of the Instant collection by Packt Publishing. Instant books are concise and focused technical guides, usually no more than 50 or 60 pages, providing the maximum amount of information in the quickest and most effective way.


Get to grips with a new technology, understand what it is and what it can do for you, and then get to work with the most important features and tasks.The book follows a starter approach for using Maven to create and build a new Java application or Web project from scratch.
I accepted the invite to write this book because, despite the huge amount of information already available on this subject, in form of other books and online material, when I started learning Maven I was searching for more concise information. The book actually doesn't aim to be a complete reference, but a place to start from and a collection of pointers to additional information. So, it is the book I wished I could read years ago.
Maven ultimately allows for the automation of the build lifecycle and independence from any IDE. You must always be able to build and test any Java project from the command line, using your favorite editor for coding. It is important to control exactly what libraries get distributed with Java projects and to have a standard project template and build process. 
Instant Apache Maven Starter will concentrate the most useful information into one single, very compact source. 

What you will learn from this book

  • Download, install, and configure Apache Maven with the minimum fuss
  • Make your own Java project templates and reuse them
  • Deploy to Tomcat or run an embedded Tomcat with Maven
  • Perform unit and integration testing with Maven and JUnit
  • Manage dependencies and project coordinates, adopting best practices
  • Create and manage multi-modules projects
  • Use Maven from your favorite IDE: Netbeans, Eclipse, or IDEA

I want to especially thank Maurizio Pillitu and the Packt Publishing editorial team, it has been great to work together guys!

The book is already available on Amazon, Packt and Safari Online.


Thursday, May 30, 2013

Open source products: the big misunderstanding

While reading an article on ZDNet titled "Open source: Its true cost and where it's going awry by Monty Widenius" I think I have realized why most people, even those tightly involved in the open-source ecosystem, are often misunderstanding its business model. In a sentence:
The open source model is about creating collaborations, not building products.
Advocating open source software since the early 90s, from my point of view an open-source business model related to products can be misleading.
"The problem is — I saw this very clearly with MariaDB — I created a company where I took the original people who were creating the product, [but] I couldn't get anybody to fund us," Widenius said.
Before being bought by Sun for an astronomical amount of money (1 billion $), MySQL was profitable but in the range of few tens millions per year. You don't meet every day somebody putting billions on the table...

My question is: what would force a company to pay for a product if they can have it for free? I guess RedHat owners asked themselves the same questions when they practically closed the RHEL product line source code, moving the community toward the Fedora project. And now RedHat is making an huge amount of money from a product that is, by all means, the (almost) closed version of an open source effort.

So, it is really hard to build open source products, like RedHat or Alfresco, for example, because, despite all the efforts to justify a dual licensing model, you cab grasp only a very small percentage of users available to pay for a commercial edition of any open-source software. Stressing the fact that going into production requires paid support can be helpful, but it's very hard to demonstrate where the break-even is. Somebody coud argue: is that product so buggy that I need to pay a lot of money for support? Very few companies have been successful in this.

Instead of selling standalone products, I see an easier path in building solutions and services on top of an open source ecosystem: companies and their developers collaborate in growing a set of tools, frameworks, libraries with an open source development model and communities. This allows to dramatically decrease R&D costs, sharing the benefits. Today I could build a whole enterprise platform with open source software only, from the operating system to middleware and client applications, probably with better quality than a closed counterpart. But, as Widenius seems is learning the hard way, building an open source product and having paying customers is a different story: not impossible, of course, but very hard.
Widenius again: "Open source is successful for OpenStack where you have a consortium of companies that are all putting money into developing it."
Exactly what I mean: join to develop the common parts, share the costs and then compete in selling some unique services. But a stand-alone, open source product, created and supported by a single company, is a different story.

Tuesday, November 13, 2012

RESTful API memo: PUT and POST differences

Before start designing a RESTful API, have a look at Hypertext Transfer Protocol -- HTTP/1.1, section 9

"The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.".

In other terms, POST is meant to handle appends to existing resources or incremental creations of subordinate resources:

"The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a database."

PUT instead seems is more appropriate to handle one-shot creations, creating or replacing an entire resource in one single transaction:

"The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI."

Differences between PUT and POST:

"The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource."

Another remarkable difference is that PUT requests are required to be idempotent, while POST are not:

"Methods can also have the property of 'idempotence' in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent."

Saturday, November 10, 2012

Creating your private Git repository on Dropbox in less than 5 minutes

Github is the tool I use daily to manage my public software projects, I love it. But sometimes I have to quickly and temporarily share private projects with colleagues or maybe even in a mixed environment, with customers and consultants from other companies. When there is no time / money to buy private remote repos from Github or even install a local Git repo on some server,  and for privacy constraints it is not possibile to publish the code on a public Github repo, then Dropbox comes to the rescue.

In this example I'm working on a simple Web application in Flask, which is a cool Python micro-framework. I created a "flask_sample" folder which contains the code I want to version with Git and share with other colleagues.

I promised it will take less than 5 minutes, so let's start.

Move to your Dropbox folder (in my case it's in /Users/mturatti/Dropbox/) and create a folder to host all your remote git repositories:

$ cd /Users/mturatti/Dropbox/
$ mkdir git

Then create here the folder to host this remote repository:

$ cd git
$ mkdir flask_sample.git
$ cd flask_sample.git

It's time to create a bare Git repository:

$ git init --bare

You'll see it creates a structure similar to the following:

mturatti:~/Dropbox/git/flask_sample.git$ ls -l
total 24
-rw-r--r--   1 mturatti  staff   23  9 Nov 18:38 HEAD
-rw-r--r--   1 mturatti  staff  112  9 Nov 18:38 config
-rw-r--r--   1 mturatti  staff   73  9 Nov 18:38 description
drwxr-xr-x  10 mturatti  staff  340  9 Nov 18:38 hooks
drwxr-xr-x   3 mturatti  staff  102  9 Nov 18:38 info
drwxr-xr-x  11 mturatti  staff  374  9 Nov 19:09 objects
drwxr-xr-x   4 mturatti  staff  136  9 Nov 18:38 refs

Now you have in place a git structure which can act as a shareable remote repository, even if in practice it's local to your hard disk. Being a Dropbox folder will do the magic in terms of backups, sharing and synchronization.

Initialize Git in your software project as usual (in my case the local project stays in /Users/mturatti/src/flask_sample)

$ git init

This creates the usual hidden .git folder.
The last configuration step is to add locally the previously created remote Git repository:

$ git remote add origin file:///Users/mturatti/Dropbox/git/flask_sample.git

Note we are using the file:// protocol for the remote Git repository here.
If you check the content of .git/config file you'll see the new origin (in bold below):

mturatti:~/src/flask_sample$ cat .git/config 

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
url = file:///Users/mturatti/Dropbox/git/flask_sample.git
fetch = +refs/heads/*:refs/remotes/origin/*

At this point you can start the usual Git lifecycle. For example, after you have added and committed all your files locally, you can "push to origin", which will push your code to your remote Git repository saved on Dropbox:

$ git push origin master

The last step will be to share the Dropbox folder with your colleagues, so that they can also add this as a remote repository and start cloning / pulling / pushing from this origin.





Saturday, September 29, 2012

Time, Cost, Quality and Agile Consulting

Types of Consulting Engagements

“Sometimes it's a little better to travel than to arrive” 
― Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance: An Inquiry Into Values
In my software consulting experience I have been engaged in many different kind of projects, but in all cases they fall into two main categories:

  1. Time and Material (T&M)
  2. Fixed Price (FP)
In most situations it happens than to decide that option #2 is achievable, then a quantity of T&M analysis must be performed in advance, in order to define the context and the scope for a possible, successive FP engagement. That's not always possible: for example, when the project is part of a public tender, you have to bid for the lowest possible price, trying to balance the need for adding a good amount of contingency, staying into the safe path, without self-sabotaging the possibility of winning the tender.

What marks the difference between T&M and fixed price? In T&M a customer is basically paying for your time, because deliverables and scope can't be clearly set in advance, or because it's already established that requirements are going to change in a way that a Fixed Price engagement is out of question, because it's too risky. A Fixed Price project is based on a set of much more stringent assumptions, in terms of context, requirements, functional and technical, which (hopefully) allows for a very accurate estimate of deliverables.

Usually customers are more keen on FP because, of course, they think it will constraint the final price by putting much more responsibilities on the consultant, while T&M seems a way to create a continuos stream of expenses. However, in reality, there is a more fundamental law which regulates any kind of software project, despite the rules of engagement, and it is related to the existing and unavoidable strong relationship among three distinct, fundamental quantities: Time, Cost and Quality.

The Basic Conjecture of Time, Cost and Quality

“When analytic thought, the knife, is applied to experience, something is always killed in the process.” 
― Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance: An Inquiry Into Values
It's almost incredible how many people actually think they can leverage Fixed Price to be in total control, at the same time, of these three quantities:
  1. The elapsed time spent from start to finish, so the final delivery date;
  2. The total cost, in terms of direct money and indirect materials;
  3. The overall quality of the final product.
This assumption has been historically proven false by practice, for any non-trivial software project or consulting engagement. It's a conjecture and not a theorem or a physical law, but reality has taught me that, in software development and software consulting, it is possible to accurately be in control of only two over three of these quantities.

Some examples are needed: if a project has a fixed delivery date and a fixed price, then the only left quantity one can possibly control is quality. Would it maybe explains why so many FP projects suffer from poor perceived quality?
On the other hand there is another fundamental speculation which states that "Nine women can't deliver a baby in one month". It means that, if delivery dates and quality are fixed, one is tempted to keep adding resources, in terms of people and infrastructure, loosing control about costs. In practice this tactic even leads to also increasing delivery time, because adding people on a late project usually delays it even more.
A third case is when we try to fix both cost and quality, but then we accept that elapsed time can't be predicted accurately. This is the case, for example, of companies trying to outsource development to offshore facilities, where cheaper labor force can easily be hired. Statistically this strategy has led many projects to both an indefinite development time but also poorer quality.

It's all about one single truth: software development is inherently not a traditional engineering activity. Actually, Programming is Gardening, not Engineering. 

Agile Development and Agile Consulting

"Simplicity is the ultimate sophistication". ~ Leonardo da Vinci.
So, at first sight, it seams there is no escape from the T, C & Q rule. But we are not doomed. In fact, as I wrote before, the rule applies for any non trivial software project. So the trick here is: to transform big projects or big consulting engagements into a finite sequence of very focused, well defined, little activities or mini-engagements. This is why time-boxing or feature-boxing usually work effectively, and that's what actually Agile Methodologies are, more or less, trying to achieve: transforming complexity into something more manageable and predictable, by splitting big activities into little, possibly trivial, short tasks, which can be handled in few hours or days by very few people.

I think that agile methodologies can and should be successfully applied also to pure software consulting, so to the kind of engagement usually performed in T&M. The main pillars of this strategy are nothing new and can be summarized as:
  • Focus on User Stories;
  • Short iterations, usually no more than two or three weeks long;
  • Continuos Integration and Continuos Delivery of valuable pieces of software;
  • Acceptance tests at the end of each iteration or when a single deliverable is ready.

As a side note: if you are strictly required to be on-site then that is not a Fixed Price project by definition! Fixed Price engagements MUST be off-site, exactly because you don't want to waste time renegotiating the scope each single moment. It is necessary to have customers involved daily and keep things very flexible, but asynchronous interruptions must be avoided at all costs. The main objective is to understand what final users want and adapt when requirements are changing, but this must be addressed by the process, not individuals. T&M is very different: as customer pays for your time he is entirely entitled to interrupt you and change tasks even in the middle of them. That's why committing on any detailed deliverable in a T&M assignment is extremely dangerous.

The Need for Good Architectural Decisions

"We are searching for some kind of harmony between two intangibles: a form which we have not yet designed and a context which we cannot properly describe." ~ Christopher Alexander.
The missing piece, for a Use Case made of several User Stories, is a comprehensive and reasonably complete Technical Architecture. In other words, I do believe in that kind of bottom up, emerging software design coming from an Agile, iterative process, but I think this must be developed within the frame of a clear up-front Architecture.

I mean that refactoring code and design is not only necessary, but even desirable. Then, in my experience, refactoring wrong initial architectural decisions can be extremely expensive and usually leads to big failures. I strongly believe that the role of an experienced architect is key to produce quality software systems, and this fact sounds to me to be often too underestimated in the field of Agile Methodologies. Do not fool yourself by believing your so-called "rockstar developers" (horrible term!) alone can also actually imagine, design and implement a complete and working technical architecture.

Speaking of consulting, even a short T&M engagement should be performed in the context of a well designed architecture, because even the best expert can be unable to deliver anything useful if the architectural context is broken. Focus your first steps at customer site on two main things: understanding their existing architecture and development process, and start fixing them if they are clearly broken. Otherwise the risk of failing and not get paid will be too high, despite the fact it's T&M or FP.

Tuesday, April 10, 2012

Managing Multiple JDK on Mac OS X

Recently I had to install the OpenJDK 7 on my Apple MacBook, but keeping the original JDK 6 as my main Java environment. After browsing the Internet I came to a decent set of instructions (Tested with OS X Lion 10.7.3).

In summary:
  1. Get the OpenJDK from http://code.google.com/p/openjdk-osx-build/ (I chose JDK 7u4, which at present seems to be the latest stable build); The JDK 7 is now a regular download by Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Install the downloaded .dmg package;
  3. Change your Java Preferences accordingly, by moving on top the "OpenJDK 7" item (by default Java SE 6 is the first item - see below picture);
  4. Automatically set the JAVA_HOME variable, so that shell tools work.
To automatically setup the JAVA_HOME variable it's necessary to add few lines to the .profile.
So, edit this file (it's in your home directory) adding the following lines:

# Change your JAVA_HOME
function setjdk() {
   if [ $# -ne 0 ];
      then export JAVA_HOME=`/usr/libexec/java_home -v $@`;
   fi;
   java -version;
}
# Automatically set the JAVA_HOME
export JAVA_HOME=`/usr/libexec/java_home` 
echo 'JAVA_HOME='$JAVA_HOME

Note that the optional setjdk function allows for dynamically changing the JAVA_HOME if you switch items in your "Java Preferences", otherwise many Java tools won't work if JAVA_HOME is not in synch with the System settings.

Whenever you change the default JDK using the "Java Preferences" tool, then any new terminal will automatically pick-up the new JAVA_HOME by executing /usr/libexec/java_home, so executing the setjdk function is not usually necessary, unless you really don't want to close and re-open the terminal (opening the terminal reloads the .profile). Alternatively issue the command source .profile in you shell.

That's it, now you can install multiple JDKs and select them dynamically, by just using the "Java Preferences" tool, without touching any system file by hand.


Saturday, April 7, 2012

XML Schema and WSDL modules for Netbeans 7.x

A couple of years ago I wrote a blog entry about how to install the missing XML Schema Editor and related utilities from the dev update center in Netbeans 6.9. Now there is a unofficial update center:

http://deadlock.netbeans.org/hudson/job/xml/lastSuccessfulBuild/artifact/build/updates/updates.xml

It contains the development branches of these and instructions on how to install, thanks to Geertjan Wielenga.

I installed the plugin on Netbeans 7.1 [update: I installed it also in 7.2] and it seems to work, even if I did not test it intensively, primarily because these days I'm no more working that much with XML Schemas and WSDL files.

There is an apparently disabled Hudson project for the XML Tools. Now, if you want to put this nice plugin back into the regular plugin repository, please vote for this issue!

Thursday, November 24, 2011

Starting with CMIS and Maven

This post aims to be an short how-to for setting up a CMIS development environment based on Maven and Apache Chemistry, specifically the OpenCMIS Java API, part of the Chemistry project.

I won't cover Maven installation and configuration here, so I assume you have Maven 2 or 3 up and running. With Maven you'll be independent from any specific IDE, so that you can manage your development cycle from the command line only.

Glossary
  • CMIS (Content Management Interoperability Services) =>"is a specification for improving interoperability between Enterprise Content Management systems. OASIS, a web standards consortium, approved CMIS as an OASIS Specification on May 1, 2010. CMIS provides a common data model covering typed files, folders with generic properties that can be set or read. In addition there may be an access control system, and a checkout and version control facility, and the ability to define generic relations. There is a set of generic services for modifying and querying the data model, and several protocol bindings for these services, including SOAP and Representational State Transfer (REST), using the Atom convention. The model is based on common architectures of document management systems."
  • Apache Chemistry => "Apache Chemistry provides open source implementations of the Content Management Interoperability Services (CMIS) specification.
  • OpenCMIS => "Apache Chemistry OpenCMIS is a collection of Java libraries, frameworks and tools around the CMIS specification. The goal of OpenCMIS is to make CMIS simple for Java client and server developers. It hides the binding details and provides APIs and SPIs on different abstraction levels. It also includes test tools for content repository developers and client application developers."
  • Apache Maven => "Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information."
Ingredients
  1. A simple text editor or any decent Java IDE 
  2. Maven 2 or 3
  3. A CMIS server for real-world testing
In my case I'm using IntelliJ IDEA, which is excellent. I'm an old Netbeans guy and both IDEs offer superior Maven integration, but it happens that I'm just having a look at IntelliJ these days.

To cover point # 3 I have selected the reference CMIS server implementation so far, which is Alfresco.  OpenCMIS offers a basic CMIS server implementation for your self-contained unit tests, but for end-to-end integration testing I prefer to link to a real ECM system.

You can download the latest Alfresco Community Edition for free from here. At present the brand new 4.0 is available.

Setup

Note: I won't cover Alfresco's installation and configuration here because it's not in the scope of this post. You can already find plenty of excellent online resources for that.

Just open a shell, place into a folder and run the following Maven command, to create a very basic Java project through the quickstart archetype:

mvn archetype:generate -DgroupId=com.myapps \
                       -DartifactId=my-first-cmis \
                       -Dversion=1.0-SNAPSHOT \
                       -DarchetypeArtifactId=maven-archetype-quickstart \
                       -DinteractiveMode=false

You'll end having the following usual project structure:

project
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |       `-- App.java
    `-- test
        `-- java
            `-- AppTest.java

The pom.xml file is the center of the Maven's universe. We need to edit it for adding a few lines of XML so that we can build with OpenCMIS libraries.
Here is the default pom.xml created by the archetype:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myapps</groupId>
  <artifactId>my-first-cmis</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-first-cmis</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Now we need to put the following XML snippet into pom.xml to activate the OpenCMIS libraries:

<dependency>
   <groupId>org.apache.chemistry.opencmis</groupId>
   <artifactId>chemistry-opencmis-client-impl</artifactId>
   <version>0.6.0</version>
</dependency>

At present the latest stable OpenCMIS release is 0.6.0, you can modify the pom.xml file accordingly whenever a new version is released.

This is the final POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myapps</groupId>
  <artifactId>my-first-cmis</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-first-cmis</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>org.apache.chemistry.opencmis</groupId>
      <artifactId>chemistry-opencmis-client-impl</artifactId>
      <version>0.6.0</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Now that your development environment is ready and you can build both from the shell and the IDE, you can start exploring some examples.

Issuing a mvn clean compile command in your shell will start the process.
If it's the first time you run Maven then it will try to download many dependencies, but don't worry and be patient, all successive runs will be very fast.


Friday, March 4, 2011

Purge Alfresco archived nodes

I was looking for a way to automatically purge the Alfresco trashcan and, after a while I think I came out to what looks like a decent solution.

DISCLAIMER: The procedure described in this article has not been tested intensively and comes without any implied warranty of fitness for a particular purpose. You should check the code, test it and decide yourself if fits your needs, saving all your data before any experiment.

The problem
After some time, deleting contents can fill the Alfresco's trashcan and removing nodes manually with the UI can be unpractical (users always forget about this). Alfresco does not actually delete content, but moves deleted nodes into the archive store, which is like a trashcan. Deleted contents can stay there forever, until users decide to clean-up the trashcan. In a big repository this could lead to a huge waste of resources.

I need a service I can invoke programmatically to empty the trashcan, for example by scheduling a task with an external job. I don't like to deploy into Alfresco a scheduled task controlled by the embedded Quartz, I think it's cleaner to move the scheduling outside and deploy into Alfresco always the bare minimum.

Even after the trashcan has been emptied, this just means nodes are only marked as "orphans", moved into alf_data/contentstore.deleted and can be phisically removed by a contentStoreCleaner asynchronous task. So there is a safety net in Alfresco to avoid at all costs accidental deletions.


Cleaning-up archived nodes
I have developed a simple Java-backed Web Script for Alfresco 3.4 (It should work with Alfresco 3.2+) which can be invoked to clean-up the archived nodes. Below its major components:

purge.get.desc.xml
Web Script descriptor

    Purge all
    Purge all archived nodes
    /purge
    user
    none

purge.get.html.ftl
Freemarker template

purge-context.xml
Spring bean's configuration

I created it/alfresco/utils folders under /Company Home/Data Dictionary/Web Scripts Extensions where I created both purge.get.desc.xml and purge.get.html.ftl.

The Spring context file purge-context.xml goes under /tomcat/shared/classes/alfresco/extension in the main alfresco installation folder.

Our bean makes use of nodeArchiveService.

Here's the Java Code:


The Purge project under Netbeans 6.9.1


The bean is injected with nodeArchiveService and calls method purgeAllArchivedNodes.

The single most important line of code is:
this.nodeArchiveService.purgeAllArchivedNodes(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

We are passing the STORE_REF_WORKSPACE_SPACESSTORE constant, which is "the store that the items originally came from", as per JavaDocs:

purgeAllArchivedNodes

void purgeAllArchivedNodes(org.alfresco.service.cmr.repository.StoreRef originalStoreRef)
Permanently delete all archived nodes.
Parameters:
originalStoreRef - the store that the items originally came from
Calling the WebScript
After starting Alfresco, to get a list of available Web Scripts and check if this new one has been installed correctly, point the browser to http://localhost:8080/alfresco/service/index and then press link "Browse all Web Scripts". Remember to authenticate as admin, so that the Web Script can be ran with administrator privileges.

The "Purge" Web Script should be the first one

To invoke its execution and clean-up the trashcan you can call:
http://localhost:8080/alfresco/service/purge

If everything went fine you should see the following response page:
Alfresco Community Edition v3.4.0 (c 3335) :
Purged all archived nodes. Elapsed time: 438 ms.
Then verify all users' trashcans are now empty:


As we now have our RESTful purge Web Script in place, it's easy to call it from an external script, maybe scheduled via a cron job for a periodical clean-up. In alternative it's possible to use the Quartz engine embedded into Alfresco, but my personal preference is to avoid putting into Alfresco too many responsibilities: if you need to change the scheduling it's easier for maintenance to have an external scheduler.

Thursday, February 10, 2011

My Career Path

At least twice a year day I'm thinking about my career path, I know it's a masochist attitude I can't prevent. I have changed many companies in the last few years and I have spent a lot of time traveling and consulting abroad, somehow until complete exhaustion. This year I'm settling down a little and this can help thinking clearly and planning for the next move.

However, you don't have many options if you leave in a mid-technical environment like Italy, where my natural attitude for freelance consulting is not easily sustainable. On the other hand, taking an airplane each Monday morning and sleeping in hotels five days out of seven is no more in my top list of wet dreams... I realized that after suddenly awaking in the middle of the night without knowing in what city or even nation I was: if you did consulting for more than few weeks per year, you know what I mean.

At the end, even if one is in the middle of a transition, the most important thing is to know who you are and where you want to go in the next following years. I then was re-reading an old, beautiful article from Dan North when, in his blog, I have found the best possibile definition for what I want to go (back) next:
[...] In particular I found I had moved away from the things I really enjoyed – writing software that matters and building high-performing software teams – more towards big organisational change, which, while it arguably has a bigger impact on an organisation, isn’t really where I wanted to be. So my criteria for what to do next came down to: writing business-critical software in a small, high-performing team, in an organisation that trusts its people and encourages them to excel. Having a great relationship with the consumers of that software and having them closely engaged with its delivery would be a huge plus.
The above bold sentence should fly into my CV under the section "Career Objectives".

Sunday, January 16, 2011

It's time to apply consumer's design models to Enterprise systems

I'm an happy Apple Mac user since one year now. I have never used a Mac before one year ago, when I decided to make the quantum leap, also because most of my Alfresco colleagues run a Mac and I have been always curious to try it. Before my idea was that Macs were cool but too much of a closed platform, now I think Macs are just the best way to have my work done. I do not want to judge some Apple's very restrictive policies here, everybody has a different opinion (I think the idea of forcing Objective-C on the iPhone is moving millions of Java developers toward Google Android, for example).

I had my MacBook Pro stolen few months ago but I also have an older PC-compatible laptop as a backup: after two days using it I felt the urgency to run to the very first Apple store to buy a new Mac. Back home, I opened the box, switch on it and after a few seconds it was able to recognize there is a NAS with Time-Machine backups: it offered me to restore the last backup and, after few hours, it was like my previous Mac was never stolen, as every piece of software was in its place, even the same desktop wallpaper and icons.

I never have to run anti-virus software, I never have to run any disk defragmentation or registry maintenance. I do not waste time in maintenance of hardware drivers: Apple design both hardware and software to work together, so that the user experience is always the smoothest. I'm also an happy user of Ubuntu Linux, which in my opinion is by far the best desktop Linux distribution. Ubuntu also runs daily in my Mac through a VirtualBox image, when I have to run some Linux software for my work. Despite the fact Ubuntu software is (almost) as easy as a Mac to install, configure and run, the fact is that Canonical - the company behind Ubuntu - is a software firm only, so they have to run their beautiful O.S. on a multitude of different hardware devices and software device drivers. This is the same problem Windows has. Each computer comes with different internal devices (motherboard, CPU, hard disk, network cards, Wifi cards, graphic card, ....), so there always a combination of hardware devices and software drivers which could cause a compatibility issue. It is always a race for Canonical, Microsoft and the others to prove their software on a plethora of hardware and sometimes broken drivers. So, when we put the blame on Microsoft in cases when Windows can be occasionally unstable, actually we should blame the real source, which usually is some sub-component of our PC and quite always a buggy software driver, which is out of control of Microsoft and others.

Of course, the above was especially true in the early days of personal computing, when enthusiasts like me were used to assemble their PC by hand. Now, if you buy especially a laptop from, say, Dell, HP, IBM, etc... you can be pretty sure all components are pre-tested, so everything will (almost) work just fine. However, nobody designs and produces beautiful hardware and client software like Apple does so, despite all competitors' efforts, my position is that the overall Apple user experience is still by far superior, exactly because every single component, together with communication, is designed with integration and user's experience in mind. It is interaction design at its best.

This positive and viable integration, by contrast, is very hard to be experienced when moving from consumer computing to Enterprise systems nowadays. Let's be honest: distributed enterprise systems are a total mess of hardware and software combinations. The level of incompatibility that we could have in a single consumer devices is multiplied by a magnitude factor. The major problems with Enterprise systems implemented, for example, in JEE or .NET, are due to inter-application and external systems integration issues. The applicative layer usually runs into different application servers, which runs over different operating systems and usually must connect to different relational databases, external information systems (ERP, CRM, ECM, etc....) and messaging systems. There is an explosive combinatorial matrix of configurations in need for testing and QA. At the end each customer needs to run on the existing infrastructure with few variations, so most of the time spent maintaining enterprise applications is actually spent trying to force a software into a specific and unique infrastructure: pitfalls are everywhere. Support centers spend most of their time just running after specific software + hardware configuration issues. No wonder if today some crucial business processes are still running into very old but well HW + SW integrated mainframes.

The positive Apple's integration model should work also for enterprise-class solutions. In my mind Sun Microsystems was one of the companies going closer to applying the Apple's consumer integrated design model to the enterprise world. Sun designed both hardware and software (Solaris O.S., Java, etc were tuned to specific Sun's servers and components). Buying a Sun server was usually a positive integrated experience, running Oracle on Sun servers was a rock-solid decision. The main problem, in my humble opinion, is that Sun was not ready or not willing to go the extra mile: moving the software stack up to applicative layer and moving their business out of the commoditized server business. I mean, Sun's management perceived they had to, as the late open-source initiatives testifies, but the company has never been structured to make this vital step forward executing the process in the right way (McNealy almost acknowledges this), so most of the ideas remained on paper or stuck without execution until Oracle's acquisition was the only way to save the company.

I think strong infrastructural integration is now not enough for a vendor to exit from commoditization trends and for a customer to solve integration's madeness. Some Cloud Computing initiatives are a clear step in the direction of moving the stack up from Infrastructure as a Service to actual Software as a Service. At the end, moving in the cloud the infrastructure only is not going to solve most of the applicative-level problems of moder enterprise solutions: if, for example, I run my software into Amazon EC2, I can solve many infrastructural provisioning problems in a row, but at the applicative layer my J2EE solution is still running into different O.S and application servers which need to be integrated and tested for compatibility and performances.

I guess, even if existing platforms are maybe too young and still immature to move all solutions there, the right direction for better isolating applications and application development from infrastructural problems will be to provide a complete, uniform applicative platform where most reliability and scalability problems are solved by model's definition. I think initiatives like the Google App Engine, VMWare's Cloud Application Framework, Salesforce Platfom are good examples of what could bring Apple's consumer-side positive experience into the enterprise applications ecosystem soon. Companies should eventually show some perspective, intelligence and courage and start experimenting as soon as possible.

Update (20 Jan 2011): Amazon has just announced the new AWS Elastic Beanstalk, which I think should be included in the above list of advanced PaaS solution. It looks much like GAP and at first sight Amazon's new platform shows an interesting degree of flexibility for developers. First released version is for Java.

Thursday, October 21, 2010

XA Transactions

Reading MySQL documentation I have found a good description of how XA distributed transactions and two-phases commit work. I like to share it because it's short, clear and applies in general situations. It also teaches us why distributed transaction, being much more complex, should be managed very carefully to avoid severe performance penalties.
Applications that use global transactions involve one or more Resource Managers and a Transaction Manager:

A Resource Manager (RM) provides access to transactional resources. A database server is one kind of resource manager. It must be possible to either commit or roll back transactions managed by the RM.

A Transaction Manager (TM) coordinates the transactions that are part of a global transaction. It communicates with the RMs that handle each of these transactions. The individual transactions within a global transaction are “branches” of the global transaction. Global transactions and their branches are identified by a naming scheme described later.

The MySQL implementation of XA MySQL enables a MySQL server to act as a Resource Manager that handles XA transactions within a global transaction. A client program that connects to the MySQL server acts as the Transaction Manager.

To carry out a global transaction, it is necessary to know which components are involved, and bring each component to a point when it can be committed or rolled back. Depending on what each component reports about its ability to succeed, they must all commit or roll back as an atomic group. That is, either all components must commit, or all components musts roll back. To manage a global transaction, it is necessary to take into account that any component or the connecting network might fail.

The process for executing a global transaction uses two-phase commit (2PC). This takes place after the actions performed by the branches of the global transaction have been executed.

In the first phase, all branches are prepared. That is, they are told by the TM to get ready to commit. Typically, this means each RM that manages a branch records the actions for the branch in stable storage. The branches indicate whether they are able to do this, and these results are used for the second phase.

In the second phase, the TM tells the RMs whether to commit or roll back. If all branches indicated when they were prepared that they will be able to commit, all branches are told to commit. If any branch indicated when it was prepared that it will not be able to commit, all branches are told to roll back.

In some cases, a global transaction might use one-phase commit (1PC). For example, when a Transaction Manager finds that a global transaction consists of only one transactional resource (that is, a single branch), that resource can be told to prepare and commit at the same time.