In questi giorni sto leggendo
"Clean Code" di Robert "Uncle Bob" Martin e volevo regalarvi alcune perle che mano mano sto trovando.
Nel capitolo 6 - Objects and Data Structures, pagina 97, circa l'
antisimmetria fra il codice procedurale e il codice ad oggetti.
Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions.
The complement is also true:
Procedural code makes it hard to add new data structures because all the functuions must change. OO code makes it hard to add new functions because all the classes must change.
So, the things that are hard for OO are easy for procedures, and the things that are hard for procedures are easy for OO!
Ma anche "est modus in rebus" ;)
Mature programmer know that the idea that everything is an object is a myth. Sometimes you really do want simple data structures with procedures operating on them.
Ammetto candidamente di non aver mai pensato alle differenze fra i due paradigmi in questi termini. Anche per quello mi considero in cammino...