Monday, December 2, 2013

Google+ gets physical!

Thanks to Davide, some weeks ago I had the pleasure and the privilege of being one of the speakers at the Google Developers Groups DevFest Lombardia in Milano. Being part of such an event, surrounded by many brilliant speakers, is not a responsibility to be taken lightly. I hope I have managed the task, and if the attendees have had at least half the fun I've had I consider myseld more than satisfied (this sentences reminds me a little bit of the parting speech of Bilbo Baggins, so if you find I have not expressed myself clearly enough please assume it was intentional)


The talk presents an introduction to the Google+ platform (thanks to Google for the materials), and shows how easy it is to go beyond social as we know it and bring it to a different level in the Internet of Things.

It was great to meet so many brilliant people, some of which were so lucky to be in Mountain View the following week, so I'm looking forward to the next DevFest!

Sunday, September 8, 2013

A bit of fun with Zend Framework 2

After writing web applications in Java for about ten years, we recently approached PHP. After a bit of training and experiments on the Zend Framework 1, before starting to actually work on a real product we decided to switch to the Zend Framework 2 (mostly because of a great Zend Framework Day).
But it was only after a few months that my colleagues had started to use the framework that I eventually joined them.

At the beginning it was really frustrating. After ten years of Java, getting "back" to PHP has been somehow weird: I kept using dots instead of arrows, always forgot the dollar sign before variables, yet insisting on declaring their types. Not to mention the syntax to declare and use arrays (which, to tell the truth, I never remember also in Java). But these were not problems, just minor diversions.

My real problem was that I didn't know what happened under the hood, and I mostly proceeded tentatively. In the Zend Framework 2, of which by the way I have quite a good opinion, so many things happen automagically, and some of them are not very well documented. I mean, thanks for a great tutorial for beginners and all, but... why on earth do I have to create an album/album directory for the view? Would it be so terrible to say that there is a folder for the module and one for the controller? Or to explain how camel case turns to dashes and dashes turn to... what do they turn to?

And so, even the simplest tasks seemed daunting. Then, after banging my head on the wall for a while, I slowly started to get the gist of it, up to the point that now I feel quite confident, at least for the basic things.

And then, suddenly (snaps glove), you get a break... all the pieces seem to fit into place

And, hear, I started to enjoy playing with it: controllers, factories, autoloading... and, last but not least, tests. And (and, even if this was the fifth and in such few a lines, I somehow managed to slap in a sixth and a seventh one) I slowly switched from "how the hell do I get this parameter from the route?" back to "where should I put the responsibility of horizontally filtering data"?

Up to the point that I am seriously considering the possibility to REALLY get way out of my comfort zone and submit a proposal for one of the next conferences introducing the framework for beginners like me, trying to smooth the path I have lightly trodden with so many difficulties.

Hey, maybe it's only me, maybe I'm particularly dumb... but then again, somebody could find it useful. As always, I'm wide open for suggestions... but closed for modification :-)

As an end note, I'd like to thank Antonio for being so patient and putting up with my musings, questions and doubts. Looking forward to some more programming fun time together!

Thursday, May 2, 2013

I broke a build... let's celebrate!

Some three years ago I wrote a small test for a very particular factory: it worked pretty well, even if I've never really liked the constraints imposed by the requirements about the exception that is expected to be thrown.

Yesterday, not quite unexpectedly, the build was broken.

Obviously this is not really a unit test, as it depends on real data, so I'd call it more an integration test. Anyway, the data changed and the test failed, thus breaking the build. Normally I wouldn't be so happy. Yet in this case, even if it might be an antipattern (it clearly is), I think I won't change the test to be independent from data, but change the test instead:

