giovedì, settembre 13, 2007

Checked Exceptions e Vista

Ovvero dell'essere rassicurato dalle idee comuni

No, checked exceptions e windows vista non sono i correlazione tra loro. E' che
talvolta capita di avere delle sensazioni e poi vedersele confermate da altri che, con maggior autorità e chiarezza, le espongono per farle diventare dei veri e propri punti di vista.

Ecco Hamilton Verissimo sulle Checked Exceptions:
If there’s one thing I hate about java…

Invece su Windows Vista niente meno che Joel Spolsky (link):

"I've been using Vista on my home laptop since it shipped, and can say with some conviction that nobody should be using it as their primary operating system -- it simply has no redeeming merits to overcome the compatibility headaches it causes. Whenever anyone asks, my advice is to stay with Windows XP (and to purchase new systems with XP preinstalled)."

martedì, aprile 17, 2007

IE quirk for js window.open

window.open is a common javascript call used to open a new browser window from the current page. The syntax is the following:


var newWin = window.open(url, name, options);

So this should be a perfect call:


But it fails with an "invalid argument" error in IE6. The problem is the '.' character in the name parameter. It seems like IE 6 accepts only letters, numbers and '_' for that parameter, but I couldn't find ANY more info about this. Does anyone have more clues about this??

lunedì, aprile 16, 2007

prototype.js su Java Journal

Sul numero 3 di JavaJournal c'è un mio articolo sull'uso di prototype.js per creare applicazioni AJAX . Qui anche un estratto.

mercoledì, aprile 04, 2007

Li Taliano

Oggi in treno ero seduto a fianco due ragazze. E ridevano tra di loro delle email e delle telefonate che ricevono da fornitori, clienti, capi, referenti. Ecco alcune perle:
"Q'uando sarà pronta sarà spedita"

"Ho appena evacuato il suo ordine"

"Sono obesa di lavoro"

(parlando di merce da ritirare)"costei è pronta da ritirare"

Purtroppo siamo arrivati in fretta, altrimenti le risate sarebbero continuate!

lunedì, febbraio 19, 2007

Code Gallery: defensive coding!

