domenica 22 luglio 2012

Filosofia della stesura del codice

Proprio l'altro giorno commentavo insieme al mio amico J0rd4n0 un link da lui twittato riguardante dieci semplici cose da ricordare quando si scrive codice. La discussione era particolarmente filosofica, e mentre l'articolo da lui postato considerava quei punti "assolutamente necessari", io ero più propenso a dire che si stesse parlando di passaggi da valutare caso per caso. Inizierò quindi un esame punto per punto di questa filosofica discussione.

Lambda Expressions in .NET

Lambda expressions are anonymous functions used to create delegates and complex expressions. They can contains expressions-only instructions and complete functions bodies.
In the beginning I must admit that I haven't seen any necessity to use them inside a context like the .NET Framework. I've mostly seen them useful for interpreted languages like Javascript. Using LINQ, I always prefered to use SQL-like sintax against extension methods and lamdba expressions.  Instead, during a recent .NET Campus event, I've completely changed my mind. I have been illuminated when I saw lambda expressions applied to several sorting and selecting algorithms in XNA development. They're the best choice for who need to write fast delegates without getting dirty the class code with functions that will be used very rarely.