<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='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'><id>tag:blogger.com,1999:blog-6200426339083146338</id><updated>2024-10-25T05:18:25.774+02:00</updated><category term="Scala"/><category term="programming"/><category term="machine learning"/><category term="events"/><category term="nosql"/><category term="C#"/><category term="architecture"/><category term="codemotion"/><category term="dependency injection"/><category term="java"/><category term="scalaz"/><category term="Android"/><category term="ID3"/><category term="LINQ"/><category term="OOP"/><category term="UI"/><category term="asp.net"/><category term="design"/><category term="gridgain"/><category term="humour"/><category term="k-NN"/><category term="leaky abstractions"/><category term="metodi"/><category term="riflessioni"/><title type='text'>onof blog</title><subtitle type='html'>Diario di un programmatore e &lt;a href=&quot;http://www.scala-lang.org/&quot;&gt;SCALA&lt;/a&gt;tore</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-2061171384607034894</id><published>2012-10-28T23:28:00.000+01:00</published><updated>2012-10-28T23:33:27.678+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="riflessioni"/><category scheme="http://www.blogger.com/atom/ns#" term="UI"/><title type='text'>Android: fragments e UI designers</title><content type='html'>Ultimamente lavoro molto in Android, a contatto con UI designers molto bravi e meno bravi.&lt;br /&gt;
&lt;br /&gt;
Premetto che sono d&#39;accordo con &lt;a href=&quot;http://www.codinghorror.com/blog/2006/11/this-is-what-happens-when-you-let-developers-create-ui.html&quot;&gt;questo celebre post di Jeff Atwood&lt;/a&gt;.&amp;nbsp;Però lasciando fare tutto ai designers si rischia l&#39;opposto: se non conosce le opportunità offerte della tecnologia, il designer potrebbe fare assunzioni sbagliate sulla possibilità di certe soluzioni o semplicemente ignorarle. Inoltre sappiamo bene come sia facile in Italia improvvisarsi in qualsiasi ruolo, soprattutto quando va di moda.&lt;br /&gt;
&lt;br /&gt;
Ad esempio un designer sprovveduto potrebbe&amp;nbsp;credere che un&#39;applicazione Android dovrebbe essere uguale per tablet e smartphone, per risparmiare sullo sviluppo.&lt;br /&gt;
E allora via con bellissimi bottoni immensi senza testo al centro! Lo store è pieno di applicazioni che per un tablet da 10 pollici diventano così:&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;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfgf0m5J8S7C24MiNLwTxHW8nXIv1kZRvTE4ME1cR8j3dhJw_sP57NOmxSWo8O5Xfn4SYPhU2HOeqUKT0R_2n2ImnbmXc_vaxsQGxTCHZJF-6S6vhgMmyW_QEqxg0-nk2O6Poy1Vv83gPO/s1600/buttons.png&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/AVvXsEgfgf0m5J8S7C24MiNLwTxHW8nXIv1kZRvTE4ME1cR8j3dhJw_sP57NOmxSWo8O5Xfn4SYPhU2HOeqUKT0R_2n2ImnbmXc_vaxsQGxTCHZJF-6S6vhgMmyW_QEqxg0-nk2O6Poy1Vv83gPO/s320/buttons.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Questo magari perché il designer non sapeva che in Android i&amp;nbsp;&lt;a href=&quot;http://developer.android.com/reference/android/app/Fragment.html&quot;&gt;fragments&lt;/a&gt;&amp;nbsp;permettono di riutilizzare le logiche del programma in modo del tutto trasparente rispetto al layout scelto per il dispositivo e ha scartato la possibilità di mostrare, per i tablet, il contenuto direttamente nell&#39;activity principale.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/2061171384607034894/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/2061171384607034894' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2061171384607034894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2061171384607034894'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2012/10/android-fragments-e-ui-designers.html' title='Android: fragments e UI designers'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfgf0m5J8S7C24MiNLwTxHW8nXIv1kZRvTE4ME1cR8j3dhJw_sP57NOmxSWo8O5Xfn4SYPhU2HOeqUKT0R_2n2ImnbmXc_vaxsQGxTCHZJF-6S6vhgMmyW_QEqxg0-nk2O6Poy1Vv83gPO/s72-c/buttons.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-4403287046458515330</id><published>2012-05-29T13:58:00.000+02:00</published><updated>2012-05-29T13:59:29.615+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="humour"/><category scheme="http://www.blogger.com/atom/ns#" term="metodi"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Introduzione a Flag Driven Development</title><content type='html'>Credo che ad ogni sviluppatore sia capitato di lavorare con questo approccio, dalle dinamiche molto interessanti. Generalmente un prodotto o una una logica in un software comincia con un algoritmo del tipo:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;per ogni x tale che x appartiene all&#39;insieme A&lt;br /&gt;esegui l&#39;operazione f(x)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Inizialmente va tutto bene e tutti sono entusiasti del prodotto. Inevitabilmente qualcuno fa notare che così com&#39;è non va bene, e bisognerebbe distinguere una situazione in cui l&#39;operazione su x non va fatta. &lt;br /&gt;
&lt;br /&gt;
La soluzione a questo problema, secondo l&#39;approccio Flag Driven Development è: aggiungere un flag su x. Il nostro algoritmo diventa:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;per ogni x tale che x appartiene all&#39;insieme A&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;se x.flag = falso&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; esegui l&#39;operazione f(x)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Qualche volta il flag indica che bisogna eseguire un&#39;altra funzione:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;per ogni x tale che x appartiene all&#39;insieme A&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;se x.flag = falso&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; esegui l&#39;operazione f(x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;altrimenti&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;esegui l&#39;operazione g(x)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Come si vede, l&#39;approccio è incrementale perché è sempre possibile aggiungere il flag del flag e rendere il sistema più potente:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;per ogni x tale che x appartiene all&#39;insieme A&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;se x.flag1 = falso&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; se x.flag2 = falso&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;esegui l&#39;operazione f(x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; altrimenti&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;esegui l&#39;operazione h(x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;altrimenti&lt;/span&gt;&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Flag_of_the_Napoleonic_Kingdom_of_Italy.svg/600px-Flag_of_the_Napoleonic_Kingdom_of_Italy.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;133&quot; src=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Flag_of_the_Napoleonic_Kingdom_of_Italy.svg/600px-Flag_of_the_Napoleonic_Kingdom_of_Italy.svg.png&quot; width=&quot;200&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;&lt;span style=&quot;font-size: small;&quot;&gt;Bandiera del Regno d&#39;Italia Napoleonico&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;esegui l&#39;operazione g(x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
Si può evitare il flag? Sì, ma perché dovremmo?&amp;nbsp;Questo&amp;nbsp;approccio&amp;nbsp;è un&amp;nbsp;obbrobrio? Anche secondo me, ciò non toglie che è sempre molto usato.&lt;br /&gt;
Nei prossimi post forse ritornerò sull&#39;argomento per esplicitare meglio certe dinamiche o forse no.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/4403287046458515330/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/4403287046458515330' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/4403287046458515330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/4403287046458515330'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2012/05/introduzione-flag-driven-development.html' title='Introduzione a Flag Driven Development'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-6032211610250388803</id><published>2011-11-05T12:42:00.000+01:00</published><updated>2011-11-05T12:42:05.666+01:00</updated><title type='text'>Machine Learning e Scala al JugMarche 2</title><content type='html'>&lt;p&gt;Pubblico le slide del meeting:&lt;br /&gt;
&lt;/p&gt;&lt;div style=&quot;width:425px&quot; id=&quot;__ss_9949056&quot;&gt;&lt;strong style=&quot;display:block;margin:12px 0 4px&quot;&gt;&lt;a href=&quot;http://www.slideshare.net/onof80/jugmarche-machine-learning-usi-pratici-di-supervised-learning&quot; title=&quot;JugMarche: Machine learning: usi pratici di supervised learning&quot; target=&quot;_blank&quot;&gt;JugMarche: Machine learning: usi pratici di supervised learning&lt;/a&gt;&lt;/strong&gt; &lt;iframe src=&quot;http://www.slideshare.net/slideshow/embed_code/9949056&quot; width=&quot;425&quot; height=&quot;355&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt; &lt;div style=&quot;padding:5px 0 12px&quot;&gt;View more &lt;a href=&quot;http://www.slideshare.net/&quot; target=&quot;_blank&quot;&gt;presentations&lt;/a&gt; from &lt;a href=&quot;http://www.slideshare.net/onof80&quot; target=&quot;_blank&quot;&gt;Onofrio Panzarino&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;&lt;p&gt;... e ringrazio tutti i partecipanti. Il codice delle demo sarà ufficialmente pubblicato su github ASAP :)&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Stay tuned!&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/6032211610250388803/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/6032211610250388803' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6032211610250388803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6032211610250388803'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/11/machine-learning-e-scala-al-jugmarche-2.html' title='Machine Learning e Scala al JugMarche 2'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-6468087299026592178</id><published>2011-10-15T16:47:00.000+02:00</published><updated>2011-10-15T16:47:13.387+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="machine learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Machine Learning e Scala al JUG Marche</title><content type='html'>Sabato 29 ottobre terrò un talk di un&#39;ora circa&amp;nbsp;al Jug Marche a Falconara Marittima (AN) trattando di usi pratici di Machine Learning ed esempi in Scala.&amp;nbsp;Maggiori dettagli sull&#39;evento ed iscrizione(gratuita)&amp;nbsp;&lt;a href=&quot;http://jugmarche.posterous.com/meeting-di-ottobre&quot;&gt;qui&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/6468087299026592178/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/6468087299026592178' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6468087299026592178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6468087299026592178'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/10/machine-learning-e-scala-al-jug-marche.html' title='Machine Learning e Scala al JUG Marche'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-5018247694252261450</id><published>2011-09-09T20:53:00.002+02:00</published><updated>2011-09-09T20:53:36.849+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Scala-recog accettato da scala-tools</title><content type='html'>&lt;div class=&#39;posterous_autopost&#39;&gt;&lt;p&gt;Per me la buona notizia della settimana &amp;egrave; che &lt;a href=&quot;http://code.google.com/p/scala-recog/&quot; title=&quot;scala-recog&quot;&gt;scala-recog&lt;/a&gt; &amp;egrave; stato accettato da &lt;a href=&quot;http://scala-tools.org/&quot; title=&quot;scala-tools&quot;&gt;scala-tools&lt;/a&gt; quindi sar&amp;agrave; scaricabile e importabile nei progetti scala con sbt, dallo stesso repository che contiene nientepopodimeno che scalaz, scalala, Lift, etc. etc.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/5018247694252261450/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/5018247694252261450' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/5018247694252261450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/5018247694252261450'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/09/scala-recog-accettato-da-scala-tools.html' title='Scala-recog accettato da scala-tools'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-8047992351370069345</id><published>2011-08-06T12:42:00.001+02:00</published><updated>2011-08-06T19:49:50.475+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="machine learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>scala-recog: flessibilità con logistic regression</title><content type='html'>&lt;p&gt;In &lt;a href=&quot;http://code.google.com/p/scala-recog/wiki/LogisticRegressionTraits&quot;&gt;questa wiki page&lt;/a&gt; ho messo qualche esempio sulla flessibilit&amp;agrave; che si pu&amp;ograve; raggiungere usando le stackable modification.&lt;/p&gt;
&lt;p&gt;In realt&amp;agrave; con la logistic regression con scala-recog era per ottenere pi&amp;ugrave; flessibilit&amp;agrave; senza rinunciare alle ottimizzazioni necessarie per un algoritmo di training.&lt;/p&gt;
&lt;p&gt;Ma quel che vorrei raggiungere raggiunge uno sforzo estra di desgin. Mi piacerebbe una libreria molto generale, indipendente dal dominio di applicazione.&lt;/p&gt;
&lt;p&gt;Per esempio mi piacerebbe poter scrivere qualcosa tipo:&lt;/p&gt;  
&lt;pre class=&quot;brush: scala&quot;&gt;
import org.scalarecog.logisticregression.SigmoidClassifier._  
val myStuff = List( 
                Stuff(3, 2.1, &amp;quot;just&amp;quot;), 
                Stuff(2, 1.1, &amp;quot;an&amp;quot;), 
                Stuff(3, 1.2, &amp;quot;example&amp;quot;) 
              )  
val trainingSet = myStuff toTrainingSet ( 
                   _.number, _.number2), _.classLabel 
                  )           
val classifier = trainingSet.train
&lt;/pre&gt;
&lt;p&gt;Ma mi piacerebbe anche raggiungere questo tipo di flessibilit&amp;agrave:&lt;/p&gt;  &lt;pre class=&quot;brush: scala&quot;&gt;
val classifier = ( 
    for(stuff &amp;lt;- trainingSet; writer &amp;lt;- stuff.toWriter ) 
  ) train  

(classifier.log) foreach(println(_))
&lt;/pre&gt;
&lt;p&gt;Forse si pu&amp;ograve; prevedendo un supporto per le monadi nei training set. Un esempio di monade pu&amp;ograve; essere &lt;a href=&quot;http://blog.tmorris.net/the-writer-monad-using-scala-example/&quot;&gt;questo di Tony Morris&lt;/a&gt;.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/8047992351370069345/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/8047992351370069345' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8047992351370069345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8047992351370069345'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/08/scala-recog-flessibilita-con-logistic.html' title='scala-recog: flessibilità con logistic regression'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-4617385790421486108</id><published>2011-07-29T13:12:00.001+02:00</published><updated>2011-07-29T13:33:03.576+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ID3"/><category scheme="http://www.blogger.com/atom/ns#" term="machine learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Alberi di decisione con scala-recog</title><content type='html'>&lt;a href=&quot;http://code.google.com/p/scala-recog/&quot;&gt;scala-recog&lt;/a&gt; &amp;egrave; un progetto open-source che ho creato su Google Code, una libreria di algoritmi di machine learning totalmente scritta in Scala.
Uno di questi è ID3, un algoritmo che permette di costruire un albero di decisione basandosi su un training set di elementi gi&amp;agrave; classificati.

&lt;h2&gt;Esempio: classificare curricula&lt;/h2&gt;
Supponiamo di avere un sito per la ricerca di lavoro e vogliamo classificare i curricula inseriti per mostrarli agli utenti che cercano delle determinate figure. 
Dai curricula si possono estrarre una enomre quantità di dati ma supponiamo di voler estrarre solo questi:
&lt;ul&gt;
&lt;li&gt;se il candidato ha delle certificazioni&lt;/li&gt;
&lt;li&gt;se &amp;egrave; una persona loquace&lt;/li&gt;
&lt;li&gt;se &amp;egrave; iscritto al golf club&lt;/li&gt;
&lt;li&gt;se ha una laurea o un master&lt;/li&gt;
&lt;/ul&gt;
e mettiamo tutto in una classe:

&lt;pre class=&quot;brush: scala&quot;&gt;
  case class Person(
                val hasCertifications : Boolean,
                val isTalkative : Boolean,
                val golfClub : Boolean,
                val hasMasterDegree : Boolean,
                val job : String
               )

  val persons = Person(hasCertifications = true, isTalkative = false, 
                       golfClub = false, hasMasterDegree = true, 
                       job = &quot;Programmer&quot;) ::
                Person(hasCertifications = false, isTalkative = false, 
                       golfClub = false, hasMasterDegree = true, 
                       job = &quot;Junior Programmer&quot;) ::
                Person(hasCertifications = true, isTalkative = false, 
                       golfClub = false, hasMasterDegree = false, 
                       job = &quot;Programmer&quot;) ::
                Person(hasCertifications = false, isTalkative = true, 
                       golfClub = false, hasMasterDegree = true, 
                       job = &quot;Seller&quot;) ::
                Person(hasCertifications = false, isTalkative = true, 
                       golfClub = false, hasMasterDegree = false, 
                       job = &quot;Seller&quot;) ::
                Person(hasCertifications = true, isTalkative = true, 
                       golfClub = false, hasMasterDegree = false, 
                       job = &quot;Seller&quot;) ::
                Person(hasCertifications = false, isTalkative = true, 
                       golfClub = true, hasMasterDegree = true, 
                       job = &quot;CEO&quot;) ::
                Person(hasCertifications = false, isTalkative = false, 
                       golfClub = true, hasMasterDegree = false, 
                       job = &quot;CEO&quot;) ::
                Person(hasCertifications = false, isTalkative = false, 
                       golfClub = true, hasMasterDegree = false, 
                       job = &quot;CEO&quot;) ::
                Nil
&lt;/pre&gt;
Nella lista &lt;em&gt;persons&lt;/em&gt; ho messo il mio training set. Per usare l&#39;algoritmo ID3, basta importare l&#39;oggetto giusto e usare la lista come training set:
&lt;pre class=&quot;brush: scala&quot;&gt;
import org.scalarecog.decisiontree._

def toVector(p : Person) = Vector(p.hasCertifications, p.isTalkative, p.golfClub, p.hasMasterDegree)
val dataset = persons map (p =&gt; (toVector(p), p.job))

val tree = new ID3[Boolean,String] buildTree dataset
&lt;/pre&gt;

La funzione &lt;em&gt;toVector&lt;/em&gt; server perch&amp;eacute; la classe ID3 ha bisogno di un 
&lt;a href=&quot;http://www.scala-lang.org/api/current/scala/collection/immutable/Vector.html&quot;&gt;Vector&lt;/a&gt;.&lt;br/&gt;
Ora &lt;em&gt;tree&lt;/em&gt; pu&amp;ograve; classificare una nuova persona:

&lt;pre class=&quot;brush: scala&quot;&gt;
val newPerson = Person(false, false, false, false, &quot;?&quot;)
assert(
   tree.classify(toVector(newPerson)) == &quot;Junior Programmer&quot;
)
&lt;/pre&gt;

Ma sarebbe carino visualizzare l&#39;albero di decisione creato da ID3.
Con &lt;a href=&quot;http://www.jgraph.com/jgraph.html&quot;&gt;JGraph&lt;/a&gt; &amp;egrave; semplicissimo e otteniamo questo:

&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/AVvXsEgjaT0dqd_1pG6zTjUlu0iNVJzHBLl9RsOCmdoHZYqZ1ipaU4WL652Qw0_DiL0l547FEBiUXa73JAqbto7HPivKC3wWD0t8NAvSyJr2PLlHrN3WiGDl4OIPhzOwnEcq3Vk3FgPGrnGPozrf/s1600/scalarecog.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; width=&quot;293&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjaT0dqd_1pG6zTjUlu0iNVJzHBLl9RsOCmdoHZYqZ1ipaU4WL652Qw0_DiL0l547FEBiUXa73JAqbto7HPivKC3wWD0t8NAvSyJr2PLlHrN3WiGDl4OIPhzOwnEcq3Vk3FgPGrnGPozrf/s400/scalarecog.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

Ehi! &amp;Egrave; proprio l&#39;algoritmo usato nella vita reale! ^_^ &lt;br/&gt;
Ecco qui il codice completo:
&lt;pre class=&quot;brush: scala&quot;&gt;

package scalarecoggraph

import org.scalarecog.decisiontree._
import javax.swing.JFrame
import com.mxgraph.swing.mxGraphComponent
import com.mxgraph.view.mxGraph

class Program(tree : DecisionTree[Vector[Boolean], String], propertyNames : Vector[String]) extends JFrame(&quot;ScalaRecog&quot;) {
  type Tree = DecisionTree[Vector[Boolean], String]
  type Vertex = (AnyRef, (Double, Double))

  draw()

  def draw() {
    val graph: mxGraph = new mxGraph
    val root = graph.getDefaultParent

    def draw(t : Tree, parentPos : (Double, Double), offset : (Int, Int)) : Vertex = {
      def createVertex(label : String, action : Vertex =&gt; Unit = v =&gt; {}) : Vertex = {
        val vertexSize = (100, 30)
        val newPos = (parentPos._1 + offset._1, parentPos._2 + offset._2)
        val created = (graph.insertVertex(root, null, label, newPos._1, newPos._2 , vertexSize._1, vertexSize._2), newPos)
        action(created)
        created
      }
      def createEdge(label : String, from : Vertex, to : Vertex) = graph.insertEdge(root, null, label, from._1, to._1)

      t match {
        case a : DecisionLeaf[Vector[Boolean],String] =&gt; createVertex(a.label)
        case a : DecisionBranchVector[String,Boolean] =&gt;
          createVertex(propertyNames(a.index), n =&gt; {
            for (  ((label, child), index) &lt;- a.branches.zipWithIndex  )
              createEdge(label.toString, n, draw(child, n._2, (120*index, offset._2)))
            })
      }
    }

    graph.getModel.beginUpdate
    try {
      draw(tree, (0, 0), (120, 120))
    }
    finally {
      graph.getModel.endUpdate
    }
    getContentPane.add(new mxGraphComponent(graph))
  }
}

object Program  {

  case class Person(
                val hasCertifications : Boolean,
                val isTalkative : Boolean,
                val golfClub : Boolean,
                val hasMasterDegree : Boolean,
                val job : String
               )

