January 21, 2009
@ 01:23 AM

.NET ya da başka diğer geliştirme ortamlarında kullandığımız diller gerek ihtiyaçlardan gerek diğer dillerdeki gelişmelerden etkilenerek zaman içerisinde ya radikal değişikliklere ya da geliştiricinin daha kolay bir şekilde kod yazabilmesi için eklentilerle gelişme sürecini yaşarlar. 70 lerde geliştirilen C bile zaman içerisinde gelişim gösterebilmekte ve yanılmıyorsam en son 99 standartları ile de eklentiler yapılmıştır. C# kullanarak uygulama geliştiren programcılar 8 9 yıllık süreçte c# dilinin 1.0 ,1.1, 2.0 ve 3.0 sürümlerini kullanmışlardır. Bu yazıyı okuyanlardan birisi hala 1.1 veya 1.0 ile uygulama geliştiriyorsa nedenlerini bizimle paylaşırlarsa sevinirim. Acaba neden hala 2.0 ve üstü bir sürümü ile kodlama yapmıyorlar.

Gerek eğitim ve seminerlerde gerek dost sohbetlerinde bu yeniliklerin programcı tarafından kolay bir şekilde kabullenilemediğini görmekteyim .Oysaki bu yeniliklerin bir çoğu programıcının kolay bir şekilde kodlama yapabilmesi (mesela generics) ya da dilin imkanları ile kodlama yapıldığında yaşanan sorunların (örneğin nullable tipler ) aşılması için dile kazandırılmıştır. Oysa ilk gelen cevap " ben bu yenilik olmadan da ben zaten yapabiliyordum, ne gerek var ki bu yenilikleri öğrenmek için harcadığım performansa ya da zamana" şeklindedir. Tamamen karşı olduğumu belirterek bir örnek üzerinden açıklamaya çalışacağım.

Azçok haberimiz vardır c# 3.0 ile birlikte gelen Lambda ifadelerinden. Çok zor anlaşılan ve kullanılmak istenmeyen kullanma ihtiyacını bile düşünmek istemeyen (mesela bir düşünün) birçok meslektalım  olduğuna eminim ;) Oysaki uyuglama geliştirirken yerinde kullanıldığında mükemmel derecede temiz ve anlamlı kodlama yapılabiliyor.
Şimdi c# dili ile farklı yollardan çok basit bir şekilde generic List<T> nesnesinin belirtilen şekilde taşıdığı değerleri filitrelemeye çalışalım.(sıfırdan büyük olan sayıları bulsun)

Ilk akla gelen foreach ile listeyi dönerek filitrelemek olacaktır.

private static List<int> Filitrele(List<int> liste)
{
   
List<int> _temp = new List<int>();
   
foreach (int sayi in liste)
    {
        
if (sayi > 0)
             _temp.Add(sayi);
    }
   
return _temp;
}

Oysaki çok daha kısa ve anlaşılır olan .net framework'ün de nimetlerinden faydalanarak aynı işi yapabileceğimiz yöntem aşağıdaki gibi olabilir.
Bu örnekte C# 2.0'ın getirdiği anonymous metodlardan da faydalanılmıştır.

private static List<int> Filitrele(List<int> liste)
{
  
return liste.FindAll(delegate(int sayi)
   {
      
return sayi > 0;
   }
   );
}


Peki bundan daha temiz ve anlaşılır bir kod yazabilir miyiz ? Eğer lambda ifadeleri ile uğraşmış isek sorunun cevabı oldukça basittir " Tabi ki evet!"
private static List<int> Filitrele(List<int> liste)
{
   
return liste.FindAll(sayi => sayi > 0);
}

Bu örnekle anlatmak istediğim aslında kullanılan dilin yeniliklerini kullanmadan da sorunlara çözüm bulunabilineceği gibi gelen yenilikleri öğrenerek aslında daha az zaman alıcı ve temiz kodlar yazabileceğimizi, bu nedenle öncelikle gelen bu yeniliklerin ne işe yaradığını ne amaçla dile eklendiğini ve bu özellik olmadan yaşanan zorluklar ya da sorunların neler olduğunu iyice kavramak gerektiğini düşünüyorum. Yoksa kullanması zaten kolay! ;)

C# 4.0 'ın resmi olarak yayınlanmasından sonra bu konu hakkında tekrar konuşalım.


 
Wednesday, January 21, 2009 12:08:36 PM (GTB Standard Time, UTC+02:00)
Harika bir konuyu ele almissiniz Oğuz bey... Okurken aninda 5 satirlik bir LinQ sorgusundan kurtuldum:))))


