<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>in Web we Trust &#187; time</title>
	<atom:link href="http://blog.danilosanchi.net/tag/time/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danilosanchi.net</link>
	<description>storie, pensieri, idee...</description>
	<lastBuildDate>Tue, 22 Apr 2025 13:55:16 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>Pioritree e Silex</title>
		<link>http://blog.danilosanchi.net/2013/01/27/pioritree-e-silex/</link>
		<comments>http://blog.danilosanchi.net/2013/01/27/pioritree-e-silex/#comments</comments>
		<pubDate>Sun, 27 Jan 2013 19:17:21 +0000</pubDate>
		<dc:creator><![CDATA[Danilo]]></dc:creator>
				<category><![CDATA[Idee]]></category>
		<category><![CDATA[Sviluppo]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[silex]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[todo]]></category>

		<guid isPermaLink="false">http://blog.danilosanchi.net/?p=123</guid>
		<description><![CDATA[Circa due anni fa stavo (finalmente) studiando i design pattern su Head First Design Patterns, un libro semplice, pieno di figure, sicuramente più accessibile (ai programmatori un po&#8217; meno svegli) del ben più noto Design Patterns: Elementi per il riuso di &#8230; <a href="http://blog.danilosanchi.net/2013/01/27/pioritree-e-silex/">Continua a leggere <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.danilosanchi.net/2013/01/27/vino-vecchio-nella-botte-nuova/post_it_tree/" rel="attachment wp-att-134"><img class="alignright  wp-image-134" alt="post_it_tree" src="http://blog.danilosanchi.net/current/wp/wp-content/uploads/2013/01/post_it_tree-267x300.jpg" width="214" height="240" /></a>Circa due anni fa stavo (finalmente) studiando i <strong>design pattern</strong> su <em><a title="Head First Design Patterns" href="http://www.headfirstlabs.com/books/hfdp/" target="_blank">Head First Design Patterns</a></em>, un libro semplice, pieno di figure, sicuramente più accessibile (ai programmatori un po&#8217; meno svegli) del ben più noto<em> <a title="Design Patterns" href="http://en.wikipedia.org/wiki/Design_Patterns" target="_blank">Design Patterns: Elementi per il riuso di software ad oggetti</a></em>, il quale è più un <strong>catalogo</strong> da consultare che un testo di <strong>apprendimento</strong>.</p>
<p>Beh, avevo letto del <strong><a title="Composite Pattern" href="http://en.wikipedia.org/wiki/Composite_pattern" target="_blank">Composite Pattern</a></strong> e mi era venuta in mente un&#8217;<strong>idea</strong> per metter in pratica quanto appreso.<br />
Cercavo un modo per <strong>dedicare il giusto tempo</strong> alle mille attività che dovevo/volevo svolgere senza trascurare nulla, ma soprattutto senza trascurare le cose più importanti:</p>
<p><em>Quanto tempo devo dedicare alla pulizia della casa? Quanto ne posso dedicare alle attività della mia associazione? Ma della pulizia della casa, quanto tempo dedico alla cucina e quanto alla camera da letto?</em></p>
<p><em><span id="more-123"></span></em></p>
<p>Insomma volevo costruire una <strong>gerarchia</strong> (un albero) di <strong>attività</strong> da svolgere, in cui ogni attività potesse essere suddivisa in sottoattività e così via. Ad ogni attività avrei quindi assegnato un <strong>livello di priorità</strong> (da 1 a 10 per esempio). Avrei infine scelto un <strong>monte ore</strong> di riferimento (ad esempio 100 ore) da <strong>distribuire automaticamente</strong> a ciascuna attività in base alle loro priorità. Il <strong>Composite Pattern</strong> era perfetto per gestire <strong>gerarchie di elementi</strong> e avrei potuto sperimentare un approccio <strong><a title="Test First" href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank">TDD</a></strong>. Il nome che gli avrei dato sarebbe stato <strong>Prioritree</strong>.</p>
<p>Non mi ci volle molto per realizzare un <strong>prototipo. </strong>Sarebbe stato impossibile implementare le classi che gestiscono una gerarchia senza l&#8217;ausilio di <strong>test unitari</strong>.<br />
Praticamente si doveva definire la propria gerarchia di attività con le loro priorità ed il monte ore assegnato su un file <strong>Yaml</strong>:</p>
<pre><span style="color: #0000ff;">// mytasks.yml</span>
<span style="color: #008000;">Root</span>:
  data: timeBox=100
  children:
     <span style="color: #008000;">Casa</span>:
        data: priority=10
        children:
           <span style="color: #008000;">Camera da letto</span>:
              data: priority=6
           <span style="color: #008000;">Bagno</span>:
              data: priority=10
           <span style="color: #008000;">Cucina</span>:
              data: priority=8
     <span style="color: #008000;">Associazione</span>:
        data: priority=6
        children:
           <span style="color: #008000;">Sito</span>:
              data: priority=2
           <span style="color: #008000;">Facebook</span>:
              data: priority=4
           <span style="color: #008000;">Eventi</span>:
              data: priority=10</pre>
<p>eseguendo un semplice <em>php index.php </em>il file veniva arricchito con le ore assegnate a ciascuna attività.</p>
<pre><span style="color: #0000ff;">// mytasks.yml</span>
<span style="color: #008000;">Root</span>:
   data: usedTime=0; timeBox=100; progress=0%; time=0/100
   children:
      <span style="color: #008000;">Casa</span>:
         data: usedTime=0; priority=10; progress=0%; time=0/62.5
         children:
            <span style="color: #008000;">Camera da letto</span>:
               data: usedTime=0; priority=6; progress=0%; time=0/15.63
            <span style="color: #008000;">Bagno</span>:
               data: usedTime=0; priority=10; progress=0%; time=0/26.04
            <span style="color: #008000;">Cucina</span>:
               data: usedTime=0; priority=8; progress=0%; time=0/20.83
      <span style="color: #008000;">Associazione</span>:
         data: usedTime=0; priority=6; progress=0%; time=0/37.5
         children:
            <span style="color: #008000;">Sito</span>:
               data: usedTime=0; priority=2; progress=0%; time=0/4.69
            <span style="color: #008000;">Facebook</span>:
               data: usedTime=0; priority=4; progress=0%; time=0/9.38
            <span style="color: #008000;">Eventi</span>:
               data: usedTime=0; priority=10; progress=0%; time=0/23.44</pre>
<p>Successivamente era possibile specificare il <strong>tempo utilizzato</strong> per ciascuna attività  a qualsiasi livello di dettaglio impostando <em>usedTime;</em> rilanciando <em>php index.php</em> veniva aggiornato il progresso percentuale e le ore assegnate su tutte le attività discendenti ed ascendenti.</p>
<pre><span style="color: #0000ff;">// mytasks.yml</span>
<span style="color: #008000;">Root</span>:
   data: usedTime=0; timeBox=100; progress=<span style="color: #0000ff;"><strong>11%</strong></span>; time=<span style="color: #0000ff;"><strong>11</strong></span>/100
   children:
      <span style="color: #008000;">Casa</span>:
         data: usedTime=<strong><span style="color: #ff0000;">2</span></strong>; priority=10; progress=<span style="color: #0000ff;"><strong>17.6%</strong></span>; time=<span style="color: #0000ff;"><strong>11</strong></span>/62.5
         children:
            <span style="color: #008000;">Camera da letto</span>:
               data: usedTime=<span style="color: #ff0000;"><strong>4</strong></span>; priority=6; progress=<span style="color: #0000ff;"><strong>29.87%</strong></span>; time=<span style="color: #0000ff;"><strong>4.67</strong></span>/15.63
            <span style="color: #008000;">Bagno</span>:
               data: usedTime=<span style="color: #ff0000;"><strong>5</strong></span>; priority=10; progress=<span style="color: #0000ff;"><strong>21.76%</strong></span>; time=<span style="color: #0000ff;"><strong>5.67</strong></span>/26.04
            <span style="color: #008000;">Cucina</span>:
               data: usedTime=0; priority=8; progress=<span style="color: #0000ff;"><strong>3.2%</strong></span>; time=<span style="color: #0000ff;"><strong>0.67</strong></span>/20.83
      <span style="color: #008000;">Associazione</span>:
         data: usedTime=0; priority=6; progress=0%; time=0/37.5
         children:
            <span style="color: #008000;">Sito</span>:
               data: usedTime=0; priority=2; progress=0%; time=0/4.69
            <span style="color: #008000;">Facebook</span>:
               data: usedTime=0; priority=4; progress=0%; time=0/9.38
            <span style="color: #008000;">Eventi</span>:
               data: usedTime=0; priority=10; progress=0%; time=0/23.44</pre>
<p>Era possibile cambiare le priorità delle attività oppure cambiare la struttura dell&#8217;albero in qualsiasi momento: le ore assegnate cambiavano, nessun problema.</p>
<p>Faceva altre cose ovviamente, come resettare il monte ore portandosi dietro i <em>debiti</em> e i <em>crediti</em> del monte ore precedente, ma l&#8217;idea in soldoni era questa.</p>
<p>Utilizzai come contenitore un <strong>microframework</strong> che stavo realizzando per i miei progetti personali ispirato a quanto avevo letto di <a title="Symfony 1.x" href="http://symfony.com/legacy" target="_blank"><strong>Symfony</strong></a> e dell&#8217;archiettura <a title="MVC" href="http://it.wikipedia.org/wiki/Model-View-Controller" target="_blank"><strong>MVC</strong></a>. Solo l&#8217;anno scorso imparai ad utilizzare <a title="Git" href="http://git-scm.com/" target="_blank"><strong>Git</strong></a> e <a title="Github" href="https://github.com" target="_blank"><strong>Github</strong></a> e vi pubblicai il mio Prioritree.</p>
<p>Quest&#8217;estate, però, ho imparato ad utilizzare <a title="Silex" href="http://silex.sensiolabs.org/" target="_blank"><strong>Silex</strong></a>, il fratellino minore di <a title="Symfony 2" href="http://symfony.com" target="_blank"><strong>Symfony 2</strong></a>, grazie ad un lavoretto con <a title="Ideato" href="http://www.ideato.it" target="_blank"><strong>Ideato</strong></a>. Quindi ho pensato di riprendere il Prioritree e sostituire il mio incompleto e rozzo microframework con Silex, al fine di costruire in un secondo momento una&#8217;interfaccia web decente per quello che ora è solo un set di classi.</p>
<p>Grazie ai vecchi test il <strong>porting</strong> è stato rapido e indolore e questo è il <a title="Prioritree" href="https://github.com/danielsan80/Prioritree" target="_blank"><strong>risultato</strong></a>.</p>
<p>Ho cercato di fare <em>commit</em> piccole e significative in modo da mettere in evidenza tutti i passaggi fatti per cambiare contenitore. I tag <a title="v1.0" href="https://github.com/danielsan80/Prioritree/tree/v1.0" target="_blank"><strong>v1.0</strong></a> e <a title="v2.0" href="https://github.com/danielsan80/Prioritree/tree/v2.0" target="_blank"><strong>v2.0</strong></a>  corrispondono rispettivamente al Prioritree prima e dopo il <em>travaso</em> in Silex.</p>
<p>Ora manca il <em>Readme</em> in <em>markdown</em> e buttar su un&#8217;interfaccia web semplice semplice per poterlo pubblicare e rendere disponibile a tutti. E&#8217; la prima volta che a distanza di anni riesco a riprendere del vecchio codice e a riutilizzarlo senza che mi faccia schifo. <img src="http://blog.danilosanchi.net/current/wp/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danilosanchi.net/2013/01/27/pioritree-e-silex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