  def main(args : Array[String]) : Unit = {

    val persons = Person(hasCertifications = true, isTalkative = false, golfClub = false, hasMasterDegree = true, job = &quot;Programmer&quot;) ::
                  Person(hasCertifications = false, isTalkative = false, golfClub = false, hasMasterDegree = true, job = &quot;Junior Programmer&quot;) ::
                  Person(hasCertifications = true, isTalkative = false, golfClub = false, hasMasterDegree = false, job = &quot;Programmer&quot;) ::
                  Person(hasCertifications = false, isTalkative = true, golfClub = false, hasMasterDegree = true, job = &quot;Seller&quot;) ::
                  Person(hasCertifications = false, isTalkative = true, golfClub = false, hasMasterDegree = false, job = &quot;Seller&quot;) ::
                  Person(hasCertifications = true, isTalkative = true, golfClub = false, hasMasterDegree = false, job = &quot;Seller&quot;) ::
                  Person(hasCertifications = false, isTalkative = true, golfClub = true, hasMasterDegree = true, job = &quot;CEO&quot;) ::
                  Person(hasCertifications = false, isTalkative = false, golfClub = true, hasMasterDegree = false, job = &quot;CEO&quot;) ::
                  Person(hasCertifications = false, isTalkative = false, golfClub = true, hasMasterDegree = false, job = &quot;CEO&quot;) ::
                  Nil

    def toVector(p : Person) = Vector(p.hasCertifications, p.isTalkative, p.golfClub, p.hasMasterDegree)
    val dataset = persons map (p =&gt; (toVector(p), p.job))

    val tree = new ID3[Boolean,String] buildTree dataset

    val newPerson = Person(false, false, false, false, &quot;?&quot;)
    assert(
      tree.classify(toVector(newPerson)) == &quot;Junior Programmer&quot;
    )

    val frame = new Program(tree, Vector(&quot;Has certifications?&quot;, &quot;Is talkative?&quot;, &quot;Likes playing golf?&quot;, &quot;Has a master degree?&quot;))
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(400, 320)
    frame.setVisible(true)
  }
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/4617385790421486108/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/4617385790421486108' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/4617385790421486108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/4617385790421486108'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/07/alberi-di-decisione-con-scala-recog.html' title='Alberi di decisione con scala-recog'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjaT0dqd_1pG6zTjUlu0iNVJzHBLl9RsOCmdoHZYqZ1ipaU4WL652Qw0_DiL0l547FEBiUXa73JAqbto7HPivKC3wWD0t8NAvSyJr2PLlHrN3WiGDl4OIPhzOwnEcq3Vk3FgPGrnGPozrf/s72-c/scalarecog.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-5480163832057615441</id><published>2011-07-17T22:11:00.000+02:00</published><updated>2011-07-17T22:11:52.866+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="k-NN"/><category scheme="http://www.blogger.com/atom/ns#" term="machine learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>algoritmo k-NN: meglio in Scala</title><content type='html'>Stavo leggendo &lt;a href=&quot;http://www.manning.com/pharrington/&quot;&gt;questo libro su machine learning&lt;/a&gt;. &amp;Egrave; un buon libro ma mi ero stufato della verbosit&amp;agrave; di Python, con cui sono presentati gli algoritmi, quindi ho scritto un&#39;implementazione dell&#39;&lt;a href=&quot;http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm&quot;&gt;algoritmo k-NN&lt;/a&gt; in Scala:

&lt;pre class=&quot;brush: scala&quot;&gt;
package knn

class Knn[TData, TClass,
          TDistance &lt;% Ordered[TDistance] ]
(
  val k : Int,
  val dataset : List[TData],
  val getClassOfData : TData =&gt; TClass,
  val getDistance : (TData, TData) =&gt; TDistance
)
{
  if(k &lt; 1)
    throw new scala.IllegalArgumentException(&quot;k must be positive&quot;)

  def classify(data : TData) : TClass = {

    // Compute distances between tested data and dataset items
    val distances = for( d &lt;- dataset ) yield (d, getDistance(d, data))

    // sort data by distance
    val sorted = distances sortBy ( d =&gt; d._2 )

    // take first k items
    val firstk = sorted take k

    // group by labels
    val classes = firstk groupBy (d =&gt; getClassOfData(d._1))

    // get most frequent label
    val classification = classes maxBy (g =&gt; g._2.length)

    classification._1
  }
}
&lt;/pre&gt;

Wow, ho scritto questa classe in dieci minuti funziona con ogni tipo di dataset dove sia definita una distanza e ovviamente una classificazione, come si pu&amp;ograve; vedere con questo test (scritto con &lt;a href=&quot;http://www.scalatest.org/&quot;&gt;ScalaTest&lt;/a&gt;):

&lt;pre class=&quot;brush: scala&quot;&gt;
package knn

import org.scalatest._
import org.scalatest.matchers._
import scala.math._

class KnnTest extends FlatSpec with ShouldMatchers {

  &quot;2nn&quot; should &quot; classify correctly with a sample near two well-known labelled items&quot; in {
    val alg = new Knn(2,
          List((3, &quot;ok&quot;), (18, &quot;ok&quot;), (21, &quot;high&quot;), (64, &quot;high&quot;)),
          (i : (Int, String)) =&gt; i._2,
          (i1: (Int, String), i2: (Int, String)) =&gt; abs(i1._1 - i2._1))

    val classified = alg.classify((4, &quot;&quot;))

    classified should equal (&quot;ok&quot;)
  }
}
&lt;/pre&gt;

Naturalmente il codice può essere ottimizzato e generalizzato ma mostra come si possa scrivere codice veramente disaccoppiato e generale in Scala.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/5480163832057615441/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/5480163832057615441' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/5480163832057615441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/5480163832057615441'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/07/algoritmo-k-nn-meglio-in-scala.html' title='algoritmo k-NN: meglio in Scala'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-2716949704945708307</id><published>2011-07-14T13:57:00.001+02:00</published><updated>2011-07-14T13:59:15.827+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="OOP"/><title type='text'>Aboliamo static</title><content type='html'>&lt;p&gt;Su &lt;a href=&quot;http://twitter.com/#!/onof80/statuses/90740628048183296&quot;&gt;twitter ho proposto scherzosamente&lt;/a&gt; di abolire la parola chiave &lt;q&gt;static&lt;/q&gt; dei linguaggi garbage collected. 
All&#39;inizio era appunto uno scherzo, poi mi sono detto: 
&lt;blockquote&gt;posso effettivamente fare a meno di &lt;em&gt;static?&lt;/em&gt;&lt;/blockquote&gt;
Innanzitutto, perch&amp;eacute; fare a meno di static? Perch&amp;eacute; pu&amp;ograve; dare un sacco di problemi. 
&lt;/p&gt;
&lt;h2&gt;Factory&lt;/h2&gt;
&lt;p&gt;
Prendiamo una classe e un&#39;innocente metodo static per costruirla:

&lt;pre class=&quot;brush: java&quot;&gt;

public class DumbClass {

  private String foo;
  public String getFoo() { return foo; }
  public void setFoo(String foo) { this.foo = foo; }

  private String initializedStuff;
  public String getInitializedStuff() { return initializedStuff; }

  private DumbClass(String foo, String initializedStuff) {
    this.initializedStuff = initializedStuff;
    this.foo = foo;
  }

  public static DumbClass create(Context c) {
    return new DumbClass( c.doSomethingToGetFoo(), c.doSomethingToGetStuff() );
  }
}

&lt;/pre&gt;

Inevitabilmente, come dice Alan Shalloway, &lt;a href=&quot;http://prasanthaboutjava.blogspot.com/2008/06/design-patterns-explained-by-alan.html&quot;&gt;le specifiche cambiano&lt;/a&gt; e uno dei vostri clienti vuole che, solo per lui, &lt;em&gt;foo&lt;/em&gt; sia in CamelCase piuttosto che tutto MAIUSCOLO. E voi: 

&lt;blockquote&gt;Facile: mettiamo in una libreria (che diamo solo a lui) una classe che estend.. Ops: non si può estendere, è un metodo statico! E se invece avessi fatto un&#39;abstract factory?&lt;/blockquote&gt;

&lt;pre class=&quot;brush: java&quot;&gt;

public class DumbClass {

  private String foo;
  public String getFoo() { return foo; }
  public void setFoo(String foo) { this.foo = foo; }

  private String initializedStuff;
  public String getInitializedStuff() { return initializedStuff; }

  DumbClass(String foo, String initializedStuff) {
    this.initializedStuff = initializedStuff;
    this.foo = foo;
  }
}

public interface IDumbClassFactory {
  DumbClass create(Context c);
}

public class DefaultDumbClassFactory {
  public DumbClass create(Context c) {
    return new DumbClass( c.doSomethingToGetFoo(), c.doSomethingToGetStuff() );
  }
}

&lt;/pre&gt;

Allora basterebbe wrappare &lt;em&gt;DefaultDumbClassFactory&lt;/em&gt; o fare un&#39;altra implementazione di &lt;em&gt;IDumbClassFactory&lt;/em&gt; e avrei fatto! &lt;br /&gt;
&lt;blockquote&gt;Morale: &lt;strong&gt;non usare metodi statici, meno che mai pubblici!&lt;/strong&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;h2&gt;Campi privati&lt;/h2&gt;
&lt;p&gt;
A volte capita di voler tenersi un contatore di istanze di una certa classe per sapere quante ce ne sono in giro. E si fa con un bel campo static:

&lt;pre class=&quot;brush: java&quot;&gt;

public class Foo {

  private static int howMany;

  public Foo(Something s) {
    howMany++;
  }
  ...
}

&lt;/pre&gt;

Risultato? Scoprite che in realt&amp;agrave; quel contatore non lo legge mai nessuno, anzi, se usate la libreria su un web server che gira per 2 anni di fila, alla fine vi va in overflow e causa un eccezione che ovviamente non gestite perch&amp;eacute; non ci avevate pensato. Oppure vorrete che non tenga traccia delle classi figlie, oppure per qualcuna s&amp;igrave; e qualcuna no, e allora? Scoprite che vi serviva un&#39;abstract factory.

&lt;blockquote&gt;Morale: quando sto per scrivere &lt;em&gt;static&lt;/em&gt; &lt;strong&gt;ci penso due volte e quasi sempre alla fine scrivo: &lt;em&gt;interface&lt;/em&gt;&lt;/strong&gt;&lt;/blockquote&gt;
&lt;/p&gt;

&lt;p style=&quot;text-align: left;&quot;&gt;
&lt;a title=&#39;By Photo: Andreas Praefcke (Self-published work by AndreasPraefcke) [CC-BY-3.0 (www.creativecommons.org/licenses/by/3.0) or GFDL (www.gnu.org/copyleft/fdl.html)], via Wikimedia Commons&#39; href=&#39;http://commons.wikimedia.org/wiki/File:Wolfsburg_VW-Werk.jpg&#39;&gt;&lt;img width=&#39;400&#39; alt=&#39;Wolfsburg VW-Werk&#39; src=&#39;http://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Wolfsburg_VW-Werk.jpg/800px-Wolfsburg_VW-Werk.jpg&#39;/&gt;&lt;/a&gt;
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/2716949704945708307/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/2716949704945708307' title='1 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2716949704945708307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2716949704945708307'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/07/aboliamo-static.html' title='Aboliamo static'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-1067553016545946268</id><published>2011-07-13T19:22:00.006+02:00</published><updated>2011-07-14T13:04:12.691+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Secondo articolo su Scala</title><content type='html'>Nel mio &lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb164/scala-2&quot;&gt;secondo articolo introduttivo su Scala&lt;/a&gt; affronto una questione secondo me cruciale per Scala, ossia la sue grandi potenzialità nella manipolazione di collezioni.
&lt;p&gt;Segnalo anche il &lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb164/bettersoftware2011&quot;&gt;bel resoconto del Better Software 2011&lt;/a&gt; di Francesco Saliola, interessante e tanto pi&amp;ugrave; utile per chi come me non ha potuto partecipare.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/1067553016545946268/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/1067553016545946268' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1067553016545946268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1067553016545946268'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/07/secondo-articolo-su-scala.html' title='Secondo articolo su Scala'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-8707888193360284213</id><published>2011-06-29T13:27:00.001+02:00</published><updated>2011-07-14T13:07:00.218+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Serie di articoli d&#39;introduzione a Scala, in italiano</title><content type='html'>Primo articolo di una serie d&#39;introduzione a Scala, in italiano, sulla rivista online &lt;a href=&quot;http://www.mokabyte.it/&quot;&gt;MokaByte&lt;/a&gt;:

&lt;div style=&quot;padding: 20px;&quot;&gt;
&lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb163/scala-1&quot;&gt;Introduzione a Scala - Prima parte: i perch&amp;eacute; di un linguaggio&lt;/a&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/8707888193360284213/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/8707888193360284213' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8707888193360284213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8707888193360284213'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/06/primo-articolo-di-una-serie.html' title='Serie di articoli d&#39;introduzione a Scala, in italiano'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-2206088176557370286</id><published>2011-06-21T21:20:00.002+02:00</published><updated>2011-06-22T22:51:17.064+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Option è un container (e una monade)!</title><content type='html'>Supponiamo di avere una lista di Option:

&lt;pre class=&quot;brush: scala&quot;&gt;
val myList = List( 
                   Some(1), 
                   Some(4), 
                   None, 
                   Some(5) 
                  )
&lt;/pre&gt;

e volete solo i valori, quindi &lt;span class=&quot;code&quot;&gt;List(1, 4, 5)&lt;/span&gt;. Qualche volta trovate codice analogo al seguente, magari scritto da me l&#39;anno scorso :)

&lt;pre class=&quot;brush: scala&quot;&gt;
val values = myList filter (! _.isEmpty) map (_.get)
assert( values == List(1, 4, 5) )
&lt;/pre&gt;
&lt;b&gt;Orribile!&lt;/b&gt;&lt;br /&gt;
 
Infatti, essendo &lt;span class=&quot;code&quot;&gt;Option&lt;/span&gt; un container possiamo (e dobbiamo) fare questo:
&lt;pre class=&quot;brush: scala&quot;&gt;
val values = myList.flatten
assert( values == List(1, 4, 5) )
&lt;/pre&gt;
o, al massimo:
&lt;pre class=&quot;brush: scala&quot;&gt;
val values = for( 
                 Some(a) &lt;- myList 
                ) yield a
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/2206088176557370286/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/2206088176557370286' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2206088176557370286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2206088176557370286'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/06/option-e-un-container-e-una-monade.html' title='Option è un container (e una monade)!'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-373900199785009942</id><published>2011-05-06T13:52:00.001+02:00</published><updated>2011-05-06T13:55:47.460+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nosql"/><title type='text'></title><content type='html'>&amp;Egrave; uscito il mio &lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb162/nosql-3&quot;&gt;terzo e ultimo articolo sui database &lt;acronym title=&quot;Not Only SQL&quot;&gt;NoSQL&lt;/acronym&gt;&lt;/a&gt; sulla rivista &lt;a href=&quot;http://www.mokabyte.it&quot;&gt;MokaByte&lt;/a&gt;; questa volta si parla di &lt;a href=&quot;http://neo4j.org/&quot;&gt;neo4j&lt;/a&gt;.

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb162/nosql-3&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; width=&quot;320&quot; src=&quot;http://www2.mokabyte.it/cms/figureproviderservlet?figureId=YHX-N3M-OZF_7f000001_32318148_b28b257b--fig01.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

Gli altri due articoli erano: &lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb160/nosql-1&quot;&gt;uno introduttivo sui database NoSQL&lt;/a&gt; e &lt;a href=&quot;http://www2.mokabyte.it/cms/p/mb161/nosql-2&quot;&gt;uno su MongoDB&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/373900199785009942/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/373900199785009942' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/373900199785009942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/373900199785009942'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/05/uscito-il-mio-terzo-e-ultimo-articolo.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-3764020656050958383</id><published>2011-04-28T13:50:00.002+02:00</published><updated>2011-04-28T14:11:32.852+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>Da Scala a LINQ</title><content type='html'>Spesso, durante il mio lavoro diurno (C# e Javascript) mi trovo a rimpiangere gli strumenti di cui dispongo nel mio lavoro notturno (Scala e Java).
&lt;p&gt;
Stavolta è andata cos&amp;igrave;. Mi trovavo spesso a scrivere codice non transazionale in cui devo fare un&#39;operazione su una serie di oggetti ma le eccezioni dovevano essere gestite ed aggregate, in questo modo:

&lt;pre class=&quot;brush: csharp&quot;&gt;

var erroriGestiti = new List&amp;lt;QualcheCosa&gt;();

foreach( var item in items ) {
   try {
      FaiQualcosaCon(item);
   }
   catch( QualcheTipoDiEccezione excp) {
      a.Add( CreaQualcheCosaDa(excp) );      
   }
}

return erroriGestiti;
&lt;/pre&gt;

&lt;a style=&quot;float: right;&quot; title=&#39;By User:Mattes (Own work) [Public domain], via Wikimedia Commons&#39; href=&#39;http://commons.wikimedia.org/wiki/File:Vigili_del_Fuoco_(Vatican)_-_fleet.jpg&#39;&gt;&lt;img width=&#39;400&#39; alt=&#39;Vigili del Fuoco (Vatican) - fleet&#39; src=&#39;http://upload.wikimedia.org/wikipedia/commons/thumb/5/5f/Vigili_del_Fuoco_%28Vatican%29_-_fleet.jpg/500px-Vigili_del_Fuoco_%28Vatican%29_-_fleet.jpg&#39;/&gt;&lt;/a&gt;

Ed ero ovviamente stufo di ripetere questo costrutto. Ora, in Scala astrarre il concetto &quot;collezionare le eccezioni di operazioni in sequenza&quot; &amp;egrave; un gioco da ragazzi, per cui lo tralascio. Per&amp;ograve;, anche se dire che LINQ ti permette di fingere di essere in Scala sarebbe un&#39;assurdit&amp;agrave; (neanche F# te lo fa dire), pu&amp;ograve; darti una mano:

&lt;pre class=&quot;brush: csharp&quot;&gt;

public static 
IEnumerable&amp;lt;TReturn&gt; CollectErrors&amp;lt;TItem, TException, TReturn&gt;(
       this IEnumerable&amp;lt;TItem&gt; items, 
       Action&amp;lt;TItem&gt; act, 
       Converter&amp;lt;TException, TReturn&gt; exceptionHandler
)
      where TException : Exception
{
   if (items == null) 
       throw new ArgumentNullException(&quot;items&quot;);
   if (act == null) 
       throw new ArgumentNullException(&quot;act&quot;);
   if (exceptionHandler == null) 
       throw new ArgumentNullException(&quot;exceptionHandler&quot;);

   return items
        .Aggregate(new List&amp;lt;TReturn&gt;(),
                   (collector, item) =&gt;
                   {
                     try
                     {
                       act(item);
                     }
                     catch (TException ex)
                     {
                       collector.Add(exceptionHandler(ex));
                     }
                     return collector;
                   });
}

// e questo mi permette di scrivere:

[TestMethod]
public void TestMethod1()
{
   var expected = new[] { &quot;error&quot;, &quot;error&quot;, &quot;error&quot; };

   var actual = new[] { 1, 2, 3, 4, 5, 6 }
       .CollectErrors(i =&gt; { if (i &gt; 3) 
                               throw new IndexOutOfRangeException(); 
                             },
                      (IndexOutOfRangeException e) =&gt; &quot;error&quot;);

   Assert.IsTrue(actual.SequenceEqual(expected));
}

&lt;/pre&gt;

certo non &amp;egrave; una sintassi molto chiara come potrebbe essere in Scala, ma non &amp;egrave; poi tanto male, no?

&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/3764020656050958383/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/3764020656050958383' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/3764020656050958383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/3764020656050958383'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/04/da-scala-linq.html' title='Da Scala a LINQ'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-1870746827051840855</id><published>2011-04-13T13:56:00.003+02:00</published><updated>2011-04-13T14:18:14.335+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nosql"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Scala e MongoDB</title><content type='html'>&lt;p&gt;Dal sito ufficiale di &lt;a href=&quot;http://www.mongodb.org/&quot;&gt;MongoDB&lt;/a&gt; si apprende che &lt;a href=&quot;https://github.com/mongodb/casbah&quot;&gt;Casbah&lt;/a&gt; &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Java+Language+Center&quot;&gt;&amp;egrave; il driver ufficiale per Scala per MongoDB&lt;/a&gt;. Queste API sono molto di basso livello, in quanto wrappano il driver JAVA per MongoDB. Ad esempio, per creare un utente nella nostra collection per MongoDB dobbiamo scrivere una cosa del genere:&lt;/p&gt;

&lt;pre class=&quot;brush: scala&quot;&gt;
val onof80 = MongoDBObject(&quot;userName&quot; -&gt; &quot;onof80&quot;,
                           &quot;openId&quot; -&gt; &quot;http://.....&quot;,
                           &quot;age&quot; -&gt; 31,
                           &quot;interests&quot; -&gt; &quot;Java,Scala&quot;)

&lt;/pre&gt;

che si mappa in un oggetto JSON simile a questo:

&lt;pre class=&quot;brush: javascript&quot;&gt;
{ 
  userName : &quot;onof80&quot;,
  openId : &quot;http://.....&quot;,
  age : 31,
  interests: &quot;Java,Scala&quot;
}
&lt;/pre&gt;

Interessante, ma sono abituato a &lt;a href=&quot;https://github.com/osinka/mongo-scala-driver&quot;&gt;mongo-scala-driver&lt;/a&gt;, che mi permette di definire una classe per l&#39;oggetto User:

&lt;pre class=&quot;brush: scala&quot;&gt;
class User(
   userName : String, 
   openId : String,
   age : Option[Int], 
   interests : String
) extends MongoObject {
     override def toString: String = userName
}
&lt;/pre&gt;

e quindi, al prezzo di un companion object che ometto, di riutilizzarlo:

&lt;pre class=&quot;brush: scala&quot;&gt;
val onof80 = new User(&quot;onof80&quot;, &quot;http://.....&quot;, 31, &quot;Java,Scala&quot;);

(dbCollection of User) += onof80;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/1870746827051840855/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/1870746827051840855' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1870746827051840855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1870746827051840855'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/04/scala-e-mongodb.html' title='Scala e MongoDB'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-8330762284849379298</id><published>2011-04-01T23:45:00.002+02:00</published><updated>2011-04-02T00:07:01.423+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><category scheme="http://www.blogger.com/atom/ns#" term="scalaz"/><title type='text'>Monad state con scalaz</title><content type='html'>Da un po&#39; di tempo studio &lt;a href=&quot;http://code.google.com/p/scalaz/&quot;&gt;scalaz&lt;/a&gt;. Una delle strutture dati pi&amp;ugrave; interessanti &amp;egrave; &lt;em&gt;State&lt;/em&gt;. Permette di mantenere lo stato degli oggetti tra le transizioni, ed &amp;egrave; molto utile quando si vogliono concatenare delle operazioni in modo puramente funzionale, senza riassegnare le variabili. &lt;br /&gt;



Ad esempio, immaginiamo di avere un messaggio, con l&#39;elenco dei destinatari a cui &amp;egrave; stato inviato:
&lt;pre class=&quot;brush: scala&quot;&gt;
import java.util.Date

case class Message(
                   text : String,
                   sent : List[(String, Date)] = Nil
                  ){

  def sendTo(address : String) : Message =
    Message(text, (address, new Date) :: sent)

  override def toString = &quot;Message &quot; + text + 
         sent.map(s =&gt; s._1 + &quot; on &quot; + s._2)
             .mkString(&quot; sent to &quot;, &quot;, to &quot;, &quot;&quot;)
}
&lt;/pre&gt;

Ora, se volessimo estendere la funzione &lt;em&gt;sendTo&lt;/em&gt; in modo da prendere una lista di destinatari a cui inviare il messaggio, con &lt;em&gt;State&lt;/em&gt; possiamo fare cos&amp;igrave;:

&lt;pre class=&quot;brush: scala&quot;&gt;
import scalaz._
import Scalaz._

def sendTo(addresses : List[String]) 
           : State[Message, List[(String, Message)]] = 
   addresses match {
       case head :: tail =&gt; 
              for( s &lt;- init[Message];
                   n &lt;- modify[Message]( _ sendTo head ) ;
                   t &lt;- sendTo(tail)
                 ) yield (head, s sendTo head) :: t
       case Nil =&gt; state(i =&gt; (i, Nil))
     }
&lt;/pre&gt;

Questa funzione prende in input la lista di destinatari e ritorna un oggetto che permette di effettuare l&#39;operazione di inviare un messaggio a quei destinatari, ad esempio:
&lt;pre  class=&quot;brush: scala&quot;&gt;
println( 
        sendTo(List(&quot;Onofrio&quot;, &quot;Claudia&quot;)) 
              (Message(&quot;Hello World!&quot;)) 
       )
&lt;/pre&gt;

che restituisce una tupla contenente il messaggio finale pi&amp;ugrave; la lista di tutti i passaggi di stato:
&lt;pre style=&quot;font-size: small; color: green;&quot;&gt;
(Message Hello World! 
 sent to Claudia on Fri Apr 01 23:21:49 CEST 2011, 
      to Onofrio on Fri Apr 01 23:21:49 CEST 2011,
List((Onofrio, Message Hello World! 
 sent to Onofrio on Fri Apr 01 23:21:49 CEST 2011), 
(Claudia, Message Hello World! 
 sent to Claudia on Fri Apr 01 23:21:49 CEST 2011, 
      to Onofrio on Fri Apr 01 23:21:49 CEST 2011)))
&lt;/pre&gt;

Ovviamente, il metodo &amp;egrave; deve essere privo di side-effect, altrimenti, poich&amp;eacute; viene eseguite pi&amp;ugrave; volte gli effetti sono imprevedibili. Per ottenere come side-effect l&#39;invio di una e-mail, per esempio, da quanto ho capito &amp;egrave; necessaria la monad &lt;em&gt;Writer&lt;/em&gt;. Scriver&amp;ograve; un post appena sar&amp;ograve; riuscito a farlo con scalaz.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/8330762284849379298/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/8330762284849379298' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8330762284849379298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/8330762284849379298'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/04/monad-state-con-scalaz.html' title='Monad state con scalaz'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-889890272504647273</id><published>2011-03-28T18:11:00.025+02:00</published><updated>2011-04-02T00:09:02.547+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nosql"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Teorema CAP: disponibilit&amp;agrave;</title><content type='html'>Riguardo al &lt;a href=&quot;http://www2.mokabyte.it/cms/article.run?permalink=mb160_nosql-1&quot;&gt;mio articolo su MokaByte&lt;/a&gt;, ho avuto uno scambio di e-mail con alcuni lettori riguardo il teorema CAP, in particolare sulla disponibilit&amp;agrave; del sistema. Il primo è stato &lt;b&gt;Enrico Oliosi&lt;/b&gt; che mi ha chiesto:

&lt;blockquote&gt;Se desidero mantenere la consistenza di dati su tutti i nodi e voglio che il sistema sia tollerante ai guasti, in che modo posso perdere la disponibilità del sistema? Questa perdita si riferisce all&#39;interno sistema o ad un singolo nodo?&lt;/blockquote&gt;

Premettendo che non sono un ricercatore n&amp;eacute; un progettista di database NoSql (anzi, se a qualcuno di loro capitasse di leggere, lo invito a commentare eventuali inesattezze o madornali errori) provo a rispondere in base a quello che ho letto sull&#39;argomento. La domanda, mi pare possa essere riassunta in: &lt;blockquote&gt;Cosa significa che il sistema non &amp;egrave; disponibile? Cos&#39;&amp;egrave; un sistema non disponibile ma tollerante?&lt;/blockquote&gt;
&lt;a title=&#39;By Computer History Museum (archive.computerhistory.org) [CC-BY-3.0 (www.creativecommons.org/licenses/by/3.0)], via Wikimedia Commons&#39; href=&#39;http://commons.wikimedia.org/wiki/File:Dec_pdp-6.lg.jpg&#39;&gt;&lt;img width=&#39;500&#39; alt=&#39;Dec pdp-6.lg&#39; src=&#39;http://upload.wikimedia.org/wikipedia/commons/3/31/Dec_pdp-6.lg.jpg&#39;/&gt;&lt;/a&gt;
Tempo fa ho letto un &lt;a href=&quot;http://dbmsmusings.blogspot.com/2010/04/problems-with-cap-and-yahoos-little.html&quot;&gt;post molto interessante di Daniel Abadi&lt;/a&gt;, che secondo me pu&amp;ograve; essere molto d&#39;aiuto per rispondere. Se, calando il teorema CAP in pratica, per disponibilit&amp;agrave; si intende la possibilità di trovare una replica dei dati in caso di fallimento, cosa succede dunque ai sistemi &lt;b&gt;AP&lt;/b&gt;, &lt;b&gt;CP&lt;/b&gt; e &lt;b&gt;CA&lt;/b&gt; in caso di network partition? Abadi dice: in realt&amp;agrave; &lt;i&gt;sembrerebbe&lt;/i&gt; che non ho tre alternative, &lt;b&gt;ma solo due: AP oppure CP/CA&lt;/b&gt;, ossia consistenza oppure no, perch&amp;eacute; se voglio la consistenza: &lt;ul&gt;&lt;li&gt;o non sono tollerante al partizionamento (il sistema non scambia messaggi, quindi in pratica non funziona)&lt;/li&gt;&lt;li&gt;oppure non &amp;egrave; disponibile (quindi in pratica non funziona).&lt;/li&gt;&lt;/ul&gt; Abadi vede in questo un&#39;incompletezza del teorema CAP, dice che, per essere utile, un teorema a riguardo dovrebbe considerare anche la latenza del sistema e si dovrebbe suddividere l&#39;analisi in due parti: in caso di funzionamento normale e in caso di partizionamento della rete, perché in effetti queste proprietà si esplicano in un certo istante nel tempo.
&lt;br /&gt;
Secondo me, il punto &amp;egrave; che, al di l&amp;agrave; di dispute accademiche, i vari sistemi Sql o NoSql, non rinunciano del tutto a una delle tre propriet&amp;agrave;, ma di fatto ne rilassano una o più di una per raggiungere determinati scopi e in determinati tempi. Tant&#39;&amp;egrave; che Abadi porta ad esempio &lt;a href=&quot;http://research.yahoo.com/node/2304&quot;&gt;PNUTS&lt;/a&gt; che sembra garantire una sola proprietà. In realtà, rilassa sia C e A in favore di una più bassa latenza. Ecco perché spesso è difficile catalogare un sistema secondo la nomenclatura CAP. Quello che si può fare è dare un&#39;indicazione di massima.  Tutto ciò perché CAP stabilisce quello che non può succedere in un istante, non quello che succede in generale.

Detto ciò, in cosa si traduce la perdita di disponibilit&amp;agrave;? In un fallimento dell&#39;intero sistema o del singolo nodo? Se la disponibilit&amp;agrave; &amp;egrave; la possibilit&amp;agrave; del sistema di supplire al fallimento di un nodo, quindi disponibilit&amp;agrave; rilassata significa che al fallimento di un nodo il sistema non riesce ad andare avanti come se niente fosse, ma il come dipende da come &amp;egrave; stato progettato il sistema.
&lt;br /&gt;
Provo, ad esempio ad ipotizzare come i tre sistemi potrebbero comportarsi in caso di partizionamento, a causa della rottura di un nodo:
&lt;ul&gt;
&lt;li&gt;
CA: i dati rimangono consistenti, il nodo rotto è stato sostituito da una replica che ha dati consistenti, ma alcune funzioni sono state disabilitate come la scrittura. Classica situazione &lt;b&gt;RDBMS&lt;/b&gt;.
&lt;/li&gt;&lt;li&gt;
AP: perdita di consistenza, le due sottoreti continuano a funzionare (essere disponibili) in autonomia, il nodo rotto è stato sostituito da una replica in una delle sottoreti, ma i dati tra le reti divergono oppure i dati tra le reti non divergono ma la replica non ha dati consistenti con il nodo rotto (si sono persi gli ultimi n update). Quando la rete si metterà a posto, la consistenza (forse) si raggiungerà a regime (tipica situazione &lt;b&gt;NoSql&lt;/b&gt;).
&lt;/li&gt;&lt;li&gt;
CP: le due sottoreti continuano a funzionare autonomamente (P) e ad avere dati tra loro consistenti (C) perché c&#39;è un failover che ri-assembla la rete in un altro modo, ma poiché la disponibilità non è garantita, ci potrebbe essere un transitorio in cui il sistema non è per nulla raggiungibile, oppure che ci saranno diversi operazioni fallite (altra situazione &lt;b&gt;NoSql&lt;/b&gt;).
&lt;/li&gt;&lt;/ul&gt;
Ma il partizionamento potrebbe essere dato anche da altri fattori, o in altre modalità e il comportamento potrebbe non essere quello, perché magari i nodi non hanno tutti la stessa importanza o le stesse funzioni. Dipende da come è stato architettato il sistema.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/889890272504647273/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/889890272504647273' title='4 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/889890272504647273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/889890272504647273'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/teorema-cap-disponibilit.html' title='Teorema CAP: disponibilit&amp;agrave;'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-6325024995833680820</id><published>2011-03-08T19:12:00.009+01:00</published><updated>2011-04-02T00:11:49.294+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gridgain"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>Vi presento GridGain</title><content type='html'>&lt;div itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.gridgain.com/&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;31&quot; width=&quot;111&quot; src=&quot;http://www.gridgain.com/images/logo2_111x31.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

Come &lt;a href=&quot;http://onof80.blogspot.com/2011/03/codemotion-2011.html&quot;&gt;promesso&lt;/a&gt;, vi presento &lt;a itemprop=&quot;itemreviewed&quot; href=&quot;http://www.gridgain.com&quot;&gt;GridGain&lt;/a&gt;. &lt;span itemprop=&quot;summary&quot;&gt;Si tratta di un framework per permettervi di fare programmazione distribuita in modo molto semplice.&lt;/span&gt; &lt;span itemprop=&quot;description&quot;&gt;Ci&amp;ograve; che lo rende veramente potente &amp;egrave; il supporto per Scala, infatti Scala d&amp;agrave; il meglio di s&amp;eacute; proprio in questi contesti. Supponete di avere una rete con &lt;span itemprop=&quot;rating&quot;&gt;5&lt;/span&gt; nodi e la vostra applicazione suddivide un certo carico di un lavoro su tutti i nodi. Se il sistema scala orizzontalmente e passiamo a 50 nodi, dobbiamo rivedere tutto il programma? Non se usate GridGain.
Se inoltre siete stati bravi, e avete applicato i bei paradigmi funzionali alla vostra applicazione, il vostro codice &amp;egrave; gi&amp;agrave; scalabile.&lt;/span&gt;
&lt;br /&gt;
Ad esempio, avete una funzione in Scala per calcolare la &lt;a href=&quot;http://it.wikipedia.org/wiki/E_(costante_matematica)&quot;&gt;costante di Nepero&lt;/a&gt;:

&lt;pre class=&quot;brush: scala&quot;&gt;
object Program {

  def invFact(i : Int) : BigDecimal = i match {
    case 0 =&gt; BigDecimal(1)
    case n if n &gt; 0 =&gt; (BigDecimal(1) / BigDecimal(n)) * invFact(n - 1)
  }

  def neper(iterations : Int) = {
    (BigDecimal(0) /: ((1 to iterations) map invFact))( _ + _)
  }

  ...
}
&lt;/pre&gt;

Dove avete utilizzato la formula: &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://upload.wikimedia.org/math/9/f/d/9fd1faf162499a102e7ca59ef1ed7e9f.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;50&quot; width=&quot;363&quot; src=&quot;http://upload.wikimedia.org/math/9/f/d/9fd1faf162499a102e7ca59ef1ed7e9f.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
All&#39;aumentare di &lt;i&gt;iterations&lt;/i&gt; aumenta la precisione. &amp;Egrave; ovvio che pu&amp;ograve; essere molto migliorato, &amp;egrave; solo un esempio. Supponiamo adesso che volete farlo andare in parallelo. Con GridGain &amp;egrave; semplicissimo: 
&lt;ol&gt;
&lt;li&gt;accedete i vostri nodi (quanti ne volete/potete) lanciando &lt;i&gt;ggstart&lt;/i&gt;. Ogni nodo si mette in attesa:&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/AVvXsEj1VrZouJb2F85Kmo8TgldBXVk5IGMR54QKsSj41RyR4V5oGLSuwARPs9bNO2iPTkALX_BZVnEQRygUGqZW6kbs8-xWKIgLqIExrTjFbfTn2RUjJ9Ix8AISiEBXib3vG-TCRReaCh6Dn6SS/s1600/gg1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;223&quot; width=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1VrZouJb2F85Kmo8TgldBXVk5IGMR54QKsSj41RyR4V5oGLSuwARPs9bNO2iPTkALX_BZVnEQRygUGqZW6kbs8-xWKIgLqIExrTjFbfTn2RUjJ9Ix8AISiEBXib3vG-TCRReaCh6Dn6SS/s400/gg1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;importate le librerie di gridgain nel progetto e modificate il codice in modo da utilizzare gridgain per il calcolo:
&lt;pre class=&quot;brush: scala&quot;&gt;
  def neper(iterations : Int) = {
    grid !*~ (
          for (w &lt;- 1 to iterations) yield () =&gt; {
            val ret = invFact(w)
            println(&quot;Ricevuto: &quot; + w + &quot; - Restituito: &quot; + ret)
            ret
          },
          (s: Seq[BigDecimal]) =&gt; (BigDecimal(0) /: s)(_ + _)
        )
  }
  
  def main(args : Array[String]) : Unit = {
    scalar {
        val n = neper(100);
        println(&quot;e = &quot; + n)
    }
  }
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
Se, per esempio, accendiamo un solo nodo, a parte quello da cui fate partire l&#39;applicazione, quindi 2 nodi in tutto, vedrete che il carico si &amp;egrave; suddiviso grosso modo a met&amp;agrave; (il balancing viene fatto dinamicamente). L&#39;output del nodo pricinpale &amp;egrave;:
&lt;pre style=&quot;font-size: 8pt; color: green;&quot;&gt;
Ricevuto: 37 - Restituito: 7.265460179153071315382745030722890E-44
Ricevuto: 71 - Restituito: 1.175808554667930839412331276025168E-102
Ricevuto: 15 - Restituito: 7.647163731819816475901131985788074E-13
Ricevuto: 57 - Restituito: 2.467495709560789306494418417905353E-77
Ricevuto: 27 - Restituito: 9.183689863795546148425716836473919E-29
Ricevuto: 47 - Restituito: 3.866628513960593886829197697871059E-60
Ricevuto: 51 - Restituito: 6.446959640457172680454177834252131E-67
Ricevuto: 21 - Restituito: 1.957294106339126123084757437350544E-20
Ricevuto: 17 - Restituito: 2.811457254345520763198945583010321E-15
Ricevuto: 61 - Restituito: 1.970131956802168311835039121583386E-84
Ricevuto: 59 - Restituito: 7.210682961895936021316243184995189E-81
Ricevuto: 63 - Restituito: 5.043860616493006430709265544248299E-88
Ricevuto: 9 - Restituito: 0.000002755731922398589065255731922398590
Ricevuto: 31 - Restituito: 1.216125041553517949629974685692294E-34
Ricevuto: 19 - Restituito: 8.220635246624329716955981236872284E-18
Ricevuto: 53 - Restituito: 2.339245152560657721500064526216304E-70
Ricevuto: 35 - Restituito: 9.677592958631890992089816380922888E-41
Ricevuto: 77 - Restituito: 6.887854405285506994393217621555398E-114
Ricevuto: 67 - Restituito: 2.741896188035459954765761198513713E-95
Ricevuto: 85 - Restituito: 3.549744558233655586243013385073271E-129
Ricevuto: 81 - Restituito: 1.724992688482351758285854365654940E-121
Ricevuto: 99 - Restituito: 1.071510288125466923183546759519195E-156
Ricevuto: 97 - Restituito: 1.039579281539328008872677066085523E-152
Ricevuto: 83 - Restituito: 2.534517614578830088577511556942316E-125
Ricevuto: 13 - Restituito: 1.605904383682161459939237717015495E-10
Ricevuto: 25 - Restituito: 6.446950284384473396194853219204692E-26
Ricevuto: 55 - Restituito: 7.876246304918039466330183589953885E-74
Ricevuto: 7 - Restituito: 0.0001984126984126984126984126984126985
Ricevuto: 3 - Restituito: 0.1666666666666666666666666666666666
Ricevuto: 87 - Restituito: 4.744379254522394528525813131613567E-133
Ricevuto: 29 - Restituito: 1.130996288644771693155876457693833E-31
Ricevuto: 11 - Restituito: 2.505210838544171877505210838544173E-8
Ricevuto: 93 - Restituito: 8.644742106836940619829775373573826E-145
Ricevuto: 89 - Restituito: 6.057685462873333156953285408086779E-137
Ricevuto: 73 - Restituito: 2.237078680875058674680995578434491E-106
Ricevuto: 23 - Restituito: 3.868170170630684037716911931522814E-23
Ricevuto: 49 - Restituito: 1.643974708316579033515815347734293E-63
Ricevuto: 91 - Restituito: 7.396441346609686394326355809629767E-141
Ricevuto: 33 - Restituito: 1.151633562077195028058688149329824E-37
Ricevuto: 69 - Restituito: 5.843768516699616271879286441845085E-99
Ricevuto: 45 - Restituito: 8.359650847182803983324725422797232E-57
Ricevuto: 5 - Restituito: 0.008333333333333333333333333333333330
Ricevuto: 65 - Restituito: 1.212466494349280391997419601982764E-91
Ricevuto: 43 - Restituito: 1.655210867742195188698295633713852E-53
Ricevuto: 95 - Restituito: 9.680562269694222418622368839388382E-149
Ricevuto: 75 - Restituito: 4.030772397973078693118910952134216E-110
Ricevuto: 1 - Restituito: 1
Ricevuto: 39 - Restituito: 4.902469756513543397694159939759036E-47
Ricevuto: 41 - Restituito: 2.989310827142404510789121914487217E-50
Ricevuto: 79 - Restituito: 1.117795262136563939369233628944401E-117
Sum = 1.71828182845904523536028747135266241129844606162999606421881338461047508297046530851272129739288024500806666138654505778398426211369899599762685530664760916526029476793035635790672605174468695
[18:09:56] GridGain stopped OK [uptime=00:00:01:898]
&lt;/pre&gt;
cio&amp;egrave; ha eseguito 55 iterazioni. Le altre sono state eseguite dall&#39;altro nodo (vi risparmio l&#39;output, che vedreste nella sua console). Se a runtime avessi lanciato ancora un terzo nodo, si sarebbe preso il proprio carico di lavoro e tutto il sistema avrebbe scalato di conseguenza, &lt;b&gt;automaticamente&lt;/b&gt;!
&lt;p&gt;Notare che sono stato comunque costretto a modificare il codice originario. Perch&amp;eacute;? Perch&amp;eacute; non ho fatto il bravo, cio&amp;eacute; non ho utilizzato n&amp;eacute; un monad &lt;i&gt;writer&lt;/i&gt; n&amp;eacute; un monad &lt;i&gt;state&lt;/i&gt;. Li vedremo in un prossimo post. :)&lt;/p&gt;

&lt;p itemprop=&quot;reviewer&quot;&gt;onof&lt;/p&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/6325024995833680820/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/6325024995833680820' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6325024995833680820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6325024995833680820'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/gridgain.html' title='Vi presento GridGain'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1VrZouJb2F85Kmo8TgldBXVk5IGMR54QKsSj41RyR4V5oGLSuwARPs9bNO2iPTkALX_BZVnEQRygUGqZW6kbs8-xWKIgLqIExrTjFbfTn2RUjJ9Ix8AISiEBXib3vG-TCRReaCh6Dn6SS/s72-c/gg1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-1551650267438008484</id><published>2011-03-07T17:58:00.001+01:00</published><updated>2011-03-10T12:56:28.237+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codemotion"/><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Codemotion 2011</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.codemotion.it/sites/codemotion.it/files/image/codemotion_120_60(1).gif&quot; imageanchor=&quot;1&quot; style=&quot;clear:right; float:right; margin-left:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;60&quot; width=&quot;120&quot; src=&quot;http://www.codemotion.it/sites/codemotion.it/files/image/codemotion_120_60(1).gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;I talk a cui ho assistito:
&lt;ol&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-database-no-sql-anything-else&quot; itemprop=&quot;itemreviewed&quot;&gt;Database NO-SQL: Anything else? di Giorgio Desideri.&lt;/a&gt;&lt;span itemprop=&quot;description&quot;&gt;L&#39;ho trovato interessante, soprattutto perch&amp;eacute; conosco poco &lt;a href=&quot;http://cassandra.apache.org/&quot;&gt;Cassandra&lt;/a&gt;.&lt;/span&gt; Voto: &lt;span itemprop=&quot;value&quot;&gt;7&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-html5-and-running&quot; itemprop=&quot;itemreviewed&quot;&gt;HTML5 Up and Running, di Marco Casario.&lt;/a&gt; Molto bello, sono stati evidenziati i punti di forza e le difficolt&amp;agrave; sul cammino di HTML5. Voto: &lt;span itemprop=&quot;value&quot;&gt;8&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-web-apps-mobile-flash-html-5adobe-c039%C3%A8&quot;  itemprop=&quot;itemreviewed&quot;&gt;Web, Apps, Mobile, Flash Html 5...Adobe c&#39;&amp;egrave;! di Andrea Amadeo.&lt;/a&gt; Le strategie di Adobe per il futuro. Voto: &lt;span itemprop=&quot;value&quot;&gt;7&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-l039azienda-oracle&quot;  itemprop=&quot;itemreviewed&quot;&gt;L&#39;azienda Oracle.&lt;/a&gt; Niente di nuovo, pi&amp;ugrave; qualche rassicurazione sul futuro di Java. Voto: &lt;span itemprop=&quot;value&quot;&gt;6&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-distributed-programming-gridgain-and-scala&quot;  itemprop=&quot;itemreviewed&quot;&gt;Distributed Programming with GridGain and Scala, di Nikita Ivanov.&lt;/a&gt; La potenza espressiva di Scala in un framework molto promettente. Voto: &lt;span itemprop=&quot;value&quot;&gt;9&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;li itemscope itemtype=&quot;http://data-vocabulary.org/Review&quot;&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-hacking-infinispan-new-open-source-data-grid-meets-nosql&quot; itemprop=&quot;itemreviewed&quot;&gt;Hacking Infinispan: the new open source data grid meets NoSQL, di Manik Surtani.&lt;/a&gt; I punti di forza di &lt;a href=&quot;http://www.jboss.org/infinispan&quot;&gt;Infinispan&lt;/a&gt;, presentati in modo molto puntuale. Da notare: in arrivo supporto per JPA!  Voto: &lt;span itemprop=&quot;value&quot;&gt;8&lt;/span&gt; su &lt;span itemprop=&quot;best&quot;&gt;10&lt;/span&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;

&lt;p&gt;
Il talk che mi è piaciuto di pi&amp;ugrave; sicuramente quello su &lt;a href=&quot;http://www.gridgain.com/&quot;&gt;GridGain&lt;/a&gt; (nei prossimi giorni seguir&amp;agrave; un post dedicato :) ). A seguire, il talk di Marco Casario, molto bello: il suo libro su HTML5 non mancher&amp;agrave; nella mia libreria.
&lt;/p&gt;

&lt;p&gt;
Purtroppo non mi &amp;egrave; stato possibile, ma avrei voluto vedere anche:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-stato-dell039arte-del-mobile-game-programming-pubblicare-un-gioco-sugli-app-store-pochi-&quot;&gt;Stato dell&#39;arte del Mobile Game Programming: pubblicare un gioco sugli app store in pochi giorni, di Ugo Landini&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-sopravvivere-felicemente-ad-un-anno-e-mezzo-di-sviluppo-android&quot;&gt;Sopravvivere felicemente ad un anno e mezzo di sviluppo Android, di Alfredo Morresi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codemotion.it/evento/talk-perch%C3%A8-potresti-aver-bisogno-di-un-database-nosql-anche-se-non-sei-google-o-facebook&quot;&gt;Perch&amp;eacute; potresti aver bisogno di un database NoSQL anche se non sei Google o Facebook di Luca Garulli&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;Da parte mia ringrazio gli organizzatori e gli speakers, un ottimo evento.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/1551650267438008484/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/1551650267438008484' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1551650267438008484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1551650267438008484'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/codemotion-2011.html' title='Codemotion 2011'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-2615981884551022237</id><published>2011-03-04T23:21:00.003+01:00</published><updated>2011-04-02T00:13:22.713+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dependency injection"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Primo sguardo a Guice</title><content type='html'>Da una recente &lt;a href=&quot;http://debasishg.blogspot.com/2011/03/pushing-envelope-on-oo-and-functional.html?showComment=1299170313724#c8614814323780197784&quot;&gt;discussione sul blog di Debasish Ghosh&lt;/a&gt;, mi &amp;egrave; nata la curiosit&amp;agrave; di guardare &lt;a href=&quot;http://code.google.com/p/google-guice/&quot;&gt;questo container di cui avevo sentito parlare&lt;/a&gt;. 

Una caratteristica che mi ha colpito &amp;egrave; il modo di definire come istanziare gli oggetti annotando un metodo, ad esempio in questo modo:

&lt;pre class=&quot;brush: java&quot;&gt;
public class OrderProcessingModule extends AbstractModule {
   
  ...

  @Provides
  IOrderRepository createRepo() {
     RemoteOrderRepositoryAdapter repo = new 
       RemoteOrderRepositoryAdapter(ThirdPartyObject.getFoo());
     repo.setStuff(ThirdPartyObject.instance.createStuff());
     // ... altro codice per inizializzare repo
     //
     return repo;
  }
}
&lt;/pre&gt;

che, da quanto ho capito (ma ho fatto solo un analisi sommaria) &amp;egrave; anche l&#39;unico metodo per iniettare componenti di terze parti.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/2615981884551022237/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/2615981884551022237' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2615981884551022237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2615981884551022237'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/guice.html' title='Primo sguardo a Guice'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-2980625474202407346</id><published>2011-03-02T18:10:00.001+01:00</published><updated>2011-04-02T00:14:16.048+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="leaky abstractions"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Leaky abstraction: Asp.Net MasterPage</title><content type='html'>Consideriamo una pagina web in cui, cliccando su un elemento in una lista, vengono visualizzati alcuni controlli, che dipendono dal tipo di elemento cliccato. A design-time non &amp;egrave; dato di sapere quali sono questi controlli, i quali, a loro volta, possono provocare postback. Sono necessari dei controlli dinamici.&lt;br /&gt;

&lt;span title=&quot;As Fair As I Know&quot;&gt;AFAIK&lt;/span&gt;, l&#39;approccio migliore a questo problema &amp;egrave;:
&lt;ul&gt;
&lt;li&gt;creazione dello &lt;span style=&quot;font-family:courier&quot;&gt;UserControl&lt;/span&gt; in un evento della pagina&lt;/li&gt;
&lt;li&gt;aggiunta del controllo in un &lt;span style=&quot;font-family:courier&quot;&gt;PlaceHolder&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;impostazione del path dello &lt;span style=&quot;font-family:courier&quot;&gt;UserControl&lt;/span&gt; in un &lt;span style=&quot;font-family:courier&quot;&gt;HiddenField&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;nell&#39;&lt;span style=&quot;font-family:courier&quot;&gt;OnInit&lt;/span&gt; della pagina creazione del controllo a partire da &lt;span style=&quot;font-family:courier&quot;&gt;Request.Form&lt;/span&gt;, per permettere il caricamento del &lt;span style=&quot;font-family:courier&quot;&gt;ViewState&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
ossia una cosa del genere:

&lt;pre class=&quot;brush: csharp&quot;&gt;
protected override void OnInit(EventArgs e) {
  if(IsPostback) {
    var currentView = Request.Form[CurrentViewHiddenControl.UniqueID];
    if (!string.IsNullOrEmpty(currentView)) {
       var control = LoadControl(currentView);
       control.ID = &quot;MyView&quot;;
       PlaceHolder1.Controls.Add(control);
    }
  }
}

protected void OnSelected(Item item) {
  PlaceHolder1.Controls.Clear();
  
  var controlPath = GetControlPathByItem( item );
  var control = LoadControl( controlPath );
  control.ID = &quot;MyView&quot;;
  PlaceHolder1.Controls.Add(control);

  CurrentViewHiddenControl.Value = controlPath;
}
&lt;/pre&gt;

Ma non funziona se i controlli vengono creati in un &lt;span style=&quot;font-family:courier&quot;&gt;UpdatePanel&lt;/span&gt; e la pagina ha una &lt;span style=&quot;font-family:courier&quot;&gt;MasterPage&lt;/span&gt;; quello che succede è che il &lt;b&gt;primo&lt;/b&gt; postback non viene gestito correttamente. &lt;span style=&quot;color: red&quot;&gt;E non c&#39;è modo di farlo funzionare, se non togliendo la &lt;span style=&quot;font-family:courier&quot;&gt;MasterPage&lt;/span&gt;&lt;/span&gt;. Ora, può anche darsi che esista qualche workaround molto tricky, ma &lt;u&gt;&amp;egrave; assurdo che un normale processo, come il ciclo di vita di una pagina, venga stravolto da un dettaglio grafico&lt;/u&gt; quindi MasterPage = &lt;a href=&quot;http://www.joelonsoftware.com/articles/LeakyAbstractions.html&quot;&gt;leaky abstraction&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/2980625474202407346/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/2980625474202407346' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2980625474202407346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/2980625474202407346'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/leaky-abstraction-aspnet-masterpage.html' title='Leaky abstraction: Asp.Net MasterPage'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-6067045770402354028</id><published>2011-03-01T11:10:00.006+01:00</published><updated>2011-04-02T00:18:06.109+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><category scheme="http://www.blogger.com/atom/ns#" term="scalaz"/><title type='text'>Scalaz: ricerche intelligenti con Burkhard-Keller</title><content type='html'>Un&#39;interessante applicazione di &lt;a href=&quot;http://scalaz.googlecode.com&quot;&gt;scalaz&lt;/a&gt; &amp;egrave; l&#39;implementazione dell&#39;algoritmo di Burkhard-Keller, utile per effettuare ricerche veloci basate sulla distanza. Ad esempio:&lt;br /&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: scala&quot;&gt;
import scalaz._
import Scalaz._

object DoQuery {
   def main(args: Array[String]) =  {
       val found = find(args(0))
       
       println( found.mkString(&quot;Forse volevi dire: &quot;, 
                               &quot; oppure &quot;, &quot;&quot;) )
   }
   
   def find( m : String) = {
       // dizionario
       val dictionary = List(&quot;Java&quot;, &quot;Scala&quot;, &quot;Haskell&quot;).bktree

       // cerca nel dizionario gli elementi con distanza minore o uguale a 2
       dictionary |=| (m, 2)
   }
}
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;che, lanciato con input &lt;span style=&quot;font-family: Courier&quot;&gt;Skala&lt;/span&gt; restituisce:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[info] &lt;br /&gt;[info] == run ==&lt;br /&gt;[info] Running bkTreeExample.DoQuery Skala&lt;br /&gt;Forse volevi dire: Scala&lt;br /&gt;[info] == run ==&lt;br /&gt;[success] Successful.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Sarebbe interessante capire se e come si possa integrare con &lt;a href=&quot;http://scalaquery.org/&quot;&gt;ScalaQuery&lt;/a&gt; per interagire con un database.</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/6067045770402354028/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/6067045770402354028' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6067045770402354028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6067045770402354028'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/03/scalaz-ricerche-intelligenti-con.html' title='Scalaz: ricerche intelligenti con Burkhard-Keller'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-1462818336616633496</id><published>2011-02-28T13:20:00.002+01:00</published><updated>2011-02-28T13:24:08.545+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codemotion"/><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Codemotion: io ci sarò</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://www.codemotion.it/&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 300px; height: 250px;&quot; src=&quot;http://www.codemotion.it/sites/codemotion.it/files/image/codemotion_300_250.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Ci vediamo là!</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/1462818336616633496/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/1462818336616633496' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1462818336616633496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/1462818336616633496'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/02/codemotion-io-ci-saro.html' title='Codemotion: io ci sarò'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6200426339083146338.post-6480509290359736252</id><published>2011-02-27T22:38:00.013+01:00</published><updated>2011-02-28T08:44:36.438+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="architecture"/><category scheme="http://www.blogger.com/atom/ns#" term="dependency injection"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Il DAL deve dipendendere dal BLL e non viceversa!</title><content type='html'>Avete presente la classica applicazione three-tier?&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Presentation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Business logic&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Data access&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Molte volte, &lt;em&gt;troppe&lt;/em&gt; volte, abbiamo visto dipendenze di questo tipo:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUAoSEHnE848y5JG5VF-DqAROwHRWrs6hzjRFujCXhdZ36NmxX0QD60l8Cipla89N-loDKY0rN1jQh-yo4PDZw5el8uWtxNlXnBJx773x-Om2skdqhffr4boCC0TlgmD9OyUlUuTNl8mQS/s1600/wrong3t.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 152px; height: 284px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUAoSEHnE848y5JG5VF-DqAROwHRWrs6hzjRFujCXhdZ36NmxX0QD60l8Cipla89N-loDKY0rN1jQh-yo4PDZw5el8uWtxNlXnBJx773x-Om2skdqhffr4boCC0TlgmD9OyUlUuTNl8mQS/s320/wrong3t.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5578491119870565810&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Io stesso avevo progettato applicazioni in questo modo, infatti risulta abbastanza naturale, per esempio, nel nostro strato di business logic scrivere qualcosa del genere (ovviamente orderRepository proviene dal DAL):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; DAL.Order order = this.orderRepository.getOrder(id);&lt;br /&gt; OrderDTO orderDto = OrderDTO.createFrom(order);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Ma in questo modo, se volessimo cambiare database come si fa? Una soluzione potrebbe essere quella di lasciare al DAL la responsabilità di gestire i differenti tipi di storage. Ma in ogni caso questo ci costringe a realizzare un business logic layer consapevole di come vengono salvati gli oggetti, cioè che nel DAL esiste un oggetto Order, (che probabilmente corrisponderà ad una tabella), quindi ci limita molto anche nella progettazione del DAL stesso. Non a caso questo tipo di architettura è il risultato del pericolosissimo &lt;a href=&quot;http://uml-tutorials.trireme.com/uml_tutorial_2_1.htm&quot;&gt;data-driven design&lt;/a&gt;, cioè quella tecnica di sviluppo che prevede le fasi:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;design del database;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;reverse-engineering dello schema del db in classi, nel DAL;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;sviluppo di servizi che manipolano queste classi, nel BLL;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;realizzazione di interfacce che grosso modo riproducono i campi del database e le sue strutture.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Ma il nocciolo dell&#39;applicazione è il suo model, il suo business logic, non il suo storage. Se ci rendiamo conto di questo, dovrebbe essere l&#39;accesso ai dati a dipendere dal business e non viceversa. Dunque come realizziamo la nostra architettura in questo modo:&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKRfqzvi2jrFPemjYZdswbsA5ftdcRMEeHenMlhLcAKywwCqaFG_2QGkEvHftJmZ7FNAzhu0CuKh3Ue_aeQEqj3TXA6QcqwtPprAWb7A210IMpso4dhan0QXg0mid-CSfN7AQTf19o141W/s1600/right3t.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 152px; height: 284px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKRfqzvi2jrFPemjYZdswbsA5ftdcRMEeHenMlhLcAKywwCqaFG_2QGkEvHftJmZ7FNAzhu0CuKh3Ue_aeQEqj3TXA6QcqwtPprAWb7A210IMpso4dhan0QXg0mid-CSfN7AQTf19o141W/s320/right3t.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5578497869115933970&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Come possiamo gestire l&#39;accesso ai dati dal BLL? In questo ci viene incontro la dependency injection, in modo semplicissimo:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;nel BLL creiamo un&#39;interfaccia IOrderRepository, che stavolta non ci restituirà degli oggetti che replicano la struttura del database ma i nostri veri oggetti di dominio;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;nel BLL creiamo il nostro servizio OrderService, con un riferimento a IOrderRepository;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;nel DAL, che dipende dal BLL, implementiamo IOrderRepository, il quale effettua la mappatura dal database al modello: è questo strato il responsabile di scelte come: usiamo un ORM? Salviamo su XML? Usiamo MongoDB?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;istruiamo il nostro dependency injection container con l&#39;implementazione da iniettare in OrderService;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;ed ecco fatto: abbiamo finalmente slegato totalmente il BLL dal DAL. Possiamo abbandonare il &lt;span style=&quot;font-weight:bold;color:red;&quot;&gt;diabolico &lt;/span&gt;data-driven design.&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoITDzP9chB14EnHszOeuutjpwOaz8WfFdFi37TqZHeXPPHzCAgeqm_s_LkbMhfUGTcpk63nj002RRh9SMy1pdcyUweJHJ8y6oZEksvmBGNTjDNPEKwxSX1WcTT7_j8F8ntJTITpBb4SSM/s1600/BllDal.png&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 92px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoITDzP9chB14EnHszOeuutjpwOaz8WfFdFi37TqZHeXPPHzCAgeqm_s_LkbMhfUGTcpk63nj002RRh9SMy1pdcyUweJHJ8y6oZEksvmBGNTjDNPEKwxSX1WcTT7_j8F8ntJTITpBb4SSM/s320/BllDal.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5578504965793887394&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://onof80.blogspot.com/feeds/6480509290359736252/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6200426339083146338/6480509290359736252' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6480509290359736252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6200426339083146338/posts/default/6480509290359736252'/><link rel='alternate' type='text/html' href='http://onof80.blogspot.com/2011/02/il-dal-deve-dipendendere-dal-bll-e-non.html' title='Il DAL deve dipendendere dal BLL e non viceversa!'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUAoSEHnE848y5JG5VF-DqAROwHRWrs6hzjRFujCXhdZ36NmxX0QD60l8Cipla89N-loDKY0rN1jQh-yo4PDZw5el8uWtxNlXnBJx773x-Om2skdqhffr4boCC0TlgmD9OyUlUuTNl8mQS/s72-c/wrong3t.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>