<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ant 2e6 + 1</title>
	<atom:link href="http://jbautistam.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jbautistam.wordpress.com</link>
	<description>Weblog sobre programación, arquitectura de sofware y administración de proyectos</description>
	<lastBuildDate>Thu, 27 Sep 2007 11:14:12 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jbautistam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ant 2e6 + 1</title>
		<link>http://jbautistam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jbautistam.wordpress.com/osd.xml" title="Ant 2e6 + 1" />
	<atom:link rel='hub' href='http://jbautistam.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Comentarios: esos grandes desconocidos</title>
		<link>http://jbautistam.wordpress.com/2007/09/27/comentarios-esos-grandes-desconocidos/</link>
		<comments>http://jbautistam.wordpress.com/2007/09/27/comentarios-esos-grandes-desconocidos/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 09:35:36 +0000</pubDate>
		<dc:creator>jbautistam</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://jbautistam.wordpress.com/2007/09/27/comentarios-esos-grandes-desconocidos/</guid>
		<description><![CDATA[Los comentarios dentro del código sirven para explicar las funciones de una serie de instrucciones y facilitar la lectura del código. Sin embargo existen ciertos comentarios que no aportan nada a la documentación del código y que de hecho pueden resultar molestos y contraproducentes. Por ejemplo:&#160; 1: Private Sub cmbo_pnt_SelectedIndexChanged(ByVal sender As Object, ByVal e [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=21&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Los comentarios dentro del código sirven para explicar las funciones de una serie de instrucciones y facilitar la lectura del código.</p>
<p>Sin embargo existen ciertos comentarios que no aportan nada a la documentación del código y que de hecho pueden resultar molestos y contraproducentes. Por ejemplo:&nbsp;</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;max-height:200px;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">Private</span> <span style="color:#0000ff;">Sub</span> cmbo_pnt_SelectedIndexChanged(<span style="color:#0000ff;">ByVal</span> sender <span style="color:#0000ff;">As</span> <span style="color:#0000ff;">Object</span>, <span style="color:#0000ff;">ByVal</span> e <span style="color:#0000ff;">As</span> System.EventArgs) <span style="color:#0000ff;">Handles</span> cmbo_pnt.SelectedIndexChanged</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>     cmbo_grupo_farma.Enabled = <span style="color:#0000ff;">True</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     cmbo_grupo_farma.Focus()</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     envia_aviso(1)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>             <span style="color:#008000;">'lbl_ayuda.Visible = False</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>             <span style="color:#008000;">'lbl_ayuda.Visible = False</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>             <span style="color:#008000;">'lbl_ayuda.Text = ""</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>             <span style="color:#008000;">'cmbo_pnt.Enabled = False</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>             <span style="color:#008000;">'cmbo_pnt.Visible = False</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>     <span style="color:#008000;">'module_uno.pnt_conf = (cmbo_pnt.Text.Trim)</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>             <span style="color:#008000;">'corro_barra()</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span>     <span style="color:#008000;">'Dim c_mc As New col_muestras_confirmar.col_muestras_confirmar</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>             <span style="color:#008000;">'' c_mc.solicito_confirmacion()</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>     <span style="color:#008000;">'c_mc = Nothing</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span>     <span style="color:#008000;">'If module_uno.pnt_conf &lt;&gt; "PNT-CO-03" Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  21:</span>             <span style="color:#008000;">'    solicito_alicuota(module_uno.pnt_conf)  ' Solicito para el pnt de confirmación</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  22:</span>     <span style="color:#008000;">'Else</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  23:</span>             <span style="color:#008000;">'    If pnt_co_03 = False Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  24:</span>             <span style="color:#008000;">'        solicito_alicuota(module_uno.pnt_conf)</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  25:</span>     <span style="color:#008000;">'    End If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  26:</span>     <span style="color:#008000;">'End If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  27:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  28:</span>             <span style="color:#008000;">'If module_uno.pnt_conf = "PNT-CO-03" Then pnt_co_03 = True</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  29:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  30:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  31:</span>             <span style="color:#008000;">'lst_sustancias.Items.Add(module_uno.pnt_conf &amp; "-" &amp; module_uno.dis_producto)</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  32:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  33:</span>     <span style="color:#008000;">'If module_uno.pnt_conf &lt;&gt; "PNT-CU-07" Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  34:</span>             <span style="color:#008000;">'    limpia_eleccion()</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  35:</span>     <span style="color:#008000;">'End If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  36:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  37:</span>     <span style="color:#008000;">'If module_uno.pnt_conf = "PNT-CU-07" Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  38:</span>             <span style="color:#008000;">'    reconfiguro_formulario()</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  39:</span>     <span style="color:#008000;">'End If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  40:</span>     <span style="color:#008000;">'' Si el procedimiento es pnt-co-03</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  41:</span>     <span style="color:#008000;">'If module_uno.pnt_conf = "PNT-CO-03" Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  42:</span> &nbsp;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  43:</span>     <span style="color:#008000;">'End If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  44:</span> <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">Sub</span></pre>
</div>
</div>
<p>&nbsp;</p>
<p>El noventa por ciento de esta función lo ocupan una serie de comentarios. En realidad son instrucciones comentadas. Pero ¿por qué están comentadas? ¿Son pruebas? ¿Es parte del código que ya no se necesita? ¿Es parte necesaria del código pero se ha comentado para arreglarla más adelante?</p>
<p>Cuando una serie de código no sea ya necesaria por cualquier motivo, la mejor opción no es comentarla si no eliminarla. Así evitamos que posteriormente surjan dudas de este tipo. Si lo que queremos es&nbsp;volver a consulta el código que hemos eliminado siempre podemos ir a la aplicación de gestión de código fuente (SourceSafe) y&nbsp;consultar las versiones anteriores.</p>
<p>Eso además evita&nbsp;construcciones&nbsp;de este tipo:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;max-height:200px;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">Private</span> <span style="color:#0000ff;">Sub</span> cmd_aceptar_Click(<span style="color:#0000ff;">ByVal</span> sender <span style="color:#0000ff;">As</span> System.<span style="color:#0000ff;">Object</span>, <span style="color:#0000ff;">ByVal</span> e <span style="color:#0000ff;">As</span> System.EventArgs)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>     <span style="color:#008000;">' Debemos de chequear que haya por lo menos una opción elegida.</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>             <span style="color:#0000ff;">If</span> lst_sustancias.Items.Count &gt; 0 <span style="color:#0000ff;">Then</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>                     descarga_solicitudes()</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>                     <span style="color:#0000ff;">Dim</span> c_mc <span style="color:#0000ff;">As</span> <span style="color:#0000ff;">New</span> col_muestras_confirmar.col_muestras_confirmar</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>                     <span style="color:#008000;">'   c_mc.descarga_confirmaciones()</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>                     c_mc = <span style="color:#0000ff;">Nothing</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>                     module_uno.confirma_mta = <span style="color:#0000ff;">True</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>             <span style="color:#0000ff;">Else</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>                     module_uno.envia_message(38)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>             <span style="color:#0000ff;">End</span> <span style="color:#0000ff;">If</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>     <span style="color:#0000ff;">End</span> Sub</pre>
</div>
</div>
<p>En la línea 5 se define un objeto, en la línea 7 se destruye y en la línea 6 que supuestamente lo utilizaba se ha comentado el código por lo que realmente nunca se utiliza el objeto que hemos creado. ¿Por qué se ha comentado? y los más importante ¿por qué se han dejado sin comentar la creación y la destrucción del objeto?</p>
<p>Aparte de los comentarios que &#8220;generan dudas&#8221; en lugar de &#8220;solucionar dudas&#8221; están los comentarios ligeramente inútiles:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;max-height:200px;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#008000;">//***************************************************************************</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> <span style="color:#008000;">//*  PROYECTO           :   ReportViewer</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> <span style="color:#008000;">//*  VERSIÓN            :   1.0</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> <span style="color:#008000;">//*  MÓDULO/PROGRAMA    :   frmReportViewer</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> <span style="color:#008000;">//*  NOMBRE             :</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> <span style="color:#008000;">//*  LENGUAJE           :   C# (C Sharp)</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span> <span style="color:#008000;">//*  TIPO               :   Clase</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> <span style="color:#008000;">//*  FECHA CREACIÓN     :   10/06/2007</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span> <span style="color:#008000;">//*  FECHA MODIFICACIÓN :</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span> <span style="color:#008000;">//*  AUTORES            :   Pedro Naranjo</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span> <span style="color:#008000;">//*</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span> <span style="color:#008000;">//*</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span> <span style="color:#008000;">//*  MODIFICADO POR     :</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span> <span style="color:#008000;">//*  DESCRIPCIÓN        :   Visor de Informes de SQL Server 2005 Reporting Service</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span> <span style="color:#008000;">//*  COMENTARIOS        :   Para su correcto funcionamiento necesita las tablas:</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span> <span style="color:#008000;">//*                         MENUS_CONFIGURACION, MENUS_ITEMS y MENUS_PERFIL</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span> <span style="color:#008000;">//*                         y el procedure: P_MENUS_PERFIL_Select_By_MEP_PERFIL_ID</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span> <span style="color:#008000;">//****************************************************************************</span></pre>
</div>
</div>
<p>Estos comentarios, aunque visualmente atractivos, no aportan realmente ninguna información. El nombre del proyecto lo sabemos a partir del nombre de archivo, el lenguaje a partir del propio código, las fechas de creación y modificación se pueden obtener a partir de las fechas de archivo y el autor a partir de la aplicación de gestión de código fuente.</p>
<p>Lo único que aporta algo es la descripción y los comentarios finales, el resto se puede obtener de otras fuentes y no deberían aparecer en el código. </p>
<p>Del mismo modo que este tipo de comentarios:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;max-height:200px;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#008000;">//****************************/</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> <span style="color:#008000;">//*    V A R I A B L E S     */</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> <span style="color:#008000;">//****************************/</span></pre>
</div>
</div>
<p>Queda bonito pero para el programador que lea el código seguramente le bastaría con una única línea que le indicase que se van a definir variables locales. Cuando se está leyendo código es interesante tener el máximo número de líneas ejecutables posible en la pantalla, tres líneas para un comentario, a mí al menos, me&nbsp;resulta una pérdida de espacio y en este caso de tiempo para formatear el aspecto del comentario.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jbautistam.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jbautistam.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbautistam.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbautistam.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbautistam.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=21&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbautistam.wordpress.com/2007/09/27/comentarios-esos-grandes-desconocidos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7ad12ba59b991ea29dedff0b46d2c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jbautistam</media:title>
		</media:content>
	</item>
		<item>
		<title>Normalizaci&#243;n de c&#243;digo</title>
		<link>http://jbautistam.wordpress.com/2007/08/31/normalizacin-de-cdigo/</link>
		<comments>http://jbautistam.wordpress.com/2007/08/31/normalizacin-de-cdigo/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 08:37:10 +0000</pubDate>
		<dc:creator>jbautistam</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://jbautistam.wordpress.com/2007/08/31/normalizacin-de-cdigo/</guid>
		<description><![CDATA[En el diseño de interfaces de usuario existe un concepto denominado “minimizar el aturdimiento”. Imaginemos por un momento un editor de texto en el que el icono del botón Grabar no represente un disco si no un hombre prehistórico cincelando una piedra. La primera vez que el usuario escriba su documento y desee grabarlo irá [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=20&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span>En el diseño de interfaces de usuario existe un concepto denominado “minimizar el aturdimiento”. Imaginemos por un momento un editor de texto en el que el icono del botón Grabar no represente un disco si no un hombre prehistórico cincelando una piedra. La primera vez que el usuario escriba su documento y desee grabarlo irá a buscar el botón de grabar, lo más lógico sería que buscase un disco y seguramente tarde un tiempo en encontrar el botón adecuado. Cuando se diseña un interface de usuario se busca que sea similar a otras aplicaciones: los botones de grabar contienen la imagen de un disco, los de nuevo documento una hoja en blanco, los de formato en negrita una B mayúscula (o una N si están en inglés)… Se intenta constantemente que cuando el usuario se enfrente por primera vez a la aplicación encuentre un entorno familiar, que no se “aturda”, en tres palabras: “minimizar el aturdimiento”.</span><br />
<span>¿Qué tiene que ver esto con la normalización de código? En nuestro trabajo el 90% del tiempo lo pasamos viendo diverso tipo de código, de diferentes aplicaciones o de diferentes módulos de la misma aplicación. Lo normal es que al cabo del tiempo veamos tanto código propio como de nuestros compañeros de equipo, cada archivo con un estilo diferente (incluso aunque provenga del mismo programador), distintas tabulaciones, diferentes formas de nombrar las variables, todo esto implica que nos lleve un tiempo más o menos largo poder leer el código y saber lo que está haciendo y un tiempo aún más largo ser capaces de modificarlo. En resumen: estamos tan “aturdidos” como el usuario al que hemos cambiado los gráficos de los botones.</span></p>
<p><span>Parte del trabajo, quizá el más importante, de la normalización del código es precisamente minimizar las diferencias de trabajo y proporcionar un entorno sensato para que el periodo de adaptación sea mínimo y facilite tanto la programación de nuevo código como el mantenimiento del antiguo. En pocas palabras, nuestro esfuerzo se dirige a minimizar el aturdimiento producido al leer código.</span></p>
<h1><strong><font FACE="Verdana"><span><font SIZE="3">Nombres de variables: u</font></span><span><font SIZE="3">nicidad y significado</font></span></font></strong></h1>
<p><span>Imaginemos que tenemos una serie de funciones en un programa en C# que graban los datos de un pedido, antes de ello, calcula el saldo a partir de las líneas:</span></p>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   1:</span> <span>public</span> <span>void</span> Save(clsPedido op)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   2:</span> { ComputeLines(op);</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   3:</span>   op.Save();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   4:</span> }</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   5:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   6:</span> <span>public</span> <span>void</span> ComputeOrder(clsPedido o)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   7:</span> { o.Saldo = ComputeLines(o);</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   8:</span> }</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   9:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  10:</span> <span>public</span> <span>int</span> ComputeLines(clsPedido ope)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  11:</span> { colLineas op = ope.LoadLines();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  12:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  13:</span>     <span>return</span> ope.SumLines();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  14:</span> }</font></pre>
<p STYLE="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0" CLASS="MsoNormal"><span>En el código anterior, las tres funciones utilizan una clase que mantiene el pedido (<em>clsPedido</em>), sin embargo, las tres funciones llaman a sus variables de forma diferente, en la primera se llama <em>op</em>, en la segunda <em>o</em> y en la tercera <em>ope</em>. Además, la tercera función utiliza de nuevo la variable <em>op</em> pero no para nombrar una variable de tipo <em>clsPedido</em> si no para identificar una variable de tipo <em>colLineas</em>. </span></p>
<p><span>El programa es corto, no existe demasiado espacio para la confusión, pero ya hemos utilizado tres nombres de variables diferentes, cada vez que entremos a modificar una función tendremos que buscar cómo se llama la variable que identifica nuestro pedido antes de poder siquiera empezar a pensar en modificarla.</span></p>
<p><span>La solución en este caso es muy sencilla, si vamos a utilizar una variable para identificar un objeto lo lógico es utilizar siempre el mismo nombre de variable:</span></p>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   1:</span> <span>public</span> <span>void</span> Save(clsPedido op)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   2:</span> {   ComputeLines(op);</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   3:</span>     op.Save();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   4:</span> }</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   5:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   6:</span> <span>public</span> <span>void</span> ComputeOrder(clsPedido op)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   7:</span> { op.Saldo = ComputeLines(op);</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   8:</span> }</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   9:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  10:</span> <span>public</span> <span>int</span> ComputeLines(clsPedido op)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  11:</span> { colLineas ol = op.LoadLines();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  12:</span>  </font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  13:</span>     <span>return</span> ol.SumLines();</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>  14:</span> }</font></pre>
<p STYLE="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0" CLASS="MsoNormal"><span>En esta ocasión sabremos que la variable que representa nuestro pedido se llama <em>op</em> mientras que la variable que representa las líneas se llama <em>ol</em>. Con algo tan simple hemos conseguido dos cosas fundamentales: en primer lugar que cada vez que entramos a una función sabemos cómo se llaman nuestras variables, en segundo lugar, si entramos en otra parte del programa y encontramos una variable denominada <em>op</em> podemos llegar a suponer que se trata de un objeto relacionado con un pedido. Esto además nos lleva a un efecto lateral que facilita un poco más el trabajo: evitamos pensar cómo tenemos que llamar un nuevo objeto de tipo <em>clsPedido</em> cuando creemos una nueva función, la elección es simple: se llamará <em>op</em>.</span></p>
<p><span>Por supuesto tenemos un pequeño problema, <em>op</em> es fácil de escribir y ligeramente sencillo de recordar pero tiene un significado cuando menos difuso, se podría referir también a la clase <em>clsProveedor</em>, por ejemplo. Debemos intentar que nuestros nombres tengan significado, que nos digan algo. ¿Y si en lugar de utilizar <em>op</em> como nombre de variable para la clase <em>clsPedido</em> utilizáramos algo más significativo como por ejemplo <em>objPedido</em>? Con este cambio conseguimos que el código sea más legible y más fácil de recordar.</span></p>
<p><span>Además podemos establecer una norma: inicialmente todos los nombres de objetos comenzarán por el prefijo <em>obj</em> y les seguirá el nombre de la clase a la que se representa. Así para la clase <em>clsPedido</em> tendremos variables que se llamarán <em>objPedido</em>, para la clase <em>clsProveedor</em> variables con el nombre <em>objProveedor</em>, para la clase <em>clsCliente</em> variables con el nombre <em>objCliente</em>.</span></p>
<p><span>Pero ¿qué ocurre cuando en una función utilizamos más de una variable de una clase? No podemos definir dos veces un nombre de variable idéntico dentro de la misma función pero sí podemos añadir un sufijo a esa variable para que nos amplíe el significado. Así por ejemplo si tenemos una función en la que se copien los datos de un pedido en otro podemos utilizar los nombres de variables <em>objPedidoOrigen</em> y <em>objPedidoDestino</em>:</span></p>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   1:</span> <span>public</span> <span>void</span> Copy(clsPedido objPedidoOrigen, clsPedido objPedidoDestino)</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   2:</span> { objPedidoDestino.Precio = objPedidoOrigen.Precio;</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #ffffff; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   3:</span>   objPedidoDestino.Unidades = objPedidoOrigen.Unidades;</font></pre>
<pre STYLE="font-size: 8pt; overflow: visible; width: 100%; color: #000000; line-height: 12pt; background-color: #f4f4f4; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0"><font FACE="Verdana"><span>   4:</span> }</font></pre>
<p><span><font FACE="Verdana">De esta forma además de identificar nuestra variable y saber que <em>objPedidoOrigen</em> es de tipo <em>clsPedido</em> puesto que sigue nuestra normativa de nombres, también sabemos que es la fuente de los datos mientras que <em>objPedidoDestino</em> representa el pedido sobre el que se van a copiar los datos.</font></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jbautistam.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jbautistam.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbautistam.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbautistam.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbautistam.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=20&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbautistam.wordpress.com/2007/08/31/normalizacin-de-cdigo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7ad12ba59b991ea29dedff0b46d2c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jbautistam</media:title>
		</media:content>
	</item>
		<item>
		<title>Hola mundo!</title>
		<link>http://jbautistam.wordpress.com/2006/08/18/hola-mundo/</link>
		<comments>http://jbautistam.wordpress.com/2006/08/18/hola-mundo/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 07:36:04 +0000</pubDate>
		<dc:creator>jbautistam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jbautistam.wordpress.com/2006/08/18/hola-mundo/</guid>
		<description><![CDATA[De acuerdo, el título del envío lo dice todo: soy programador. Sobre todo programador. Además analista y jefe de proyecto en ciernes pero lo que más me gusta es programar. En mi blog por tanto intentaré hablar de tres temas principales: programación, arquitectura de software&#160;y dirección de proyectos, aunque no descarto hablar también de tecnología [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=8&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>De acuerdo, el título del envío lo dice todo: soy programador. Sobre todo programador. Además analista y jefe de proyecto en ciernes pero lo que más me gusta es programar.</p>
<p>En mi blog por tanto intentaré hablar de tres temas principales: programación, arquitectura de software&nbsp;y dirección de proyectos, aunque no descarto hablar también de tecnología en general, aplicaciones, software libre, etc&#8230; </p>
<p>Por supuesto se aceptan críticas, nuevos temas y sobre todo comentarios. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jbautistam.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jbautistam.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jbautistam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jbautistam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jbautistam.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jbautistam.wordpress.com&amp;blog=336754&amp;post=8&amp;subd=jbautistam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jbautistam.wordpress.com/2006/08/18/hola-mundo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fb7ad12ba59b991ea29dedff0b46d2c1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jbautistam</media:title>
		</media:content>
	</item>
	</channel>
</rss>
