<?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>Burak IŞIKLI :))</title>
	<atom:link href="http://burakisikli.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://burakisikli.wordpress.com</link>
	<description>Impossible is nothing</description>
	<lastBuildDate>Thu, 13 Aug 2009 23:50:51 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>tr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='burakisikli.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/5af9f2ad9d4489c91efef4851888d89d?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Burak IŞIKLI :))</title>
		<link>http://burakisikli.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://burakisikli.wordpress.com/osd.xml" title="Burak IŞIKLI :))" />
		<item>
		<title>Google App Engine Java İpuçları</title>
		<link>http://burakisikli.wordpress.com/2009/08/14/google-app-engine-java-ipuclari/</link>
		<comments>http://burakisikli.wordpress.com/2009/08/14/google-app-engine-java-ipuclari/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 23:50:51 +0000</pubDate>
		<dc:creator>Burak IŞIKLI</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Engine]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google App Engine]]></category>

		<guid isPermaLink="false">http://burakisikli.wordpress.com/?p=227</guid>
		<description><![CDATA[Google, geçtiğimiz günlerde app engine yani uygulama sunucusunu piyasaya sürdü. İlk izlenimlerimin ardından app engine ile ilgili birkaç detay vermek istedim. Yemek tarzındaki kurulumu birçok sitede kurulumun nasıl yapılacağını bulmanız mümkün. Ben de ayrıca java programcıları ve teknolojileri derneği tarafından yayınlanmış sitenin pdf dosyasını veriyorum.
Kurulumu yapıp örnek bir proje oluşturduktan sonra uygulamanın nasıl çalıştığını anlayalım. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=227&subd=burakisikli&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Google, geçtiğimiz günlerde <a href="http://code.google.com/appengine/" target="_blank">app engine</a> yani uygulama sunucusunu piyasaya sürdü. İlk izlenimlerimin ardından app engine ile ilgili birkaç detay vermek istedim. Yemek tarzındaki kurulumu birçok sitede kurulumun nasıl yapılacağını bulmanız mümkün. Ben de ayrıca java programcıları ve teknolojileri derneği tarafından yayınlanmış sitenin <a href="http://burakisikli.files.wordpress.com/2009/08/google-app-engine.pdf" target="_blank">pdf dosyasını </a>veriyorum.</p>
<p>Kurulumu yapıp örnek bir proje oluşturduktan sonra uygulamanın nasıl çalıştığını anlayalım. Öncelikle deploy yapmadan projeniz web&#8217;e atılmaz. Bu nedenle de yerel alanda istediğiniz kadar değişiklik yaparken asıl sayfanız(belirttiğinizad.appspot.com) herhangi bir değişiklik olmaz.</p>
<p>Her zaman belirttiğiniz proje isminin servlet&#8217;i oluşturuluyor. Örneğin deneme diye proje oluşturuyorsanız servlet&#8217;inizin adı otomatik olarak denemeServlet oluyor. Peki bunu nasıl değiştireceğiz? Refactor kullanmanız ismini değiştirmek için yeterli gelmiyor. Bunu deneyip deploy ederseniz karşınıza boş bir sayfa çıkacaktır. Bildiğiniz üzere bu servlet&#8217;imizin bağlı olduğu web.xml dosyası olması gerekiyor. İşte bu dosya war klasörünün altındaki web-inf klasöründedir. Aşağıdakine benzer bir dosya karşınıza gelecektir.</p>
<p><strong>web.xml</strong></p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; version=&quot;2.5&quot;&gt;
 &lt;servlet&gt;
 &lt;servlet-name&gt;Deneme&lt;/servlet-name&gt;
 &lt;servlet-class&gt;edu.burakkk.google.app.DenemeServlet&lt;/servlet-class&gt;
 &lt;/servlet&gt;
 &lt;servlet-mapping&gt;
 &lt;servlet-name&gt;Deneme&lt;/servlet-name&gt;
 &lt;url-pattern&gt;/deneme&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;
 &lt;welcome-file-list&gt;
 &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
 &lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<p>Buradan servlet-class ismini de değiştirerek servlet isminde kolayca değişiklik yapabilirsiniz. Ayrıca url-pattern ile servletinizin çalışacağı uzantıyı da değiştirebilirsiniz. deneme yerine deneme.do yapabilirsiniz. Başlangıçta google app engine tarafından oluşturulan index.html yerine de welcome-file değiştirerek de kendi istediğiniz dosyayı hatta çalıştıracağınız servlet&#8217;i yapabilirsiniz. Bunun anlamı xxx.appspot.com sayfasını açtığınızda kendi tarafından oluşturulmuş index sayfası yerine sizin sayfanız çıkabilir.</p>
<p>Eğer uygulama ismini veya versiyonu değiştirmek istiyorsanız aynı dizindeki(war/web-inf) appengine-web.xml dosyasından yapacaksınız.</p>
<p><strong>appengine-web.xml</strong></p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
 &lt;application&gt;bisikli&lt;/application&gt;
 &lt;version&gt;1&lt;/version&gt;

 &lt;!-- Configure java.util.logging --&gt;
 &lt;system-properties&gt;
&lt;property name=&quot;java.util.logging.config.file&quot; value=&quot;WEB-INF/logging.properties&quot;/&gt;
 &lt;/system-properties&gt;

&lt;/appengine-web-app&gt;
</pre>
<p>Application kısmından uygulama ismini versiyon kısmından da versiyonunu değiştirebilirsiniz.</p>
<p>Bunları dikkate alarak anasayfamızda gerçek ip&#8217;nizi çıkaran bir servlet yapalım.</p>
<p>edu.burakkk.google.app isimli paket ipAlma isimli servlet yaratıyoruz.</p>
<p><strong>ipAlma.java</strong></p>
<pre class="brush: java;">

package edu.burakkk.google.app;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.*;

@SuppressWarnings(&quot;serial&quot;)
public class ipAlma extends HttpServlet {
 public void doGet(HttpServletRequest req, HttpServletResponse resp)
 throws IOException {
 resp.setContentType(&quot;text/html&quot;);
 PrintWriter out = resp.getWriter();
 out.println(&quot;IP: &quot; + req.getRemoteHost());
 out.flush();
 out.close();
 }
}
</pre>
<p><strong>web.xml</strong></p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; version=&quot;2.5&quot;&gt;
 &lt;servlet&gt;
 &lt;servlet-name&gt;ipAlma&lt;/servlet-name&gt;
 &lt;servlet-class&gt;edu.burakkk.google.app.ipAlma&lt;/servlet-class&gt;
 &lt;/servlet&gt;
 &lt;servlet-mapping&gt;
 &lt;servlet-name&gt;ipAlma&lt;/servlet-name&gt;
 &lt;url-pattern&gt;/ipAlma&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;
 &lt;welcome-file-list&gt;
 &lt;welcome-file&gt;ipAlma&lt;/welcome-file&gt;
 &lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<p>Bu projeyi deploy ettiğinizde anasayfanızda IP: XXXXX şeklinde ip&#8217;nizi yazan bir web sayfası çıkacaktır. Örnek sayfaya <a href="http://bisikli.appspot.com/" target="_blank">http://bisikli.appspot.com/</a>(sizinUygulamaAdınız.appspot.com) adresinden ulaşabilirsiniz. Ayrıca aynı sayfaya servlet&#8217;mize <a href="http://bisikli.appspot.com/ipAlma" target="_blank">http://bisikli.appspot.com/ipAlma</a> bu adresle de ulaşabiliriz.</p>
Posted in Java Tagged: App, Engine, Google, Google App Engine, Java <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burakisikli.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burakisikli.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burakisikli.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burakisikli.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burakisikli.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burakisikli.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burakisikli.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burakisikli.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burakisikli.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burakisikli.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=227&subd=burakisikli&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://burakisikli.wordpress.com/2009/08/14/google-app-engine-java-ipuclari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d297c033bacffbd3953502202ebc2602?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">burakkk</media:title>
		</media:content>
	</item>
		<item>
		<title>Dinamik Programlama(Dynamic Programming)</title>
		<link>http://burakisikli.wordpress.com/2009/08/14/dinamik-programlamadynamic-programming/</link>
		<comments>http://burakisikli.wordpress.com/2009/08/14/dinamik-programlamadynamic-programming/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 23:00:16 +0000</pubDate>
		<dc:creator>Burak IŞIKLI</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Dinamik]]></category>
		<category><![CDATA[Dinamik Programlama]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[Optimal Substructure]]></category>
		<category><![CDATA[Overlapping Subproblems]]></category>
		<category><![CDATA[Programlama]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rekürsif]]></category>
		<category><![CDATA[Serisi]]></category>

		<guid isPermaLink="false">http://burakisikli.wordpress.com/?p=220</guid>
		<description><![CDATA[inamik programlama bir problemi çözerken aynı alt-problemi birden fazla çözmemiz gereken durumlarda bu alt-problemi birden fazla kez çözmemizi engelleyen bir tekniktir. Dinamik programalama, matematik ve bilgisayar bilimler
inde karmaşık problemleri çözmek için kullanılan bir metottur. Overlapping subproblems ve optimal substructure denilen problemlerde uygunabiliyor.
Eğer problemimiz kendi içinde alt problemlere ayrılabiliyorsa overlapping subproblems&#8217;dir. Buna en iyi örnek Fibanicci [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=220&subd=burakisikli&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>inamik programlama bir problemi çözerken aynı alt-problemi birden fazla çözmemiz gereken durumlarda bu alt-problemi birden fazla kez çözmemizi engelleyen bir tekniktir. Dinamik programalama, matematik ve bilgisayar bilimler</p>
<p>inde karmaşık problemleri çözmek için kullanılan bir metottur. <a title="Overlapping subproblem" href="http://en.wikipedia.org/wiki/Overlapping_subproblem">Overlapping subproblems</a> ve <a title="Optimal substructure" href="http://en.wikipedia.org/wiki/Optimal_substructure">optimal substructure</a> denilen problemlerde uygunabiliyor.<a title="Optimal substructure" href="http://en.wikipedia.org/wiki/Optimal_substructure"></a></p>
<p>Eğer problemimiz kendi içinde alt problemlere ayrılabiliyorsa overlapping subproblems&#8217;dir. Buna en iyi örnek Fibanicci serisidir. Daha önceden <a href="http://burakisikli.wordpress.com/2009/06/15/fibonacci-serisi/" target="_blank">bu yazımda</a> fibonacci serisini anlatmıştım.</p>
<p><img class="alignleft size-full wp-image-221" title="Shortest Path Optimal Substructure" src="http://burakisikli.files.wordpress.com/2009/08/shortest_path_optimal_substructure.png?w=200&#038;h=107" alt="Shortest Path Optimal Substructure" width="200" height="107" />Fakat problemimiz kendi içinde alt problemlere ayrıldığında daha iyi bir performans sağlıyorsa buna optimal substructure deniliyor. Buna en iyi örnek ise greedy algoritmasıdır. Dinamik programlamada geçen programlama sözcüğü sadece bilgisayar programlarını kapsamamaktadır, çünkü burada kullandığımız program sözcüğü “matematiksel programlama” dan gelmektedir, ki bu da kısaca sıkça kullandığımız optimizasyon(bir nevi iyileştirme demek optimizasyon belki kullanmayan da vardır <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  kelimesine denk gelmektedir.</p>
<p>Dinamik programlama uygulamalarımızda temel olarak 3 teknikten faydalanacağız:</p>
<ul>
<li>Çözümü aynı olan alt-problemler</li>
<li>Büyük bir problemi küçük parçalara bölmek ve bu küçük parçaları kullanarak baştaki büyük problemimizin sonucuna ulaşmak</li>
<li>Çözdüğümüz her alt-problemin sonucunu bir yere not almak ve gerektiğinde bu sonucu kullanarak aynı problemi tekrar tekrar çözmeyi engellemek.</li>
</ul>
<p>Şimdi örneğimiz olan fibonacci dizimize başlayalım. Fibonacci dizimizi kısaca bir hatırlayalım.</p>
<p>Eğer herhangi bir sayının Fibonacci karşılığına F(n) dersek,</p>
<p>F(0) = F(1) = 1 olmak üzere</p>
<p>F(n) = F(n-1) + F(n-2)&#8217;dir.</p>
<p>İlk yaptığımız prosesimizin fonksiyonunu hatırlayalım:</p>
<p><strong>fib.cpp</strong></p>
<pre class="brush: cpp;">
// Recursive Function
int fib(int num) {
 if ((num == 0) || (num == 1))
 return num;
 else
 return (fib(num - 1) + fib(num - 2));
}
</pre>
<p>Bu kadar kısa bir kod yazarak çözümü sağlamıştık. Ancak bu yöntem kodun kısa olmasına rağmen performans açısından kötü bir yöntemdir.  Nedenine gelirsek mesela F(3)&#8217;ü adım adım hesaplayalım:</p>
<p>F(4) = (F(2) + F(1)))</p>
<p>= ((F(1) + F(0)) + F(1)) + F(2)</p>
<p>= ((F(1) + F(0)) + F(1)) + (F(1) + F(0))</p>
<p>Görüldüğü gibi F(4) değerini hesaplarken F(1)&#8217;ye 2 defa ihtiyacımız oldu ama 2 seferde de hesapladık. Prosesimizi değiştirerek bir de şu hale getirelim.</p>
<p><strong>fib2.cpp</strong></p>
<pre>
<pre class="brush: cpp;">
/*
 *
 * Program:  Fibonacci Series v2
 * Programmer: Burak ISIKLI
 *
 */

#include &lt;iostream.h&gt;

unsigned int fib2(unsigned int num);

unsigned int fibArray[1000];

// Main Function
int main() {
 unsigned int number, result;
 cout &lt;&lt; &quot;Fibonacci serisinin(fib(x)) sayisini giriniz x = &quot;;
 cin &gt;&gt; number;

 result = fib2(number);
 cout &lt;&lt; &quot;fib( &quot; &lt;&lt; number &lt;&lt; &quot; ) = &quot; &lt;&lt; result &lt;&lt; &quot;\n\n&quot;;

 return 0;
}

unsigned int fib2(unsigned int num)
{
 unsigned int i = 2;
 fibArray[0] = fibArray[1] = 1;
 while(i &lt;= num)
 {
 fibArray[i] = fibArray[i - 1] + fibArray[i - 2];
 i++;
 }
 return fibArray[num];
}
</pre>
</pre>
<p>Burada yaptığımız işlem ise şu. Hesapladığımız Fibonacci sayılarını bir diziye kaydediyoruz. Daha sonra lazım olunca bu değerleri direkt diziden hazır bi şekilde alıyoruz. Böylece aynı işlemi tekrar tekrar yapmaktan kurtuluyoruz.</p>
<p>Performans karşılaştırması yapacak olursak kendi bilgisayarımda fibonacci(50) 8dk. 36 sn&#8217;de sonuç verirken fibonacci2(50) 0.003 sn&#8217;de sonuç veriyor. Daha bilimsel konuşacak olursak problemi temelde aynı mantıkla çalışan iki fonksiyonun birincisi O(2^n) iken ikincisi O(n) zamanda çözmektedir.</p>
<p><strong>Kaynaklar:</strong></p>
<p><a href="http://en.wikipedia.org/wiki/Dynamic_programming" target="_self">http://en.wikipedia.org/wiki/Dynamic_programming</a></p>
<p><a href="http://en.wikipedia.org/wiki/Optimal_substructure" target="_blank">http://en.wikipedia.org/wiki/Optimal_substructure</a></p>
<p><a href="http://e-bergi.com/2008/Mart/Dinamik-Programlama" target="_blank">http://e-bergi.com/2008/Mart/Dinamik-Programlama</a></p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:1557px;width:1px;height:1px;">
<pre>
<pre class="brush: cpp;">
/*
 *
 * Program:  Fibonacci Series v2
 * Programmer: Burak ISIKLI
 *
 */

#include &lt;iostream.h&gt;

unsigned int fib2(unsigned int num);

unsigned int fibArray[1000];

// Main Function
int main() {
 unsigned int number, result;
 cout &lt;&lt; &quot;Fibonacci serisinin(fib(x)) sayisini giriniz x = &quot;;
 cin &gt;&gt; number;

 result = fib2(number);
 cout &lt;&lt; &quot;fib( &quot; &lt;&lt; number &lt;&lt; &quot; ) = &quot; &lt;&lt; result &lt;&lt; &quot;\n\n&quot;;

 return 0;
}

unsigned int fib2(unsigned int num)
{
 unsigned int i = 2;
 fibArray[0] = fibArray[1] = 1;
 while(i &lt;= num)
 {
 fibArray[i] = fibArray[i - 1] + fibArray[i - 2];
 i++;
 }
 return fibArray[num];
}
</pre>
</pre>
</div>
Posted in Algorithm, C/C++ Tagged: Dinamik, Dinamik Programlama, Dynamic, Fibonacci, Optimal Substructure, Overlapping Subproblems, Programlama, Programming, Rekürsif, Serisi <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burakisikli.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burakisikli.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burakisikli.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burakisikli.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burakisikli.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burakisikli.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burakisikli.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burakisikli.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burakisikli.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burakisikli.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=220&subd=burakisikli&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://burakisikli.wordpress.com/2009/08/14/dinamik-programlamadynamic-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d297c033bacffbd3953502202ebc2602?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">burakkk</media:title>
		</media:content>

		<media:content url="http://burakisikli.files.wordpress.com/2009/08/shortest_path_optimal_substructure.png" medium="image">
			<media:title type="html">Shortest Path Optimal Substructure</media:title>
		</media:content>
	</item>
		<item>
		<title>Web Service ile Sıcaklık Dönüşümü</title>
		<link>http://burakisikli.wordpress.com/2009/07/29/web-service-ile-sicaklik-donusumu/</link>
		<comments>http://burakisikli.wordpress.com/2009/07/29/web-service-ile-sicaklik-donusumu/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 00:06:36 +0000</pubDate>
		<dc:creator>Burak IŞIKLI</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Axis]]></category>
		<category><![CDATA[Axis 2]]></category>
		<category><![CDATA[Örnek]]></category>
		<category><![CDATA[Converter]]></category>
		<category><![CDATA[Dönüşümü]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Service]]></category>
		<category><![CDATA[Servis]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Sıcaklık]]></category>
		<category><![CDATA[Temperature]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[Web Servis]]></category>
		<category><![CDATA[WSDL]]></category>

		<guid isPermaLink="false">http://burakisikli.wordpress.com/?p=201</guid>
		<description><![CDATA[ 
Daha önceden blogumdaki Axis 2 Kullanılarak Web Servis Oluşturma adlı yazımda web servisin nasıl oluşturulacağını anlatmıştım. Fakat çok iyi bir örnek vermediğim için biraz havada kaldı. Şimdi anlatacağım örnekle konu tam anlamıyla oturmuş olacak. Web servislerde internette biraz araştırma yaparsanız en sık öne çıkan örnekler sıcaklık dönüşümü, para dönüşümü, kimlik sorgulama gibi hizmetler olacaktır. Bende [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=201&subd=burakisikli&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong> </strong></p>
<p>Daha önceden blogumdaki <a title="Edit “Axis 2 Kullanılarak Web Servis Oluşturma”" href="post.php?action=edit&amp;post=162">Axis 2 Kullanılarak Web Servis Oluşturma</a> adlı yazımda web servisin nasıl oluşturulacağını anlatmıştım. Fakat çok iyi bir örnek vermediğim için biraz havada kaldı. Şimdi anlatacağım örnekle konu tam anlamıyla oturmuş olacak. Web servislerde internette biraz araştırma yaparsanız en sık öne çıkan örnekler sıcaklık dönüşümü, para dönüşümü, kimlik sorgulama gibi hizmetler olacaktır. Bende bunlardan biri olan sıcaklık dönüşümünü java ve jsp kullanarak anlatacağım.</p>
<p>Yapacağımız programı iki aşamalı olarak anlatacağım. Birinci versiyonumuz için paket adımız “edu.burakkk.webservice.tempConverter.v1”. İlk önce birinci versiyonu yapalım.</p>
<p><strong> </strong></p>
<p><strong>TempConverter.java</strong></p>
<pre class="brush: java;">

package edu.burakkk.webservice.tempConverter.v1;

/**
 * Web Service
 * Temp Converter
 *
 *@version 1.0 Release 1
 *@author burakkk
 *
 **/

public class TempConverter{
 public String FahrenheitToCelsius(String Input) {
 if (!Input.isEmpty() &amp;&amp; isNumber(Input)) {
 double result = 0;
 result = Double.parseDouble(Input);
 result = (((result) - 32) / 9) * 5;
 Input = Double.toString(result);
 return Input;
 } else {
 return &quot;ERROR! Please enter the input number...&quot;;
 }
 }

 public String CelsiusToFahrenheit(String Input) {
 if (!Input.isEmpty() &amp;&amp; isNumber(Input)) {
 double result = 0;
 result = Double.parseDouble(Input);
 result = (((result) * 9) / 5) + 32;
 Input = Double.toString(result);
 return Input;
 } else {
 return &quot;ERROR! Please enter the input number...&quot;;
 }
 }

 private boolean isNumber(String num) {
 try {
 Double.parseDouble(num);
 } catch (NumberFormatException nfe) {
 return false;
 }
 return true;
 }
}
</pre>
<p><strong> </strong></p>
<p>Aslında yaptığımız programı bu şekilde kullanmak doğru olmaz. Çünkü her metodu çağırmak için ayrı bir forma gerek olur ki bu da gereksiz yer, yük ve işlem getirir. Ancak bu şekilde yaparak anlatmak istediğim bir başka konu var. Bu web servis yerine başka bir web servis düşünün. Öyle ki bu web servisin iki metodundan biri özel yani sadece üyelere açık, diğeri ise public yani herkese açıktır. İşte bu işlemi bu şekilde iki ayrı metoda bölerek rahatlıkla yapabiliriz. Özel olan metoda önce kullanıcı üye mi değil mi diye üyelik testi yaptırırız. Bu sebeple de sınıfımıza private olan ayrı bir metod daha ekleriz. Bu private metod, gelen kullanıcının üye olup olmadığını kontrol eder. Örneğin boolean türünde olursa true sonuç döndürürse istediğimiz webservisin sonucunu döndürürüz aksi takdirde üye olmadığına dair hata sonucunu döndürürüz.</p>
<p>Bu prosesimizi(web servisimizi) kullanacağımız zaman yani çağırmak için olan prosesimizi yapalım. Aslında bunu bir web sayfası olarak JSP ile yapacağız. Ancak daha öncedende anlattığım gibi web servis genel bir konsept olduğu için her programlama dilinde yapmak mümkündür. Ben sadece örnek olarak JSP kullanacağım.</p>
<p><strong>TempConverter.v1.jsp</strong></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;title&gt;Temp Converter&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form
action='http://localhost:8080/WebService/services/TempConverter/FahrenheitToCelsius'
method=&quot;post&quot; target=&quot;_blank&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Fahrenheit to Celsius:&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; size=&quot;30&quot; name=&quot;Input&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Convert&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

&lt;form
action='http://localhost:8080/WebService/services/TempConverter/CelsiusToFahrenheit'
method=&quot;post&quot; target=&quot;_blank&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Celsius to Fahrenheit:&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;text&quot; size=&quot;30&quot; name=&quot;Input&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Convert&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>Ekran Görüntüsü:</strong></p>
<p><img class="aligncenter size-full wp-image-203" title="Result" src="http://burakisikli.files.wordpress.com/2009/07/11.jpg?w=380&#038;h=166" alt="Result" width="380" height="166" /></p>
<p>Sayfamızı çalıştırdığımızda yukarıdaki gibi bir ekran karşımıza gelecektir. Buraya fahrenheit olarak veya celcius olarak çevirmek istediğimiz rakamı girip convert butonuna bastığımızda karşımıza sonuç gelecektir. Ancak web servis bir xml tabanlı olduğu için sonucumuz da xml formatında gelecektir.</p>
<p>Programımızın ikinci aşamasına gelelim. İkinci programımızın paket adı “edu.burakkk.webservice.tempConverter.v2”dır. Web servisimizi yaratalım.</p>
<p><strong>TempConverter.java</strong></p>
<pre class="brush: java;">

package edu.burakkk.webservice.tempConverter.v2;

/**
 * Web Service
 * Temp Converter
 *
 *@version 1.1 Release 1
 *@author Burak ISIKLI
 *
 **/

public class TempConverter {
 public String Convert(String type, String Input) {
 if (Input.isEmpty() || !isNumber(Input)) {
 return &quot;ERROR! Please enter the input number...&quot;;
 }
 // Fahrenheit To Celsius
 if (type.equals(&quot;F&quot;)) {
 double result = 0;
 result = Double.parseDouble(Input);
 result = (((result) - 32) / 9) * 5;
 Input = Double.toString(result);
 return Input;
 }
 // Celsius To Fahrenheit
 else if (type.equals(&quot;C&quot;)) {
 double result = 0;
 result = Double.parseDouble(Input);
 result = (((result) * 9) / 5) + 32;
 Input = Double.toString(result);
 return Input;
 }
 return &quot;ERROR! Please enter the input number...&quot;;

 }

 private boolean isNumber(String num) {
 try {
 Double.parseDouble(num);
 } catch (NumberFormatException nfe) {
 return false;
 }
 return true;
 }
}
</pre>
<p>Bu prosesimiz bir öncekinden biraz daha farklı oldu. Bu prosesimizde tek fonksiyonda olayı çözdük. Ancak fahrenheit mı celcius mu olduğunu kısaca hangi tür olduğunu kullancıdan başkan bir değişken isteyerek yaptık. Bu istediğimiz değişkeni formda belirleyerek programa derdimizi anlattık. Böylelikle tek hamlede istediğimiz web servisi yapmış olduk. Aslında benim yaptığım hata döndürme olaylarını da web tarafında yapmak daha doğru olur. Basit bir örnek vermek istediğim için detaylı incelemedim. Formda javascriptle gerekli eklemeler yapılarak hatta ajax kullanılarak çok daha kullanışlı bir sayfa yapmak mümkün olabilir.</p>
<p><strong>TempConverter.v1.1.jsp</strong></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;title&gt;Temp Converter&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form
 action='http://localhost:8080/WebService/services/TempConverter/Convert'
 method=&quot;post&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Enter the input number: &lt;input type=&quot;text&quot; size=&quot;30&quot; name=&quot;Input&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type=&quot;radio&quot; name=&quot;type&quot; value=&quot;F&quot; /&gt; Fahrenheit
 &lt;input type=&quot;radio&quot; name=&quot;type&quot; value=&quot;C&quot; checked /&gt; Celsius&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=&quot;left&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Convert&quot;
 class=&quot;button&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Ekran Görüntüsü:</strong></p>
<p><strong> </strong></p>
<p><strong><img class="aligncenter size-full wp-image-204" title="Result-2" src="http://burakisikli.files.wordpress.com/2009/07/12.jpg?w=380&#038;h=166" alt="Result-2" width="380" height="166" /></strong>45 Celcius’u Fahrenheit’e çevirmek istediğimizde karşımıza gelen ekran şu şekilde olacaktır.</p>
<p><strong> </strong></p>
<p><strong>Ekran Görüntüsü:</strong></p>
<p><strong><img class="aligncenter size-full wp-image-205" title="Result-3" src="http://burakisikli.files.wordpress.com/2009/07/13.jpg?w=643&#038;h=66" alt="Result-3" width="643" height="66" /><br />
</strong></p>
<p><strong> </strong></p>
Posted in Java, Web Services Tagged: Axis, Axis 2, Örnek, Converter, Dönüşümü, Eclipse, Example, Service, Servis, SOA, SOAP, Sıcaklık, Temperature, Web, Web Service, Web Servis, WSDL <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burakisikli.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burakisikli.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burakisikli.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burakisikli.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burakisikli.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burakisikli.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burakisikli.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burakisikli.wordpress.com/201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burakisikli.wordpress.com/201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burakisikli.wordpress.com/201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burakisikli.wordpress.com&blog=5601887&post=201&subd=burakisikli&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://burakisikli.wordpress.com/2009/07/29/web-service-ile-sicaklik-donusumu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d297c033bacffbd3953502202ebc2602?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">burakkk</media:title>
		</media:content>

		<media:content url="http://burakisikli.files.wordpress.com/2009/07/11.jpg" medium="image">
			<media:title type="html">Result</media:title>
		</media:content>

		<media:content url="http://burakisikli.files.wordpress.com/2009/07/12.jpg" medium="image">
			<media:title type="html">Result-2</media:title>
		</media:content>

		<media:content url="http://burakisikli.files.wordpress.com/2009/07/13.jpg" medium="image">
			<media:title type="html">Result-3</media:title>
		</media:content>
	</item>
	</channel>
</rss>