Nothing frights more a developer than a NPE! A C# reporting app, period: year 2007:
public AReport generateReport(...)
{
    //do somethig
    AReport report= new AReport(...);
    if ( report != null )
    {
      return report;
    }
    else
    {
      return null; //!!!!
    }
}
Comment: how to smartly avoid a (brrr!) feared NPE! Here's the clever algorithm, stated after long mumble numble the author:
1- instantiate an object with a new Something()
2- don't rely on "new"! what if it doesn't work? (what if the moon crashes on hearth, I'd reply...)
3- test the newly instantiated object: is it null?
4- if yes... That's the unexpected case, I think! our man had to be in real trouble: what to do NOW? Here comes the artist touch and sensibility, if it is null... well... simply... return null!

A great little cameo: how to look busy and fill of dust a 3 lines method.

mercoledì, febbraio 14, 2007

Fisica dello stato solido al Politecnico

Io mi sono laureato al Politecnico di Torino nel 1999. Oggi, dopo ben 8 anni, mi è capitato di entrarci di nuovo, da un ingresso un po' laterale, di quello che pochi usano. E' ho scoperto che il cartello misterioso, che tante domande ha sollevato è ancora lì. Qualcuno sa dare qualche significato?

Jug Torino Meeting 21 - febb - 2007

La prossima settimana tengo un seminario al meeting mensile del JugTorino!
Tutti dettagli qui e qui sotto il programma:


JugTorino Meeting
21 - febbraio - 2007


Presso CSP SpA Corso Svizzera 185, 10149, Torino
Fabbricato 1, Scala H, 2° Piano


PROGRAMMA:

h18:30 Check-In

h18:45 JugTO Quickie:UML for Dummies
Impara a leggere e scrivere class e sequence diagram in pochi minuti!
Bruno Bossola, JUGTorino

h19:00 JugTO Hands-On: Design Patterns by Examples: il Decorator
Come aggiungere comportamenti e responsabilità alle classi esistenti senza modificarle. Entriamo nel JugTO Lounge Bar per fare pratica!
Domenico Ventura, JUGTorino

h20:00 JugTO Pizzata!

INFO:
http://www.jugtorino.it/vqwiki/jsp/Wiki?MeetingFebbraio2007
meetingfebbraio@jugtorino.it

lunedì, febbraio 12, 2007

lunedì, febbraio 05, 2007

Code Gallery: create and destroy

Known as "stable" code, a so called J2EE web application, period: year 2005:

//used in the creation of some kind report
public void shiftColumn(...)
{
    //do somethig
    if ( isBlankCell(table, row, srcCol) )
    {
      cell = row.createCell((short) destCol);
      row.removeCell(cell);
    }
    //do somethig else
}


Comment: a great example of coding for obfuscation, which states: "never ever will you clearly express your intention through code".
Why creating a new cell and destroying it the line after? And why that subtle test, which checks for srcCol, but creates a new cell at destCol? The artist leaves us slightly dazed and confused, while thinking of his wisdom.

giovedì, febbraio 01, 2007

Code Gallery: error messages

Production code, unknown artist, VB school, period: beginning of 2000th:

Public Function getGridURL(...,ByVal values As xxx,...) As String
    Dim url As String
    -- Do some stuff
    If values Is Nothing Then

        url = "ERRORE PIRLA" -- italian for "FUCKING ERROR"
    Else
        --Do other stuff
    End If
    Return url
End Function

Comment: a little masterpiece for its conciseness, the clean stroke and the ability to crash the whole application.

Il Cardinale Poletto

Ecco uno splendido campionario delle posizioni della chiesa cattolica. Difficile capire in quale mondo vivono (non su questo sicuramente):
Articolo [La Stampa]

venerdì, gennaio 26, 2007

Surviving a .Net web project (1 episode)

(from a java developer perspective...)

It happened: I was asked to build a webapp using .Net, and the old 1.1 version, too!
Discarded (without a real evaluation...) VB.Net, I went discovering C#, hoping it would be more comfortable for a Java developer.

So I downloaded the .Net framework, installed Visual Studio for .Net (hey, does anyone know some sort of plugin for Ecplise or some other C# IDE to use?) and started with some HelloWorld, HelloEverybody and so on.

First reaction: VStudio sucks! really! Particularly if you got used to Eclipse. Or maybe I' m not good in using it...
Some examples:
- It opens all files in tabs, like Eclipse, like UltraEdit, like PSPad, but... No close all command!
- Absolutely no navigation through code (like ctrl+click in Eclipse): just go to definition
- No refactoring utilities at all: cannot automatically rename even a local variable!

C#, in version 1.1 is quite like Java, no especial oddities, apart for property definition in interfaces, but done with an expressive syntax:

string AProperty { get; set:}

More to come, stay tuned!

mercoledì, gennaio 17, 2007

Checked vs Unchecked Exception

Una delle principali differenze rispetto a Java che ho trovato lavorando in C#, è l'assenza di Checked Exceptions. Cioè in C# tutte le eccezioni sono unchecked.

Mentre altre differenze mi convincono oppure no, di questa non riesco ad avere una opinione precisa.
Sono (o ero?) abituato a considerare le Checked Exception una BUONA COSA, ma..

  • Ad esempio ho visto che per l'integrazione e il supporto di Hibernate in Spring, la classe HibernateTemplate una delle cose principali che fa è trappare tutte le checked exception di Hibernate e rilanciarle come unchecked.
  • Ho visto (e scritto anche) troppo codice Java con metodi che rilanciano 7,8,9 eccezioni diverse, che si propagano, si propagano, si propagano, fino al catch/finally del main...
  • Ho letto questo:
    http://www.artima.com/intv/handcuffs.html

    dove uno degli architetti di C# spiega i perché non ci siano checked exception in C#

Insomma, non riesco ad avere una opinione precisa:
per alcuni versi le checked exception mi sembrano utili e necessarie, per altri mi dico (forse anche a causa dell'abuso che ne fa il JDK) che se ne farebbe volentieri a meno.