Sunday, December 12, 2010

Dom_12_Dic_2010_18:07:53_CET.log

Playing around with python messaging, in particular RabbitMQ, celery and pika, yesterday night till 5pm! I should probably get a life.

Sunday, September 5, 2010

Python and Oracle: you need to start somewhere!

If you need to access an Oracle database using python (actually, to access any database), the first thing you'll need to read is the Python Database API Specification 2.0, which proposes a standard interface to be used by database access libraries. This specification is database agnostic, and various libraries exist which implement it (more or less strictly) for different DBMS.
The library I am using for Oracle access is cx-Oracle, which (almost!) conforms to this specification.
If the Python Database API Specification is too abstract for you and you'd be happy if the official cx-Oracle docs contained more examples, what you need is a nice tutorial to introduce yourself to this library. Then maybe another tutorial to go beyond the basics. Now probably the Specification and the cx-Oracle docs make more sense!
Oh, if you want to work with cx-oracle, you will need to install it first :-). I found very useful this howto  by Catherine Devlin. If you work with Ubuntu, you will love it for sure.
Hope this helps!

PS
I assume that yo have some familiarity with Python and Oracle.
If not, I bet this post is not the most interesting you've ever read!

Sunday, May 16, 2010

Model View Controller

Straight to the point: in a MVC architecture, do Model and View need to communicate directly, or all the communications should be mediated by the Controller? There are two schools of thought regarding this topic, and the question often generates little funny religion wars.
The best answer to this question which I have ever found is in the Cocoa Design Patterns document, available on the Apple dev center website (by the way, the document is a recommended reading regarding design patterns in general, whatever the language, platform or technology you use).

To sum up, the document describes both models, named "traditional model" (in which there is direct communication between model and view) and the "Cocoa model", in which the Controller always mediates between View and Model.

Here is the "Traditional" MVC model:

Here is the "Cocoa" MVC model:


One of the main arguments in defence of the second architecture is that it theoretically improves the reusability of View and Model, because they are totally decoupled.
Read Cocoa Design Patterns for a thorough discussion!

Iphone Application startup: the complexity behind the scenes.

Let' write an IPhone application which displays a single "Helloworld" label at the center of the display.
It's plenty of tutorials and books which explain how to do that: usually they explain how to use a View Based project template in X-Code, add a label with Interface Builder, and run the application.
Very easy.
But have a look to the set of files generated by Xcode while choosing the View based template: you will see a main method, an Application Delegate class, a ViewController class, a plist file, and two .xib files which define the main Window and the main View of the application.
Also, you will notice that the main .xib file is referenced in the plist file (as the "main nib" ..), and that it is made up of five objects: a UIApplication, a UI Responder, the Application Delegate, the View Controller and a Window Object. Also, some references between objects (or, more precisely "Outlets") are defined: the UIApplication contains a reference to the Delegate Object, which in turn contains references to both the ViewController and the Main window. Finally the ViewController is owner of the second .xib file, which defines the actual interface of our application and is connected to our ViewController class by the usual mechanism of Outlets and Actions.
Quite complicated for a simple HelloWorld application!

Fortunately, somebody (Bill Dudney) already made an effort to put all the pieces together and explain very clearly how they all work together: Demystifying iPhone App Startup
Really a great post, highly recommended!

Sunday, May 9, 2010

Did I write that code?!?

Preliminary warning: this post is not worth reading for you if you never make mistakes.


Illusory superiority is, according to Wikipedia's definition, "a cognitive bias that causes people to overestimate their positive qualities and abilities and to underestimate their negative qualities, relative to others"
It is that well-known, well documented phenomenon (also known as the above average effect) that makes so easy for us (T)IT professionals to judge and criticize other people's work. It's a fact of life.
In other words, we tend naturally to have a distorted perception of reality when it comes to evaluate the quality/effectiveness of our work compared to the quality/effectiveness of the work of our colleagues.
It is extremely therapeutic, in order to come back to reality, to periodically try to spot major flaws in your own work: poor design or shitty code, completely wrong approach to problems, wrong organizational choices. Try to be as cruel as possible (which means: as cruel as you would be if you were analyzing other people's work).
The epiphany will occur when you'll find yourself wondering, confused: "did I really write this code?" (or "did I really choose this process? did I really proposed this solution? did I really ignore this issue?", depending on what your actual work is).
Everybody makes mistakes, experience allows us to improve ourselves recognizing them, but this virtuous path requires humility, as written in almost all books of self improvement written by spiritual gurus, genuinely illuminated guides or simply people which love making money selling books about this kind of stuff (And they actually sell them: smart guys, definitely above the average).

Tuesday, April 13, 2010

Iphone Apps vs Mobile Web vs Android vs... The winner is...

... Apple!

Yesterday night I attended a Mobile Monday meeting in Düsseldorf about current trends in mobile development, namely native apps (Iphone, Android, ...) vs browser-based web applications.
The meeting did not make me change my mind about the best opportunities the market is offering these days to smart developers. I actually think there's a winner around, Apple, and its mobile eco-system (Iphone, Ipod, Ipad, ...).
Why? A few reasons here:
  1. Apple Iphone Apps and the App Store proofed to be effective, changing the mobile standards and defining a brand new profitable business model paradigm; the other main actors (including Google, I would say) are making their moves, of course, but they are all, still, behind
  2. Objective C's popularity is quickly increasing, but still there are not as many good OC developers on the market as many web developers or java developers. Have a look to the job offers and you'll be quickly convinced that learning OC is not a waste of time on a career perspective.
  3. The market requires Iphone developers: loads of major companies want a branded Iphone application because it's cool, because it contributes positively to the brand, because the Iphone is de facto  the "smart phone" par excellence. An example to make my point clear: http://www.tecnisa.com.br/lp-iphone.html. Tecnisa is one of the major brazilian construction firms, and they have a branded Iphone app, beautifully advertised in their website. No Android application, did you notice it?
  4. Have you ever browsed your huge collection of porn pictures on an Ipad (come on, I know you DO have a huge collection of porn pictures, and you DO know who Peter North, Davide Jannello and Jenna Jameson are...)? The truth is: Apple devices are the coolest around (but I'm looking forward to see Casio mobile devices!!!).
Prepare to buy my applications on the Apple Store!

PS
Of course I know you still can make loads of money developing "traditional" Web Apps, or Android Apps or.. whatever. Even developing python scripts or java command-line tools for DBA's or Sys-Admins. Probably even playing a Calabash-made harp-lute. It all depends on three factors:
  1. How smart you are
  2. How business oriented you are
  3. How lucky you are!