<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4364592042964713187</atom:id><lastBuildDate>Mon, 09 Sep 2024 03:44:31 +0000</lastBuildDate><category>scala</category><category>c#</category><category>coffeescript</category><category>costing</category><category>first class functions</category><category>java</category><category>mixin</category><category>project costing</category><category>project management</category><category>python</category><category>ruby</category><category>Agile</category><category>Convention over Configuration</category><category>FX4</category><category>Firefox 4</category><category>IE9</category><category>IT</category><category>Intel</category><category>Linux</category><category>Maven</category><category>Project Cost Estimation</category><category>REST</category><category>Ruby On Rails</category><category>SBT</category><category>Silverlight</category><category>Ubuntu 8.10</category><category>Web Service</category><category>X3100</category><category>XAML</category><category>Xorg</category><category>air</category><category>ajax</category><category>android</category><category>app</category><category>async</category><category>asynchronous programming</category><category>await</category><category>chrome</category><category>closure</category><category>computer languages</category><category>crisi</category><category>database</category><category>enterprise architecture</category><category>ereditarietà</category><category>espressività</category><category>flex</category><category>font</category><category>fp</category><category>functional programming</category><category>git</category><category>github</category><category>gps</category><category>groovy</category><category>igoogle</category><category>igoogle alternatives</category><category>indicizzazione</category><category>interfaccia</category><category>javascript</category><category>json</category><category>lavoro</category><category>leadership</category><category>linguaggi</category><category>nfc</category><category>oop</category><category>phishing</category><category>programmazione funzionale</category><category>prototype</category><category>ricerca</category><category>sinteticità</category><category>switch</category><category>swype</category><category>version control</category><category>windows 8</category><category>xorg.conf</category><title>AlessioSaltarin WebLog</title><description>&lt;small&gt;&lt;i&gt;&quot;Stanco dell’infinitamente piccolo e dell’infinitamente grande, lo scienziato si dedicò all’infinitamente medio&quot;&lt;/i&gt; &lt;br&gt;&#xa;(Ennio Flaiano, 1956)&lt;/small&gt;</description><link>http://alessiosaltarin.blogspot.com/</link><managingEditor>noreply@blogger.com (Guildenstern70)</managingEditor><generator>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-7429015684683880579</guid><pubDate>Fri, 21 Aug 2015 12:39:00 +0000</pubDate><atom:updated>2015-08-21T15:05:20.431+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">leadership</category><title>Lezioni di leadership da Flo Rida</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Nell&#39;&lt;a href=&quot;https://www.youtube.com/watch?v=Tw8mpgccugc&quot; target=&quot;_blank&quot;&gt;ultimo video&lt;/a&gt; del rapper nero &lt;i&gt;Flo Rida&lt;/i&gt;, c&#39;è una scena che secondo me insegna almeno quattro punti fondamentali nell&#39;esercizio di una leadership vera.&lt;br /&gt;
&lt;br /&gt;
Nel &lt;a href=&quot;https://www.youtube.com/watch?v=Tw8mpgccugc&quot; target=&quot;_blank&quot;&gt;video&lt;/a&gt;, Flo Rida è seduto per strada con i suoi amici - il suo &lt;i&gt;team&lt;/i&gt;, potremmo dire - &amp;nbsp;e a un certo punto succede &lt;i&gt;qualcosa di notevolmente straordinario&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFWWLcxzummZGObdcPHcuhWflPxyGjzlIyiVUFoUMe7twn_M9YJHfDc6McyOhBfAj6JD13TQHh_DbYTJLVE2rd_jNamMYpfpoPuYZxQTmLFIGWNfE8pKeQjpSMrhobAz_JJ8nnER1joOn1/s1600/Capture.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;245&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFWWLcxzummZGObdcPHcuhWflPxyGjzlIyiVUFoUMe7twn_M9YJHfDc6McyOhBfAj6JD13TQHh_DbYTJLVE2rd_jNamMYpfpoPuYZxQTmLFIGWNfE8pKeQjpSMrhobAz_JJ8nnER1joOn1/s400/Capture.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Passa un ambulante di gelati (&lt;a href=&quot;https://www.youtube.com/watch?v=Tw8mpgccugc&quot; target=&quot;_blank&quot;&gt;54&quot;&lt;/a&gt;) e Flo Rida si alza e offre il gelato ai suoi amici. Fin qui, niente di strano. E&#39; il &lt;i&gt;come&lt;/i&gt; lo fa, che è straordinario.&lt;br /&gt;
&lt;br /&gt;
Ordina un gelato per ciascuno dei suoi amici, poi se lo fa dare di persona, poi lo porge, con cura,&amp;nbsp;personalmente a ciascuno dei suoi: &lt;i&gt;Ecco questo è per te, Alessio&lt;/i&gt;, &lt;i&gt;Questo è il tuo, Daniela&lt;/i&gt;. Non è notevole? Avremmo fatto lo stesso?&lt;br /&gt;
&lt;br /&gt;
In questo brevissimo passaggio, il rapper esercita la leadership in quattro importanti modi: il vero leader:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;i&gt;ti indica la via e ti spiana la strada&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;ti coinvolge personalmente e ti chiama per nome&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;si prende cura di te, assicurandosi che tu abbia tutto il necessario per proseguire&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;si spende in prima persona e ci mette la faccia&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Nella mia carriera ho lavorato con tanti leader, veri o presunti tali, leader naturali o imposti dall&#39;alto. Ho notato nei primi, sempre rispettati, i quattro punti di cui sopra.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2015/08/lezioni-di-leadership-da-flo-rida.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFWWLcxzummZGObdcPHcuhWflPxyGjzlIyiVUFoUMe7twn_M9YJHfDc6McyOhBfAj6JD13TQHh_DbYTJLVE2rd_jNamMYpfpoPuYZxQTmLFIGWNfE8pKeQjpSMrhobAz_JJ8nnER1joOn1/s72-c/Capture.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-7818260027620727177</guid><pubDate>Thu, 28 Aug 2014 08:17:00 +0000</pubDate><atom:updated>2014-08-28T10:28:11.762+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">indicizzazione</category><category domain="http://www.blogger.com/atom/ns#">ricerca</category><category domain="http://www.blogger.com/atom/ns#">swype</category><category domain="http://www.blogger.com/atom/ns#">windows 8</category><title>Cercare in un file in Windows 8</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Vi sarà sicuramente capitato di&amp;nbsp;ricercare i contenuti&amp;nbsp;di un&amp;nbsp;file in Windows 8... &lt;em&gt;e di non trovarli mai!&lt;/em&gt;&amp;nbsp;Fate il vostro bel &quot;swype&quot; come vi hanno insegnato, andate sulla lente di ingrandimento, mettete la parola da cercare e... mai che vi trovi il documento che contiene quella parola!&lt;br /&gt;
&lt;br /&gt;
Avrete sicuramente mandato a quel paese gli ingegneri del software della Microsoft, e avrete pensato che quelli che dicono che Windows non funziona hanno ragione!&lt;br /&gt;
&lt;br /&gt;
No, in realtà la ricerca indicizzata di Windows 8 (e 8.1 ovviamente) funziona molto bene, peccato che occorra personalizzarla - e questa è una delle prime cose che andrebbe fatte dopo aver installato il sistema operativo. &lt;br /&gt;
&lt;br /&gt;
Per ovvi motivi, Windows appena installato indicizza solo alcune (poche!) cartelle, perché altrimenti le operazioni di indicizzazione sarebbero molto lunghe, e il file che contiene l&#39;indice potrebbe diventare enorme.&lt;br /&gt;
&lt;br /&gt;
Tuttavia, è molto semplice personalizzare le opzioni di ricerca e ottenere un&#39;indicizzazione dei vostri contenuti, in modo da poterli trovare immediatamente.&lt;br /&gt;
&lt;br /&gt;
Per prima cosa, &lt;em&gt;swype&lt;/em&gt; (cioè passare il mouse sulla parte destra dello schermo), selezionare &quot;Impostazioni&quot; (&quot;Settings&quot;) e poi &quot;Pannello di Controllo&quot; (&quot;Control Panel&quot;).&lt;br /&gt;
&lt;br /&gt;
In alto a sinistra nel box di ricerca scrivete, se avete Windows in inglese &quot;index&quot;, altrimenti in italiano &quot;indicizzazione&quot;. Verrete portati a questa schermata:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjovN_LOGmkhbeNCLE3plnDgcVLkQuxtFvADXAk0QeUGguAUlotCe3jqxBrpnmqFrzWdY1Iz0boqN07delDMo90Rr58GytJlrn-FL9KwTHXI1NavOD1OTtKll1o4Yk5YaQCSTRF5Q6nCas8/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjovN_LOGmkhbeNCLE3plnDgcVLkQuxtFvADXAk0QeUGguAUlotCe3jqxBrpnmqFrzWdY1Iz0boqN07delDMo90Rr58GytJlrn-FL9KwTHXI1NavOD1OTtKll1o4Yk5YaQCSTRF5Q6nCas8/s1600/Capture.PNG&quot; height=&quot;320&quot; width=&quot;318&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Attraverso questa schermata, premendo &quot;Modify&quot; (&quot;Modifica&quot;), è possibile selezionare le cartelle del PC i cui contenuti verranno indicizzati e saranno quindi disponibili per una ricerca veloce.&lt;br /&gt;
&lt;br /&gt;
Unico consiglio: non esagerate! Immettete solamente le cartelle dove effettivamente archiviati i vostri documenti. &lt;br /&gt;
&lt;br /&gt;
Se, come me, avete due dischi, e sul primo mettete solamente il sistema operativo, è&amp;nbsp;buona norma cambiare la posizione del file di indice in modo che questo risieda sul vostro disco più capiente.&lt;br /&gt;
&lt;br /&gt;
Per farlo andate su &quot;Advanced&quot; (&quot;Impostazioni avanzate&quot;):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbQAbgsa8yeE6_FAdX0rWdLQ2us78Cz6NE6CtPJO7ijnGdvGDd3CyJVVINOdtV45N3KnmuaeD5KRAtsIfjAFToyrHo4dykKW6qrS0xLR7uWwYvEgBmudXreiqWUR79kuFk2Z0ksQQlhIg/s1600/Capture1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwbQAbgsa8yeE6_FAdX0rWdLQ2us78Cz6NE6CtPJO7ijnGdvGDd3CyJVVINOdtV45N3KnmuaeD5KRAtsIfjAFToyrHo4dykKW6qrS0xLR7uWwYvEgBmudXreiqWUR79kuFk2Z0ksQQlhIg/s1600/Capture1.PNG&quot; height=&quot;320&quot; width=&quot;275&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Selezionate la cartella che conterrà i file di indice, e poi premete il tasto &quot;Rebuild&quot; (&quot;Ricostruisci&quot;). In questo modo, i vecchi file indice verranno cancellati, e quelli nuovi verranno salvati nella nuova posizione.&lt;br /&gt;
&lt;br /&gt;
Infine, valutate se vi interessa che le ricerche fatte con lo swype includano o meno risultati dal Web. Per personalizzare quest&#39;ultima opzione potete agire su: &quot;Settings&quot; (&quot;Impostazioni&quot;), &quot;Change PC Settings&quot; (&quot;Cambia impostazioni&quot;), &quot;Search and Apps&quot; (&quot;Ricerca e App&quot;), e poi mettete a &quot;Off&quot; (oppure &quot;On&quot;) l&#39;impostazione &quot;Use Bing to search online&quot; (&quot;Usa Bing per cercare online&quot;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2014/08/cercare-file-in-windows-8.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjovN_LOGmkhbeNCLE3plnDgcVLkQuxtFvADXAk0QeUGguAUlotCe3jqxBrpnmqFrzWdY1Iz0boqN07delDMo90Rr58GytJlrn-FL9KwTHXI1NavOD1OTtKll1o4Yk5YaQCSTRF5Q6nCas8/s72-c/Capture.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-2037043417573834659</guid><pubDate>Wed, 14 May 2014 17:12:00 +0000</pubDate><atom:updated>2014-05-14T19:12:33.443+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">git</category><category domain="http://www.blogger.com/atom/ns#">github</category><category domain="http://www.blogger.com/atom/ns#">version control</category><title>Clonare un repository da GitHub</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Ecco una breve guida per effettuare il clone di un repository di codice sorgente da &lt;a href=&quot;https://github.com/&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;, modificarlo e poi sottomettere le modifiche. Il tutto direttamente da linea di comando. Com&#39;è ovvio, occorre aver installato in locale &lt;a href=&quot;http://git-scm.com/&quot; target=&quot;_blank&quot;&gt;git&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Per prima cosa occorre creare una directory e posizionarvisi sopra. &lt;br /&gt;
&lt;br /&gt;
Quindi occorre effettuare il &#39;&lt;b&gt;cloning&lt;/b&gt;&#39;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;git clone https://github.com/guildenstern70/cpp11learn.git
git status
&lt;/pre&gt;
&lt;br /&gt;
Questa operazione crea un&#39;esatta replica di tutti i file sul repository, non solo i sorgenti ma anche tutti i file ancillari, ad esempio la &#39;History&#39;.&lt;br /&gt;
&lt;br /&gt;
&#39;git status&#39; mi dà un feedback delle operazioni effettuate.&lt;br /&gt;
&lt;br /&gt;
A questo punto posso cominciare a modificare i miei file. Quando ho finito il lavoro, occorre mettere in &#39;&lt;b&gt;stage&lt;/b&gt;&#39; le modifiche, che saranno così pronte per essere committate: lo si fa con il comando &#39;add&#39;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;git add &lt;span style=&quot;color: #e28964;&quot;&gt;&amp;lt;&lt;/span&gt;files...&lt;span style=&quot;color: #e28964;&quot;&gt;&amp;gt;&lt;/span&gt;
git status
&lt;/pre&gt;
&lt;br /&gt;
Con il comando &#39;&lt;b&gt;add&lt;/b&gt;&#39; aggiungo i file che non erano presenti, oppure indico quali file esistenti sono stati modificati - esatto, è lo stesso comando per entrambe le operazioni.&lt;br /&gt;
&lt;br /&gt;
Quando sono pronto per rendere operative le modifiche, effettuo il commit in locale:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;git commit
git status
&lt;/pre&gt;
&lt;br /&gt;
Ora occorre dare un nome al branch remoto, ad esempio: github. In questo modo posso indicare su quale repository lavorare, quello in locale, che normalmente è indicato come &#39;master&#39; e quello in remoto, che qui chiamo &#39;github&#39;, ma che normalmente si indica come &#39;origin&#39;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;git remote add github https://github.com/[username]/[projectname].git
git remote -v
&lt;/pre&gt;
&lt;br /&gt;
L&#39;indirizzo https del repository si trova sul sito github del repository stesso. &lt;br /&gt;
&lt;br /&gt;
Infine, per sincronizzare il repository locale con quello remoto, cioè in un certo senso per fare l&#39;upload delle modifiche si dà il comando &#39;push&#39;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;git push -u github master
&lt;/pre&gt;
&lt;br /&gt;
Viene chiesta la nostra username e password su GitHub, e dopo averle inserite, il gioco è fatto.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2014/05/clonare-un-repository-da-github.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-813197540580738120</guid><pubDate>Tue, 29 Apr 2014 12:37:00 +0000</pubDate><atom:updated>2014-04-29T14:42:01.662+02:00</atom:updated><title>Di che tipo è una Funzione Lambda?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Le funzioni &lt;em&gt;lambda &lt;/em&gt;sono balzate agli onori delle cronache soprattutto perché l&#39;ultima versione di &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html&quot; target=&quot;_blank&quot;&gt;Java&lt;/a&gt; le supporta direttamente, mentre sono molti altri i linguaggi che le integrano nella loro sintassi, ad esempio Ruby, Python e Scala.&lt;br /&gt;
&lt;br /&gt;
Nel campo della programmazione una &lt;a href=&quot;http://en.wikipedia.org/wiki/Lambda_calculus&quot; target=&quot;_blank&quot;&gt;funzione lambda&lt;/a&gt; è una funzione &lt;em&gt;anonima&lt;/em&gt; che può essere chiamata e passata direttamente, senza cioè essere&amp;nbsp;nominata con un&amp;nbsp;identificatore, come&amp;nbsp;lo è&amp;nbsp;una funzione normale, che ha un suo nome che rende possibile chiamarla nominalmente.&lt;br /&gt;
&lt;br /&gt;
Ad esempio, in &lt;a href=&quot;http://www.scala-lang.org/&quot; target=&quot;_blank&quot;&gt;Scala&lt;/a&gt;, una &lt;em&gt;funzione lambda&lt;/em&gt; ha questa sintassi:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;

