martedì, settembre 09, 2003

Why extends is evil: Gosling che dice che se dovesse rifare Java lo farebbe senza classi? E' una provocazione interessante che serve ad Allen Holub per partire sul conflitto fra ereditarietà e aggregazione. La banda dei quattro di Eric Gamma e il movimento dei pattern sono stati chiari in proposito: aggregare è meglio di ereditare. "I once attended a Java user group meeting where James Gosling (Java's inventor) was the featured speaker. During the memorable Q&A session, someone asked him: 'If you could do Java over again, what would you change?' 'I'd leave out classes,' he replied. After the laughter died down, he explained that the real problem wasn't classes per se, but rather implementation inheritance (the extends relationship). Interface inheritance (the implements relationship) is preferable. You should avoid implementation inheritance whenever possible. "

Nessun commento: