<?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>CODIGO.actionscript &#187; polimorfismo</title>
	<atom:link href="http://www.codigoactionscript.org/tag/polimorfismo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codigoactionscript.org</link>
	<description>Blog de programación en ActionScript. Tips, tutoriales, ejemplos de Adobe Flash, Flex y AIR</description>
	<lastBuildDate>Fri, 30 Sep 2011 11:25:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>POO: Dependencia de clases y Polimorfismo</title>
		<link>http://www.codigoactionscript.org/poo-dependencia-de-clases-y-polimorfismo/</link>
		<comments>http://www.codigoactionscript.org/poo-dependencia-de-clases-y-polimorfismo/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 02:26:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[patrones]]></category>
		<category><![CDATA[polimorfismo]]></category>
		<category><![CDATA[POO]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=377</guid>
		<description><![CDATA[<p>La dependencia de clases es un concepto de la programación orientada a objetos que nos indica la relación existente entre dos clases. Como su nombre indica nos está diciendo que una clase depende de otra ara realizar su funcionamiento.</p>
<p>Cuando trabajamos con clases es una buena práctica que una clase realice una única función. De manera que las clases que deban realizar funciones complejas estarán formadas a partir de una asociación de diversas pequeñas clases en las que delegará cada funcionalidad en concreto.</p>
<p>Este sería un ejemplo simple de una relación de [...]
Related posts:<ol>
<li><a href='http://www.codigoactionscript.org/programacion-orientada-a-objetos-herencia-de-clases/' rel='bookmark' title='Programación orientada a objetos: Herencia de clases.'>Programación orientada a objetos: Herencia de clases.</a></li>
<li><a href='http://www.codigoactionscript.org/asignar-codigo-actionscript-en-clases-a-fotogramas-concretos/' rel='bookmark' title='Asignar código actionscript en clases a fotogramas concretos'>Asignar código actionscript en clases a fotogramas concretos</a></li>
<li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>La <strong>dependencia de clases</strong> es un concepto de la <a href="http://www.cristalab.com/tips/tags/poo">programación orientada a objetos</a> que nos indica la relación existente entre dos clases. Como su nombre indica nos está diciendo que una clase <em>depende</em> de otra ara realizar su funcionamiento.</p>
<p>Cuando trabajamos con clases es una buena práctica que una clase realice una única función. De manera que las clases que deban realizar funciones complejas estarán formadas a partir de una <strong>asociación</strong> de diversas pequeñas clases en las que <strong>delegará</strong> cada funcionalidad en concreto.</p>
<p>Este sería un ejemplo simple de una relación de <strong>asociación</strong> y de <strong>delegación</strong> entre clases:</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-9"><a href="#" onclick="javascript:showPlainTxt('actionscript-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-9">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Foro</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _moderador:Zguillez;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Foro<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _moderador = <span style="color: #000000; font-weight: bold;">new</span> Zguillez<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> moderar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _moderador.<span style="color: #006600;">moderar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Aqui vemos como la clase "Foro" está delegando toda la funcionalidad del método "moderar" al objeto de clase "Zguillez", haciendo de esta manera que toda la implementación esté en esa clase dejando la clase principal más limpia y ordenada. Esto nos permite una mayor reutilización de nuestras clases.</p>
<p>El problema que nos encontramos aquí es que se ha creado una relación de dependencia muy grande entre estas dos clases. La clase "Foro" tiene una referencia directa a la clase "Zguillez" y necesita estrictamente de esa clase para funcionar.</p>
<p>De manera que si tuviésemos (por requisitos de la aplicación o por reutilización del código) que cambiar la implementación de la función "moderar" tendríamos que reescribir la la clase "Zguillez" para cambiar su implementación concreta o resescribir la clase "Foro" para delegar esa función a la clase "Zah" (por ejemplo). Con lo que hace estas clases poco reutilizables...</p>
<p>Esta dependencia la podemos romper gracias al <strong>Polimorfismo</strong> de las clases. El polimorfismo es la propiedad que tienen las clases de ocultar la estructura interna en una jerarquía de clases, implementando de manera diferente un mismo método. El polimorfismo nos permite que una identificación se refiera a diferentes entidades.</p>
<p>En este caso haremos que "moderador" se pueda referir tanto a "Zguillez" como a "Zah". Este polimorfismo lo podemos conseguir gracias a la <a href="http://www.codigoactionscript.org/category/POO">=http://www.codigoactionscript.org/category/POO</a>herencia de clases[/url] o a la implementación de una <strong>Interface</strong>.</p>
<p>Definiremos una Interface que contendrá las funciones que estamos delegando a la clase asociada. En este caso sería así:</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-10"><a href="#" onclick="javascript:showPlainTxt('actionscript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-10">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IModerador</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> moderar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Ahora asociaremos el objeto a la Interface en lugar de a una clase en concreto:</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-11"><a href="#" onclick="javascript:showPlainTxt('actionscript-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-11">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _moderador:IModerador; </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Tendremos que hacer que tanto la clase "Zguillez" como la clase "Zah" implementen la Interface "IModerador".</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-12"><a href="#" onclick="javascript:showPlainTxt('actionscript-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-12">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Zguillez <span style="color: #0066CC;">implements</span> IModerador </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-13"><a href="#" onclick="javascript:showPlainTxt('actionscript-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-13">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Zah <span style="color: #0066CC;">implements</span> IModerador </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>De manera que ahora podemos asociar cualquiera de las dos clases a la propiedad "moderador".</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-14"><a href="#" onclick="javascript:showPlainTxt('actionscript-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-14">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">_moderador = <span style="color: #000000; font-weight: bold;">new</span> Zguillez<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// o _moderador = new Zah(); </span></div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Gracias al polimorfismo hemos ganado en dinamismo y reutilizabilidad, ya que podemos hacer que nuestra aplicación la "modere" Zguillez o Zah según nos interese.</p>
<p>Pero en este punto aun no nos hemos liberado de la dependencia de clases, ya que la clase que realiza la delegación está escrita en la implementación de la clase. Con lo que si quisiésemos cambiar la clase en la que delegamos tendríamos que rescribir la clase para colocar la otra.</p>
<p>Esto lo solucionamos con lo que se llama "<strong>Inyección de dependencias</strong>", que consiste en insertar los objetos a la clase en lugar de que sea la clase la que cree el objeto.</p>
<p>Haremos que la clase "Foro" no genere directamente el objeto que realizará la delegación sino que ese objeto le venga <em>inyectado</em>.</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-15"><a href="#" onclick="javascript:showPlainTxt('actionscript-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-15">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Foro</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _moderador:IModerador;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Foro<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> moderador<span style="color: #66cc66;">&#40;</span>m:IModerador<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _moderador = m;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> moderar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _moderador.<span style="color: #006600;">moderar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Para inyectarle la dependencia utilizaremos el <em>setter</em>.</p>
<div id="codigo">
<div class="igBar"><span id="lactionscript-16"><a href="#" onclick="javascript:showPlainTxt('actionscript-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-16">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> foro:Foro = <span style="color: #000000; font-weight: bold;">new</span> Foro<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">foro.<span style="color: #006600;">moderador</span> = <span style="color: #000000; font-weight: bold;">new</span> Zguillez<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">foro.<span style="color: #006600;">moderar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>De esta manera hemos conseguido que la clase "Foro" sea totalmente independiente de las clases que vayan a realizar la delegación haciendo el sistema totalmente reutilizable sin tener que realizar cambios en las clases existentes.</p>
<p>Related posts:<ol>
<li><a href='http://www.codigoactionscript.org/programacion-orientada-a-objetos-herencia-de-clases/' rel='bookmark' title='Programación orientada a objetos: Herencia de clases.'>Programación orientada a objetos: Herencia de clases.</a></li>
<li><a href='http://www.codigoactionscript.org/asignar-codigo-actionscript-en-clases-a-fotogramas-concretos/' rel='bookmark' title='Asignar código actionscript en clases a fotogramas concretos'>Asignar código actionscript en clases a fotogramas concretos</a></li>
<li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/poo-dependencia-de-clases-y-polimorfismo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