val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;circleArea&lt;/span&gt; = (&lt;span style=&quot;color: #3e87e3;&quot;&gt;radius&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Double&lt;/span&gt;) =&amp;gt; 
                     { radius * radius * &lt;span style=&quot;color: #89bdff;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #89bdff;&quot;&gt;PI&lt;/span&gt; }


&lt;/pre&gt;
&lt;br /&gt;
in questo caso il nome &quot;circleArea&quot; non è il nome della funzione, ma è il nome dell&#39;oggetto a cui si associa la &lt;em&gt;funzione lambda&lt;/em&gt;. La differenza è sottile ma sostanziale: una funzione lambda può essere associata a molte diverse variabili con diverso nome, mentre una funzione normale ha uno e un solo nome.&lt;br /&gt;
&lt;br /&gt;
Perché mai un programmatore dovrebbe usare funzioni senza nome? Il motivo principale risiede nell&#39;immediatezza: sono parti di codice di facile scrittura, tipicamente formule matematiche, il cui uso è in porzioni di codice &quot;vicine&quot; a quello in cui vengono definite. Oppure ancora si tratta di &lt;em&gt;shortcut&lt;/em&gt;, cioè di un modo veloce per passare mini-funzioni ad una super-funzione che le&amp;nbsp;richiama all&#39;interno di se stessa - il caso, nell&#39;esempio sotto in Java8,&amp;nbsp;della gestione degli eventi nei controlli:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Lambda in Java 8&lt;/span&gt;
button&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;addActionListener( (e) &lt;span style=&quot;color: #e28964;&quot;&gt;-&amp;gt;&lt;/span&gt; {
        &lt;span style=&quot;color: #99cf50;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;out&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;println(&lt;span style=&quot;color: #65b042;&quot;&gt;&quot;The button was clicked. From lambda expressions !&quot;&lt;/span&gt;);
});

&lt;/pre&gt;
&lt;br /&gt;
C&#39;è però una questione: quando passo una funzione anomima ad un&#39;altra funzione, qual è il &quot;tipo&quot; con cui la identifico? In altre parole: se scrivo un metodo che prende come input una funzione lambda, come sarà la &quot;firma&quot; di quel metodo? Qual è insomma il tipo di una funzione lambda?&lt;br /&gt;
&lt;br /&gt;
La questione è cruciale nei linguaggi fortemente tipizzati, dove è necessario identificare sempre il tipo di un oggetto per poterlo passare.&lt;br /&gt;
&lt;br /&gt;
In Scala, che è un linguaggio fortemente tipizzato, la cosa viene risolta in modo elegante, cioè dando al tipo&amp;nbsp;&quot;funzione&quot; una sintassi propria.&amp;nbsp;Di seguito l&#39;esempio di una &lt;em&gt;High Order Function&lt;/em&gt;, cioè di una funzione che prende in input un&#39;altra funzione:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;function &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;highOrderFunction&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;func&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Double&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;Double&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;v&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Double&lt;/span&gt; ):&lt;span style=&quot;color: #99cf50;&quot;&gt;String&lt;/span&gt; = {
        
        &lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;result&lt;/span&gt; = func(v)
        result.toString();
        
}
&lt;/pre&gt;
&lt;br /&gt;
Il primo parametro dice che deve essere passata una &quot;funzione&quot; che ritorna un numero decimale&amp;nbsp;&lt;em&gt;Double&lt;/em&gt; e prende in input un altro&amp;nbsp;&lt;em&gt;Double&lt;/em&gt;. Quindi, in Scala, la domanda non ha molto senso: il tipo di una funzione non è necessario specificarlo, perché il linguaggio ha una sintassi propria per definire un &lt;em&gt;placeholder&lt;/em&gt; di funzione, che è il seguente:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;
(&lt;span style=&quot;color: #89bdff;&quot;&gt;Input Parameters&lt;/span&gt;) =&amp;gt; (&lt;span style=&quot;color: #89bdff;&quot;&gt;Expression&lt;/span&gt;)

&lt;/pre&gt;
&lt;br /&gt;
Però in altri linguaggi la questione si pone eccome. Ad esempio in C#. In questo linguaggio una &lt;em&gt;funzione lambda&lt;/em&gt; viene definita come segue:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;(&lt;span style=&quot;color: #99cf50;&quot;&gt;double&lt;/span&gt; radius) =&amp;gt; { radius * radius * Math&lt;span style=&quot;color: #3e87e3;&quot;&gt;.PI&lt;/span&gt;}

&lt;/pre&gt;
&lt;br /&gt;
Ma se voglio &quot;tradurre&quot; la funzione Scala che abbiamo visto sopra (highOrderFunction) in C#, ho bisogno di sapere di che &quot;tipo&quot; è la funzione lambda.&lt;br /&gt;
&lt;br /&gt;
Bene, in C# esistono due tipi (in realtà sono &lt;em&gt;delegates&lt;/em&gt;) che rappresentano procedure e funzioni, sia che queste siano normali, e quindi nominali, sia che siano anonime, o lambda. Consideriamo di avere una procedura &quot;VoidProcedure&quot;, che prende in input un intero, e una funzione &quot;SimpleFunction&quot; che prende in input un intero e ritorna un decimale:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #99cf50;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;VoidProcedure&lt;/span&gt;(int i)
{
    Console.&lt;span style=&quot;color: #dad085;&quot;&gt;WriteLine&lt;/span&gt;(i);
}

&lt;span style=&quot;color: #99cf50;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;double&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;SimpleFunction&lt;/span&gt;(int i)
{
    return (double)i/2;
}

&lt;/pre&gt;
&lt;br /&gt;
I tipi che le possono rappresentare sono:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/it-it/library/018hxwa8(v=vs.110).aspx&quot; target=&quot;_blank&quot;&gt;Action&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/it-it/library/bb549151(v=vs.110).aspx&quot; target=&quot;_blank&quot;&gt;Func&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Per cui&amp;nbsp;si può scrivere un programma per invocarle indirettamente attraverso questi due nuovi tipi (delegati):&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #99cf50;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Main&lt;/span&gt;(string[] args)
{
    Action&lt;int&gt; myAction = new Action&lt;int&gt;(VoidProcedure);
    myAction.&lt;span style=&quot;color: #dad085;&quot;&gt;Invoke&lt;/span&gt;(123);           &lt;span style=&quot;background-color: black; color: #6aa84f;&quot;&gt;// Prints out &quot;123&quot;&lt;/span&gt;

    Func&lt;int double=&quot;&quot;&gt; myFunc = new Func&lt;int double=&quot;&quot;&gt;(SimpleFunction);
    Console.&lt;span style=&quot;color: #dad085;&quot;&gt;WriteLine&lt;/span&gt;(&lt;span style=&quot;color: #dad085;&quot;&gt;myFunc&lt;/span&gt;(5));   &lt;span style=&quot;color: #6aa84f;&quot;&gt;// Prints out &quot;2.5&quot;&lt;/span&gt;

    Console.&lt;span style=&quot;color: #dad085;&quot;&gt;ReadKey&lt;/span&gt;();
}

&lt;/int&gt;&lt;/int&gt;&lt;/int&gt;&lt;/int&gt;&lt;/pre&gt;
&lt;br /&gt;
Ora, utilizzando al posto delle funzioni, le funzioni &lt;em&gt;lambda&lt;/em&gt;, lo stesso programma diventa:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #99cf50;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;void&lt;/span&gt; Main(string[] args)
{
    &lt;span style=&quot;color: #99cf50;&quot;&gt;Action&lt;int&gt;&lt;/int&gt;&lt;/span&gt; myAction &lt;span style=&quot;color: #e28964;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #e28964;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;Action&lt;int&gt;&lt;/int&gt;&lt;/span&gt;(

        &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Lambda procedure&lt;/span&gt;
        (i) &lt;span style=&quot;color: #e28964;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;WriteLine(i)

        );
    &lt;span style=&quot;color: #99cf50;&quot;&gt;myAction&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;Invoke&lt;/span&gt;(&lt;span style=&quot;color: #3387cc;&quot;&gt;123&lt;/span&gt;);           &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Prints out &quot;123&quot;&lt;/span&gt;

    &lt;span style=&quot;color: #99cf50;&quot;&gt;Func&lt;int double=&quot;&quot;&gt;&lt;/int&gt;&lt;/span&gt; myFunc &lt;span style=&quot;color: #e28964;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #e28964;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;Func&lt;int double=&quot;&quot;&gt;&lt;/int&gt;&lt;/span&gt;(
               
        &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Lambda function&lt;/span&gt;
        (i) &lt;span style=&quot;color: #e28964;&quot;&gt;=&amp;gt;&lt;/span&gt; (&lt;span style=&quot;color: #99cf50;&quot;&gt;double&lt;/span&gt;)i&lt;span style=&quot;color: #e28964;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #3387cc;&quot;&gt;2&lt;/span&gt;
                
        );
    &lt;span style=&quot;color: #99cf50;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;WriteLine(myFunc(&lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;));   &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Prints out &quot;2.5&quot;&lt;/span&gt;

    &lt;span style=&quot;color: #99cf50;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;ReadKey();
}

&lt;/pre&gt;
&lt;br /&gt;
In Java, i tipi lambda sono addirittura sei:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/javax/sql/rowset/Predicate.html&quot; target=&quot;_blank&quot;&gt;Predicate&lt;/a&gt;: una funzione che torna un booleano (normalmente per fare query)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://download.java.net/lambda/b81/docs/api/java/util/function/Consumer.html&quot; target=&quot;_blank&quot;&gt;Consumer&lt;/a&gt;: simile alla Action di cui sopra&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Function.html&quot; target=&quot;_blank&quot;&gt;Function&lt;/a&gt;: simile alla Func di cui sopra&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html&quot; target=&quot;_blank&quot;&gt;Supplier&lt;/a&gt;: una funzione factory, che genera oggetti di tipo &lt;t&gt;&lt;/t&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.oracle.com/javase/8/docs/api/java/util/function/UnaryOperator.html&quot; target=&quot;_blank&quot;&gt;UnaryOperator&lt;/a&gt;: funzione unaria che trasforma un oggetto&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.oracle.com/javase/8/docs/api/java/util/function/BinaryOperator.html&quot; target=&quot;_blank&quot;&gt;BinaryOperator&lt;/a&gt;: funzione binaria che trasforma due parametri in un valore di ritorno.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Cosicché il nostro esempio, in Java8, può scriversi come:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;package&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;lambdajava&lt;/span&gt;;

&lt;span style=&quot;color: #e28964;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;java.util.function.Function&lt;/span&gt;;

&lt;span style=&quot;color: #99cf50;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;LambdaJava&lt;/span&gt; {

    &lt;span style=&quot;color: #99cf50;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;main&lt;/span&gt;(&lt;span style=&quot;color: #99cf50;&quot;&gt;String&lt;/span&gt;[] &lt;span style=&quot;color: #3e87e3;&quot;&gt;args&lt;/span&gt;) {

        &lt;span style=&quot;color: #99cf50;&quot;&gt;byte&lt;/span&gt;[] ch &lt;span style=&quot;color: #e28964;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3387cc;&quot;&gt;null&lt;/span&gt;;
        &lt;span style=&quot;color: #99cf50;&quot;&gt;Function&amp;lt;&lt;span style=&quot;color: #99cf50;&quot;&gt;Integer&lt;/span&gt;, &lt;span style=&quot;color: #99cf50;&quot;&gt;Double&amp;gt;&lt;/span&gt;&lt;/span&gt; myFunc &lt;span style=&quot;color: #e28964;&quot;&gt;=&lt;/span&gt; i &lt;span style=&quot;color: #e28964;&quot;&gt;-&amp;gt;&lt;/span&gt; (&lt;span style=&quot;color: #99cf50;&quot;&gt;double&lt;/span&gt;)i&lt;span style=&quot;color: #e28964;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #3387cc;&quot;&gt;2&lt;/span&gt;;
        &lt;span style=&quot;color: #99cf50;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;out&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;println(myFunc&lt;span style=&quot;color: #e28964;&quot;&gt;.&lt;/span&gt;apply(&lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;));
        
    }
      
}
&lt;/pre&gt;
&lt;br /&gt;
&amp;nbsp;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2014/04/di-che-tipo-e-una-funzione-lambda.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-6916204715206682985</guid><pubDate>Tue, 20 Aug 2013 09:19:00 +0000</pubDate><atom:updated>2013-08-23T14:48:56.815+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">first class functions</category><category domain="http://www.blogger.com/atom/ns#">functional programming</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Funzioni &quot;First Class&quot; e &quot;Higher Order&quot; nella Programmazione Funzionale</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
In un &lt;a href=&quot;http://alessiosaltarin.blogspot.it/2012/12/sviluppare-codice-migliore-con-la.html&quot; target=&quot;_blank&quot;&gt;recente post&lt;/a&gt; ho parlato della &lt;b&gt;Programmazione Funzionale (FP)&lt;/b&gt; come di un paradigma di programmazione per computer che è sostanzialmente esente da &lt;i&gt;side-effect&lt;/i&gt;, cioè a dirla in modo un po&#39; brutale: è esente da comportamenti anomali a run-time.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJQYWSsDEOeOQK6Z1RSaLshFRhF31Lrj7Svr3xHff8KdBmIVj2lpxFYhEfZODCAuh-11oqUxZmTAzKAbxAds_QS80jZ1WPPQRcPWBwsJ89-WUpTQf6XIo8wn4rvEFK5sa5fHneZJhaD6-I/s1600/Brain.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJQYWSsDEOeOQK6Z1RSaLshFRhF31Lrj7Svr3xHff8KdBmIVj2lpxFYhEfZODCAuh-11oqUxZmTAzKAbxAds_QS80jZ1WPPQRcPWBwsJ89-WUpTQf6XIo8wn4rvEFK5sa5fHneZJhaD6-I/s400/Brain.jpg&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
In pratica, un programma scritto in FP pura si comporta come un foglio Excel. Si è mai visto un foglio Excel avere comportamenti anomali? Ci sono dei valori in input, ci sono delle formule e tutto quello che si ottiene sono dei valori di output che derivano dall&#39;applicazione di quelle formule.&lt;br /&gt;
&lt;br /&gt;
In modo simile, un programma FP è una funzione che prende come input una funzione - quindi, si potrebbe dire: una formula - e dà in output un certo risultato. A complicare le cose, c&#39;è il fatto che una funzione FP solitamente prende in input una funzione che a sua volta prende in input una funzione e così via, fin quando ce ne sia bisogno per realizzare lo scopo del programma.&lt;br /&gt;
&lt;br /&gt;
Per indicare questo tipo di comporamento, si dice che un generico linguaggio FP supporta le &lt;b&gt;&lt;i&gt;First Class Functions&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Una funzione, per essere &quot;&lt;i&gt;First Class&lt;/i&gt;&quot;, deve avere questa caratteristica: può essere passata ad un&#39;altra funzione come qualsiasi altro valore.&lt;br /&gt;
&lt;br /&gt;
Facciamo un esempio. (&lt;i&gt;L&#39;esempio in basso è scritto in &lt;a href=&quot;http://www.scala-lang.org/&quot; target=&quot;_blank&quot;&gt;linguaggio Scala&lt;/a&gt;, che è un linguaggio&amp;nbsp;di programmazione&amp;nbsp;che supporta molto bene il paradigma funzionale&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: rgb(0, 0, 0); color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;areaDelCerchio&lt;/span&gt; = (&lt;span style=&quot;color: #3e87e3;&quot;&gt;raggio&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Double&lt;/span&gt;) =&amp;gt; { 
    raggio*raggio*&lt;span style=&quot;color: #89bdff;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #89bdff;&quot;&gt;PI&lt;/span&gt; 
}
    
&lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;printResult&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;result&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Any&lt;/span&gt;) {
    println(&lt;span style=&quot;color: #65b042;&quot;&gt;&quot;L&#39;area del cerchio e&#39; : &quot;&lt;/span&gt; + result.toString)
}
    
printResult( areaDelCerchio(&lt;span style=&quot;color: #3387cc;&quot;&gt;10.0&lt;/span&gt;) )&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
La formula dell&#39;area del cerchio viene memorizzata come valore (&lt;i&gt;val&lt;/i&gt;). Questo basta per far sì che Scala possa dirsi un linguaggio dove le funzioni sono First Class, cioè vengono trattate come valori di prima classe, come lo sono solitamente gli interi o le stringhe. Significa che qualunque funzione può prendere come parametro un valore di prima classe: quindi, tipi elementari, oggetti e funzioni.&lt;br /&gt;
&lt;br /&gt;
La funzione &lt;i&gt;printResult&lt;/i&gt;&amp;nbsp;è una funzione che si dice di ordine superiore&lt;i&gt;, &lt;b&gt;Higher Order Function&lt;/b&gt;&lt;/i&gt;, perché può prendere come parametro un qualsiasi valore e - anche! - una funzione. &lt;br /&gt;
&lt;br /&gt;
Da un punto di vista di controllo dei tipi, la funzione/valore&amp;nbsp;&lt;i&gt;areaDelCerchio&lt;/i&gt; prende come parametro un Double (&lt;i&gt;raggio&lt;/i&gt;, un valore decimale a doppia precisione) e ritorna un Double.&lt;br /&gt;
&lt;br /&gt;
Qualsiasi oggetto in Scala - e quindi un Double, o una First Class Function - può essere convertito in Stringa. Ed ecco che &lt;i&gt;printResult&lt;/i&gt; prende come parametro &lt;i&gt;Any&lt;/i&gt;, cioè qualsiasi tipo o funzione, che possa essere rappresentato come stringa - che possegga il metodo &lt;i&gt;.toString&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Poichè la funzione &lt;i&gt;areaDelCerchio&lt;/i&gt; non mantiene variabili di stato e non accetta input dall&#39;esterno che potrebbero modificarla, il suo comportamento è predicibile a priori ed esente da side-effect.&lt;br /&gt;
&lt;br /&gt;
Una funzione Higher Order che prende come input tipi semplici o funzioni o funzioni di funzioni, ha un comportamento sempre predicibile e, una volta compilata, sarà esente da bug a &lt;i&gt;run-time&lt;/i&gt;. Detto in altri termini: se un programma funzionale puro si compila - quindi non dà errori a &lt;i&gt;compile-time&lt;/i&gt; - sarà esente da bug.&lt;br /&gt;
&lt;br /&gt;
La capacità di esprimere un programma per computer, anche complesso, in termini di &lt;i&gt;Higher Order Functions&lt;/i&gt; è dunque una garanzia che lo stesso, se si compila, avrà un comportamento predicibile e senza malfunzionamenti.&lt;br /&gt;
&lt;br /&gt;
Se si pensa alle ingenti risorse che vengono impiegate normalmente in informatica per il test e il controllo della qualità del software, le implicazioni economiche di un simile approccio alla programmazione sono del tutto evidenti.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2013/08/funzioni-first-class-e-higher-order.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJQYWSsDEOeOQK6Z1RSaLshFRhF31Lrj7Svr3xHff8KdBmIVj2lpxFYhEfZODCAuh-11oqUxZmTAzKAbxAds_QS80jZ1WPPQRcPWBwsJ89-WUpTQf6XIo8wn4rvEFK5sa5fHneZJhaD6-I/s72-c/Brain.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-6133412162415377719</guid><pubDate>Thu, 07 Mar 2013 11:37:00 +0000</pubDate><atom:updated>2013-03-07T15:37:20.937+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">async</category><category domain="http://www.blogger.com/atom/ns#">asynchronous programming</category><category domain="http://www.blogger.com/atom/ns#">await</category><category domain="http://www.blogger.com/atom/ns#">c#</category><title>Programmazione asincrona in C# 5</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/vstudio/jj573641.aspx&quot; target=&quot;_blank&quot;&gt;C# versione 5&lt;/a&gt; rende l&#39;utilizzo della programmazione asincrona piuttosto agevole attraverso l&#39;utilizzo di un pattern molto semplice e di due keyword: &lt;i&gt;async &lt;/i&gt;e &lt;i&gt;await&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3YDPNLFRPqPuACqxriVlA2vPokHTskdsUKrvy_kbRGrKJtuUllQx6Bnyi6mK33nGQiVBobu7olU0jvIPeesYBvneOMhCIWlp64rVe-SuAqWjQ0IWQ2r8xx0LDajuLviWDvCrBZCF-Tth/s1600/eternal-clock-shani.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3YDPNLFRPqPuACqxriVlA2vPokHTskdsUKrvy_kbRGrKJtuUllQx6Bnyi6mK33nGQiVBobu7olU0jvIPeesYBvneOMhCIWlp64rVe-SuAqWjQ0IWQ2r8xx0LDajuLviWDvCrBZCF-Tth/s320/eternal-clock-shani.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Utilizzare codice &quot;asincrono&quot; è una necessità non solo quando si vuole parallelizzare l&#39;esecuzione di procedure, ma anche quando si vuole rendere la logica di business indipendente dal codice che gestisce e muove l&#39;interfaccia grafica. L&#39;idea è che nessuna operazione debba &quot;stoppare&quot; l&#39;esecuzione del codice deputato a gestire l&#39;input dell&#39;utente o a fornirgli un feedback.&lt;br /&gt;
&lt;br /&gt;
Tanto più urgente è questa necessità quanto più il device ha processori poco potenti: che è il caso tipico dei device mobile. Ad esempio, il framework di programmazione di Windows Phone, WinRT, si basa pesantemente sul concetto di programmazione asincrona, ed il suo uso è obbligatorio. Non è possibile, giusto per citare un caso, in &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Windows_Runtime&quot; target=&quot;_blank&quot;&gt;WinRT&lt;/a&gt;,&amp;nbsp;&lt;/i&gt;leggere un file in sincrono: è invece necessario predisporre il codice asincrono, in modo che mentre le operazioni di lettura del file sono in esecuzione, l&#39;interfaccia e il resto del programma continuano a funzionare in parallelo.&lt;br /&gt;
&lt;br /&gt;
La gestione della programmazione asincrona, benché semplice, è piuttosto controintuitiva. Su MSDN si legge che &quot;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx&quot; target=&quot;_blank&quot;&gt;l&#39;operatore await dice al compilatore che il metodo marcato async non può continuare dopo quel punto fino a che il processo asincrono che si aspetta non è terminato&lt;/a&gt;&quot;. Cerchiamo di capire cosa significa con un esempio.&lt;br /&gt;
&lt;br /&gt;
Supponiamo di avere una ipotetica funzione di business che ci impiega molto tempo per completare. Ad esempio questa, che su un portatile non troppo vecchio impiega qualche secondo:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; LongRunningComputation&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;int&lt;/span&gt; i&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Random&lt;/span&gt; cycleSeed &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;Random&lt;/span&gt;()&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; result &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;int&lt;/span&gt; rnd &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ff9d00;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; j &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt; j &lt;span style=&quot;color: #ff9d00;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;cycleSeed&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Next&lt;/span&gt;() &lt;span style=&quot;color: #ff9d00;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;1E5&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;3E6&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt; j&lt;span style=&quot;color: #ff9d00;&quot;&gt;++&lt;/span&gt;)
    {
        rnd &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;cycleSeed&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Next&lt;/span&gt;(&lt;span style=&quot;color: #ff628c;&quot;&gt;11&lt;/span&gt;)&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
        result &lt;span style=&quot;color: #ff9d00;&quot;&gt;+=&lt;/span&gt; (rnd &lt;span style=&quot;color: #ff9d00;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #ff628c;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #ff9d00;&quot;&gt;?&lt;/span&gt; rnd &lt;span style=&quot;color: #ff9d00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;-&lt;/span&gt;rnd&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    }
    &lt;span style=&quot;color: #ff9d00;&quot;&gt;return&lt;/span&gt; result&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;
&lt;br /&gt;
La prima cosa che occorre fare è incapsulare questa funzionalità in un metodo asincrono. Ogni metodo asincrono è tale se ritorna un oggetto &lt;i&gt;Task&lt;/i&gt;. Un oggetto &lt;i&gt;Task &lt;/i&gt;si costruisce con una &lt;i&gt;Factory &lt;/i&gt;che si chiama &lt;i&gt;Task.Run&lt;/i&gt; e prende in input &lt;a href=&quot;http://msdn.microsoft.com/it-it/library/bb397687.aspx&quot; target=&quot;_blank&quot;&gt;una funzione &lt;/a&gt;&lt;i&gt;&lt;a href=&quot;http://msdn.microsoft.com/it-it/library/bb397687.aspx&quot; target=&quot;_blank&quot;&gt;lambda&lt;/a&gt; &lt;/i&gt;qualsiasi, con questa sintassi:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; async &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;long&gt;&lt;/long&gt;&lt;/span&gt; LongTaskAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;int&lt;/span&gt; i&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;long&gt;&lt;/long&gt;&lt;/span&gt; longOperation &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; 
            &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Run&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;() &lt;span style=&quot;color: #ff9d00;&quot;&gt;&amp;gt;&lt;/span&gt; LongRunningComputation&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;i&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

    &lt;span style=&quot;color: #ff9d00;&quot;&gt;return&lt;/span&gt; await longOperation&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;
&lt;br /&gt;
La prima istruzione serve per costruire l&#39;oggetto &lt;i&gt;Task&lt;/i&gt;. Questo è un oggetto che mantiene lo stato e le informazioni sul processo asincrono che è in corso. Il fatto che la nostra operazione ritorni un intero viene riflesso nel fatto che Task è di fatto un contenitore generico (di un intero lungo).&lt;br /&gt;
&lt;br /&gt;
La funzione &lt;i&gt;lambda &lt;/i&gt;è in grado di &quot;leggere&quot; i parametri che sono in scope nel momento in cui è definita, quindi non c&#39;è bisogno di specificare che intendiamo passargli l&#39;intero &quot;i&quot; - &lt;i&gt;questa cosa io ci ho messo francamente un po&#39; per capirla... io avrei messo&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;((i) =&amp;gt; LongRunningComputation(i))&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&amp;nbsp;però il parametro di Task.Run è un delegato che non accetta parametri!&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
La norma vuole che ogni funzione &quot;asincrona&quot; abbia un nome che termina in &quot;Async&quot; e non ci adeguiamo. La parola &quot;await&quot; significa che questo metodo deve aspettare il termine dell&#39;operazione &quot;&lt;i&gt;LongRunningComputation&lt;/i&gt;&quot; prima di tornare un valore che abbia senso! Infatti il codice &lt;i&gt;LongRunningComputation &lt;/i&gt;viene lanciato in asincrono, e quindi la linea di codice successiva viene eseguita immediatamente.&lt;br /&gt;
&lt;br /&gt;
Senza la programmazione asincrona, si potrebbe pensare di costruire una funzione che esegue due chiamate all&#39;operazione lunga e somma i loro risultati, così:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; GoInLineNormally&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;Going in sequence, normally&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; x1 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; LongRunningComputation&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X1 (NORMAL) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x1&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; x2 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; LongRunningComputation&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X2 (NORMAL) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x2&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ff9d00;&quot;&gt;return&lt;/span&gt; (x1 &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x2)&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;
&lt;br /&gt;
Siccome abbiamo detto che l&#39;operazione lunga ci mette grossomodo due secondi, la procedura di cui sopra ci metterebbe circa quattro secondi per essere eseguita.&lt;br /&gt;
&lt;br /&gt;
Ma abbiamo la programmazione asincrona, e quindi è lecito pensare che le due possano essere lanciate sue due &lt;i&gt;thread &lt;/i&gt;differenti, e quando ciascun &lt;i&gt;thread &lt;/i&gt;esce con un risultato, sommarli e stamparli a video.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; async &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;long&gt;&lt;/long&gt;&lt;/span&gt; GoInParallelAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;Going in parallel&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

    var t1 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; LongTaskAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    var t2 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; LongTaskAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

    await &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WhenAll&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;t1&lt;span style=&quot;color: #e1efff;&quot;&gt;,&lt;/span&gt; t2&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X1 (PARALLEL) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;t1&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Result&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X2 (PARALLEL) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;t2&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Result&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ff9d00;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #ffee80;&quot;&gt;t1&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Result&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;t2&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Result&lt;/span&gt;)&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
}

&lt;/pre&gt;
&lt;br /&gt;
Per farlo abbiamo lanciato &lt;i&gt;LongTaskAsync &lt;/i&gt;e poi, attraverso la funzione &lt;i&gt;Task.WhenAll&lt;/i&gt;, abbiamo &quot;aspettato&quot; che entrambi finissero per raccogliere i risultati. L&#39;esecuzione totale, come ci aspettavamo è di circa due secondi invece che quattro.&lt;br /&gt;
&lt;br /&gt;
Ricapitolando. Se un metodo asincrono viene lanciato con l&#39;operatore &quot;await&quot;, l&#39;esecuzione si ferma finché il metodo non ha ritornato un risultato - ma questo metodo viene comunque lanciato su un thread differente rispetto al programma che lo ha lanciato, il quale può ad esempio continuare così ad aggiornare l&#39;interfaccia grafica e a rimanere in ascolto di eventuali eventi. Se invece un metodo asincrono viene lanciato senza l&#39;operatore await, la linea successiva di codice viene eseguita immediatamente, e il controllo sull&#39;esecuzione del task asincrono è demandato ai metodi della classe &lt;i&gt;Task&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Infatti, se lanciamo con:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; async &lt;span style=&quot;color: #ffee80;&quot;&gt;Task&lt;long&gt;&lt;/long&gt;&lt;/span&gt; GoInLineAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;Going in sequence, but async&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; x1 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; await LongTaskAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X1 (SEQUENCE) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x1&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;long&lt;/span&gt; x2 &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; await LongTaskAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff628c;&quot;&gt;22&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;X2 (SEQUENCE) = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x2&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ff9d00;&quot;&gt;return&lt;/span&gt; (x1 &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; x2)&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
il codice esegue prima &lt;i&gt;LongTaskAsync&lt;/i&gt;(11) e solamente dopo aver ottenuto il risultato (ciò che è espresso dall&#39;operatore await), lancia il &lt;i&gt;LongTaskAsync&lt;/i&gt;(22).&lt;br /&gt;
&lt;br /&gt;
Questo codice, benché funzionalmente identico a &lt;i&gt;GoInLineNormally &lt;/i&gt;è molto diverso dal punto di vista del comportamento! Il primo infatti è rigorosamente sincrono: ogni linea di codice viene eseguita solo e soltanto se quella precendente è terminata. Il secondo, invece, attraverso l&#39;operatore &quot;await&quot; dice al compilatore: adesso esegui in asincrono su un thread differente &lt;i&gt;LongTaskAsync, &lt;/i&gt;e aspetta che il metodo asincrono sia terminato prima di proseguire con la prossima linea di codice.&lt;br /&gt;
&lt;br /&gt;
E&#39; da notare in particolare il codice &lt;i&gt;entry point&lt;/i&gt;, Main, che richiama le procedure scritte sopra:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;&lt;span style=&quot;color: #ffee80;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;void&lt;/span&gt; Main&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;string[] args&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
{
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;AYNC/AWAIT TEST v.1.0&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

    &lt;span style=&quot;color: #0088ff; font-style: italic;&quot;&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;//&lt;/span&gt;long r = GoInLineNormally();&lt;/span&gt;
    var t &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; GoInLineAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0088ff; font-style: italic;&quot;&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;//&lt;/span&gt;var t = GoInParallelAsync();&lt;/span&gt;

    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;END TEST (Is it really ended?)&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt;Result = &lt;span style=&quot;color: #3ad900;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #ff9d00;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ffee80;&quot;&gt;t&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;Result&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;WriteLine&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #ffee80;&quot;&gt;Console&lt;/span&gt;&lt;span style=&quot;color: #ff9d00;&quot;&gt;.&lt;/span&gt;ReadKey&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;;&lt;/span&gt;

}
&lt;/pre&gt;
&lt;br /&gt;
Domanda: quando viene stampata la linea &quot;END TEST&quot;?&lt;br /&gt;
&lt;br /&gt;
Alla fine dell&#39;esecuzione dei vari metodi&lt;i&gt; GoIn...? &lt;/i&gt;La risposta è sì, se si tratta di &lt;i&gt;GoInLineNormally&lt;/i&gt;(), ma è no in entrambi gli altri casi: si tratta di metodi asincroni che ritornano subito (non c&#39;è &lt;i&gt;await&lt;/i&gt;)! Quindi &quot;END TEST&quot; non è proprio un messaggio di End, perché viene stampato immediatamente, mentre i metodi asincroni sono in esecuzione. Viceversa, &quot;&lt;i&gt;Result =&lt;/i&gt;&quot; viene stampato effettivamente alla fine dei calcoli, perché il valore di t è &quot;awaited&quot; da &lt;i&gt;t.Result&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
E se avessimo voluto &quot;aspettare&quot; l&#39;esecuzione GoInLineAsync() prima di scrivere &quot;END&quot;? Non avremmo potuto farlo! Infatti un metodo che contiene una chiamata &quot;await&quot; deve per forza essere marcato &quot;async&quot;. Ma il metodo Main non può essere &quot;async&quot;! Quindi non abbiamo potuto scrivere, per esempio:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #002240; color: white;&quot;&gt;var t &lt;span style=&quot;color: #ff9d00;&quot;&gt;=&lt;/span&gt; await GoInLineAsync&lt;span style=&quot;color: #e1efff;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #e1efff;&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Se avessimo marcato il metodo Main come &quot;async&quot;, avremmo detto al compilatore che quel metodo va eseguito in asincrono e che deve ritornare immediatamente al chiamante, per poi &quot;rientrare&quot; quando il metodo sia terminato:&lt;a href=&quot;http://blog.stephencleary.com/2012/02/async-console-programs.html&quot; target=&quot;_blank&quot;&gt; due cose che un programma a console, evidentemente, non può fare&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2013/03/programmazione-asincrona-in-c-5.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3YDPNLFRPqPuACqxriVlA2vPokHTskdsUKrvy_kbRGrKJtuUllQx6Bnyi6mK33nGQiVBobu7olU0jvIPeesYBvneOMhCIWlp64rVe-SuAqWjQ0IWQ2r8xx0LDajuLviWDvCrBZCF-Tth/s72-c/eternal-clock-shani.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-3235240107465147116</guid><pubDate>Thu, 28 Feb 2013 16:47:00 +0000</pubDate><atom:updated>2013-03-02T10:47:24.054+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">first class functions</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>First Class Functions in Scala</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
A volte è necessario passare come argomenti dei metodi o delle funzioni non un parametro normale come un intero o una stringa, ma un&#39;altra funzione. Ad esempio vorremmo scrivere un metodo che applica una somma o una moltiplicazione di due numeri, e vogliamo passargli come argomento la funzione &quot;somma&quot; o la funzione &quot;moltiplicazione&quot;.&lt;br /&gt;
&lt;br /&gt;
Un esempio meno banale: vorremmo scrivere una funzione di sorting che prende in input la collezione di oggetti da ordinare e l&#39;algoritmo di sort. Questa funzione avrebbe quindi due parametri: la collezione e una funzione con l&#39;implementazione dello specifico algoritmo.&lt;br /&gt;
&lt;br /&gt;
Dunque vorremmo costruire una procedura che esegue una determinata &lt;i&gt;operazione &lt;/i&gt;sui suoi parametri, e vorremmo passare come parametro l&#39;&lt;i&gt;operazione&lt;/i&gt; stessa, in modo da rendere la procedura del tutto generica, e perciò anche riutilizzabile.&lt;br /&gt;
&lt;br /&gt;
Normalmente, nella programmazione orientata agli oggetti, questo si ottiene con un pattern che si chiama &quot;Functor&quot;. Il Functor è un&#39;interfaccia che espone un metodo che includerà la nostra funzione. Sta poi alla particolare implementazione dell&#39;interfaccia stabilire se quella funzione è, ad esempio, una moltiplicazione o una somma.&lt;br /&gt;
&lt;br /&gt;
Posto che in Scala le interfacce non esistono, ma esistono i &quot;trait&quot;, di cui ho parlato &lt;a href=&quot;http://alessiosaltarin.blogspot.com/2009/07/ereditarieta-multipla-in-scala.html&quot; target=&quot;_blank&quot;&gt;in un altro post&lt;/a&gt;, si potrebbe pensare di scrivere due classi, Somma e Moltiplicazione, così fatte:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;trait&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Functor&lt;/span&gt; {
  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;function&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;y&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;) : &lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;
}

&lt;span style=&quot;color: #e28964;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Somma&lt;/span&gt; &lt;span style=&quot;color: #e28964;&quot;&gt;extends&lt;/span&gt; &lt;span style=&quot;color: #9b5c2e; font-style: italic;&quot;&gt;Functor&lt;/span&gt; {
  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;function&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;y&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;) : &lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt; = (x+y)
}

&lt;span style=&quot;color: #e28964;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Moltiplicazione&lt;/span&gt; &lt;span style=&quot;color: #e28964;&quot;&gt;extends&lt;/span&gt; &lt;span style=&quot;color: #9b5c2e; font-style: italic;&quot;&gt;Functor&lt;/span&gt; {
  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;function&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;y&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;) : &lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt; = (x*y)
}
&lt;/pre&gt;
&lt;br /&gt;
Cosa sono le &quot;first class functions&quot;? Sono una particolarità del linguaggio che ci permette di passare, come argomento di una funzione o di un metodo di classe, una funzione; esattamente quello che otteniamo con il pattern &quot;Functor&quot;.&lt;br /&gt;
&lt;br /&gt;
In questo caso però, noi non passiamo un oggetto che ha come metodo una specifica funzione: noi passiamo direttamente la funzione!&lt;br /&gt;
&lt;br /&gt;
Questa è la sintassi da usare:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;FirstClassFunctions&lt;/span&gt; {
  &lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;somma&lt;/span&gt; = (&lt;span style=&quot;color: #3e87e3;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;y&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;) =&amp;gt; (x+y)
  &lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;moltiplicazione&lt;/span&gt; = (&lt;span style=&quot;color: #3e87e3;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;, &lt;span style=&quot;color: #3e87e3;&quot;&gt;y&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Int&lt;/span&gt;) =&amp;gt; (x*y)
}

&lt;/pre&gt;
&lt;br /&gt;
La variabile &quot;somma&quot; non è né un tipo primitivo (intero o stringa, ad esempio), nè un oggetto. E&#39; una funzione. La prima parte dice quali sono i tipi che la funzione manipola, e la seconda parte è la funzione vera e propria. &lt;i&gt;Somma &lt;/i&gt;è una funzione che somma il valore x al valore y. Similmente per&amp;nbsp;&lt;i&gt;moltiplicazione.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #000; color: #f8f8f8;&quot;&gt;&lt;span style=&quot;color: #e28964;&quot;&gt;object&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Main&lt;/span&gt; {

  &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Functor&lt;/span&gt;
  &lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;functSomma&lt;/span&gt; : &lt;span style=&quot;color: #89bdff;&quot;&gt;Functor&lt;/span&gt; = &lt;span style=&quot;color: #e28964;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Somma&lt;/span&gt;()
  &lt;span style=&quot;color: #e28964;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;functMoltiplicazione&lt;/span&gt; : &lt;span style=&quot;color: #89bdff;&quot;&gt;Functor&lt;/span&gt; = &lt;span style=&quot;color: #e28964;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;Moltiplicazione&lt;/span&gt;()

  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;testFunctor&lt;/span&gt;(f:&lt;span style=&quot;color: #89bdff;&quot;&gt;Functor&lt;/span&gt;, x:&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;, y:&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;) {
    println(&lt;span style=&quot;color: #65b042;&quot;&gt;&quot;Il risultato e&#39; = &quot;&lt;/span&gt; + f.function(x,y))
  }

  &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// First Class&lt;/span&gt;
  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;testFirstClass&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;f&lt;/span&gt;: (&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;,&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;) =&amp;gt; &lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;, x:&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;, y:&lt;span style=&quot;color: #99cf50;&quot;&gt;Int&lt;/span&gt;)  {
    println(&lt;span style=&quot;color: #65b042;&quot;&gt;&quot;Il risultato e&#39; = %d&quot;&lt;/span&gt;.format(f(x,y)))
  }


  &lt;span style=&quot;color: #aeaeae; font-style: italic;&quot;&gt;// Main&lt;/span&gt;
  &lt;span style=&quot;color: #e28964;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #89bdff;&quot;&gt;main&lt;/span&gt;(&lt;span style=&quot;color: #3e87e3;&quot;&gt;args&lt;/span&gt;: &lt;span style=&quot;color: #89bdff;&quot;&gt;Array&lt;/span&gt;[&lt;span style=&quot;color: #99cf50;&quot;&gt;String&lt;/span&gt;]) {

    testFunctor(functSomma, &lt;span style=&quot;color: #3387cc;&quot;&gt;6&lt;/span&gt;, &lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;)
    testFunctor(functMoltiplicazione, &lt;span style=&quot;color: #3387cc;&quot;&gt;6&lt;/span&gt;, &lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;)

    testFirstClass(&lt;span style=&quot;color: #89bdff;&quot;&gt;FirstClassFunctions&lt;/span&gt;.somma, &lt;span style=&quot;color: #3387cc;&quot;&gt;6&lt;/span&gt;, &lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;)
    testFirstClass(&lt;span style=&quot;color: #89bdff;&quot;&gt;FirstClassFunctions&lt;/span&gt;.moltiplicazione, &lt;span style=&quot;color: #3387cc;&quot;&gt;6&lt;/span&gt;, &lt;span style=&quot;color: #3387cc;&quot;&gt;5&lt;/span&gt;)

  }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Il codice di sopra richiama le funzioni sia sotto forma di &lt;i&gt;Functor&lt;/i&gt;, che sotto forma di &lt;i&gt;First Class Functions&lt;/i&gt;.&lt;br /&gt;
Com&#39;è ovvio, la possibilità di passare direttamente funzioni come parametri di metodi, piuttosto che inventare una tassonomia apposita di classi, riduce la complessità del codice, aumenta la leggibilità e quindi in definitiva migliora la qualità del codice sorgente.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2013/02/first-class-functions-in-scala.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-3786351430056760118</guid><pubDate>Fri, 08 Feb 2013 16:26:00 +0000</pubDate><atom:updated>2013-02-08T17:26:52.226+01:00</atom:updated><title>Aiuto mi sono scomparsi i favoriti!</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
E&#39; possibile che dal menù di apertura o salvataggio dei file in Windows 8 scompaia la selezione delle locazioni preferite, in inglese &quot;Favourites&quot;, nella barra a sinistra, altrimenti detta &quot;Places Bar&quot;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Tra queste locazioni ci sono normalmente il Desktop, i Download e i Recent Places, in più lo shortcut è facilmente personalizzabile facendo drag&#39;n&#39;drop del folder che vogliamo aggiungere.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Pochi però sanno che è possibile eliminare i Favourites, anche inavvertitamente, spuntando l&#39;opzione &quot;Mostra Preferiti&quot; della Places Bar.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaUPy-lGRz0vqReRvWTCb4-AvCRWnaq_R9wuIsZMSk1pHNxtCnSzV0h00Z6c1RaVPFNDFZX2OnkuKiEFWakoOFjsljzoOtb7KXfE_HXct0LsX6y060UcGLPz7eVUKMp5IHS6Rh5xsZVR71/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;281&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaUPy-lGRz0vqReRvWTCb4-AvCRWnaq_R9wuIsZMSk1pHNxtCnSzV0h00Z6c1RaVPFNDFZX2OnkuKiEFWakoOFjsljzoOtb7KXfE_HXct0LsX6y060UcGLPz7eVUKMp5IHS6Rh5xsZVR71/s400/Capture.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Per ripristinarli, basta spostarsi in basso nella Places Bar e selezionare &quot;Mostra Preferiti&quot; (Show Favourites).&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsISKiPMPujL7WPRR4ltHn7NiOMY8GaX7yobTMI_w37OAWqsu0lSyh6poXSyRK4bF9_xT4b_wvHtEiK3ZyNh8uBRvc4H5k8c5mXGecddjfVd4BbHhNLdfrcx-QT7v2cKEL4oIQ__xMExrB/s1600/Capture2.PNG&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsISKiPMPujL7WPRR4ltHn7NiOMY8GaX7yobTMI_w37OAWqsu0lSyh6poXSyRK4bF9_xT4b_wvHtEiK3ZyNh8uBRvc4H5k8c5mXGecddjfVd4BbHhNLdfrcx-QT7v2cKEL4oIQ__xMExrB/s320/Capture2.PNG&quot; width=&quot;348&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2013/02/aiuto-mi-sono-scomparsi-i-favoriti.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaUPy-lGRz0vqReRvWTCb4-AvCRWnaq_R9wuIsZMSk1pHNxtCnSzV0h00Z6c1RaVPFNDFZX2OnkuKiEFWakoOFjsljzoOtb7KXfE_HXct0LsX6y060UcGLPz7eVUKMp5IHS6Rh5xsZVR71/s72-c/Capture.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-8146114722641628288</guid><pubDate>Fri, 28 Dec 2012 13:39:00 +0000</pubDate><atom:updated>2012-12-29T11:35:27.172+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c#</category><category domain="http://www.blogger.com/atom/ns#">fp</category><category domain="http://www.blogger.com/atom/ns#">oop</category><category domain="http://www.blogger.com/atom/ns#">programmazione funzionale</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Sviluppare codice migliore con la programmazione funzionale</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Minimizzare gli impatti del cambiamento dovrebbe essere uno degli obiettivi prioritari nella produzione del software, soprattutto se in contesti di medio-alta complessità. Normalmente, infatti, si assiste al fenomeno dell&lt;i&gt;&#39;ingessatura&lt;/i&gt; del codice: nessuno si azzarda a introdurre cambiamenti migliorativi perché questo potrebbe portare a conseguenze inaspettate, potenzialmente drammatiche.&lt;br /&gt;
&lt;br /&gt;
Per minimizzare gli impatti del cambiamento esistono strumenti e tecniche diverse: ad esempio il &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Test-driven_development&quot; target=&quot;_blank&quot;&gt;test driven development&lt;/a&gt;&lt;/i&gt;, oppure il &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Defensive_programming&quot; target=&quot;_blank&quot;&gt;defensive programming&lt;/a&gt;&lt;/i&gt;. Un altro metodo è quello di scrivere codice secondo il paradigma della programmazione funzionale (FP = &lt;a href=&quot;http://en.wikipedia.org/wiki/Functional_programming&quot; target=&quot;_blank&quot;&gt;Functional Programming&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-HjwwFdf9uNzhRHRal4IvsHUSYDZ70xWSEzjFCnTRHo6gzXFiY0OQGkDzRoRoLFzlTx6HsPjst0wSiEyQAgAjoIrUGLG0vRXvwSmG6wcF-zHpjfVcYZiYP_YFhdJ7ULx9OsSHXD0tgeSf/s1600/fx.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-HjwwFdf9uNzhRHRal4IvsHUSYDZ70xWSEzjFCnTRHo6gzXFiY0OQGkDzRoRoLFzlTx6HsPjst0wSiEyQAgAjoIrUGLG0vRXvwSmG6wcF-zHpjfVcYZiYP_YFhdJ7ULx9OsSHXD0tgeSf/s1600/fx.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Un programma scritto in un linguaggio FP puro è normalmente esente da &quot;side-effect&quot;: cioè è un software che si comporta in un solo modo, predicibile, e che ha un comportamento identico una volta compilato. Questo perché si traduce sostanzialmente in una funzione che prende in input una qualunque serie di funzioni che agiscono su costanti. E&#39; come un meccanismo di ruote e pulegge: una volta in movimento, si comporta sempre nello stesso identico modo.&lt;br /&gt;
&lt;br /&gt;
Purtroppo solo una piccolissima parte di programmi può essere scritta in FP pura. Questo perché un programma per essere utile deve poter prevedere: 1) input dall&#39;esterno e 2) mantenimento di uno stato. Queste però sono due cose che sono &quot;inesprimibili&quot; in FP puro.&lt;br /&gt;
&lt;br /&gt;
Quello che possiamo fare è invece utilizzare un linguaggio ibrido, che permetta cioè sia la programmazione imperativa (magari ad oggetti) cui siamo abituati, sia la programmazione funzionale, cercando di minimizzare e confinare la parte imperativa in un punto noto - e ridotto - del codice sorgente. Eccellenti esempi di linguaggi ibridi sono oggi &lt;a href=&quot;http://www.scala-lang.org/&quot; target=&quot;_blank&quot;&gt;Scala &lt;/a&gt;e &lt;a href=&quot;http://msdn.microsoft.com/it-it/library/kx37x362.aspx&quot; target=&quot;_blank&quot;&gt;C#&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In Scala, le variabili vengono nominate in due modi diversi: &lt;b&gt;&lt;i&gt;var&lt;/i&gt;&lt;/b&gt;, la variabile &quot;normale&quot; cui siamo abituati, e &lt;b&gt;&lt;i&gt;val&lt;/i&gt;&lt;/b&gt;, una variabile che, una volta che abbia assegnato un valore, non lo modificherà mai per tutta la sua vita. (In C# le variabili &lt;i&gt;val &lt;/i&gt;di Scala sono scritte come &lt;i&gt;readonly&lt;/i&gt;) Un programma scritto in Scala che abbia molte &lt;b&gt;var&lt;/b&gt;, è un programma che segue la logica imperativa, che crea oggetti che mantengono uno stato e che quindi è potenzialmente pieno di side-effects. Viceversa, un programma che abbia pochissime o nessuna &lt;i&gt;var&lt;/i&gt;, e &lt;i&gt;val &lt;/i&gt;al loro posto, è un programma scritto in logica funzionale, e che avrà pochi o nessun side-effect. Questo secondo tipo di programma è molto più facile da mantenere, dovrà essere testato di meno, e quindi avrà maggiore valore.&lt;br /&gt;
&lt;br /&gt;
Come si possono scrivere normali costrutti in logica funzionale? E&#39; difficile, perché il nostro cervello è abituato a pensare in termini di &quot;oggetti&quot; e di &quot;stato&quot;, e molto poco in termini di &quot;funzioni&quot; e &quot;funzioni di funzioni&quot;. Però con un po&#39; di pratica l&#39;obiettivo può essere centrato.&lt;br /&gt;
&lt;br /&gt;
Vediamo un esempio. Supponiamo di voler scrivere una classe che prende in input una stringa e ne calcola il suo valore ASCII (il valore ASCII di una stringa è la somma dei suoi caratteri intesi secondo la codifica ASCII).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;scala&quot; style=&quot;background-color: #f0f0f0; border: 1px solid rgb(208, 208, 208); font-family: monospace;&quot;&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;/a&gt; TestClass&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;givenString&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; require&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;givenString &lt;span style=&quot;color: navy;&quot;&gt;!=&lt;/span&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;var&lt;/span&gt;&lt;/a&gt; gStr&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; givenString&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;/a&gt; getValue&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;compute&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;/a&gt; compute&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; Int &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;var&lt;/span&gt;&lt;/a&gt;&amp;nbsp;tempSum&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; Int &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;for&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;charV &lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;-&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #000066;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;gStr&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;toCharArray&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;tempSum&amp;nbsp;+&lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; charV.&lt;span style=&quot;color: black;&quot;&gt;toInt&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;tempSum&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Questo programma in Scala contiene due &lt;i style=&quot;font-weight: bold;&quot;&gt;var&lt;/i&gt;: una per mantenere lo &quot;stato&quot;, che è la variabile che contiene la stringa da trasformare in numero, e una per mantenere il numero associato alla stringa mentre viene calcolato, all&#39;interno di un ciclo for.&lt;br /&gt;
&lt;br /&gt;
Come trasformare questa classe in logica funzionale?&lt;br /&gt;
&lt;br /&gt;
Dobbiamo come prima cosa far sparire lo &quot;stato&quot; dalla classe. La nostra classe deve comportarsi come una &quot;funzione&quot; e quindi non deve mantenere in memoria parametri che possono cambiare valore nel tempo. Farlo è molto semplice: invece che memorizzare &lt;i&gt;givenString &lt;/i&gt;come variabile (&lt;i&gt;var&lt;/i&gt;) lo memorizzeremo come costante (&lt;i&gt;val&lt;/i&gt;). Oppure, potremmo non memorizzarlo del tutto e passarlo così com&#39;è al metodo di calcolo &lt;i&gt;compute()&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Più difficile è invece sostituire il costrutto for che calcola il valore. Qui useremo invece una formula classica della FP. Creeremo un metodo che ritorna una collezione, cioè un array dinamico, di valori ASCII, ognuno per ciascun carattere che forma la stringa. Poi su questa collezione applicheremo una funzione di trasformazione: nel nostro caso &quot;sum&quot;. Ogni collezione fornisce metodi operatore sui valori che la compongono, e in più può accettarne di nuovi appositamente scritti.&lt;br /&gt;
&lt;br /&gt;
Ecco il nostro codice trasformato in logica funzionale:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;scala&quot; style=&quot;background-color: #f0f0f0; border: 1px solid rgb(208, 208, 208); font-family: monospace;&quot;&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;/a&gt; ImmutableTestClass&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;givenString&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; require&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;givenString &lt;span style=&quot;color: navy;&quot;&gt;!=&lt;/span&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;val&lt;/span&gt;&lt;/a&gt; gStr&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; givenString&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;/a&gt; getValue&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;compute&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;gStr&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;/a&gt; listOfValues&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;valStr&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;for&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;j &lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt; until valStr.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;yield&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; valStr.&lt;span style=&quot;color: black;&quot;&gt;charAt&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;j&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;toInt&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green; font-style: italic;&quot;&gt;// 1. Convert the sequence to actual collection&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green; font-style: italic;&quot;&gt;// 2. Add &quot;mapping&quot; to collection, example: .sum, .mkString&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;/a&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;/a&gt; compute&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;valStr&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; String&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; Int &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #f78811;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;val&lt;/span&gt;&lt;/a&gt; listOfVals&lt;span style=&quot;color: navy;&quot;&gt;:&lt;/span&gt; List&lt;span style=&quot;color: #f78811;&quot;&gt;[&lt;/span&gt;Int&lt;span style=&quot;color: #f78811;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: navy;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://scala-lang.org/&quot; style=&quot;color: #000060;&quot;&gt;&lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;listOfValues&lt;/span&gt;&lt;span style=&quot;color: #f78811;&quot;&gt;(&lt;/span&gt;valStr&lt;span style=&quot;color: #f78811;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;toList&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; listOfVals.&lt;span style=&quot;color: black;&quot;&gt;sum&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;span style=&quot;color: #f78811;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Abbiamo buttato via le &lt;i&gt;var &lt;/i&gt;e le abbiamo sostituite con &lt;i&gt;val&lt;/i&gt;. Il codice è ora puramente funzionale. (E, tra parentesi, funzionerà molto meglio in contesti multi-threading).&lt;br /&gt;
&lt;br /&gt;
Naturalmente lo stesso risultato si può ottenere con C#:
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;csharp&quot; style=&quot;background-color: #f0f0f0; border: 1px solid rgb(208, 208, 208); font-family: monospace;&quot;&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;class&lt;/span&gt; Immutable&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;readonly&lt;/span&gt; &lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;String&lt;/span&gt; tString&lt;span style=&quot;color: green;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;public&lt;/span&gt; Immutable&lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;String&lt;/span&gt; testString&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;tString&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;=&lt;/span&gt; testString&lt;span style=&quot;color: green;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;int&lt;/span&gt; GetSum&lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;.C&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;harList&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Sum&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #000066;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt; IEnumerable&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;int&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;&amp;nbsp;CharList&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;char&lt;/span&gt; ch &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;tString&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;yield&lt;/span&gt; &lt;span style=&quot;color: #0600ff; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #6666cc; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;)&lt;/span&gt;ch&lt;span style=&quot;color: green;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: green;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #000066;&quot;&gt;
&lt;span style=&quot;color: green;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2012/12/sviluppare-codice-migliore-con-la.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-HjwwFdf9uNzhRHRal4IvsHUSYDZ70xWSEzjFCnTRHo6gzXFiY0OQGkDzRoRoLFzlTx6HsPjst0wSiEyQAgAjoIrUGLG0vRXvwSmG6wcF-zHpjfVcYZiYP_YFhdJ7ULx9OsSHXD0tgeSf/s72-c/fx.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-2845100077580232503</guid><pubDate>Sat, 22 Dec 2012 10:04:00 +0000</pubDate><atom:updated>2012-12-22T11:18:58.490+01:00</atom:updated><title>Masterizzare e montare una ISO su Windows 8</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://it.wikipedia.org/wiki/Windows_8&quot; target=&quot;_blank&quot;&gt;Windows 8&lt;/a&gt; supporta nativamente il formato ISO, cosicché è possibile sia montare un&#39;immagine ISO come drive virtuale, sia masterizzarla su CD/DVD/BluRay.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;ATTENZIONE: se si è installato un software che gestisce i file .ISO (ad esempio WinZip o Demon Tools), le opzioni per la gestione dei file ISO non sono più visibili da menù contestuale. Occorre modificare le impostazioni dei software di cui sopra, per togliere l&#39;associazione con i file .ISO.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;b&gt;PER MONTARE UN FILE .ISO&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Clickare con il tasto destro del mouse sul file .ISO e selezionare &quot;Monta&quot;. Il nuovo drive apparirà tra le risorse del computer.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYK40C_0Jv4S6cgVUwVnwRVdiXk52PuF_7wvftaW5DWrEIyxm00bO7Pmi7D2liI3ugSlXuHE34ht0J3_JGdTeJfeoM_uHXDIraRtrCkDu-JAYLpLl61tErCxafWpVVgsV5kxsaKkwYviNR/s1600/Cattura+di+schermata+%25283%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;251&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYK40C_0Jv4S6cgVUwVnwRVdiXk52PuF_7wvftaW5DWrEIyxm00bO7Pmi7D2liI3ugSlXuHE34ht0J3_JGdTeJfeoM_uHXDIraRtrCkDu-JAYLpLl61tErCxafWpVVgsV5kxsaKkwYviNR/s320/Cattura+di+schermata+%25283%2529.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;PER MASTERIZZARE UN FILE .ISO&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Per prima cosa inserire un disco CD/DVD/BluRay vuoto nel masterizzatore. Quindi clickare con il tasto destro del mouse sul file .ISO e selezionare &quot;Masterizza immagine disco&quot;. Il disco verrà masterizzato con i contenuti del file immagine .ISO&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqhqW96MSkONGuZXluxSiXqiuag7pQH0Ed6xFUFZCY0Nz9fTYM6PDmMfQi6EcbOsjpzJY9w6sjwBEWGa4jWjEW-05E54GSrHBKvcu6-5gBFnQ2dxh2rCplDpMyl0dpyCFkQi5VHp8nMiRf/s1600/Cattura+di+schermata+%25284%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqhqW96MSkONGuZXluxSiXqiuag7pQH0Ed6xFUFZCY0Nz9fTYM6PDmMfQi6EcbOsjpzJY9w6sjwBEWGa4jWjEW-05E54GSrHBKvcu6-5gBFnQ2dxh2rCplDpMyl0dpyCFkQi5VHp8nMiRf/s320/Cattura+di+schermata+%25284%2529.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2012/12/masterizzare-e-montare-una-iso-su.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYK40C_0Jv4S6cgVUwVnwRVdiXk52PuF_7wvftaW5DWrEIyxm00bO7Pmi7D2liI3ugSlXuHE34ht0J3_JGdTeJfeoM_uHXDIraRtrCkDu-JAYLpLl61tErCxafWpVVgsV5kxsaKkwYviNR/s72-c/Cattura+di+schermata+%25283%2529.png" height="72" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-781201480171663143</guid><pubDate>Mon, 22 Oct 2012 13:20:00 +0000</pubDate><atom:updated>2012-10-22T15:21:18.619+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">app</category><category domain="http://www.blogger.com/atom/ns#">chrome</category><category domain="http://www.blogger.com/atom/ns#">json</category><title>Creare un&#39;app per Google Chrome</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Piuttosto sorprendentemente, non esiste in tutto il &lt;a href=&quot;https://chrome.google.com/webstore&quot; target=&quot;_blank&quot;&gt;Chrome Web Store&lt;/a&gt;, un&#39;app che aggiunga al &lt;a href=&quot;https://www.google.com/intl/it/chrome/browser/&quot; target=&quot;_blank&quot;&gt;browser di Google&lt;/a&gt;, la ricerca delle immagini attraverso il motore Google stesso.&lt;br /&gt;
&lt;br /&gt;
Detto fatto, ne facciamo una noi. Con un solo, piuttosto importante limite: non potremo distribuirla sullo Store, poiché il sito in questione appartiene a Google.&lt;br /&gt;
&lt;br /&gt;
La nostra &quot;app&quot; apparirà nella &quot;&lt;i&gt;Nuova Scheda&lt;/i&gt;&quot; di default del browser, e assomiglierà all&#39;icona col cerchio intorno:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvyliwfqet1K_RoniQ2l7-_g7_LGCXgAEXid07w5pNo809-0s4ORWGWtgvpmmQ5_kxBHzz5b-ro5Ty6KK8DD-AdccG-8rxtcCuKL8FdQm5pZTLPT948rADPLUIMeF1U9Gnq2NqNjI9Rkwp/s1600/Capture.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvyliwfqet1K_RoniQ2l7-_g7_LGCXgAEXid07w5pNo809-0s4ORWGWtgvpmmQ5_kxBHzz5b-ro5Ty6KK8DD-AdccG-8rxtcCuKL8FdQm5pZTLPT948rADPLUIMeF1U9Gnq2NqNjI9Rkwp/s320/Capture.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Un &quot;&lt;i&gt;app&lt;/i&gt;&quot; per Chrome è nel nostro caso - cioè se vogliamo tipicamente rendere un link - molto semplicemente l&#39;unione di un file manifesto e di un&#39;icona.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
L&#39;icona la potete scegliere liberamente tra le molte disponibili su Internet. Io ho scelto &lt;a href=&quot;http://www.iconarchive.com/show/aire-icons-by-gakuseisean/Search-Images-icon.html&quot; target=&quot;_blank&quot;&gt;questa&lt;/a&gt;. Scaricatela come PNG e salvatela col nome di icon.png.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Create una cartella sul Desktop e nominatela &quot;&lt;i&gt;ImageSearch&lt;/i&gt;&quot;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Adesso, occorre aprire un editor - a me ultimamente piace molto &lt;a href=&quot;http://www.sublimetext.com/2&quot; target=&quot;_blank&quot;&gt;Sublime Text&lt;/a&gt;, ma il Notepad o Vim può andare lo stesso, e copiare il seguente testo.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; background: white; border-width: .1em .1em .1em .8em; border: solid gray; color: black; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25&lt;/pre&gt;
&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;{

&lt;span style=&quot;color: #007000;&quot;&gt;&quot;name&quot;&lt;/span&gt;: &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;ImageSearch&quot;&lt;/span&gt;,
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;version&quot;&lt;/span&gt;: &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;1.1&quot;&lt;/span&gt;,
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;manifest_version&quot;&lt;/span&gt;: &lt;span style=&quot;color: #0000d0; font-weight: bold;&quot;&gt;2&lt;/span&gt;,
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;description&quot;&lt;/span&gt;: &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Google Images&quot;&lt;/span&gt;,

&lt;span style=&quot;color: #007000;&quot;&gt;&quot;icons&quot;&lt;/span&gt;: 
{
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;128&quot;&lt;/span&gt;: &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;icon.png&quot;&lt;/span&gt;
},


&lt;span style=&quot;color: #007000;&quot;&gt;&quot;app&quot;&lt;/span&gt;: 
{
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;urls&quot;&lt;/span&gt;: [&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://www.google.net/&quot;&lt;/span&gt;],
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;launch&quot;&lt;/span&gt;: 
{
&lt;span style=&quot;color: #007000;&quot;&gt;&quot;web_url&quot;&lt;/span&gt;: &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://www.google.it/imghp?hl=it&amp;amp;tab=wi&quot;&lt;/span&gt;
}
},

&lt;span style=&quot;color: #007000;&quot;&gt;&quot;permissions&quot;&lt;/span&gt;: [ &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://www.google.it&quot;&lt;/span&gt; ]

}
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Infine, salvate il testo di cui sopra come &quot;&lt;i&gt;manifest.json&lt;/i&gt;&quot;. (Notate che nella sezione &quot;urls&quot; ho messo un indirizzo falso. Questo serve se voleste pubblicare la app su un sito di vostra appartenenza).&lt;br /&gt;
&lt;br /&gt;
Per usare l&#39;app, basta aprire il Menù di Chrome (il tasto a destra a fianco della URL) e scegliere Strumenti/Estensioni.&lt;br /&gt;
&lt;br /&gt;
Dopo aver spuntato l&#39;opzione &quot;&lt;i&gt;Modalità Sviluppatore&lt;/i&gt;&quot;, si clicka su &quot;&lt;i&gt;Crea Pacchetto Estensione&lt;/i&gt;&quot;. A questo punto basta dare in input la directory che contiene il file json e l&#39;icona, e il gioco è fatto.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2012/10/creare-unapp-per-google-chrome.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvyliwfqet1K_RoniQ2l7-_g7_LGCXgAEXid07w5pNo809-0s4ORWGWtgvpmmQ5_kxBHzz5b-ro5Ty6KK8DD-AdccG-8rxtcCuKL8FdQm5pZTLPT948rADPLUIMeF1U9Gnq2NqNjI9Rkwp/s72-c/Capture.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-5993237314240879833</guid><pubDate>Fri, 31 Aug 2012 10:25:00 +0000</pubDate><atom:updated>2012-09-04T16:00:09.873+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">igoogle</category><category domain="http://www.blogger.com/atom/ns#">igoogle alternatives</category><title>Come ti rimpiazzo iGoogle</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.google.it/ig&quot; target=&quot;_blank&quot;&gt;iGoogle &lt;/a&gt;è stato la mia home page per quasi dieci anni. Mi ci trovavo molto bene. Era veloce, gradevole da vedere, aveva la toolbar di search di Google (fondamentale) e insomma tutto quello che secondo me la&amp;nbsp;&lt;i&gt;home page&lt;/i&gt;&amp;nbsp;deve avere.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdvVJB5Pm_O3-BsY9hgr7b8tUPeh-vT79eLdGBxNuUEeHn-jPBv3fbJDGeRqnjhoVrkyJOHyUL5hNbngXj5CGuk_hjlLQPB4iAClPzXsuMwBQxcdPIM-KVpkI_yRGoGipxQ1J6QeQAxyDQ/s1600/2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;iGoogle&quot; border=&quot;1&quot; height=&quot;114&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdvVJB5Pm_O3-BsY9hgr7b8tUPeh-vT79eLdGBxNuUEeHn-jPBv3fbJDGeRqnjhoVrkyJOHyUL5hNbngXj5CGuk_hjlLQPB4iAClPzXsuMwBQxcdPIM-KVpkI_yRGoGipxQ1J6QeQAxyDQ/s320/2.PNG&quot; title=&quot;iGoogle&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Dopo anni di ottimizzazioni varie, ci avevo messo dentro tutte le cose che volevo vedere dal Web appena collegato. Per esempio ci avevo messo:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;News feed dei principali giornali italiani (&lt;i&gt;Corriere&lt;/i&gt;, &lt;i&gt;Repubblica&lt;/i&gt;, &lt;i&gt;Sole 24 Ore&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;Feed dei principali siti di gaming (&lt;i&gt;Kotaku&lt;/i&gt;, &lt;i&gt;Gamespot&lt;/i&gt;...)&lt;/li&gt;
&lt;li&gt;Feed dei principali siti di programming (&lt;i&gt;MSDN&lt;/i&gt;,&amp;nbsp;&lt;i&gt;StackOverflow, CodeProject&lt;/i&gt;...)
&lt;/li&gt;
&lt;li&gt;Un traduttore online (il migliore: &lt;i&gt;Google Translate&lt;/i&gt;)&lt;/li&gt;
&lt;li&gt;Il meteo di Milano e dintorni&lt;/li&gt;
&lt;li&gt;Una lista dei miei cinque link web preferiti&lt;/li&gt;
&lt;li&gt;I blog miei e dei miei amici&lt;/li&gt;
&lt;li&gt;Ultimi tweet che seguo&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Cosa invece volutamente non ci avevo messo:&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;News feed sportive (terribili se per caso ho un evento &quot;in registrazione&quot;)&lt;/li&gt;
&lt;li&gt;Mail (troppo disturbo: meglio andarci di proposito)&lt;/li&gt;
&lt;li&gt;Facebook (come sopra)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Poi improvvisamente una tragica notizia: &lt;i&gt;iGoogle chiude&lt;/i&gt;! Pare che sarà a Novembre &lt;i&gt;(2013, v.commenti&lt;/i&gt;), comunque è irrevocabile, han detto quelli di Google che chiude.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Così ho cominciato a guardarmi intorno per rimpiazzarlo, e ogni prova che facevo mi convinceva che iGoogle era meglio. Ad esempio ho provato:&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.netvibes.com/&quot; target=&quot;_blank&quot;&gt;Netvibes&lt;/a&gt;&amp;nbsp;(bello, ma lentissimo)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://myfav.es/&quot;&gt;MyFav.es&lt;/a&gt;&amp;nbsp;(ok, ma mancano i feed)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://protopage.com/&quot; target=&quot;_blank&quot;&gt;Protopage &lt;/a&gt;(bruttissimo)&lt;/li&gt;
&lt;li&gt;uStart (ha chiuso!)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Nessuno mi soddisfaceva. Allora ho cominciato a riflettere: ma insomma, cos&#39;ha iGoogle di così speciale? O meglio, cosa deve avere una Home Page per essere una buona Home Page?&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Fondamentalmente deve avere 3 cose:&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Una toolbar di search (quella di Google va benissimo)&lt;/li&gt;
&lt;li&gt;Link ai siti utili (Translate / Calendar / Mail...)&lt;/li&gt;
&lt;li&gt;News dal mondo&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Poi mi sono reso conto di una cosa: i primi due punti sono implementati direttamente dalla quasi totalità dei browser moderni. Ad esempio in Chrome la toolbar che mostra la URL di un sito, è anche una toolbar di ricerca in Google. Sempre in Chrome, la Home Page di default è una collezione di icone (&lt;i&gt;apps&lt;/i&gt;) che portano ai siti di maggior interesse: ad esempio la mia è così:&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwyp18HWAXv0bMJ2_YJo_PDZxPs7A4vzmi5VkXRQ4JlBB0juwQw7g4hUAXq7BLiTgwy8acn4dOtnKQ1KX3S3i8jcJ2OmIm1FaA_9ZmiePRXPncHQLw1ss19h0is2kYH8C3G8UfGQLmicyt/s1600/Capture3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;85&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwyp18HWAXv0bMJ2_YJo_PDZxPs7A4vzmi5VkXRQ4JlBB0juwQw7g4hUAXq7BLiTgwy8acn4dOtnKQ1KX3S3i8jcJ2OmIm1FaA_9ZmiePRXPncHQLw1ss19h0is2kYH8C3G8UfGQLmicyt/s400/Capture3.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Le &quot;news dal mondo&quot; sono sostanzialmente dei &lt;a href=&quot;http://it.wikipedia.org/wiki/RSS&quot; target=&quot;_blank&quot;&gt;feed RSS&lt;/a&gt;. Quindi mi rimaneva solo da scegliere un buon &quot;news reader&quot;, cioè un programma che mi mostrasse i feed RSS nel modo giusto, cioè che mi permettesse di categorizzarli (news, gaming, programming, blog...) e visualizzarli in modo piacevole.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Ne ho provati un po&#39;. Google Reader è un po&#39; troppo spartano, altri erano troppo &quot;barocchi&quot; o mancavano di funzionalità. Alla fine ho scelto&amp;nbsp;&lt;a href=&quot;http://www.feedly.com/&quot; target=&quot;_blank&quot;&gt;Feedly&lt;/a&gt;&amp;nbsp;e lo trovo perfetto (un po&#39; ostica l&#39;interfaccia utente, ma dopo qualche tentativo si riesce a fare quello che si vuole). Ecco la mia page di News:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf9_RUHcOx93va9SYrqmPJ07XFeS0jtrP0oleQcBLsYMQPMyVu0hBkr03ru871RpmG0lBPKr2ZW2-yXWXEsXxhyphenhyphennxPuqbU7VoTdVH-alyOYWDBETFKD-o_i5oSGrARv2tlFZ7qW4w7krch/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;1&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf9_RUHcOx93va9SYrqmPJ07XFeS0jtrP0oleQcBLsYMQPMyVu0hBkr03ru871RpmG0lBPKr2ZW2-yXWXEsXxhyphenhyphennxPuqbU7VoTdVH-alyOYWDBETFKD-o_i5oSGrARv2tlFZ7qW4w7krch/s400/Capture.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In definitiva così ho rimpiazzato &lt;i&gt;iGoogle&lt;/i&gt;: il browser &lt;i&gt;Chrome &lt;/i&gt;mi toglie la necessità di partire da un sito di ricerca come Google. Come &lt;i&gt;Home Page&lt;/i&gt; (e &lt;i&gt;New Tab&lt;/i&gt;) ho la pagina di apps di Chrome che mi porta alla mail, a Facebook, a quant&#39;altro mi interessa; infine per leggere le news clicko su &lt;i&gt;Feedly&lt;/i&gt;, anch&#39;esso disponibile come &quot;app&quot; di Chrome.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2012/08/come-ti-rimpiazzo-igoogle.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdvVJB5Pm_O3-BsY9hgr7b8tUPeh-vT79eLdGBxNuUEeHn-jPBv3fbJDGeRqnjhoVrkyJOHyUL5hNbngXj5CGuk_hjlLQPB4iAClPzXsuMwBQxcdPIM-KVpkI_yRGoGipxQ1J6QeQAxyDQ/s72-c/2.PNG" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-671806202007393431</guid><pubDate>Fri, 24 Aug 2012 11:51:00 +0000</pubDate><atom:updated>2012-08-24T13:55:19.529+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Convention over Configuration</category><category domain="http://www.blogger.com/atom/ns#">Maven</category><category domain="http://www.blogger.com/atom/ns#">Ruby On Rails</category><category domain="http://www.blogger.com/atom/ns#">SBT</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Convenzione invece che Configurazione</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Una delle rivoluzioni silenziose più importanti degli ultimi anni in informatica è l&#39;avvento di strumenti, linguaggi e sistemi che sposano il concetto di&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;Convention over Configuration (CoC)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;
ovvero, in italiano, potremmo dire: &lt;i&gt;seguire una convenzione piuttosto che configurare&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
I più eclatanti risultati di questa impostazione - ovviamente solo tra quelli che ho potuto provare - sono, ad esempio:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;i&gt;&lt;a href=&quot;http://maven.apache.org/&quot; target=&quot;_blank&quot;&gt;Maven&lt;/a&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;Un tool di management dei sorgenti, che effettua l&#39;organizzazione e la compilazione del codice e della documentazione di un progetto software&lt;/li&gt;
&lt;li&gt;&lt;i style=&quot;color: purple;&quot;&gt;&lt;a href=&quot;http://rubyonrails.org/&quot; target=&quot;_blank&quot;&gt;Ruby On Rails&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;Un famoso framework per scrivere applicazioni Web data-intensive.&lt;/li&gt;
&lt;li&gt;&lt;i style=&quot;color: purple;&quot;&gt;&lt;a href=&quot;https://github.com/harrah/xsbt/wiki/&quot; target=&quot;_blank&quot;&gt;SBT&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;Un tool per la compilazione di codice sorgente in Scala (e non solo...)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;
Che cos&#39;hanno di speciale questi oggetti software che implementano la CoC? Be&#39; è presto detto: funzionano &quot;da soli&quot; come per magìa, senza bisogno di:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;parametri a linea di comando&lt;/li&gt;
&lt;li&gt;file di configurazione&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Li scarichi, li lanci, e funzionano. Così, senza far niente, magicamente appunto! Chiaramente, dopo una prima fase in cui il tool si comporta in &lt;i&gt;default&lt;/i&gt;, è sempre possibile arricchire e dettagliare in modo che esso faccia esattamente ciò di cui si ha bisogno.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Faccio un esempio. Comincio a scrivere il mio codice in Scala, un progettino, niente di che, ma comunque un bel po&#39; di file sorgenti e documentazione. Ho bisogno di compilare, e scelgo un tool CoC come SBT. Lo scarico e lo lancio, così, nudo, senza alcun parametro!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;b&gt;&amp;gt; sbt&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Come prima cosa, SBT si rende conto che gli mancano delle librerie per partire. Ok, le scarica tutte dalla rete e le installa.&lt;/li&gt;
&lt;li&gt;Poi vede che non ho l&#39;ultima versione di Scala: me la scarica e la mette &quot;a fianco&quot; alla versione che uso io.&lt;/li&gt;
&lt;li&gt;Si accorge che l&#39;ho lanciato in una directory che contiene codice Scala: fa il parsing dei sorgenti e individua il file che contiene il metodo principale (Main)&lt;/li&gt;
&lt;li&gt;Compila tutti i miei file&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Trova le dipendenze (Scala e Java), le compila e le mette in una directory di libreria&lt;/li&gt;
&lt;li&gt;Esegue il mio programma compilato!&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Fantastico, no?&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Cos&#39;ho fatto io per permettere a SBT di funzionare così bene? Nient&#39;altro che seguire delle &quot;convenzioni&quot;: ad esempio, ovviamente, i miei file in Scala hanno estensione .scala, ma non molto più di questo.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Allo stesso modo, se scarico &lt;i&gt;Ruby On Rails&lt;/i&gt; e ho il database Pippo, mi basta lanciare:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;gt; rails pippo&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
perché &quot;lui&quot; mi sondi il database e mi costruisca un sito Web completo con tutte le funzioni di front-end per gestire il DB Pippo.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In maniera analoga, &lt;i&gt;Maven&lt;/i&gt;, è in grado di scandagliare un progetto in Java, identificare le dipendenze, scaricarle da Internet, aggiornare il sistema e infine compilare e lanciare il progetto. Basta ovviamente che io segua delle &quot;convenzioni&quot; (ad esempio, le librerie sono in una directory /lib).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Questo è il futuro dei tool per lo sviluppo software, e sempre maggiormente la comunità di sviluppatori si aspetterà di avere a che fare con sistemi CoC che funzionano bene &lt;i&gt;out-of-the-box&lt;/i&gt;, senza dover leggere quintali di documentazione o seguire passo passo noiosissimi esempi.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://alessiosaltarin.blogspot.com/2012/08/convenzione-invece-che-configurazione.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-770072571897555156</guid><pubDate>Mon, 30 Jul 2012 14:38:00 +0000</pubDate><atom:updated>2012-07-31T09:56:02.530+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><category domain="http://www.blogger.com/atom/ns#">costing</category><category domain="http://www.blogger.com/atom/ns#">Project Cost Estimation</category><category domain="http://www.blogger.com/atom/ns#">project costing</category><category domain="http://www.blogger.com/atom/ns#">project management</category><title>Non molto Agili... fin qui!</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Navigando sul sito&amp;nbsp;&lt;a href=&quot;http://agilemanifesto.org/&quot;&gt;http://agilemanifesto.org&lt;/a&gt;&amp;nbsp;mi sono accorto che sono passati otto anni da quando firmai il manifesto sullo &lt;a href=&quot;http://it.wikipedia.org/wiki/Metodologia_agile&quot; target=&quot;_blank&quot;&gt;sviluppo agile&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ0FkEY5Uo2lr8cU2GjxCJEi2T9z8UeJ6TMMvZ08dsEgGAiGO7ujUK20OdQPsdnuDVx6cOV62XNpYjg2x_YOj0Yu-RcJSP6W6MixuOANmjiOL4ZJoFmnD-sHVAgqIh5pQBlPjdhyphenhyphenSggPld/s1600/AgileDevelopment.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ0FkEY5Uo2lr8cU2GjxCJEi2T9z8UeJ6TMMvZ08dsEgGAiGO7ujUK20OdQPsdnuDVx6cOV62XNpYjg2x_YOj0Yu-RcJSP6W6MixuOANmjiOL4ZJoFmnD-sHVAgqIh5pQBlPjdhyphenhyphenSggPld/s320/AgileDevelopment.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Cos&#39;è successo in questi otto anni? Si fa un gran parlare, è vero, delle tecniche di sviluppo agili e termini come &lt;a href=&quot;http://it.wikipedia.org/wiki/Scrum&quot;&gt;Scrum &lt;/a&gt;ed&amp;nbsp;&lt;a href=&quot;http://it.wikipedia.org/wiki/Extreme_Programming&quot; target=&quot;_blank&quot;&gt;eXtreme Programming&lt;/a&gt; sono molto di moda, ma di fatto nella realtà &lt;i&gt;enterprise &lt;/i&gt;- specie in quella italiana - continuano a non vedersi progetti sviluppati secondo la filosofia Agile dello sviluppo del software. Viceversa, nel mondo&amp;nbsp;&lt;i&gt;Open Source&lt;/i&gt;, l&#39;Agile è di fatto la norma.&lt;br /&gt;
&lt;br /&gt;
Spesso si vedono applicate le tecniche agili, come ad esempio &lt;a href=&quot;http://it.wikipedia.org/wiki/Programmazione_di_coppia&quot; target=&quot;_blank&quot;&gt;Pair programming&lt;/a&gt;&amp;nbsp;o &lt;a href=&quot;http://it.wikipedia.org/wiki/Feature_Driven_Development&quot; target=&quot;_blank&quot;&gt;Feature Driven Programming&lt;/a&gt;, ma in contesti che sono quelli tradizionali, e cioè quelli dello &lt;a href=&quot;http://it.wikipedia.org/wiki/Modello_a_cascata&quot; target=&quot;_blank&quot;&gt;sviluppo waterfall&lt;/a&gt;, che nella realtà &lt;i&gt;enterprise &lt;/i&gt;è tuttora l&#39;unico modello supportato.&lt;br /&gt;
&lt;br /&gt;
Frequentemente ho proposto di utilizzare un approccio Agile in diversi progetti reali, ma al di là di un qualche superficiale apprezzamento non si è mai andati.
&lt;br /&gt;
&lt;br /&gt;
Perché dunque, nonostante l&#39;entusiasmo, specie degli addetti ai lavori, la metodologia Agile non ha preso piede? Io credo che le cause siano principalmente tre.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;1. Il sistema non recepisce processi iterativi&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Quello che caratterizza principalmente l&#39;approccio Agile rispetto al Waterfall è il suo essere iterativo&lt;i&gt; by design&lt;/i&gt;. Il progettista Agile sa che lo sviluppo software è spesso un processo &quot;&lt;i&gt;prima volta-primo uso&lt;/i&gt;&quot;, caratterizzato da un altissimo grado di incertezza, per affrontare il quale deve applicarsi una metodologia di gestione del rischio che non può che essere iterativa. L&#39;iterazione tipica dell&#39;Agile è quella indicata in figura:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguvNIV05gCDmilG2a4pTqKiOQvfCVRAqb0sYehq4s0-uTsewgrUtcMqc_iC87_l9D_d7sBcNsbTWSxwlvkIuNRD5LcDujP72slcJgoCeWobKXZYyDOgJ-NUfvB8ko_DIH7IBjdjHMeMPxN/s1600/iterative-development1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguvNIV05gCDmilG2a4pTqKiOQvfCVRAqb0sYehq4s0-uTsewgrUtcMqc_iC87_l9D_d7sBcNsbTWSxwlvkIuNRD5LcDujP72slcJgoCeWobKXZYyDOgJ-NUfvB8ko_DIH7IBjdjHMeMPxN/s400/iterative-development1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Normalmente, in un progetto complesso, le iterazioni possono essere decine. Ma il &quot;sistema&quot; non è in grado di gestire le iterazioni! Se da una parte il Cliente vuole subito sapere quanto costerà il suo nuovo sistema informativo e quanto durerà il suo sviluppo, anche dall&#39;altra il Fornitore ha tutta una serie di strumenti che funzionano solo se vengono immessi valori &quot;a preventivo&quot;: quante risorse il progetto occuperà e per quanto tempo. Come ho riportato &lt;a href=&quot;http://alessiosaltarin.blogspot.it/2010/09/il-fisico-e-il-meteorologo-o-del-perche.html&quot; target=&quot;_blank&quot;&gt;in altri post&lt;/a&gt;, la stima del costo (tempo, denaro e altre risorse) di un progetto &quot;&lt;i&gt;prima volta-primo uso&lt;/i&gt;&quot; è un esercizio di fantasia destinato al fallimento. Tipicamente perciò chi fornisce un servizio di sviluppo software applica dei coefficienti di rischio molto alti proprio per cercare di assorbire questa incognita. Di fatto, nei sistemi dove è &quot;necessaria&quot; una stima dei costi a preventivo, il metodo Agile è escluso a priori.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;2. Un processo che ricicla è considerato un processo di &quot;serie B&quot;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Nella concezione del Project Management classico, &amp;nbsp;il &quot;riciclo&quot; - quindi la re-iterazione - è considerato come un &quot;difetto&quot;, o meglio come la &quot;conseguenza di un difetto&quot;. Il progetto perfetto non presenta ricicli: viene eseguito così com&#39;era stato pensato la prima volta. Per chi non possiede una cultura informatica (direi, una cultura informatica recente) l&#39;idea stessa che una metodologia preveda molti ricicli è semplicemente orrenda. E&#39; orrendo dover immaginare di avere stime riviste, nuove implementazioni e nuovi test ad ogni riciclo. Impensabile immettere ad ogni nuova iterazione nuove funzioni e quindi nuovi bug! Il Cliente percepisce il metodo Agile come una mancanza di professionalità (&lt;i&gt;non sviluppano: provano a sviluppare!&lt;/i&gt;) e lo staff non tecnico del Fornitore la percepisce come una intollerabile mancanza di certezze: quanto ci costerà il progetto, quante risorse impiegherà e per quanto tempo.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Bisogna però fare i conti con la dura realtà: che è tanto più vera e documentata quanto più i progetti aumentano in complessità e novità: all&#39;inizio nessuno può sapere quanto costerà il progetto, nemmeno a grandi linee. Si possono fare delle stime, sulle quali però non può essere calcolato il prezzo al Cliente. Proprio per la grande aleatorietà di queste stime &quot;a-priori&quot;, il prezzo sarà o largamente esagerato per assorbire il rischio, o sottostimato destinato cioè ad andare in perdita. Come dicevo, i sistemi (finanziari, di controllo e gestione e via dicendo) aziendali prevedono che questo prezzo venga calcolato all&#39;inizio, sulla base del quale verranno poi derivati tutti i &lt;i&gt;driver &lt;/i&gt;economici dell&#39;azienda. Un calcolo basato, il più delle volte, sulla fantasia.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;3. La metodologia Agile presuppone il &lt;i&gt;Time&amp;amp;Materials&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Esistono tipicamente due modi per vendere un servizio informatico: a pacchetto (&lt;i&gt;turn-key&amp;nbsp;&lt;/i&gt;o &lt;i&gt;fixed bid&lt;/i&gt;) o a tempo (&lt;i&gt;time&amp;amp;materials, T&amp;amp;M&lt;/i&gt;). Nel primo, chi offre &quot;scommette&quot; su quanto effettivamente gli costerà il servizio: applica alla scommessa il proprio coefficiente di profitto e ottiene il prezzo. Nel secondo, semplicemente vengono erogati dei servizi e il Cliente paga &quot;il tempo&quot; di erogazione.&lt;br /&gt;
Per quanto abbiamo detto sin qui, la metodologia Agile presuppone la seconda opzione. Perché per poter vendere qualcosa &lt;i&gt;turn-key &lt;/i&gt;occorre essere confidenti sulla stima dei costi, cosa che abbiamo visto è molto difficile nel caso di progetti complessi. E perchè l&#39;Agile è iterativo di suo.&lt;br /&gt;
Il committente di un progetto informatico complesso è molto poco propenso a iniziare a lavorare T&amp;amp;M, perché anche lui deve fornire una stima di quali saranno i suoi costi/tempi, e questo a priori! La naturale conseguenza di questo stato di cose è che si formulerà un&#39;offerta &lt;i&gt;turn-key &lt;/i&gt;molto sovrastimata nei costi, ed esageratamente lunga nei tempi.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Io credo che queste tre siano le cause principali che hanno bloccato l&#39;introduzione dei modelli Agili nella pratica dello sviluppo software a livello &lt;i&gt;enterprise&lt;/i&gt;. Sono convinto che un approccio iterativo e T&amp;amp;M possa permettere significative economie sia per chi vende, sia per chi compra soluzioni software. Tuttavia, perché lo sviluppo Agile possa essere effettivamente utilizzato, occorrono notevoli cambiamenti in termini di cultura, processi e strumenti di supporto aziendali.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/07/non-molto-agili-fin-qui.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ0FkEY5Uo2lr8cU2GjxCJEi2T9z8UeJ6TMMvZ08dsEgGAiGO7ujUK20OdQPsdnuDVx6cOV62XNpYjg2x_YOj0Yu-RcJSP6W6MixuOANmjiOL4ZJoFmnD-sHVAgqIh5pQBlPjdhyphenhyphenSggPld/s72-c/AgileDevelopment.png" height="72" width="72"/><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-9038445027282448289</guid><pubDate>Fri, 13 Jul 2012 09:51:00 +0000</pubDate><atom:updated>2012-07-31T09:57:02.075+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ajax</category><category domain="http://www.blogger.com/atom/ns#">coffeescript</category><category domain="http://www.blogger.com/atom/ns#">prototype</category><title>Ajax + Prototype + CoffeeScript</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In rete abbondano gli esempi CoffeeScript per chiamate Ajax con la libreria jQuery. Se uno - come me - preferisce Prototype, è abbandonato al proprio destino.&lt;br /&gt;
&lt;br /&gt;
Perciò pubblico qui sotto l&#39;esempio di una pagina CoffeeScript con chiamate Ajax in Prototype.&lt;br /&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;span style=&quot;color: dimgrey;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;span style=&quot;color: dimgrey;&quot;&gt;//= require prototype&lt;/span&gt;

pe &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0f4d75;&quot;&gt;null&lt;/span&gt;

invitations_args &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;
  method&lt;span style=&quot;color: purple;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;get&#39;&lt;/span&gt;
  onSuccess&lt;span style=&quot;color: purple;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;transport&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
    inviter &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; transport&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;responseText
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;if&lt;/span&gt; inviter&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;length &lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #008c00;&quot;&gt;1&lt;/span&gt;
      $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;invitation&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;show&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
      $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;proposal&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;update
&lt;span style=&quot;color: #808030;&quot;&gt;             (&lt;/span&gt;inviter &lt;span style=&quot;color: #808030;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39; invites you to join a game:&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
      pe&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;stop&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
      &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt;
  onFailure&lt;span style=&quot;color: purple;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
    $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;invitation&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;show&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; 
    $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;proposal&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;update&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;Error retrieving invitation&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt;

invitations &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; Ajax&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;Request 
&lt;span style=&quot;color: #0000e6;&quot;&gt;      &#39;/player/lookforinvitations&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; invitations_args
  
main_loop &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
  pe &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;new&lt;/span&gt; PeriodicalExecuter&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt; invitations&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #008c00;&quot;&gt;3&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;

Event&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;observe&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;window&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;load&#39;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; main_loop&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;span style=&quot;color: #808030;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
La parte principale (&lt;i&gt;main_loop&lt;/i&gt;) è invocata sull&#39; &lt;i&gt;onLoad &lt;/i&gt;della pagina HTML. Qui, un PeriodicalExecuter esegue una chiamata Ajax ogni tre secondi ad un metodo (/player/lookforinvitations) che cerca se sul database qualcuno ci ha invitato a giocare. Se sì la pagina mostra un messaggio: ad esempio: Pippo ti invita a giocare con lui, e ferma il processo PeriodicalExecuter. Altrimenti la pagina continua ad inviare richieste Ajax al server finchè l&#39;utente non cambia pagina.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;(Una cosa interessante e che mi ha fatto perdere molto tempo è che anche in CoffeeScript l&#39;ordine in cui vengono definite le funzioni è importante!! Se mettete ad esempio &lt;/i&gt;Event.Observe&lt;i&gt; all&#39;inizio del file, otterrete un errore di oggetto &lt;/i&gt;undefined&lt;i&gt;: l&#39;oggetto in questione è &lt;/i&gt;main_loop&lt;i&gt;, che viene definito solamente più sotto!)&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/07/ajax-prototype-coffeescript.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-7263545450752576934</guid><pubDate>Wed, 11 Jul 2012 10:17:00 +0000</pubDate><atom:updated>2012-07-31T09:57:33.376+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">coffeescript</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><title>CoffeeScript e le var locali</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;http://coffeescript.org/&quot;&gt;CoffeeScript &lt;/a&gt;è un linguaggio moderno, sintetico ed efficace che compila in JavaScript. Nei progetti web complessi, l&#39;uso di CoffeeScript si sta via via imponendo, perché rende la creazione e la manutenzione del codice lato client molto più veloce e snella.&lt;br /&gt;
&lt;br /&gt;
Una delle prime difficoltà, tuttavia, che si incontrano quando si comincia ad usare CoffeeScript è il fatto che per convenzione tutte le variabili (e quindi anche le funzioni, che in CoffeeScript sono anonime e associate ad un nome di variabile) sono locali.&lt;br /&gt;
&lt;br /&gt;
Un esempio può chiarire meglio. Supponiamo di avere questa semplice pagina in HTML5:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;span style=&quot;color: #004a43;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;CoffeeScript Palestra&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color: #274796;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;span style=&quot;color: #274796;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;css/main.css&quot;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;script src=&quot;js/vendor/jquery-1.7.2.min.js&quot;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;script src=&quot;js/script.js&quot;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;CoffeeScript Scripts&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;Premi &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: #274796;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;span style=&quot;color: #274796;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;run()&quot;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;qui&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: #274796;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;&quot;pippo&quot;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;nbsp&lt;/span&gt;&lt;span style=&quot;color: #074726;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #a65700;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Se l&#39;utente preme il link &quot;qui&quot; vogliamo che accada qualcosa, ad esempio compaia la scritta &quot;Ciao Mondo!&quot;&lt;br /&gt;
&lt;br /&gt;
La prima idea che ci viene in mente è quella di scrivere due funzioni, una che ritorna &quot;Ciao Mondo&quot; e una che aggiorna il contenuto del DIV &quot;Pippo&quot; appunto con &quot;Ciao Mondo&quot;, in questo modo:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;i&gt;&lt;b&gt;# COFFEESCRIPT SCRIPTS&lt;/b&gt;&lt;/i&gt;

run &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
  $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;#pippo&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;html&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;helloworld&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #0f4d75;&quot;&gt;null&lt;/span&gt;


helloworld &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;Ciao Mondo!&#39;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Mettiamo questo codice nel file &quot;&lt;i&gt;script.coffee&lt;/i&gt;&quot; e poi lo compiliamo con CoffeeScript. Otterremo&amp;nbsp;&lt;i&gt;script.js &lt;/i&gt;che viene poi richiamato dal nostro file HTML (sotto la riga che carica &lt;i&gt;JQuery&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;
Peccato che una volta eseguito il tutto, quando l&#39;utente preme &quot;qui&quot;, non accade nulla.&lt;br /&gt;
&lt;br /&gt;
Il motivo è che il compilatore CoffeeScript traduce le due funzioni &quot;run&quot; e &quot;helloworld&quot; come funzioni locali, quindi di fatto invisibili all&#39;esterno dello stesso codice. Ecco il codice compilato:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;span style=&quot;color: dimgrey;&quot;&gt;// Generated by CoffeeScript 1.3.3&lt;/span&gt;
&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;var&lt;/span&gt; run&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; helloworld&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

  run &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
    $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;#pippo&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;html&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;helloworld&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0f4d75;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

  helloworld &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;Ciao Mondo!&#39;&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;call&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
E&#39; giusto che sia così: infatti per evitare conflitti di nomi e variabili globali che rimangono inutilmente appese, mentre in JavaScript è buona norma dichiarare tutto con &quot;var&quot;, in CoffeeScript questa diviene la regola.&lt;br /&gt;
&lt;br /&gt;
Per &quot;esportare&quot; il nome di una variabile all&#39;esterno si può agire in diversi modi. Quello che personalmente preferisco è di associare allo spazio dei nomi dello script un nome che espliciti la sua funzione di &quot;esportatore&quot; (ad esempio: &lt;i&gt;exports&lt;/i&gt;), e poi di dichiarare le variabili da esportare come appartenenti a questo spazio.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: #ffffff; color: black;&quot;&gt;&lt;i&gt;&lt;b&gt;# COFFEESCRIPT SCRIPTS&lt;/b&gt;&lt;/i&gt;

exports &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;

exports&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;run &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt;
  $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;#pippo&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;html&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;helloworld&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;
  &lt;span style=&quot;color: #0f4d75;&quot;&gt;null&lt;/span&gt;


helloworld &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808030;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;Ciao Mondo!&#39;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
In questo modo, la funzione &lt;i&gt;run()&lt;/i&gt; - o meglio, la variabile &#39;run&#39; associata alla funzione anonima - diventa visibile all&#39;interno del nostro file HTML e perciò direttamente utilizzabile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;color: dimgrey;&quot;&gt;// Generated by CoffeeScript 1.3.3&lt;/span&gt;
&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;var&lt;/span&gt; exports&lt;span style=&quot;color: #808030;&quot;&gt;,&lt;/span&gt; helloworld&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

  exports &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

  exports&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;run &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
    $&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000e6;&quot;&gt;#pippo&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;html&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;helloworld&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0f4d75;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

  helloworld &lt;span style=&quot;color: #808030;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000e6;&quot;&gt;&#39;Ciao Mondo!&#39;&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;.&lt;/span&gt;call&lt;span style=&quot;color: #808030;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: maroon; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #808030;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Come conseguenza non banale, le funzioni ancillari come per esempio la &#39;&lt;i&gt;helloworld&lt;/i&gt;&#39;, non vengono esposte, diventando di fatto &#39;private&#39;.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/07/coffeescript-e-le-var-locali.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-7781129998133039173</guid><pubDate>Thu, 05 Apr 2012 12:25:00 +0000</pubDate><atom:updated>2012-04-05T14:25:01.478+02:00</atom:updated><title>Perle di Gantt</title><description>I fautori delle teorie di Project Management, i vari &lt;i&gt;aficionados &lt;/i&gt;dei diagrammi Gantt e CPM che ogni azienda come si deve sparacchia su vecchi template Powerpoint per giustificare ogni tipo di decisione, dovrebbero rileggersi con attenzione queste parole che Henry Gantt, che fu tra i padri delle moderne teorie di programmazione e inventore del diagramma omonimo, scrisse nel 1900:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&amp;nbsp;
&lt;i&gt;&quot;La programmazione è una scienza empirica&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;basata su teoremi inesatti&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;che sviluppa algoritmi approssimativi&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&amp;nbsp;costruiti su ipotesi sommarie.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Le persone che la praticano&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&amp;nbsp;tentano di concretizzare
l’astratto&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;attraverso l’impossibile.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Per fare programmazione&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;non è necessario essere
pazzi,&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;ma il fatto di esserlo aiuta&quot;&lt;/i&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/04/perle-di-gantt.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-1374865626133734622</guid><pubDate>Fri, 09 Mar 2012 16:24:00 +0000</pubDate><atom:updated>2012-03-09T17:25:53.339+01:00</atom:updated><title>Un font monospace per Linux</title><description>Uno dei problemi &quot;storici&quot;, diciamo così, di Linux, è che i suoi font di default sono mediamente bruttini.&lt;br /&gt;
&lt;br /&gt;
La situazione si fa più drammatica quando uno in Linux ci programma. Stare ore davanti a un font brutto e per di più sfocato non è piacevole.&lt;br /&gt;
&lt;br /&gt;
Ecco dunque la mia personalissima scelta come pretendente al titolo di miglior font monospace su Linux. &lt;i&gt;E il vincitore è....&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;Droid Sans Mono&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Ecco uno screenshot da Eclipse (Linux Mint 12):&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKbN5r2QaA1m-Ie0DrAvMXauOZddQoVX2wprO12sLTvEMdq4mPGLPJPFx3SWyp9S8Q-WBVbmq9flVL3Wi0wOjWByQ9WZVw__vfnjvxEvdbqWCktzLodfMQ1oIf9WoPFQdZe7NaIi3g6wZa/s1600/Screenshot+at+2012-03-09+17:22:11.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKbN5r2QaA1m-Ie0DrAvMXauOZddQoVX2wprO12sLTvEMdq4mPGLPJPFx3SWyp9S8Q-WBVbmq9flVL3Wi0wOjWByQ9WZVw__vfnjvxEvdbqWCktzLodfMQ1oIf9WoPFQdZe7NaIi3g6wZa/s1600/Screenshot+at+2012-03-09+17:22:11.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Esempio di font &#39;Droid Sans Mono&#39; sotto Linux Mint&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/03/un-font-monospace-per-linux.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKbN5r2QaA1m-Ie0DrAvMXauOZddQoVX2wprO12sLTvEMdq4mPGLPJPFx3SWyp9S8Q-WBVbmq9flVL3Wi0wOjWByQ9WZVw__vfnjvxEvdbqWCktzLodfMQ1oIf9WoPFQdZe7NaIi3g6wZa/s72-c/Screenshot+at+2012-03-09+17:22:11.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-4342431568166777131</guid><pubDate>Wed, 29 Feb 2012 09:07:00 +0000</pubDate><atom:updated>2012-02-29T14:47:49.086+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">phishing</category><title>Smascherare il phishing</title><description>Subiamo un tentativo di &lt;i&gt;&lt;b&gt;phishing&lt;/b&gt;&lt;/i&gt;&amp;nbsp;quando riceviamo una e-mail che:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;pretende di arrivare da un&#39;istituzione di qualche tipo (finanziaria, commerciale)&lt;/li&gt;
&lt;li&gt;contiene un link fasullo che ci porta su un sito sul quale ci viene chiesto di inserire qualche dato privato (ad esempio: una username e una password)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
Normalmente queste mail sono studiate per catturare la nostra attenzione, dicendo ad esempio che il nostro account di banca, carta di credito, o altre forme di pagamento è stato bloccato, per cui &quot;è urgente&quot; fare qualcosa, cioè clickare sul link fasullo.&lt;br /&gt;
&lt;br /&gt;
Una volta clickato il link, arriviamo su una pagina di un sito costruito per &quot;sembrare&quot; il sito dell&#39;istituzione, ci viene chiesto di inserire la nostra password e il gioco è fatto: così rubano le password di accesso, che useranno in seguito per azioni fraudolente.&lt;br /&gt;
&lt;br /&gt;
Fortunatamente è facile smascherare un tale tentativo di phishing. Ecco come.&lt;br /&gt;
&lt;br /&gt;
Questa di seguito è l&#39;immagine di un&#39;e-mail di phishing:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglddbXTOKyLqD4Mi2af_-mKTXCFLodftkyTVuSU7kvLMYmSqrTQEpIrAs45V2ZZ0j6a3PizmHfYtNstUFRPLn-Pf2QSuVGmjGwg8ywVzwip_J6Xx9rsDssnd5n7LcU4MCa9fYvFrVg5Iph/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;199&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglddbXTOKyLqD4Mi2af_-mKTXCFLodftkyTVuSU7kvLMYmSqrTQEpIrAs45V2ZZ0j6a3PizmHfYtNstUFRPLn-Pf2QSuVGmjGwg8ywVzwip_J6Xx9rsDssnd5n7LcU4MCa9fYvFrVg5Iph/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Gli elementi ci sono tutti:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;la mail sostiene che &quot;qualcosa di grave è successo&quot;: è stato &quot;bloccato&quot; l&#39;account della carta di credito&lt;/li&gt;
&lt;li&gt;c&#39;è un link per &quot;fare qualcosa per aggiustare la situazione&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Primo indizio - le banche non mandano e-mail&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Nessuna istituzione seria (banche, carte di credito, siti commerciali) ci invierà mai una mail che contiene il link ad un sito. Proprio per evitare tentativi di phishing, tutte le mail che riceviamo da enti seri, non contengono link. Casomai l&#39;invito a collegarsi autonomamente al loro sito. Ma, in generale, nessuna mail NON RICHIESTA ci verrà mai inviata.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Secondo indizio - orrori ortografici&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Tutte le e-mail di phishing contengono orripilanti errori di italiano, perchè normalmente sono la &quot;traduzione automatica&quot; di analoghe e-mail in inglese. Leggiamo attentamente:
&lt;i&gt;&#39;Si prega di non utilizzare il link all&#39;interno di questa e-mail a ripristinare un altro conto di quanto il tuo&#39;&lt;/i&gt; oppure&lt;i&gt; &#39;Si prega di seguire attentamente le nostre indicazioni e sarà in grado di ripristinare l&#39;accesso al conto in pochi minuti&#39;&lt;/i&gt;...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Terzo indizio - link fasulli&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Come funziona il phishing? Cercando di portare la persona su un sito che &quot;finge&quot; di essere ciò che non è. E&#39; facile in HTML dire che un link porta da una parte, quando invece porta da un&#39;altra. Però è anche facile capirlo: basta posizionare il mouse sul link stesso per controllare che il link porti veramente dove dice di voler portare: la freccia in verde indica &quot;dove&quot; il link finge di volerci portare (su www.cartasi.it) e quella in blu dove ci porta veramente (su wiki.tenfor..com)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh20X9o9K2_ysHe9ja4cKfjFTdjVCNDBu6Ry3fb9BxCr6tZzQveusPNFoJYD2wEO2xKZDN-MOL8T2ImWM65l8Qwy1_g2oED4Dcz6Han_dt41D6aIbyHY2Gns8a36xmeHBm2sl1gDsHwhMLd/s1600/Image1.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh20X9o9K2_ysHe9ja4cKfjFTdjVCNDBu6Ry3fb9BxCr6tZzQveusPNFoJYD2wEO2xKZDN-MOL8T2ImWM65l8Qwy1_g2oED4Dcz6Han_dt41D6aIbyHY2Gns8a36xmeHBm2sl1gDsHwhMLd/s320/Image1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;i&gt;Quarto indizio - sender fasullo&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Lo stesso giochetto viene applicato al sender della mail. La mail dice di essere stata spedita da CartaSi S.p.A. Ma se guardiamo bene nei dettagli scopriamo che invece è stata spedita da e-vendax.pop.com.br

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1sFYdcDuIPzbzndYt-o-U7H2-bg_cvSCaK2r9x7-aTHd3LSp7j0A5bSJlWnySFi5coEFdnuEGVpbeBtFbi0wpixioiv_bDGGIPpPXoFcAv6N3_ZLtRKXnk01dq4nEKd0ldudX8LNo_4Wo/s1600/Image2.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1sFYdcDuIPzbzndYt-o-U7H2-bg_cvSCaK2r9x7-aTHd3LSp7j0A5bSJlWnySFi5coEFdnuEGVpbeBtFbi0wpixioiv_bDGGIPpPXoFcAv6N3_ZLtRKXnk01dq4nEKd0ldudX8LNo_4Wo/s320/Image2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Normalmente, in un tentativo di phishing questi indizi sono sempre presenti. Ovviamente: mai clickare sul link, e men che mai inserire informazioni personali (come username, password e numero conti) su siti che non abbiamo raggiunto &quot;volontariamente&quot; - ad esempio partendo da un bookmark del browser.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Cosa fare, infine quando si riceve una e-mail di phishing?&lt;/i&gt; Sicuramente segnalarlo al provider, in questo caso GMail:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIWDxica06QMEqN5Ltkne0BNHgm8VhMRKn9txs0S0Kf2Z2QanPjzWr2NgOE0xLMjAo9VBVhnEQev8Acsfoi2a1wsvDUPRNz2KPvTrBMsV6yUGDmyCva_byQEUG3uwYC65dqhriatw6x8t_/s1600/Image3.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;106&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIWDxica06QMEqN5Ltkne0BNHgm8VhMRKn9txs0S0Kf2Z2QanPjzWr2NgOE0xLMjAo9VBVhnEQev8Acsfoi2a1wsvDUPRNz2KPvTrBMsV6yUGDmyCva_byQEUG3uwYC65dqhriatw6x8t_/s320/Image3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Inoltre, è sempre possibile avvisare dell&#39;avvenuto tentativo di truffa la sezione locale della Polizia Postale, che in Italia si occupa anche di reati informatici.&lt;br /&gt;
&lt;br /&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/02/smascherare-il-phising.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglddbXTOKyLqD4Mi2af_-mKTXCFLodftkyTVuSU7kvLMYmSqrTQEpIrAs45V2ZZ0j6a3PizmHfYtNstUFRPLn-Pf2QSuVGmjGwg8ywVzwip_J6Xx9rsDssnd5n7LcU4MCa9fYvFrVg5Iph/s72-c/Capture.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-8018255926183891688</guid><pubDate>Thu, 23 Feb 2012 10:15:00 +0000</pubDate><atom:updated>2012-02-29T10:43:14.403+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">REST</category><category domain="http://www.blogger.com/atom/ns#">Web Service</category><title>Pensare in REST (Thinking in REST)</title><description>La progettazione di applicazioni &lt;i&gt;Web based&lt;/i&gt; ha subìto una silenziosa rivoluzione quando nel 2000 Roy Fielding ha pubblicato la sua ormai celebre dissertazione dal titolo: &lt;i&gt;&quot;Architectural Styles and the Design of Network-based Software Architectures&quot;&lt;/i&gt;, e in particolare il capitolo cinque: &lt;i&gt;&quot;Representational State Transfer (REST)&quot;&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
In cosa consiste questa rivoluzione? Esiste una modalità, diciamo così, &quot;classica&quot; di concepire un&#39;applicazione per computer, e questa prevede la composizione di un algoritmo più o meno complesso che prende in input una serie di dati, li trasforma e poi li rende persistenti - ad esempio salvandoli su un database. L&#39;essere umano interagisce con l&#39;applicazione attraverso una &quot;interfaccia utente&quot; che viene aggiornata a seconda del cambiamento di stato - o dell&#39;input o dell&#39;output. Così, in modo appunto &quot;classico&quot;, un&#39;applicazione è costituita di un&#39;interfaccia utente, una logica, e uno stato - cioè dei dati persistenti.&lt;br /&gt;
&lt;br /&gt;
Le prime applicazioni Web complesse, rese possibili dalle primigenie tecnologie di trasformazione dinamica dell&#39;HTML, lato server con ASP o PHP ad esempio e lato client con DOM/Javascript, implementavano questo modello classico. Vale a dire, presentavano all&#39;utente un&#39;interfaccia grafica con la quale inserire i dati, offrivano una serie di comandi associati a una logica di esecuzione, e infine persistevano i risultati su un database.&lt;br /&gt;
&lt;br /&gt;
Il problema di questo approccio è che l&#39;applicazione diventa un monolite che si può utilizzare solamente nel modo in cui è stata inizialmente concepita.&lt;br /&gt;
&lt;br /&gt;
Con l&#39;aumentare delle necessità di servizi Web, con l&#39;aumentare dei device eterogenei che vi accedono - dai computer ai telefonini, dai videogiochi alle lavastoviglie - questo tipo di approccio è diventato controproducente: l&#39;applicazione monolitica impedisce di utilizzare i dati e le informazioni che è in grado di veicolare appunto perché è concepita per essere utilizzata &lt;i&gt;in un solo modo&lt;/i&gt;, che è quello inizialmente concepito dai suoi autori. La conseguenza di tutto ciò è che ogni nuova esigenza di accedere ad un dato o ad un servizio veicolato dall&#39;applicazione necessita di un cambiamento nel codice applicativo o, peggio, nella creazione di una nuova applicazione &lt;i&gt;ad hoc&lt;/i&gt;. &lt;br /&gt;
&lt;br /&gt;
Oggi le aziende spendono moltissime risorse IT proprio perché hanno a che fare con applicazioni monolitiche che non riescono a &quot;servire&quot; il dato in maniera abbastanza neutra.&lt;br /&gt;
&lt;br /&gt;
L&#39;idea alla base del protocollo REST inventato da Roy Fielding è che le applicazioni Web devono essere progettate in modo tale per cui immettendo direttamente le URL (che così diventano URI) su un browser si ottengano immediatamente i dati che servono, e che queste URL possano essere &quot;combinate&quot; tra loro in un workflow per ottenere un&#39;applicazione, allo stesso modo con cui nelle architetture SOA noi combiniamo i &quot;servizi&quot; per ottenere sempre nuove applicazioni.&lt;br /&gt;
&lt;br /&gt;
La URL così richiamata deve essere in grado di rispondere in formato &quot;neutro&quot;, possibilmente veicolando solamente &quot;i dati&quot;, senza cioè alcuna informazione &quot;grafica&quot; di supporto. Le URL stesse devono specificare il formato dei dati che richiedono: se la URL finisce per &quot;.xml&quot; il dato verrà restituito in XML, per &quot;.json&quot; in JSON, e, naturalmente, di default rispondere con un HTML &lt;i&gt;human readable&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Per finire un esempio. Supponiamo di scrivere un videogioco Web, magari per Facebook. Avremo da qualche parte una struttura dati che prende tutte le informazioni relative al giocatore (Player). Questa struttura dati raccoglie e persiste lo &quot;stato&quot; del giocatore durante il gioco. La modalità classica consiste nello scrivere un&#39;applicazione che, a seconda dei comandi dati via web dal giocatore, cambia lo stato e aggiorna di conseguenza la tabella &quot;Player&quot;. Esagerando, l&#39;applicazione potrebbe essere costituita da un&#39;unica &quot;pagina&quot; che, a seconda del comando HTTP ricevuto, risponde in un modo o in un altro. Ovviamente, così facendo, nessuno, ad esempio, potrebbe costruire un altro gioco a partire dai dati correnti dei giocatori: perché le informazioni di stato dei giocatori sono &quot;chiuse&quot;, e utilizzabili solo dalla &quot;pagina&quot; di cui parlavamo prima.&lt;br /&gt;
&lt;br /&gt;
Se volessimo applicare il protocollo REST all&#39;entità &quot;Giocatore&quot; (Player), come prima cosa dovremmo definire le &quot;URL&quot; che accedono a ciascuna informazione del giocatore, e le URL che vanno a modificare lo stato del giocatore stesso. Ad esempio:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;rails&quot; style=&quot;background-color: #f0f0f0; border: 1px solid #d0d0d0; color: #000066; font-family: monospace;&quot;&gt;
GET &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;list&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#list&lt;/span&gt;&lt;br /&gt;
POST &amp;nbsp; &lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;list&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#list&lt;/span&gt;&lt;br /&gt;
GET &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#index&lt;/span&gt;&lt;br /&gt;
POST &amp;nbsp; &lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#create&lt;/span&gt;&lt;br /&gt;
GET &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #5a0a0a; font-weight: bold;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#new&lt;/span&gt;&lt;br /&gt;
GET &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;:id&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;edit&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp;player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#edit&lt;/span&gt;&lt;br /&gt;
GET &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;:id&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#show&lt;/span&gt;&lt;br /&gt;
PUT &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;:id&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#update&lt;/span&gt;&lt;br /&gt;
DELETE &lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;player&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;/&lt;/span&gt;:id&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;(&lt;/span&gt;.:&lt;span style=&quot;color: #cc0066; font-weight: bold;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #006600; font-weight: bold;&quot;&gt;)&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player&lt;span style=&quot;color: green; font-style: italic;&quot;&gt;#destroy&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Questa tabella fornisce un verbo HTTP e una URL associata. Queste URL, se chiamate con il rispettivo verbo HTTP, sono già in grado di descrivere le funzionalità di base con cui l&#39;utente può ottenere le informazioni sui giocatori! La prima fornisce una lista dei giocatori, la seconda modifica la lista, la terza ottiene informazioni generiche, la quarta e la quinta inseriscono nuovi giocatori, la sesta  permette di modificare i dati di uno specifico giocatore e via dicendo...&lt;br /&gt;
&lt;br /&gt;
Se chiamo &lt;i&gt;/player/list&lt;/i&gt; ottengo una pagina HTML, &lt;i&gt;/player/list.json&lt;/i&gt; un array di giocatori, &lt;i&gt;/player/list.xml&lt;/i&gt; un documento XML. Applicazioni sempre diverse accedono agli stessi dati in maniera omogenea. In questo modo, se l&#39;applicazione è ben scritta, sarà sempre possibile immaginare nuovi modi per accedere ai dati, e produrre applicazioni nuove senza dover modificare il codice lato server.&lt;br /&gt;
&lt;br /&gt;
Chiaramente, progettare un&#39;architettura Web in modalità REST comporta un ribaltamento del modo di pensare: invece che partire dalle esigenze &quot;funzionali&quot;, bisogna partire dai dati, e dal modo con cui si può manipolarli. Ma il vantaggio di farlo fin dall&#39;inizio, con disciplina, produrrà significativi risparmi nella gestione evolutiva dell&#39;applicazione, e darà l&#39;opportunità di costruire nuovi modi d&#39;uso di applicazioni esistenti praticamente senza sforzo.&lt;br /&gt;
&lt;br /&gt;
Oggi esistono molti framework che producono applicazioni Web RESTful. Il più famoso è &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;&quot;Ruby On Rails&quot;&lt;/a&gt;. Seguono &lt;a href=&quot;http://bowlerframework.org/&quot;&gt;&quot;Bowler&quot;&lt;/a&gt; per Scala, &lt;a href=&quot;http://jersey.java.net/&quot;&gt;&quot;Jersey&quot;&lt;/a&gt; per Java. E molti altri stanno nascendo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://alessiosaltarin.blogspot.com/2012/02/pensare-in-rest-thinking-in-rest.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-3162894106302709360</guid><pubDate>Tue, 24 Jan 2012 14:47:00 +0000</pubDate><atom:updated>2012-02-29T10:43:31.799+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">scala</category><title>Interoperabilità tra Scala e Java</title><description>&lt;a href=&quot;http://www.scala-lang.org/&quot;&gt;Scala&lt;/a&gt; è interoperabile con Java, poiché entrambi i linguaggi producono Java bytecode. Questo significa che tutte le seguenti frasi sono vere:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Codice Scala può essere eseguito da una Java Virtual Machine&lt;/li&gt;
&lt;li&gt;Codice Java può essere &quot;visto&quot; da codice Scala&lt;/li&gt;
&lt;li&gt;Codice Scala può esserre &quot;visto&quot; da codice Java&lt;/li&gt;
&lt;/ul&gt;
Supponiamo di avere ad esempio la seguente classe di business in Scala, una generica struttura che rappresenta l&#39;astrazione di un numero razionale. E&#39; costruita passando numeratore e denominatore, ad esempio Rational(2,3) è due terzi (2/3).

&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDXGST_yZm0CS5a_rpg_qQHHnHlRYqeR2jIvhcUWZj8-Kxe3ljTt-584rDAT0d5juaxXT9-ArZdZMDXmSC8tW-dMBaoB5GXhtT1MJ-m9M3PLaR0DWRcaQxojslpp2mW_9GkeSUYGBQCIr2/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package net.alessiosaltarin.rationals  
   
 class Rational(n: Int, d: Int) {  
   require(d != 0)  
   
   private val g = this.gcd(n.abs, d.abs)  
   val numer: Int = (n / g)  
   val denom: Int = (d / g)  
   println(&quot;Created &quot; + this.toString())  
   
   def this(n: Int) = this(n, 1)  
   
   override def toString = this.numer + &quot;/&quot; + this.denom  
   
   def +(that: Rational): Rational =  
     new Rational(  
       this.numer * that.denom + that.numer * this.denom,  
       this.denom * that.denom)  
   
   def *(that: Rational): Rational =  
     new Rational(this.numer * that.numer, this.denom * that.denom)  
   
   private def gcd(a: Int, b: Int): Int =  
     if (b == 0) a else gcd(b, a % b)  
 }  
   
 object RationalComputer {  
   
   def performSum(r1: Rational, r2: Rational): String =  
     (r1 + r2).toString()  
   
   def performMultiply(r1: Rational, r2: Rational): String =  
     (r1 * r2).toString()  
   
 }  
   
 object RationalFactory {  
   
   def create(rationalStr: String): Rational =  
     {  
       val indexOfSlash = rationalStr indexOf &#39;/&#39;  
       val n = nrParse(rationalStr.substring(0, indexOfSlash))  
       val d = nrParse(rationalStr.substring(indexOfSlash + 1))  
       new Rational(n, d)  
     }  
   
   private def nrParse(nstr: String): Integer = Integer.parseInt(nstr)  
 }  
&lt;/code&gt;&lt;/pre&gt;
Se vogliamo offrire a questo codice una user interface, che non sia Web, abbiamo ben poche possibilità, se vogliamo rimanere nell&#39;ambito di Scala, e cioè quelle di usare il wrapping delle librerie Swing scritto in Scala, vale a dire:

&lt;a href=&quot;http://www.scala-lang.org/api/current/scala/swing/package.html&quot;&gt;
http://www.scala-lang.org/api/current/scala/swing/package.html
&lt;/a&gt;

Il problema di questo approccio è che alla data di questo post manca totalmente un editor visuale che generi in output un codice Scala.

Quello che abbiamo, invece, sono degli editor visuali che generano codice Swing in Java, ad esempio:

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; Netbeans Matisse &lt;/li&gt;
&lt;li&gt; Eclipse Visual Editor &lt;/li&gt;
&lt;/ul&gt;
La buona notizia è che, stanti le premesse di cui sopra, codice Scala può essere visto da Java come se fosse una &quot;libreria&quot; esterna (e viceversa, tra l&#39;altro). Possiamo infatti pensare di realizzare un&#39;interfaccia di questo tipo:

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3NIlGn3L5Drfa34m3AdIr8BTamC_HlQtuDDX2NxEtWIzcE-sPRRNqgcZxG77ugNp1uw1H3tza2gesR0ZDKOQfczblQhVyVRbgvTQdVJ5_Xmlo3qhjvHsdlMcHb7ma5g3JsdWFAnwmApey/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;309&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3NIlGn3L5Drfa34m3AdIr8BTamC_HlQtuDDX2NxEtWIzcE-sPRRNqgcZxG77ugNp1uw1H3tza2gesR0ZDKOQfczblQhVyVRbgvTQdVJ5_Xmlo3qhjvHsdlMcHb7ma5g3JsdWFAnwmApey/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
attraverso l&#39;editor visuale che preferiamo, generare il codice Java equivalente, e poi eseguirlo.

Per farlo possiamo seguire due approcci, entrambi validi: eseguire dalla macchina virtuale Scala il codice Scala e il codice Java interpretarlo come bytecode esterno, oppure eseguire da una qualsiasi macchina virtuale Java il codice dell&#39;interfaccia grafica e da questo richiamare il bytecode compilato da Scala come una libreria esterna.

Chiaramente, è il secondo approccio quello più interessante. Infatti nella pratica avremo a disposizione macchine virtuali Java, ottimizzate a seconda dell&#39;uso.

Perché questo approccio sia percorribile, occorre costruirsi un proxy Java in grado di richiamare il codice di business in Scala. Il proxy conterrà i metodi richiamati direttamente dall&#39;interfaccia - nell&#39;esempio, il pulsante di &#39;esegui operazione&#39;. Ad esempio:

&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDXGST_yZm0CS5a_rpg_qQHHnHlRYqeR2jIvhcUWZj8-Kxe3ljTt-584rDAT0d5juaxXT9-ArZdZMDXmSC8tW-dMBaoB5GXhtT1MJ-m9M3PLaR0DWRcaQxojslpp2mW_9GkeSUYGBQCIr2/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package net.alessiosaltarin.javaproxy;  
   
 import net.alessiosaltarin.rationals.Rational;  
 import net.alessiosaltarin.rationals.RationalFactory;  
 import net.alessiosaltarin.rationals.RationalComputer;  
   
 public class ProxyLogic  
 {  
   public static String performOperation(Operation op,   
                           String rationalOne,   
                           String rationalTwo)  
   {  
     Rational r1 = RationalFactory.create(rationalOne);  
     Rational r2 = RationalFactory.create(rationalTwo);  
     String result;  
       
     switch (op)  
     {  
          case ADD:  
          default:  
               result = RationalComputer.performSum(r1, r2);  
               break;  
                 
          case SUBTRACT:  
               throw new UnsupportedOperationException();  
                 
          case MULTIPLY:  
               result = RationalComputer.performMultiply(r1, r2);  
               break;  
                 
          case DIVIDE:  
               throw new UnsupportedOperationException();  
     }  
       
     return result;  
   }    
 }  
&lt;/code&gt;&lt;/pre&gt;
Il codice sopra richiama il codice Scala - il namespace 

&lt;br /&gt;
&lt;pre&gt;net.alessiosaltarin.rationals.Rational&lt;/pre&gt;
Come fa? Semplicemente lo trova nel percorso del codice compilato come Java bytecode, a patto di avere la libreria Scala 

&lt;br /&gt;
&lt;pre&gt;scala-library.jar
&lt;/pre&gt;
nel classpath corrente. Supponendo che la classe RationalGUI sia quella generata dal tool visuale, il codice eterogeneo Scala/Java verrà eseguito dalla JVM in questo modo:

&lt;br /&gt;
&lt;pre&gt;java -cp scala-library.jar;[jre,...] net.alessiosaltarin.javaproxy.RationalGUI
&lt;/pre&gt;
Utilizzando ad esempio &lt;i&gt;Eclipse&lt;/i&gt;, è possibile aprire due progetti, uno in Scala e uno in Java, e in quello Java che contiene il metodo &lt;i&gt;main&lt;/i&gt;, referenziare come libreria esterna il codice Scala custom e la libreria &lt;i&gt;scala-library.jar&lt;/i&gt;.</description><link>http://alessiosaltarin.blogspot.com/2012/01/interoperabilita-tra-scala-e-java.html</link><author>noreply@blogger.com (Guildenstern70)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3NIlGn3L5Drfa34m3AdIr8BTamC_HlQtuDDX2NxEtWIzcE-sPRRNqgcZxG77ugNp1uw1H3tza2gesR0ZDKOQfczblQhVyVRbgvTQdVJ5_Xmlo3qhjvHsdlMcHb7ma5g3JsdWFAnwmApey/s72-c/Capture.PNG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-705783240670469022</guid><pubDate>Fri, 30 Dec 2011 09:10:00 +0000</pubDate><atom:updated>2011-12-30T10:26:05.925+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">crisi</category><category domain="http://www.blogger.com/atom/ns#">lavoro</category><title>Il negozio di scarpe di mio nonno</title><description>&lt;br /&gt;
&lt;br /&gt;
&quot;&lt;i&gt;Io appartengo a una grande azienda che produce scarpe...&lt;/i&gt;&quot; disse l&#39;ingegner Carozzi. &quot;In questi tempi di crisi, l&#39;azienda sta andando molto male, e sta cominciando a licenziare. Io mi guardo intorno, e credo di aver capito perchè l&#39;azienda in cui lavoro sta fallendo: è perché noi siamo dei bravi venditori, siamo degli ottimi manager, ma non ci capiamo un gran che di scarpe! Anzi, nelle riunioni aziendali si sente spesso dire con una punta di orgoglio dai nostri capi che loro non ci capiscono molto di scarpe, del resto loro sono bravi dirigenti, bravi venditori, non importa che vendano scarpe oppure lustrini natalizi. Non importerà, d&#39;accordo, intanto però l&#39;azienda sta fallendo.&quot; L&#39;ingegner Carozzi si scostò un attimo per accendersi la pipa. Fuori stava cominciando a nevicare. &quot;Io dico queste cose con cognizione di causa, sapete.&quot; Fece una pausa di riflessione, poi continuò: &quot;Mio nonno aveva un negozio di calzature in centro. Il suo negozio era sempre pieno di gente! E tutti erano molto sorpresi che il negozio di mio nonno fosse sempre pieno. Perché dovete sapere che mio nonno aveva un carattere difficile, era un burbero, un uomo molto pragmatico, era l&#39;esatto contrario di un buon venditore. Lui era capace di dire a un cliente che aveva messo gli occhi su una scarpa molto costosa, che quella scarpa non era per lui, di lasciar perdere, di uscire dal negozio e risparmiare i suoi soldi. Il negozio di scarpe di mio nonno era sempre pieno perché la gente sapeva che quell&#39;uomo burbero era davvero un intenditore di scarpe! Questo perché prima di essere un negoziante era stato un calzolaio. La gente sapeva che quando andava da lui poteva chiedere un consiglio sulla scarpa adatta a lui, e ricevere una risposta del tutto sincera e competente. La gente in quegli anni doveva risparmiare su tutto: non poteva permettersi un acquisto sbagliato! E sapeva che mio nonno gli avrebbe venduto la scarpa giusta. E il suo negozio era sempre pieno! Nonostante lui fosse un burbero, avesse un carattere difficile e non fosse tagliato per il mestiere di commerciante.&quot; L&#39;ingegner Carozzi si voltò verso i suoi interlocutori, sorrise loro con un sorriso amaro, poi si voltò e se ne andò per la sua strada.&lt;br /&gt;
&lt;br /&gt;</description><link>http://alessiosaltarin.blogspot.com/2011/12/il-negozio-di-scarpe-di-mio-nonno.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-8437758525518638926</guid><pubDate>Wed, 31 Aug 2011 12:38:00 +0000</pubDate><atom:updated>2011-10-17T14:19:12.150+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">gps</category><category domain="http://www.blogger.com/atom/ns#">nfc</category><title>Navigazione e geolocalizzazione</title><description>Sono a P., una città a me sconosciuta, per un meeting. Ho bisogno di una farmacia - mi sono dimenticato le aspirine a casa! Fortunatamente ho con me il mio cellulare Android. Ecco cosa faccio:&lt;br /&gt;&lt;br /&gt;1) Apro &lt;a href=&quot;http://www.google.it&quot;&gt;Google&lt;/a&gt;. Siccome ho attivato il geolocalizzatore, la pagina visualizzata riporta chiaramente che mi trovo a P.&lt;br /&gt;2) Seleziono &lt;a href=&quot;http://www.google.com/places/&quot;&gt;Places&lt;/a&gt;&lt;br /&gt;3) Da lì digito &quot;Farmacia&quot;. Appare un elenco delle farmacie, in ordine di vicinanza.&lt;br /&gt;4) Scelgo la prima e visualizzo la &lt;a href=&quot;http://maps.google.com/&quot;&gt;mappa&lt;/a&gt;, con le informazioni in tempo reale del traffico.&lt;br /&gt;5) Ok, il traffico è leggero. Maps mi dice che ci arriverò in cinque minuti in macchina e in nove minuti a piedi! Sono in macchina, ci vado in macchina.&lt;br /&gt;6) Clicko sul &lt;a href=&quot;www.google.com/navigation&quot;&gt;Navigatore&lt;/a&gt;, che immediatamente attiva il GPS. La voce di una signorina, in bell&#39;italiano, mi racconta la strada da fare, nominando anche le vie.&lt;br /&gt;&lt;br /&gt;Il tutto con un Android senza nessuno speciale software a pagamento, con una configurazione &quot;out-of-the-box&quot;. Niente male!&lt;br /&gt;&lt;br /&gt;Il prossimo passo è andare in un supermercato, fare la spesa, e uscire senza pagare alla cassa - ma ritrovandosi il conto esatto addebitato sulla carta di credito. (&lt;a href=&quot;http://en.wikipedia.org/wiki/Near_field_communication&quot;&gt;Il che non è propriamente fantascienza...&lt;/a&gt;)</description><link>http://alessiosaltarin.blogspot.com/2011/08/navigazione-e-geolocalizzazione.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-3052065587084137361</guid><pubDate>Fri, 24 Jun 2011 17:25:00 +0000</pubDate><atom:updated>2011-06-24T19:36:21.845+02:00</atom:updated><title>Fammi ripetere con parole mie</title><description>Come Software Architect, la lezione più preziosa è stata imparare che io e lo sponsor del progetto - o meglio, si dovrebbe dire gli stakeholder - parliamo lingue differenti.&lt;br /&gt;&lt;br /&gt;Abbiamo del resto una formazione differente, esperienze differenti, e significative difformità nei punti di vista.&lt;br /&gt;&lt;br /&gt;Per questo la chiave del successo di un progetto software, oggi, è la chiarezza di comunicazione tra chi fornisce la tecnologia - l&#39;Architect, appunto - e chi intende utilizzarla per raggiungere i suoi scopi di business.&lt;br /&gt;&lt;br /&gt;Ecco perché è fondamentale che l&#39;Architect si chieda sempre: ho capito quali sono gli obiettivi di questo progetto? Esiste uno strumento formidabile: dopo aver letto un documento, aver partecipato a una riunione, avere ascoltato le parole degli stakeholder, fermarsi un attimo e dire: &quot;Ok, ora fammi ripetere con parole mie&quot;. Vediamo cosa ho capito davvero.&lt;br /&gt;&lt;br /&gt;Altrettando fondamentale è chiarire fin dall&#39;inizio che cosa la tecnologia può offrire, e che cosa non può offrire. E&#39; bene fin da subito spianare il campo da miti e leggende. (&lt;span style=&quot;font-style:italic;&quot;&gt;E lo so che è difficile: è bello all&#39;inizio avere uno sponsor che ci guarda come Bilbo Baggins guardava Gandalf nello Hobbit!&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Direi quindi che sono due le chiavi importanti per il successo di un progetto software enterprise: &lt;br /&gt;&lt;br /&gt;1) Voglio capire bene quali sono gli obiettivi da ottenere con il sistema&lt;br /&gt;2) Voglio comunicare bene cosa un sistema è in grado di offrire (e cosa no)&lt;br /&gt;&lt;br /&gt;Le questioni tecniche, i disegni architetturali, i dettagli implementativi vengono molto dopo.</description><link>http://alessiosaltarin.blogspot.com/2011/06/fammi-ripetere-con-parole-mie.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4364592042964713187.post-829694376587546056</guid><pubDate>Fri, 17 Jun 2011 14:26:00 +0000</pubDate><atom:updated>2011-06-18T10:34:12.464+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">database</category><category domain="http://www.blogger.com/atom/ns#">enterprise architecture</category><title>Basta Database!</title><description>Una domanda che non fareste mai ad un Cliente, che ha un sistema informativo con un suo potentissimo sistema di RDBMS (database relazionale, normalmente Oracle o MS Sql Server), è: &quot;Ok, ma a cosa ti serve?&quot;&lt;br /&gt;&lt;br /&gt;Come a cosa serve un database? (Ti guardano come un poveretto, con tanto di occhi sgranati)... Ma non lo sai che in un database ci sono tutti i dati aziendali? Ma non lo sai che è il cuore del sistema informatico? Ma non lo sai che nessuno nemmeno osa pensare di non averne uno...&lt;br /&gt;&lt;br /&gt;Mentre sento queste cose mi aggiro curioso tra gli utenti (solitamente disperati) di un tale eccellente sistema: sono lì che combattono con infinite tabelle, piene di dati ridondanti e infinitamente inutili, che per essere tirati fuori hanno bisogno di uno stranissimo linguaggio, perlopiù incomprensibile alle logiche umane, chiamato SQL.&lt;br /&gt;&lt;br /&gt;La maggior parte delle aziende, per cercare di tirar fuori qualcosa da quei mostri lì, compra sistemi di Datawarehouse e Business Intelligence che costano loro un ordine di grandezza in più...&lt;br /&gt;&lt;br /&gt;Mi aggiro tra sistemisti che sognano vacanze ai Caraibi e mondi senza computer - soprattutto senza database - e tra manager che guardano fuori dalla finestra cercando di capire con quali soldi pagare l&#39;espertone Oracle (o quello che volete) che gli risolverà il loro maggior problema, e cioè: perché ho milioni di dati inutili e non trovo mai quelli che mi servono?&lt;br /&gt;&lt;br /&gt;A cosa serve un database? &quot;Ad archiviare i dati&quot;. Sono scettico. &quot;A gestire le transazioni...&quot; ok, ci avviciniamo. &quot;Ad estrarre dai miei dati le informazioni che servono per il mio business...&quot; Ah no! Ecco il punto!&lt;br /&gt;&lt;br /&gt;Il punto è che la tecnologia delle basi di dati è nata quando i computer erano relativamente lenti, soprattutto i dischi, poco capienti e le applicazioni molto costose da scrivere, perché difficili da creare e debuggare. Perciò si è inventato un sistema altamente efficace nell&#39;archiviare i dati (scrittura) e nel recuperarli (lettura), e questo a scapito della loro intelligibilità e facilità d&#39;uso.&lt;br /&gt;&lt;br /&gt;Il sistema relazionale inventato da Cobb è un sistema efficace con computer poco potenti e capienti, esattamente il contrario dei computer di cui disponiamo oggi.&lt;br /&gt;&lt;br /&gt;Oggi possiamo tranquillamente immaginare (e realizzare!) un sistema informativo complesso senza database sotto. &quot;E come fai ad archiviare i tuoi dati?&quot; Li scrivo sul disco, ovvio. Sì ma in che formato?&lt;br /&gt;&lt;br /&gt;Ecco una buona domanda. Le cui risposte possono essere almeno tre, e ricoprire con ciò gran parte delle necessità di archiviazione di un&#39;applicazione anche di media/grande complessità.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Prima possibilità&lt;/span&gt;: flat file. Salviamo tutti i nostri dati in file di testo in formato flat. Esempi: il win.ini, YAML, SQLite, TextDB ecc. ecc. (&lt;a href=&quot;http://en.wikipedia.org/wiki/Flat_file_database&quot;&gt;http://en.wikipedia.org/wiki/Flat_file_database&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Seconda possibilità&lt;/span&gt;: chi ha necessità di immagazzinare relazioni gerarchiche di tipo padre-figlio, o strutture fortemente innestate, può usare il formato di testo più potente in assoluto: XML. Il che è però fin troppo per la stragrande maggioranza delle applicazioni. &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Terza possibilità&lt;/span&gt;: ok, proprio non potete fare a meno di Oracle! Almeno lasciatelo scrivere a chi lo sa fare, e voi non sporcatevi le mani. Utilizzate dunque uno strumento di ORM - &lt;span style=&quot;font-style:italic;&quot;&gt;object relational mapping&lt;/span&gt; - che ha il compito di serializzare, deserializzare e ricercare i vostri oggetti di business in un normale database relazionale. &lt;br /&gt;&lt;br /&gt;Quest&#39;ultima possibilità è quella secondo me più interessante, e che spero prenda piede nelle applicazioni enterprise del prossimo lustro. L&#39;articolo che più concisamente descrive la tecnica è &lt;a href=&quot;http://www.service-architecture.com/object-relational-mapping/articles/transparent_persistence.html&quot;&gt;questo&lt;/a&gt;.&lt;br /&gt;Seguito dall&#39;ottima &lt;a href=&quot;http://it.wikipedia.org/wiki/Object-relational_mapping&quot;&gt;voce su Wikipedia&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In soldoni, nelle applicazioni moderne, le attività di DDL (Data Definition Language) e DML (Data Manipulation Language) debbono essere demandate ad un apposito strato software (l&#39;ORM appunto) che le svolge al meglio e in modo &quot;trasparente&quot; per l&#39;utente. In questo caso ciò che conta maggiormente nell&#39;applicativo non è più il modello concettuale dei dati, ma il modello concettuale degli oggetti (sottinteso, di business, cioè a dire: web services, remote procedure calls e quant&#39;altro). Il vantaggio consiste, di fatto, nella drastica diminuzione delle risorse necessarie al disegno e allo sviluppo della base dati - fino quasi ad annullarle.&lt;br /&gt;&lt;br /&gt;Per Java, il miglior strumento ORM è senz&#39;altro &lt;a href=&quot;http://www.hibernate.org/&quot;&gt;Hibernate&lt;/a&gt;, mentre per il mondo Microsoft è l&#39;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa697427%28v=vs.80%29.aspx&quot;&gt;Entity Framework&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Entrambi sono ottimi punti di partenza per dire definitivamente addio agli odiati database.</description><link>http://alessiosaltarin.blogspot.com/2011/06/basta-database.html</link><author>noreply@blogger.com (Guildenstern70)</author><thr:total>1</thr:total></item></channel></rss>