public void makeBaby() {
  Family family = moz.getFamily();
  assertEquals(3, family.getChildren().size());
  BabyFactory factory = family.getWife();
  Baby babyboy = factory.makeBabyBoy("Ethan");
  assertEquals(4, family.getChildren().size());


Now I'm only waiting for the requirements to change so that I can remove the exception...

Monday, February 4, 2013

PHP Application Development with NetBeans: a review

After too much time I've been able to review "PHP Application Development with NetBeans: Beginner's Guide" by M.A. Hossain Tonu, published bky Packt. The official description of the book says that it's "aimed at PHP developers who wish to develop PHP applications while taking advantage of NetBeans functionality to ease their software development efforts and utilize the powerful features of the IDE. Familiarity with NetBeans is not assumed. However, a little familiarity with PHP development is expected.".

TLDR? You can skip the review and jump to the rating. Of course that would kill my ego, but if you still want to stab me in the back here's your knife. Et tu, Brute?

A small disclaimer

I do have a little familiarity with PHP development, and I have a strong familiarity with NetBeans, being a NetBeans Certified Professional, so while on the one hand I belong to the right target, on the other hand I might get extra-critical. Well, the book has been reviewed by no less than six professionals, so I guess my rants can happily and safely be ignored.

I must also note that I have received a free copy of the book in exchange for the review.

Here we go

As every Packt book I've seen (and I've not seen a few) the fonts are easy on the eye and there are many clear pictures. A bit of critic on the code sections, sometimes too long and with a lot of boilerplate that could be found in a downloadable file (it actually is) or confined in an appendix dedicated to the complete code.

Every now and then there are some "Pop quiz" sections, short multiple choice questions. As a rule of thumb I am not very impressed, because they remind me too much of a braindump. I'm OK with the ones on concepts, but not so much with the ones regarding actions, for which I'd rather have more hands-on. Speaking of which, we have the "have a go hero" sections, that often asks us to do completely new things rather than insisting on variations of what has already been done: that can be seen as a plus or a minus, depending on the eyes of the reader.

The first chapter guides the reader through the installation of the IDE and the whole stack environment. Having everything already installed (see initial disclaimer) I didn't check each and every passage, but everything seems very well explained and pretty much the way I remembered it.

The second chapter introduces the editor, yet I'm afraid it doesn't effectively convey all its power and potential, many things have been left unsaid or have not been deepened enough, like the possibility to customize the code templates and the folding criteria, not to mention specific editors for other languages.

One thing I didn't like is the position of the shortcuts, which are often presented out of context and way after the corresponding feature has been described. I think that an approach like "this is your action, and this is its shortcut" would be much better, as the proximity helps to sink the concept in.

The chapter follows the "here's the theory, try it in practice" pattern, yet I find the loop between the two to be too long. This is an issue throughout all the book (at least, it is in my opinion). A little less conversation, a little more action.

The third chapter introduces us to project in which we complete a whole user story. It starts with a description of the technologies used, then slowly presents all the code. The chapter is very similar in concept and structure to the seventh one, in which the skeleton for an enterprise feature (user registration, login and logout) is presented. In both cases there is a lot (trust me, when I say a lot I mean it, particularly in chapter 7) of code before we can actually see something working. Forgive me for the politically uncorrect comparison to another publisher, but from this point of view the "Head First" series are much better, as they start with something working, then they slowly build things up.

Moreover, the chapters are more about the technologies used in the application rather than NetBeans. Chapter 7 in my opinion is even worse, because it deals with more advanced subjects that a beginner probably doesn't know. OK, take the probably away. Yet, ironically, after several patterns and abstractions, and almost at the end of the book, the author says "it is recommended that you are familiar with PHP sessions and cookies in this tutorial", a subject simpler than many others that are taken for granted.

Chapter 4 is on testing and debugging, it's quite good (I must admit I had some problems with my instance of PEAR but that has nothing to do with the book). Some more details on Selenium would do no harm, at least a screenshot of the results should be inserted.

Chapter 5 deals with documenting your code and it's quite good. It also happens to be the chapter that you can download to evaluate the book.

Chapter 6 is about versioning with git and NetBeans. It's not bad, yet it does not show how to unstage a file (why not a have a go hero here?). Another feature that's dealt with too lightly is merging, and the resolution of conflicts is only briefly cited. And, talking about versioning, chapter 2 ends with a warning about the position of NetBeans metadata directory with respect to versioning, but it does not explain the consequences of the choice; some hints or advice would be nice.


Now, here we are with the conclusions. If you skipped all the article to jump to this section, please feel a little guilty.

The book should be an introduction, yet some PHP concept are quite advanced for a beginner. It helps you to get up and running with a complete environment and introduces you to many features of NetBeans, yet some important things are left out. All in all, in my very personal scale the books rates 3.5 our of 5.