<?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>Alexander Zerr &#187; Programmieren</title>
	<atom:link href="http://www.xelaz.de/tag/programmieren/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xelaz.de</link>
	<description>Meine Erfahrungen in der Web Entwicklung</description>
	<lastBuildDate>Mon, 19 Jul 2010 15:05:31 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Eine Zeile reicht auch aus</title>
		<link>http://www.xelaz.de/eine-zeile-reicht-auch-aus/</link>
		<comments>http://www.xelaz.de/eine-zeile-reicht-auch-aus/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 17:56:55 +0000</pubDate>
		<dc:creator>Alexander Zerr</dc:creator>
				<category><![CDATA[Tipps]]></category>
		<category><![CDATA[Programmieren]]></category>

		<guid isPermaLink="false">http://www.xelaz.de/?p=38</guid>
		<description><![CDATA[Es gibt viele Möglichkeiten einen Kurzen Code zu schrieben, ein paar werde ich hier zeigen. Solche Techniken kann man in vielen Programmier Sprachen einsetzen. Durch diese Abkürzungen spart man zum Beispiel im JavaScript an Download Trafic, was bei großer anzahl an Anfragen schon was rein bringt.
Kleiner Rechen Beispiel: Man kürzt den Script sagen wir mal [...]]]></description>
			<content:encoded><![CDATA[<p>Es gibt viele Möglichkeiten einen Kurzen Code zu schrieben, ein paar werde ich hier zeigen. Solche Techniken kann man in vielen Programmier Sprachen einsetzen. Durch diese Abkürzungen spart man zum Beispiel im JavaScript an Download Trafic, was bei großer anzahl an Anfragen schon was rein bringt.<br />
Kleiner Rechen Beispiel: Man kürzt den Script sagen wir mal um 8 Bytes das können schon Acht Buchstaben sein. Beim einem Request ist es lächerlich, bei 1000 auch bei einer Million werden es schon 7,8 Mb. Wenn man jetzt aber ein paar Zeilen an Code ersetzt, kann es bei den Größten wie Google und Youtube schon an Tb an Trafic pro Monat ein Sparren. Aber bei den Flatrates ist es eigentlich egal.<br />
Der andere Vorteil ist bei manchen Abkürzungen ist, dass der Code etwas schneller abgearbeitet werden kann. Der Nachteil ist, dass die Leserlichkeit etwas leidet für die die nicht so Fit im Coden sind.</p>
<p>Hier sind ein paar:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> isEqual <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>a == b<span style="color: #66cc66;">&#41;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>;
 <span style="color: #000066; font-weight: bold;">else</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>ersetzt durch</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> isEqual <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>a == b ? <span style="color: #003366; font-weight: bold;">true</span> : <span style="color: #003366; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>
&nbsp;
oder
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> isEqual <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>a == b<span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
 <span style="color: #ff0000">$a</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$myClass</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">getA</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
 <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$a</span> <span style="color: #66cc66;">!=</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$a</span><span style="color: #66cc66;">;</span>
 <span style="color: #b1b100;">else</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">;</span> 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>ersetzt durch</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
 <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$a</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$myClass</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">getA</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!=</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$a</span><span style="color: #66cc66;">;</span>
 <span style="color: #b1b100;">else</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">;</span> 
<span style="color: #66cc66;">&#125;</span>
&nbsp;
oder
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$a</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$myClass</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">getA</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!=</span> <span style="color: #000000; font-weight: bold;">null</span> ? <span style="color: #ff0000">$a</span> <span style="color: #66cc66;">:</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>
Nur Javascript</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> getTime <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
 <span style="color: #003366; font-weight: bold;">var</span> d = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #000066; font-weight: bold;">return</span> d.<span style="color: #006600;">getTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>ersetzt durch</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> getTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Durch die () Klammern setzt man eine Verschachtelung die dann direkt weiter bearbeitet oder genutzt werden kann. </p>
<p>Und noch ein Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> eventHandler<span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> evt,elm;
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span>
  evt = e;
 <span style="color: #000066; font-weight: bold;">else</span> 
  evt = window.<span style="color: #006600;">event</span>
&nbsp;
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>evt.<span style="color: #006600;">target</span><span style="color: #66cc66;">&#41;</span>
  elm= evt.<span style="color: #006600;">target</span>;
 <span style="color: #000066; font-weight: bold;">else</span> 
  elm = evt.<span style="color: #006600;">srcElement</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>ersetzt durch</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> eventHandler<span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> evt = e <span style="color: #66cc66;">||</span>window.<span style="color: #006600;">event</span>;
 <span style="color: #003366; font-weight: bold;">var</span> elm = evt.<span style="color: #006600;">target</span> <span style="color: #66cc66;">||</span> evt.<span style="color: #006600;">srcElement</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Diese Techniken sind sehr schnell beim Schreiben als auch beim Interpretieren. Beim schnellen Coden fahlen sie aber nicht sofort ein. Nach dem man aber den Code Entwickelt hat, merkt man beim durchschauen, dass solche Techniken schon da reinpassen würden.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xelaz.de/eine-zeile-reicht-auch-aus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