ESKİ HALİ
private static IEnumerable<emlakci_Log> SorguMethod(List<emlakci_Log> loglar, string tip)
{
var emlakciSabahGiris = (from x in loglar
where x.AksiyonTipi == tip
select x).ToList();
return emlakciSabahGiris;
}
----------------------------------------------------------------------------------------------

YENİ HALİ.
private static List<emlakci_Log> Filtrele(List<emlakci_Log> liste, string tip)
{
return liste.FindAll(sayi => sayi.AksiyonTipi == tip);
}
Wednesday, March 25, 2009 10:36:13 AM (GTB Standard Time, UTC+02:00)
Ben düz vites kullanırım. erkek adam otomatik vites kullanır mı gibi bir şey :)
Elinize sağlık
Wednesday, June 17, 2009 5:31:15 PM (GTB Daylight Time, UTC+03:00)
Size katılıyorum Oğuz Bey
dil yeniliklerini takip etmek ve adapte olup aktif olarak kullanmak aslında bizim için bir zorunluluk
en alttaki supermen kedi hoş olmuş:)
Kadir Kartal
Friday, October 16, 2009 5:27:05 AM (GTB Daylight Time, UTC+03:00)
<h2 align="center">Costs For Uggs--What It Costs?</h2>
<p>--&gt;Are you lusting after a few (or even more) <a href="http://www.goodugg.co.uk/ugg-classic-cardy-c-161.html">Ugg boots</a> and if so, you're in good company, as girls and women of all ages, especially with the simple, slipper-like design of these sheepskin <a href="http://www.goodugg.co.uk/grey-ugg-boots-5819-classic-cardy-p-23458.html">ugg boots sale </a>, which are relatively easy and very comfortable to wear. And they appear to be affected. Some men are also jumping on the trend and luxury UGGs? Australia, the brand also offers a range of contemporary styles for them.</p>
<p>--&gt;Could you mind giving everyone loves from <a href="http://www.goodugg.co.uk/ugg-classic-tall-c-162.html">ugg classic </a>? There are so many types of uggs, <a href="http://www.goodugg.co.uk/ugg-bailey-button-c-178.html?zenid=847c0f495b87cb43928dcc19d09f4019">ugg bailey button</a>,ugg <a href="http://www.goodugg.co.uk/ugg-classic-tall-c-162.html">classic tall</a>, ugg <a href="http://www.goodugg.co.uk/ugg-classic-short-c-160.html">classic short</a>, ugg <a href="http://www.goodugg.co.uk/ugg-classic-cardy-c-161.html">classic cardy</a>. How to choose your favorite? Or do you really want to one uggs regardless its style? Despite their design is awkward and slipper-lile, <a href="http://www.goodugg.co.uk/">Uggs</a> is one of the few stations that are of general interest, have argued that cross generational lines.</p>
<p>--&gt;Young people, students and young mothers and the Middle Ages, the original Black <a href="http://www.goodugg.co.uk/ugg-ultra-tall-c-167.html">Ultra Tall UGG Boots</a>, seem pulled the fleecy-lined boots that are manufactured in Australia, with the best materials. Are you sure that your feet warm in winter without socks, and cool in summer so that is more versatile too? If no, hurry up to take one <strong>ugg boots </strong>on <a href="http://www.goodugg.co.uk/ugg-classic-tall-c-162.html">uggs on sale</a> ! That's why we see people wear them in schools, supermarkets, on the slopes and even in the most popular beaches in the United States and abroad. Many surfers also use uggs to keep their feet warm.</p>
<p>--&gt;What do you really care about? Is its price or quality, or you just following the general trend? You know what are you thinking in your heart!</p>
Thursday, October 22, 2009 4:12:18 AM (GTB Daylight Time, UTC+03:00)
Thanks a lot.i like your articles very much,well work.do you like ugg boots.The <A href="http://www.realugg.com/ugg-mini-boots-c-33.html/"><strong>ugg clasic </strong></A>starter collections we offer includes<a href="http://www.realugg.com/ugg-mini-boots-c-33.html"><strong>Ugg classic Cardy boot</strong></a>, <A href="http://www.realugg.com/ugg-short-boots-c-28.html"><strong>Ugg classic short boot</strong></A>, <a href="http://www.realugg.com/ugg-sundance-c-32.html"><strong>Ugg Sundance boots</strong></a>, etc.. <BR>
<A href="http://www.realugg.com/ugg-bailey-button-c-52.html"><strong>UGG Bailey Button</strong></A>?fire sale, <A href="http://www.realugg.com/ugg-knightsbridge-c-58.html"><strong>UGG Knightsbridge</strong></A>, <strong><A href="http://www.realugg.com/ugg-lo-pro-button-c-57.html">Ugg Lo Pro Button</A>?</strong>, <A href="http://www.realugg.com/ugg-tall-boots-c-30.html"><strong>UGG Tall Boots</strong></A>,<A href="http://www.realugg.com/ugg-nightfall-c-31.html"><strong>UGG Nightfall</strong></A>?,Unbeatable quality ugg starting We proposed unbeatable price, not hesitate to take action to move along with your love!
Saturday, October 24, 2009 3:01:57 PM (GTB Daylight Time, UTC+03:00)
why the ugg bailey<strong> <a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge sale</a> </strong>button boot is so popular? as we known,<strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge boots</a></strong> have morphed together their two most popular styles. they started with the ever-popular <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge sand</a></strong> and then added a wooden <strong><a href="http://www.linkboots.com/ugg-classic-cardy-5819-c-26.html">classic cardy uggs grey</a></strong> from their best-selling, as seen on oprah, uggcardy. they are one pop-fusion<strong> <a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge black</a></strong>. when the new fall step into our life this year, <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge on sale</a></strong> are beginning search for an footwear going together with their jeans. now you are reaching to the every <strong><a href="http://www.linkboots.com/ugg-classic-cardy-5819-c-26.html">classic cardy ugg australia</a></strong> for the latest fashion trend. in past two or<A href="http://www.thegoodboots.com/specials.html" target="_blank"><strong> </strong></A>three years, the <strong><a href="http://www.linkboots.com/ugg-classic-cardy-5819-c-26.html">classic cardy uggs on sale</a></strong> kept women, men and kids <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge boot</a></strong> salewarm and cozy under its super-popular fashion. <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge chestnu</a></strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">t</a> the new fall in 2009, we get<strong> <a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge uk</a></strong>. the <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">knightsbridge uggs</a></strong> become the first choice for ugg follower<strong> <a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge ugg boots</a> </strong>and getting hotter and hotter. the <strong><a href="http://www.linkboots.com/ugg-womens-knightsbridge-c-50.html">ugg knightsbridge uggs on sale</a> </strong>style c the bailey button has become a must have this winter. now<strong> <a href="http://www.linkboots.com/ugg-bailey-button-5803-c-30.html">ugg australia bailey button</a> </strong>there are 5 colors available in 5 colors including black, chestnut, grey, chocolate and sand on<strong> <a href="http://www.linkboots.com/ugg-bailey-button-5803-c-30.html">ugg australia bailey button boot</a></strong>. we provide enough stock for this fall and winter. you <A href="http://www.thegoodboots.com/ugg-classic-cardy-c-2.html" target="_blank"><strong>ugg shoes </strong></A>wil enjoy shopping anytime before this <strong><a href="http://www.linkboots.com/ugg-bailey-button-5803-c-30.html">ugg boots bailey button</a></strong>. anyway, the popular classic styles including <strong><a href="http://www.linkboots.com/ugg-bailey-button-5803-c-30.html">bailey button grey uggs</a></strong>, ugg boot short (5825) and<a href="http://www.linkboots.com/ugg-classic-cardy-5819-c-26.html"> <strong>classic cardy ugg boots</strong></a><strong></strong> are all your choices. tags ?
Saturday, October 31, 2009 2:57:36 AM (GTB Standard Time, UTC+02:00)
Accidentally come here , I am incomparable to enjoy myself when i appreciate your beautiful article from my deep heart
Sunday, November 01, 2009 2:53:16 AM (GTB Standard Time, UTC+02:00)
Thanks for article. Everytime like to read you.<br /><p><a href="http://www.topugg.com/ugg-classic-tall-boots-c-3.html">UGG Classic Tall</a></p>
Thanks for article. Everytime like to read you.<br /><p><a href="http://www.topugg.com/ugg-bailey-button-boots-c-14.html">Ugg Bailey Button </a></p>

Thursday, November 26, 2009 7:09:31 AM (GTB Standard Time, UTC+02:00)
<a href="http://www.gouggs.com/">Ugg Australia</a> Brand by the American company Deckers is a popular maker of Ugg Boots and fashion footwear. As we specialize in Australian made <a href="http://www.gouggs.com/">Ugg Boots</a> we do not sell Ugg Australia brand boots on this site but due to popular demand we can offer Ugg Australia Brand at our affiliated site: www.e-uggs.com;UGG New Style Boots are made from the <a href="http://www.gouggs.com/">highest quality plush twin-faced sheepskin</a>with craftsmanship you expect from UGG Australia.100% premium
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview