GTD en PHP
A los informaticos muchas veces nos cuesta aceptar los métodos y somos más bien de mente un poco cerrada, nos movemos en entornos que conocemos y tendemos a traducir la información a sistemas que nos resultan más conocidos, para mejorarlos y alterarlos como nos guste. Por eso rechazamos el método GTD, hasta que nos lo explican en nuestra lenguaje. Con este pequeño post, pretendo traducir a modo de broma el proceso GTD en lenguaje PHP (no OOP que quedaría más bonito) entendible por cualquier programador.<pre><?php<span style="color: blue;">function</span> requiere_accion() <span style="color: red;">{</span><span style="color: #e6e6e6;">// Pensar en la cantidad de acciones</span> <span style="color: blue;">return</span> $n_acciones;<span style="color: red;">}</span><span style="color: blue;">function</span> archivar($cosa) <span style="color: red;">{</span><span style="color: #e6e6e6;">// Cosa a BBDD</span> $conexion = mysql_connect(<span style="color: green;">"</span>localhost<span style="color: green;">"</span>, <span style="color: green;">"</span>usuario<span style="color: green;">"</span>, <span style="color: green;">"</span>clave<span style="color: green;">"</span>); $tabla = mysql_select_db(<span style="color: green;">"</span>base_datos<span style="color: green;">"</span>,$conexion); $sql = mysql_query(<span style="color: green;">"</span>INSERT INTO archivado (cosa) values('$cosa')<span style="color: green;">"</span>);<span style="color: red;">}</span><span style="color: blue;">function</span> eliminar($cosa) <span style="color: red;">{</span><span style="color: #e6e6e6;">// A la papelera</span><span style="color: red;">}</span><span style="color: blue;">function</span> siguiente_accion() <span style="color: red;">{</span><span style="color: #e6e6e6;">// Pensar en cuál es la siguiente acción</span> sleep(120);<span style="color: red;">}</span><span style="color: blue;">function</span> delegar($cosa) <span style="color: red;">{</span><span style="color: #e6e6e6;">// Averiguar persona dispobible</span><span style="color: #e6e6e6;">// Delegar Tarea</span> <span style="color: blue;">return</span> $propietario;<span style="color: red;">}</span><span style="color: blue;">function</span> anyadir_lista($lista,$cosa,$propietario) <span style="color: red;">{</span><span style="color: #e6e6e6;">// Delegar</span><span style="color: #e6e6e6;">// Añadir a lista</span><span style="color: red;">}</span><span style="color: blue;">function</span> hacer($cosa) <span style="color: red;">{</span><span style="color: red;">}</span><span style="color: #e6e6e6;">// Paso 1 Recopilar</span><span style="color: #e6e6e6;">// Metemos las cosas en la bandeja de entrada</span>$bandeja = $HTTP_GET_VARS;$lista[] = <span style="color: green;">"</span><span style="color: green;">"</span>;$proyectos[] = <span style="color: green;">"</span><span style="color: green;">"</span>;<span style="color: #e6e6e6;">// Paso 2 Procesar</span><span style="color: blue;">foreach</span> ($bandeja as $cosa<span style="color: blue;">=></span>$que_es) <span style="color: red;">{</span> $acciones = requiere_accion($que_es); <span style="color: blue;">switch</span> ($acciones) <span style="color: red;">{</span> case 0 : <span style="color: blue;">if</span> (!$eliminar($cosa)) <span style="color: red;">{</span> archivar($cosa); <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> eliminar($cosa); <span style="color: red;">}</span> <span style="color: blue;">break</span> ; case 1 : $siguiente = siguiente_accion($que_es); <span style="color: blue;">if</span> (propietario <span style="color: blue;">==</span> $me) <span style="color: red;">{</span> <span style="color: blue;">if</span> (calcular_tiempo($cosa) < 120) <span style="color: red;">{</span> <span style="color: blue;">if</span> (checkdate($cosa)) <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Agenda<span style="color: green;">"</span>,$que_es,$me); <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Acciones_Siguientes<span style="color: green;">"</span>,$que_es,$me); <span style="color: red;">}</span> <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> hacer($cosa); <span style="color: red;">}</span> <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Espera<span style="color: green;">"</span>,$que_es,delegar($que_es)); <span style="color: red;">}</span> <span style="color: blue;">break</span> ; <span style="color: blue;">default</span> : anyadir_lista(<span style="color: green;">"</span>Proyectos<span style="color: green;">"</span>,$que_es,$me); <span style="color: blue;">if</span> (!checkdate($cosa)) <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Algun Día<span style="color: green;">"</span>,$que_es,$me); <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> $siguiente = siguiente_accion($que_es); <span style="color: blue;">if</span> (propietario <span style="color: blue;">==</span> $me) <span style="color: red;">{</span> <span style="color: blue;">if</span> (calcular_tiempo($cosa) < 120) <span style="color: red;">{</span> <span style="color: blue;">if</span> (checkdate($cosa)) <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Agenda<span style="color: green;">"</span>,$que_es,$me); <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Acciones_Siguientes<span style="color: green;">"</span>,$que_es,$me); <span style="color: red;">}</span> <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> hacer($cosa); <span style="color: red;">}</span> <span style="color: red;">}</span> <span style="color: blue;">else</span> <span style="color: red;">{</span> anyadir_lista(<span style="color: green;">"</span>Espera<span style="color: green;">"</span>,$que_es,delegar($que_es)); <span style="color: red;">}</span> <span style="color: red;">}</span> <span style="color: red;">}</span><span style="color: red;">}</span><span style="color: #e6e6e6;">// Paso 3 Organizar</span><span style="color: blue;">foreach</span> ($lista as $nombre<span style="color: blue;">=></span>$accion) <span style="color: red;">{</span> <span style="color: blue;">if</span> ($nombre<span style="color: blue;">==</span> <span style="color: green;">"</span><span style="color: green;">"</span>) <span style="color: red;">{</span> anyadir_lista($contexto,$accion,$propietario); <span style="color: red;">}</span><span style="color: red;">}</span><span style="color: #e6e6e6;">// Paso 4 Hacer</span><span style="color: blue;">foreach</span> ($lista as $cosa<span style="color: blue;">=></span>$que_es) <span style="color: red;">{</span> hacer($que_es);<span style="color: red;">}</span><span style="color: #e6e6e6;">// Paso 5 Revisión Semanal</span><span style="color: blue;">foreach</span> ($proyectos as $cosa<span style="color: blue;">=></span>$que_es) <span style="color: red;">{</span><span style="color: red;">}</span><span style="color: blue;">foreach</span> ($lista as $cosa<span style="color: blue;">=></span>$que_es) <span style="color: red;">{</span><span style="color: red;">}</span>?></pre>
Publicado el 20090820