<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nihat Çelik on Medium]]></title>
        <description><![CDATA[Stories by Nihat Çelik on Medium]]></description>
        <link>https://medium.com/@nihatclk?source=rss-b6f2d408a104------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CK_fJHaeJ3sOIHK2UEft2A.jpeg</url>
            <title>Stories by Nihat Çelik on Medium</title>
            <link>https://medium.com/@nihatclk?source=rss-b6f2d408a104------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 12:42:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nihatclk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[EN] Creating Code Snippets with Visual Studio Guide]]></title>
            <link>https://medium.com/@nihatclk/en-creating-code-snippets-with-visual-studio-guide-42b6de0fdfe8?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/42b6de0fdfe8</guid>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[code-snippet]]></category>
            <category><![CDATA[development-tips]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 20:02:28 GMT</pubDate>
            <atom:updated>2023-08-14T20:02:28.887Z</atom:updated>
            <content:encoded><![CDATA[<p>In this guide, you will learn how to create customized code snippets using Visual Studio. We will provide a step-by-step guide on how to use snippets to quickly insert recurring code patterns.</p><h4><strong>Introduction: What are Snippets and Why Use Them?</strong></h4><p>We often develop our projects following specific coding standards. When adding new features, classes, or methods to a project, we often develop structures in a similar manner. For such cases, instead of writing the same code repeatedly, we can use snippets. Think of it as typing “for” and pressing the Tab key twice to generate the structure of a for loop.</p><h4>Creating Snippets</h4><p>If you are working on a project as part of a team, I recommend keeping the snippets within our project. This enables other team members to use them as well.</p><p>Let’s create a folder named “CodeSnippets.” Then, add an XML file and name it “ClassTemplate.snippet.”</p><pre>&lt;CodeSnippets xmlns=&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;&gt;<br>  &lt;CodeSnippet Format=&quot;1.0.0&quot;&gt;<br>    &lt;Header&gt;<br>      &lt;Title&gt;Class Template&lt;/Title&gt;<br>      &lt;Shortcut&gt;myclass&lt;/Shortcut&gt;<br>      &lt;Description&gt;Creates a class with properties&lt;/Description&gt;<br>      &lt;Author&gt;YourName&lt;/Author&gt;<br>      &lt;SnippetTypes&gt;<br>        &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;<br>      &lt;/SnippetTypes&gt;<br>    &lt;/Header&gt;<br>    &lt;Snippet&gt;<br>      &lt;Declarations&gt;<br>        &lt;Literal&gt;<br>          &lt;ID&gt;className&lt;/ID&gt;<br>          &lt;ToolTip&gt;Class Name&lt;/ToolTip&gt;<br>          &lt;Default&gt;MyClass&lt;/Default&gt;<br>        &lt;/Literal&gt;<br>        &lt;Literal&gt;<br>          &lt;ID&gt;property1&lt;/ID&gt;<br>          &lt;ToolTip&gt;First Property&lt;/ToolTip&gt;<br>          &lt;Default&gt;Property1&lt;/Default&gt;<br>        &lt;/Literal&gt;<br>        &lt;!-- Diğer değişkenler burada eklenebilir --&gt;<br>      &lt;/Declarations&gt;<br>      &lt;Code Language=&quot;csharp&quot;&gt;<br>        &lt;![CDATA[<br>public class $className$<br>{<br>    public $property1$ { get; set; }<br>    // Diğer özellikler burada eklenebilir<br>}<br>        ]]&gt;<br>      &lt;/Code&gt;<br>    &lt;/Snippet&gt;<br>  &lt;/CodeSnippet&gt;<br>&lt;/CodeSnippets&gt;</pre><p>After saving the file, go to Tools =&gt; Code Snippets Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*75dPl9rsk5gRAno5.png" /></figure><p>Select the C# language from the Language section. Once you’ve chosen the “My Code Snippets” folder, click on Import to add our snippet.</p><blockquote>Note: While I’ve provided an example for C#, you can perform the same process for other languages.</blockquote><p>That’s it. Now, type “myclass” and press the TAB key twice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*oFY003rR2z2TkLkn.png" /></figure><h4>Result: Accelerating Code Writing</h4><p>From now on, you can use the shortcut or name you’ve defined to use the snippet in your projects. Snippets assist in quickly adding repetitive code patterns, helping you achieve a more efficient coding experience.</p><p>In this guide, we have provided a detailed walkthrough of creating code snippets using Visual Studio. With this powerful tool, you can expedite your coding process and engage in more effective development.</p><h4>References</h4><p><a href="https://learn.microsoft.com/en-us/visualstudio/ide/code-snippets-schema-reference?view=vs-2022">Code snippets schema reference - Visual Studio (Windows)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42b6de0fdfe8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[TR] Visual Studio ile Kod Parçacığı (Snippet) Oluşturma Rehberi]]></title>
            <link>https://medium.com/devopsturkiye/visual-studio-ile-kod-par%C3%A7ac%C4%B1%C4%9F%C4%B1-snippet-olu%C5%9Fturma-rehberi-a26052a70073?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/a26052a70073</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[development-tips]]></category>
            <category><![CDATA[code-snippet]]></category>
            <category><![CDATA[visual-studio]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 17:52:28 GMT</pubDate>
            <atom:updated>2023-08-15T08:14:11.607Z</atom:updated>
            <content:encoded><![CDATA[<p>Bu rehberde, Visual Studio kullanarak özelleştirilmiş kod parçacıkları (snippet) oluşturmayı öğreneceksiniz. Tekrar eden kod kalıplarını hızla eklemek için snippet kullanmanın nasıl yapıldığına dair adım adım bir rehber sunacağız.</p><h4><strong>Giriş: Snippet Nedir ve Neden Kullanılır?</strong></h4><p>Projelerimizi genellikle belirli bir kod standartında geliştiririz. Projeye yeni özellikler, sınıflar, metotlar eklerken genellikle yapıları benzer bir şekilde geliştirme yaparız. Bu tarz durumlar için kodları tekrar tekrar yazmak yerine snippet kullanabiliriz. En basit bilindiklerden olan for yazıp 2 kere tab tuşuna basınca for döngüsünün yapısını oluşturması gibi düşünebiliriz.</p><h4>Snippet Oluşturma</h4><p>Eğer takım halinde çalışılan bir proje ise projemizde saklamamızı öneririm. Diğer takım arkadaşlarında kullanabilmesi için.</p><p>CodeSnippets isimli bir klasör oluşturalım. Ardından bir xml dosyası ekleyelim ve adını ClassTemplate.snippet yapalım.</p><pre>&lt;CodeSnippets xmlns=&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;&gt;<br>  &lt;CodeSnippet Format=&quot;1.0.0&quot;&gt;<br>    &lt;Header&gt;<br>      &lt;Title&gt;Class Template&lt;/Title&gt;<br>      &lt;Shortcut&gt;myclass&lt;/Shortcut&gt;<br>      &lt;Description&gt;Creates a class with properties&lt;/Description&gt;<br>      &lt;Author&gt;YourName&lt;/Author&gt;<br>      &lt;SnippetTypes&gt;<br>        &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;<br>      &lt;/SnippetTypes&gt;<br>    &lt;/Header&gt;<br>    &lt;Snippet&gt;<br>      &lt;Declarations&gt;<br>        &lt;Literal&gt;<br>          &lt;ID&gt;className&lt;/ID&gt;<br>          &lt;ToolTip&gt;Class Name&lt;/ToolTip&gt;<br>          &lt;Default&gt;MyClass&lt;/Default&gt;<br>        &lt;/Literal&gt;<br>        &lt;Literal&gt;<br>          &lt;ID&gt;property1&lt;/ID&gt;<br>          &lt;ToolTip&gt;First Property&lt;/ToolTip&gt;<br>          &lt;Default&gt;Property1&lt;/Default&gt;<br>        &lt;/Literal&gt;<br>        &lt;!-- Diğer değişkenler burada eklenebilir --&gt;<br>      &lt;/Declarations&gt;<br>      &lt;Code Language=&quot;csharp&quot;&gt;<br>        &lt;![CDATA[<br>public class $className$<br>{<br>    public $property1$ { get; set; }<br>    // Diğer özellikler burada eklenebilir<br>}<br>        ]]&gt;<br>      &lt;/Code&gt;<br>    &lt;/Snippet&gt;<br>  &lt;/CodeSnippet&gt;<br>&lt;/CodeSnippets&gt;</pre><p>Dosyayı kaydettikten sonra Tools =&gt; Code Snippets Manager kısmına geliyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*rqkvErXZB3xUEiK9bx6DJw.png" /></figure><p>Language kısmından C# dilini seçiyoruz. My Code Snippets klasörünü seçtikten sonra Import diyerek snippet’ımızı ekliyoruz.</p><blockquote>Not: Ben C# için örneklendirdim fakat siz diğer dillerle de aynı işlemi yapabilirsiniz.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*c_1o-uDM3knFlw8ICEIBqQ.png" /></figure><p>İşlemimiz bu kadardı. Şimdi myclass yazıp TAB tuşuna 2 kere basalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*fam_xUU0ftJPeSa84zAvNw.png" /></figure><h4>Sonuç: Kod Yazımını Hızlandırma</h4><p>Artık, belirlediğiniz kısayol veya adı kullanarak snippet’i projelerinizde kullanabilirsiniz. Snippet, tekrar eden kod kalıplarını hızlıca eklemenize ve daha verimli bir kod yazma deneyimi elde etmenize yardımcı olur.</p><p>Bu rehberde, Visual Studio kullanarak kod parçacığı (snippet) oluşturmanın adımlarını ayrıntılı bir şekilde ele aldık. Bu güçlü araçla, kod yazma sürecinizi hızlandırabilir ve daha etkili bir şekilde geliştirme yapabilirsiniz.</p><h4>Kaynakça</h4><p><a href="https://learn.microsoft.com/en-us/visualstudio/ide/code-snippets-schema-reference?view=vs-2022">Code snippets schema reference - Visual Studio (Windows)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a26052a70073" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/visual-studio-ile-kod-par%C3%A7ac%C4%B1%C4%9F%C4%B1-snippet-olu%C5%9Fturma-rehberi-a26052a70073">[TR] Visual Studio ile Kod Parçacığı (Snippet) Oluşturma Rehberi</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[EN] .NET EditorConfig: Standardizing and Sharing Code Quality]]></title>
            <link>https://medium.com/@nihatclk/en-net-editorconfig-standardizing-and-sharing-code-quality-1e3cdc887619?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e3cdc887619</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[code-style]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[editorconfig]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 17:17:07 GMT</pubDate>
            <atom:updated>2023-07-05T17:17:07.918Z</atom:updated>
            <content:encoded><![CDATA[<h3>[EN] .NET EditorConfig: Standardizing and Sharing Code Quality</h3><p>In development projects, it is important to maintain code quality and write in a consistent style when working with multiple developers or development teams. It is a common problem for different developers to adopt different code styles and have different formatting preferences. To solve these types of issues and standardize the codebase, .NET EditorConfig comes into play as a tool developed by the .NET community. In this article, I will explain what .NET EditorConfig is, how it is used, and how it helps standardize code quality.</p><h4>What is .NET EditorConfig?</h4><p>.NET EditorConfig is a file format used to standardize code style and formatting among collaborating developers in .NET projects. The EditorConfig file can be located in a project folder or parent folder and defines the style rules that apply to all files at the project level. It can be used in any .NET language (C#, VB.NET, F#, etc.).</p><h4>Creating an EditorConfig File and Defining Formatting Rules</h4><p>The EditorConfig file is created in the root directory of the project with the name “.editorconfig”. This file can establish rules based on file extensions, file names, language features, or other factors specific to a given style.</p><p>Assuming we have multiple projects in a solution and we want the applied rules to be applied to all projects in the solution, we can add the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C1S0Tcu9lGPlrJtM.gif" /></figure><p>Then, to indicate that there is a root editorconfig file in all projects, we should write the following code. This will ensure the enforcement of rules in the Entity and WebAPI layers as well.</p><pre>root = true</pre><h4>Defining Rules in Detail</h4><p>In fact, when we create a new project, it comes together in the Dependencies =&gt; Analyzers section. Here, our rules are present, and each has a default value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*QU3RTpgdgzlorswz.png" /></figure><p>We can right-click on the rules we want to modify and change the severity level.</p><ul><li><strong>Default:</strong> The default severity level is applied when no specific level is assigned to a rule in the .NET EditorConfig file. If no other level is specified for a rule, the Default level will be applied.</li><li><strong>Error:</strong> This level is the highest level to report when there is a code error. It causes a compilation error when the rule is violated.</li><li><strong>Warning:</strong> This level is used to indicate potential issues that do not affect the compilation and execution process. Warnings can cover topics such as the logic or performance of the code.</li><li><strong>Suggestion:</strong> This level is used to provide the developer with a better way of writing code or an alternative approach. Suggestions are made to write code in a more readable, maintainable, or better-performing way. For example, a suggestion might propose a simpler or more optimized implementation of a code structure. Messages at the Suggestion level are shown during compilation or debugging.</li><li><strong>Silent:</strong> This level provides the developer with a better way of writing code or an alternative approach while working in the editor. However, it is not displayed in the Error List.</li><li><strong>None:</strong> This level ensures that no warnings are displayed in the editor or the Error List.</li></ul><p>Here is an example where I added the CA1823 rule as an error. This rule “provides a warning for private fields that are defined but never used.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eyWJCDTyFfOdFC28.gif" /></figure><pre># CA1823: Avoid unused private fields<br>dotnet_diagnostic.CA1823.severity = error</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*HLsttA58E145bMQJ.png" /></figure><h4><strong>Conclusion</strong></h4><p>.NET EditorConfig is a powerful tool for standardizing code quality and writing code in a consistent style. The rules defined across the entire project or specific sections ensure that developers write code consistently. By eliminating style debates and compatibility issues among the project team, saves time and helps produce cleaner, more readable code.</p><h4><strong>Source</strong></h4><p><a href="https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022">Define consistent coding styles with EditorConfig - Visual Studio (Windows)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e3cdc887619" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[TR] .NET EditorConfig: Kod Kalitesini Standartlaştırma ve Paylaşma]]></title>
            <link>https://medium.com/devopsturkiye/tr-net-editorconfig-kod-kalitesini-standartla%C5%9Ft%C4%B1rma-ve-payla%C5%9Fma-187def1f343d?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/187def1f343d</guid>
            <category><![CDATA[editorconfig]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[coding-style]]></category>
            <category><![CDATA[standardization]]></category>
            <category><![CDATA[code-quality]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Tue, 04 Jul 2023 07:54:48 GMT</pubDate>
            <atom:updated>2023-07-04T11:13:31.963Z</atom:updated>
            <content:encoded><![CDATA[<h3>[TR] .NET EditorConfig: Kod Kalitesini Standartlaştırma ve Paylaşma</h3><p>Geliştirme projelerinde, birden fazla geliştirici veya geliştirme ekibiyle çalışırken kod kalitesini korumak ve tutarlı bir stille yazmak önemlidir. Farklı geliştiricilerin farklı kod stillerini benimsemesi ve farklı biçimlendirme tercihlerine sahip olması yaygın bir sorundur. Bu tür sorunları çözmek ve kod tabanını standartlaştırmak için .NET topluluğu tarafından geliştirilen bir araç olan .NET EditorConfig devreye girer. Bu makalede, .NET EditorConfig’in ne olduğunu, nasıl kullanıldığını ve kod kalitesini standartlaştırmak için nasıl yardımcı olduğunu anlatacağım.</p><h4><strong>.NET EditorConfig Nedir?</strong></h4><p>.NET EditorConfig, .NET proje dosyalarında birlikte çalışan geliştiriciler arasında kod stilini ve biçimlendirmeyi standartlaştırmak için kullanılan bir dosya formatıdır. EditorConfig dosyası, bir proje klasöründe veya üst klasörlerde bulunabilir ve proje seviyesindeki tüm dosyalar için geçerli olan stil kurallarını tanımlar. Herhangi bir .NET dilinde (C#, VB.NET, F# vb.) kullanılabilir.</p><h4><strong>EditorConfig Dosyası Oluşturma ve Biçimlendirme Kuralları </strong>Tanımlama</h4><p>EditorConfig dosyası, projenin kök dizininde .editorconfig adıyla oluşturulur. Bu dosya, belirli bir stil için dosya uzantılarına, dosya isimlerine, dil özelliklerine veya diğer faktörlere dayalı olarak kurallar belirleyebilir.</p><p>Bir solutionda birden fazla projemiz olduğunu varsayalım. Uygulanan kuralların solutionda bulunan tüm projelere uygulanmasını istiyorsak aşağıdaki gibi ekleyebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6WK0p0LMOFYayMWwv05pQ.gif" /></figure><p>Ardından tüm projelerdeki kök editorconfig dosyası olduğunu belirtmek için aşağıdaki kodu yazmalıyız. Böylece Entity ve WebAPI katmanlarında da kontrol işlemi sağlanacaktır.</p><pre>root = true</pre><h4>Detaylı Olarak Kuralları Tanımlamak</h4><p>Aslında yeni bir proje oluşturduğumuzda Dependencies =&gt; Analyzers kısmında birlikte gelmektedir. Burada kurallarımız bulunmaktadır ve hepsinin varsayılan bir değeri vardır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*iv7MYp94HM3TuFqZYl-ZtA.png" /></figure><p>Değiştirmek istediğiniz kurallar için sağ tıklayıp severity seviyesini değiştirebiliriz.</p><ul><li><strong>Default:</strong> .NET EditorConfig dosyasında bir kurala özel bir seviye atanmadığında varsayılan olarak uygulanan seviyedir. Yani, belirli bir kural için başka bir seviye belirtilmediyse, o kural için Default seviyesi geçerli olacaktır.</li><li><strong>Error:</strong> Bu seviye, bir kod hatası olduğunda bildirilecek en yüksek önem düzeyidir. Kural ihlalinde derleme hatası aldırır.</li><li><strong>Warning:</strong> Bu seviye, potansiyel bir soruna işaret eden, ancak derleme ve çalışma sürecini etkilemeyen durumları belirtmek için kullanılır. Uyarılar, kodun mantığı veya performansı gibi konuları kapsayabilir.</li><li><strong>Suggestion: </strong>Bu seviye, geliştiriciye daha iyi bir kod yazma yöntemi veya alternatif bir yaklaşım sunmak için kullanılır. Öneriler, kodun daha okunabilir, daha sürdürülebilir veya daha iyi performans gösteren bir şekilde yazılması için yapılır. Örneğin, bir kod yapısının daha basit veya daha optimize edilmiş bir şekilde uygulanması önerilebilir. Öneri seviyesindeki mesajlar, derleme veya hata ayıklama sırasında gösterilir.</li><li><strong>Silent:</strong> Bu seviye, editör üzerindeyken 3 nokta ile geliştiriciye daha iyi bir kod yazma yöntemi veya alternatif bir yaklaşım sunar. Ancak Error List kısmında gösterilmez.</li><li><strong>None: </strong>Bu seviye, editör üzerinde veya Error List kısmında uyarı gösterilmemesini sağlar.</li></ul><p>Aşağıda bir örnek bulunmaktadır. Örneğin CA1823 kuralını error olarak ekledim. Bu kural “private olarak tanımlanan ancak hiç kullanılmayan değişkenler için uyarı verir.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2L7fQIAq-J0mOrRSAz3fg.gif" /></figure><pre># CA1823: Avoid unused private fields<br>dotnet_diagnostic.CA1823.severity = error</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*UByG79cdOhR_iXSTQZVcvA.png" /></figure><h4><strong>Sonuç</strong></h4><p>.NET EditorConfig, kod kalitesini standartlaştırmak ve tutarlı bir stilde kod yazmak için güçlü bir araçtır. Tüm projede veya belirli bölümlerde belirlenen kurallar, geliştiricilerin uyumlu bir şekilde kod yazmalarını sağlar. Proje ekibi arasında stil tartışmalarını ve uyumluluk sorunlarını ortadan kaldırarak zaman kazandırır ve daha temiz, daha okunabilir kodlar üretmeye yardımcı olur.</p><h4>Kaynakça</h4><p><a href="https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022">Define consistent coding styles with EditorConfig - Visual Studio (Windows)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=187def1f343d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/tr-net-editorconfig-kod-kalitesini-standartla%C5%9Ft%C4%B1rma-ve-payla%C5%9Fma-187def1f343d">[TR] .NET EditorConfig: Kod Kalitesini Standartlaştırma ve Paylaşma</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[EN] Generating Sample Data Using .NET Bogus]]></title>
            <link>https://medium.com/@nihatclk/en-generating-sample-data-using-net-bogus-6354931c2ce1?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/6354931c2ce1</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 20:20:43 GMT</pubDate>
            <atom:updated>2023-06-03T20:20:43.197Z</atom:updated>
            <content:encoded><![CDATA[<h3>[EN] Generating Sample Data Using .NET Bogus</h3><p>Hello, in this blog post, I will show you how to generate sample data for your software projects.</p><p>Firstly, if we don’t need a large amount of data, we can use the following websites:</p><ul><li><a href="https://www.mockaroo.com/">Mockaroo</a> (Free option: Generate up to 1000 records in formats like CSV, SQL, XML, JSON)</li><li><a href="https://generatedata.com/generator">generatedata.com</a> (Free option: Generate up to 500 records in formats like CSV, SQL, XML, JSON)</li><li><a href="https://cobbl.io/">cobbl.io</a> (Free option: Generate up to 10,000 records in formats like CSV, JSON, JSONL)</li></ul><p>But what if we need more complex data, such as relational records? Let’s say we have customers with multiple addresses.</p><h4>.NET Bogus</h4><p>Bogus is a useful package for generating random data and making the process of creating example data easier. Here’s how to use it.</p><ul><li>Add Bogus to your project. You can do this by using the NuGet Package Manager. Open the “Package Manager Console” and run the following command:</li></ul><pre>Install-Package Bogus</pre><p>This will install the latest version of Bogus in your project.</p><p>Let’s create the models to store our customers and their addresses:</p><pre>public class Customer<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>    public string Email { get; set; }<br>    public List&lt;CustomerAddress&gt; CustomerAddresses { get; set; }<br>}<br><br>public class CustomerAddress<br>{<br>    public int Id { get; set; }<br>    public string Address { get; set; }<br>}</pre><ul><li>Generating Sample Data</li></ul><pre>var faker = new Faker();<br>var customerAddress = new Faker&lt;CustomerAddress&gt;()<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Address, (f, c) =&gt; f.Address.StreetAddress(true));<br><br>var customers = new Faker&lt;Customer&gt;()<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Name, (f, c) =&gt; f.Name.FullName())<br>                    .RuleFor(c =&gt; c.Email, (f, c) =&gt; f.Internet.Email())<br>                    .RuleFor(c =&gt; c.CustomerAddresses, f =&gt; customerAddress.Generate(f.Random.Int(min: 1, max: 5)));<br><br>var customerData = customers.Generate(3);</pre><ul><li>When we print the results, we will get the following output:</li></ul><pre>foreach (var customer in customerData)<br>{<br>    Console.WriteLine($&quot;Id: {customer.Id}, Name: {customer.Name}, Email: {customer.Email}\n&quot;);<br>    foreach (var address in customer.CustomerAddresses)<br>    {<br>        Console.WriteLine($&quot;Id: {address.Id}, Full Address: {address.Address}&quot;);<br>    }<br>    Console.WriteLine(&quot;------------------------------&quot;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*H8Bm9vu-c4oRrZLH.png" /></figure><ul><li>If we want the generated data to be in Turkish, we just need to provide the “tr” locale parameter when creating the Faker object. To generate Turkish data, we can modify our code as follows:</li></ul><pre>var customerAddress = new Faker&lt;CustomerAddress&gt;(&quot;tr&quot;)<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Address, (f, c) =&gt; f.Address.StreetAddress(true));<br><br>var customers = new Faker&lt;Customer&gt;(&quot;tr&quot;)<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Name, (f, c) =&gt; f.Name.FullName())<br>                    .RuleFor(c =&gt; c.Email, (f, c) =&gt; f.Internet.Email())<br>                    .RuleFor(c =&gt; c.CustomerAddresses, f =&gt; customerAddress.Generate(f.Random.Int(min: 1, max: 5)));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/0*Oy9yAUzZs7bOcBg8.png" /></figure><p>For more examples, you can visit the Bogus GitHub address from <a href="https://github.com/bchavez/Bogus">here</a>.</p><h4>Source</h4><p><a href="https://github.com/bchavez/Bogus">GitHub - bchavez/Bogus: :card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6354931c2ce1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[TR] .NET’te Bogus Kullanarak Örnek Veri Oluşturma]]></title>
            <link>https://medium.com/devopsturkiye/tr-nette-bogus-kullanarak-%C3%B6rnek-veri-olu%C5%9Fturma-c3944e3d9779?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3944e3d9779</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[bogus]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 06:24:38 GMT</pubDate>
            <atom:updated>2023-07-03T14:27:10.755Z</atom:updated>
            <content:encoded><![CDATA[<h3>[TR] .NET Bogus Kullanarak Örnek Veri Oluşturma</h3><p>Merhaba, bu blog yazısında yazılımlarımız için nasıl örnek veri oluşturabileceğimizi göstereceğim.</p><p>Öncelikle eğer çok fazla veriye ihtiyacımız yoksa aşağıdaki websitelerini kullanabiliriz.</p><ul><li><a href="https://www.mockaroo.com/">https://www.mockaroo.com/</a> (Ücretsiz seçenek için 1000 kayda kadar örnek veri oluşturabiliyoruz ve csv, sql, xml, json gibi çıktılar alabiliyoruz)</li><li><a href="https://generatedata.com/">https://generatedata.com/generator</a> (Ücretsiz seçenek için 500 kayda kadar örnek veri oluşturabiliyoruz ve csv, sql, xml, json gibi çıktılar alabiliyoruz)</li><li><a href="https://cobbl.io/">https://cobbl.io/</a> (Ücretsiz seçenek için 10000 kayda kadar örnek veri oluşturabiliyoruz ve csv, json, jsonl gibi çıktılar alabiliyoruz)</li></ul><p>Peki daha kompleks data oluşturmak istiyorsak (Örnek: İlişkili kayıtlar)</p><p>Müşterilerimiz olduğunu ve bu müşterlerimizin birden fazla adreslerinin olduğunu düşünelim.</p><h4>.NET Bogus</h4><p>Bogus, rastgele veriler oluşturmak için kullanışlı bir pakettir ve örnek veri oluşturma sürecini kolaylaştırır. Nasıl kullanabileceğimize bakalım.</p><ul><li>Projenize Bogus paketini ekleyin. Bu işlemi yapmak için NuGet paket yöneticisini kullanabilirsiniz. “Package Manager Console” penceresini açın ve aşağıdaki komutu çalıştırın:</li></ul><pre>Install-Package Bogus</pre><p>Bu şekilde Bogus paketinin en güncel halini projemize yüklemiş olacağız.</p><ul><li>Müşterilerimizin ve adreslerinin tutulacağı modelleri oluşturalım.</li></ul><pre>public class Customer<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>    public string Email { get; set; }<br>    public List&lt;CustomerAddress&gt; CustomerAddresses { get; set; }<br>}<br><br>public class CustomerAddress<br>{<br>    public int Id { get; set; }<br>    public string Address { get; set; }<br>}</pre><ul><li>Örnek Veri Oluşturma</li></ul><pre>var faker = new Faker();<br>var customerAddress = new Faker&lt;CustomerAddress&gt;()<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Address, (f, c) =&gt; f.Address.StreetAddress(true));<br><br>var customers = new Faker&lt;Customer&gt;()<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Name, (f, c) =&gt; f.Name.FullName())<br>                    .RuleFor(c =&gt; c.Email, (f, c) =&gt; f.Internet.Email())<br>                    .RuleFor(c =&gt; c.CustomerAddresses, f =&gt; customerAddress.Generate(f.Random.Int(min: 1, max: 5)));<br><br>var customerData = customers.Generate(3);</pre><ul><li>Sonuçları ekrana bastığımızda ise aşağıdaki gibi örnek bir çıktı alacağız</li></ul><pre>foreach (var customer in customerData)<br>{<br>    Console.WriteLine($&quot;Id: {customer.Id}, Name: {customer.Name}, Email: {customer.Email}\n&quot;);<br>    foreach (var address in customer.CustomerAddresses)<br>    {<br>        Console.WriteLine($&quot;Id: {address.Id}, Full Address: {address.Address}&quot;);<br>    }<br>    Console.WriteLine(&quot;------------------------------&quot;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*rgzsDmpMUlOjbAb3rlHNhg.png" /></figure><p>Peki verilerimizin Türkçe oluşmasını istiyorsak ne yapmalıyız?</p><p>Tek yapmamız gereken Faker sınıfı için yeni bir nesne oluştururken locale parametresini doldurmak. Türkçe veriler oluşturmak için aşağıdaki gibi kodumuzu düzeltmeliyiz.</p><pre>var customerAddress = new Faker&lt;CustomerAddress&gt;(&quot;tr&quot;)<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Address, (f, c) =&gt; f.Address.StreetAddress(true));<br><br>var customers = new Faker&lt;Customer&gt;(&quot;tr&quot;)<br>                    .RuleFor(c =&gt; c.Id, (f, c) =&gt; f.IndexFaker + 1)<br>                    .RuleFor(c =&gt; c.Name, (f, c) =&gt; f.Name.FullName())<br>                    .RuleFor(c =&gt; c.Email, (f, c) =&gt; f.Internet.Email())<br>                    .RuleFor(c =&gt; c.CustomerAddresses, f =&gt; customerAddress.Generate(f.Random.Int(min: 1, max: 5)));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*s-TCjHklo4ycXo18OzAKfw.png" /></figure><p>Daha fazla örnek için Bogus’un github adresini <a href="https://github.com/bchavez/Bogus">buradan</a> ziyaret edebilirsiniz.</p><h4>Kaynakça</h4><p><a href="https://github.com/bchavez/Bogus">GitHub - bchavez/Bogus: :card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3944e3d9779" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/tr-nette-bogus-kullanarak-%C3%B6rnek-veri-olu%C5%9Fturma-c3944e3d9779">[TR] .NET’te Bogus Kullanarak Örnek Veri Oluşturma</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EF IQueryable vs IEnumerable]]></title>
            <link>https://medium.com/devopsturkiye/iqueryable-vs-ienumerable-68b2541969cc?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/68b2541969cc</guid>
            <category><![CDATA[linq-to-sql]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[ienumerable]]></category>
            <category><![CDATA[iqueryable]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Sun, 29 May 2022 12:03:24 GMT</pubDate>
            <atom:updated>2022-06-02T08:51:44.003Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhabalar,</p><p>Bu yazımızda Entity Framework kullanırken IQueryable ve IEnumerable hangi işlemlerde hangisi kullanılmalıdır bunu inceleyeceğiz.</p><p><strong>IQueryable: </strong>Bellekte olmayan veriler için kullanılmalıdır. Veritabanımızda bir sorgulama işlemi yaparken belirlediğimiz tüm filtreleri sorguya uyarlar. Dolayısıyla sadece ihtiyacımız olan datayı çekmiş oluruz.</p><p><strong>IEnumerable: </strong>Bellekte olan veriler için kullanılmalıdır. Eğer veritabanı işlemlerinde kullanırsanız tüm datayı belleğe çekmiş olursunuz.</p><p>Bir örnek sorgu yazalım ve SQL Profiler ile Sql’e giden sorguya bakalım.</p><p><em>Not: Veritabanına 50 bin kayıt ekledim.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qD99f8cV_CuIAoc0s5zQw.png" /><figcaption>IEnumerable Example</figcaption></figure><p>Görüldüğü üzere işlemimiz 2549 milisaniye sürdü. Sebebi ise ben 40 yaşından büyükleri istememe rağmen herhangi bir where şartını sql sorgusunda yazmaması.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jEnzAL4fT_yFkbIqZ1OmKA.png" /><figcaption>IQueryable Example</figcaption></figure><p>IQueryable örneği için ise işlemimiz 2053 milisaniye sürdü. Sebebi ise where şartının direkt olarak sorgumuzda uygulanması.</p><p>İlk başta da belirttiğimiz gibi IEnumerable bellekten, IQueryable ise dış kaynaktan sorgulama yapar. Bunun farkında olarak yazacağımız Linq’larıda ona göre kullanmamız gerek. Eğer aynı sorgu için birden fazla kez SQL’e gidecekseniz onu belleğe alıp bellekten sorgulamakta fayda var.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LM4OZE5_hV-5nKl9_rlogQ.png" /><figcaption>IQueryable vs IEnumerable Benchmark</figcaption></figure><p>Benchmark işleminde de görüldüğü üzere belleğe tüm datayı çekmediğimiz için IQueryable 88MB IEnumerable ise 147MB, ve ortalama zaman olarak <br>.NET 5.0 için<br>IEnumerable: 544ms <br>IQueryable: 318ms</p><p>.NET 6.0 için ise <br>IEnumerable: 481ms <br>IQueryable: 296ms</p><p>Benchmark testi nasıl yapıldığını merak ediyorsanız eğer <a href="https://medium.com/devopsturkiye/benchmarkdotnet-kullan%C4%B1m%C4%B1-ve-string-vs-stringbuilder-k%C4%B1yaslamas%C4%B1-3b4ca41dd415">buradan</a> Benchmark Kullanımı yazımı okuyabilirsiniz.</p><p><strong>Not:</strong> Performans ile ilgili sonuçlar benim kendi makinem baz alınarak yapılmıştır.</p><p>Başka bir yazıda görüşmek üzere.</p><p>Kaynakça</p><p><a href="https://medium.com/@mohamedabdeen/iqueryable-vs-ienumerable-in-net-92a15a803da3">IQueryable vs. IEnumerable in .NET</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68b2541969cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/iqueryable-vs-ienumerable-68b2541969cc">EF IQueryable vs IEnumerable</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EF AsNoTracking Kullanımı]]></title>
            <link>https://medium.com/devopsturkiye/ef-asnotracking-kullan%C4%B1m%C4%B1-ea4c4d959e24?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea4c4d959e24</guid>
            <category><![CDATA[entity-framework]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[asnotracking]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Sat, 23 Apr 2022 19:01:44 GMT</pubDate>
            <atom:updated>2022-04-24T20:29:45.763Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhabalar,</p><p>Yazılım mülakatlarında da sorulan bir kavram olan AsNoTracking nedir, ne işe yarar gibi soruların cevaplarını arayacağız.</p><p>Öncelikle default olarak çalışan Entity Framework’ün Select işlemleri döndürdüğü datayı cachleyerek takibe alır. Bunun sebebi datayı güncelleyip SaveChanges metodunu çağırdığımızda değişikliklerin veritabanına yansımasını sağlamaktır. Bir örnekle inceleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*VIg8hsOOVfFCjz-U7o623A.png" /></figure><p>Yukarıdaki işlemde Users tablosunda Id si 1 olan kaydın Name değerini Nihat olarak değiştirip SaveChanges ile veritabanına yansıttık. Peki madem bu şekilde tracking’den faynalanıp datayı bu şekilde güncelleyebiliyorken neden AsNoTracking kullanalım ki dediğinizi duyar gibiyim :) Bunun da cevabını aşağıdaki kod açıklıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*fI4s4jZjRV1_3SkmOwhtgA.png" /></figure><p>Buradaki örnekte ben geriye sadece veritabanındaki kullanıcıları dönüyorum. Herhangi bir izleme veya değişiklik yapmayacağım. Bu yüzden cachlemeye ve izlememize gerek yok. Bundan dolayı da AsNoTracking kullanırsak performans artışı sağlamış olacağız.</p><p>Ben benchmark testi için tabloya 50 bin kayıt ekledim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIoAxomg49yh4wVH2UDalQ.png" /></figure><p>Test sonuçlarına bakarsak eğer 50 bin kayıt için AsNoTracking kullanmazsak .Net 5 için 200ms ve 71MB, AsNoTracking kullanırsak 106ms ve 34MB gibi değer almışız. .NET 6 için ise ram bakımından değerler aynı, süre olarak biraz daha iyileştirme var fakat fark yaklaşık 2 katı. Yani çıkardığımız sonuç eğer select işleminde update işlemi yapmayacaksak AsNoTracking kullanmakta fayda var.</p><p>Benchmark testi nasıl yapıldığını merak ediyorsanız eğer <a href="https://medium.com/devopsturkiye/benchmarkdotnet-kullan%C4%B1m%C4%B1-ve-string-vs-stringbuilder-k%C4%B1yaslamas%C4%B1-3b4ca41dd415">buradan</a> Benchmark Kullanımı yazımı okuyabilirsiniz.</p><p>Projenin Github Linki: <a href="https://github.com/NihatCelik/EFAsNoTrackingBenchmark">https://github.com/NihatCelik/EFAsNoTrackingBenchmark</a></p><p><a href="https://medium.com/devopsturkiye/benchmarkdotnet-kullan%C4%B1m%C4%B1-ve-string-vs-stringbuilder-k%C4%B1yaslamas%C4%B1-3b4ca41dd415">BenchmarkDotNet Kullanımı ve String vs StringBuilder Kıyaslaması</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea4c4d959e24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/ef-asnotracking-kullan%C4%B1m%C4%B1-ea4c4d959e24">EF AsNoTracking Kullanımı</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cancellation Token Kullanımı]]></title>
            <link>https://medium.com/devopsturkiye/cancellation-token-kullan%C4%B1m%C4%B1-a033ff19e118?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/a033ff19e118</guid>
            <category><![CDATA[cancellationtoken]]></category>
            <category><![CDATA[task-management]]></category>
            <category><![CDATA[cancellations]]></category>
            <category><![CDATA[cancellationtokensource]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 18:36:13 GMT</pubDate>
            <atom:updated>2022-03-01T10:37:24.964Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Cancellation Token İhtiyacını Anlamak<br></strong>Hiç kullandığınız bir uygulamada yanlış bir iş yapıp ardından işlem devam ederken yapılan işlem iptal olsun diye uygulamayı kapattığınız oldu mu? Peki uygulamayı kapatınca işlem iptal mi oldu yoksa tamamlandı mı? Veya API’ ye atılan bir istekte isteğin yanıtı uzun sürdüğünde isteği beklemek yerine iptal etmek isteyebiliriz. Peki atılan isteği nasıl iptal edebiliriz?</p><p>Başlıkta da gördüğünüz teknolojiyi kullanmıyorsanız ve apiye isteğiniz gittikten sonra uygulamayı kapatsanız dahi api isteği aldığı için işlemine devam edecektir. Veya isteği iptal edemediğimiz için mecburen bekleyeceğiz.<br>İşte bu noktada Cancellation Token bizim imdadımıza yetişiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*YGD5ZqUVdAfG-vRv.jpg" /><figcaption>Cancellation Token</figcaption></figure><p><strong>Peki yazılım geliştiriciler olarak bunu nasıl kullanırız?<br></strong>Paralel programlama işlemlerinde CancellationToken tipinde bir parametre vardır. CancellationTokenSource ile CancellationToken sınıfını kullanarak Cancel metodu ile devam eden Task’ı da iptal edebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*BhlqI0ArpmZoIWnO8sPO-w.png" /><figcaption>CancellationTokenSource</figcaption></figure><p>Task sınıfına ait bir bölüm. Bu parametreyi verdiğimizde task iptal edildiği anda task’ı throw eder. Böylece bizim devam eden işlemlerde iptal edilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*Sv_IxHXeUfNLau1IMf8MTw.png" /><figcaption>Task class</figcaption></figure><p>Örnek bir API hazırladım. Bu örnekte CancellationToken parametresini alan ve almayan 2 adet endpoint bulunmaktadır. Postman ile 2 endpointe ayrı ayrı istek atıp istek işlemdeyken isteği iptal edeceğiz ve Output’u inceleyeceğiz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d4f12bfa60ee6cc677cdefe960e7062/href">https://medium.com/media/9d4f12bfa60ee6cc677cdefe960e7062/href</a></iframe><p>Şimdi postmandan 2 endpointe de istek yapıp iptal edeceğim ve Output çıktısına bakalım. Beklenen sonuç output da sadece CancellationToken kullandığımız metodun hatasının yazılması.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*gsxy0IFxHn-jVfpFz3iz6Q.png" /><figcaption>CancellationToken Cancelled Exception</figcaption></figure><p>Ayrıca GetDays endpointine istek atacağım ve ardından Postman’dan isteği iptal edeceğiz. Beklediğimiz sonuç ise isteğin iptal olmasına rağmen breakpoint ile return ifadesine gelmemiz. Çünkü CancellationToken kullanılmadığı için işlemin iptalini gerçekleştirecek herhangi bir kodumuz yok.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*4hu5h4iVcOvgsbaEzYjyTg.png" /></figure><p><strong>ThrowIfCancellationRequested</strong></p><p>WebAPI ye istek attığımızda yukarıdaki yapıyı kullanabiliyoruz fakat diğer teknolojilerde (web, masaüstü gibi) işlemleri nasıl iptal edebiliriz diye soruyorsanız eğer bu kod tam olarak size göre.</p><p>Aşağıdaki örnekte sonsuz bir for döngüsü var ve i değeri 100. ifade de CancellationToken işlemimizi Cancel ediyoruz. Böylece ilk 100 işlemde exception hatası almazken 101. değer de OperationCancelledException fırlatılıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*esDnGruq1P0SV40EwM-IOQ.png" /><figcaption>ThrowIfCancellationRequested</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*YGZLPntNwLW8PDp5uLiLxQ.png" /></figure><p>Makalede kullanılan kodları aşağıdaki github bağlantımdan inceleyebilirsiniz.</p><p><a href="https://github.com/NihatCelik/CancellationTokenExample">GitHub - NihatCelik/CancellationTokenExample</a></p><p><strong>Kaynaklar:</strong></p><ul><li><a href="https://docs.microsoft.com/tr-tr/dotnet/api/system.threading.cancellationtoken?view=net-6.0">CancellationToken Yapı (System.Threading)</a></li><li><a href="https://www.buraksenyurt.com/post/Task-Iptal-Islemlerinin-Izlenmesi(Monitoring-Cancellation)">Task İptal İşlemlerinin İzlenmesi(Monitoring Cancellation)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a033ff19e118" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/cancellation-token-kullan%C4%B1m%C4%B1-a033ff19e118">Cancellation Token Kullanımı</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BenchmarkDotNet Kullanımı ve String vs StringBuilder Kıyaslaması]]></title>
            <link>https://medium.com/devopsturkiye/benchmarkdotnet-kullan%C4%B1m%C4%B1-ve-string-vs-stringbuilder-k%C4%B1yaslamas%C4%B1-3b4ca41dd415?source=rss-b6f2d408a104------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b4ca41dd415</guid>
            <category><![CDATA[stopwatch]]></category>
            <category><![CDATA[string-builder]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[benchmarking]]></category>
            <category><![CDATA[string]]></category>
            <dc:creator><![CDATA[Nihat Çelik]]></dc:creator>
            <pubDate>Mon, 31 Jan 2022 11:43:08 GMT</pubDate>
            <atom:updated>2022-04-23T08:12:13.362Z</atom:updated>
            <content:encoded><![CDATA[<p>Muhtemelen daha öncesinde aynı görevi yapan iki veya daha fazla farklı algoritmadan hangisinin daha performanslı ve az bellek kullanan olduğunu merak etmişizdir. Hatta belkide süre bakımından hangisinin daha hızlı olduğunu <strong>Stopwatch</strong> kütüphanesini kullanarak incelemişsinizdir. Birlikte Önce <em>Stopwatch </em>ile ardından da <em>BenchmarkDotNet </em>ile kıyaslama yapalım.</p><p><strong>Stopwatch Kullanımı</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dc773e041708abb4d3494584ef11474/href">https://medium.com/media/4dc773e041708abb4d3494584ef11474/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*tE_9UMbsOudgvCNYkwW-TA.png" /><figcaption>Stopwatch String vs StringBuilder</figcaption></figure><p>Göründüğü üzere 10.000 tane sayıyı yan yana yazdırmak string işleminde toplama ile ortalama 0.025 milisaniye StringBuilder ile ise 0.00027 milisaniye civarında.</p><p><strong>BenchmarkDotNet</strong> <strong>Nedir?<br></strong>Benchmark kısaca yukarıdaki yaptığımız işi yapan bir kıyaslama tooludur.</p><p><strong>BenchmarkDotNet Kullanmanın Avantajları</strong></p><ul><li>Yukarıdaki örneklerdeki kod kalabağını ve kirliliğini ortadan kaldırır.</li><li>Bize farklı değerlerle aynı kodları karşılaştırabilmemizi sağlar. Böylece sürekli tekrar tekrar değer verip projeyi çalıştırmamış oluruz.</li><li>Karşılaştırma sonuçlarını Csv, Html ve Markdown olarak dışarı aktarır.</li><li>Bellek kullanımlarını görebiliriz.</li><li>Farklı ortamlarda karşılaştırma işlemleri gerçekleştirebiliriz.</li><li>Stopwatch kütüphanesini kullandığımızda aslında net olarak sonuç elde etmiş sayılmayız. Çünkü o anki bilgisayarın durumuna göre sonuçları alırız. BenchmarkDotNet’te ise öncesinde ısındırma turları yaparak en iyi sonuçları almaya çalışır.</li></ul><p><strong>Bazı BenchmarkDotNet Parametreleri</strong></p><p><strong>RuntimeMoniker: </strong>Testin gerçekleştireceği .Net sürümü</p><p><strong>LaunchCount: </strong>Test Exelerinin kaç kez çalıştırılacağı.</p><p><strong>WarmupCount: </strong>Her exe’de kaç kez ısınma çalışması yapılacağı</p><p><strong>TargetCount: </strong>Her exe çalıştırılmasında ilgili metotun kaç kez test edilmesi</p><p><strong>Benchmark Kullanımı</strong></p><p>İlk olarak projemize <strong>BenchmarkDotNet </strong>nuget paketini yükleyelim.</p><pre>Install-Package BenchmarkDotNet</pre><p><strong>StringVsStringBuilder</strong> isminde bir class oluşturalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d79f9458af4a1c4157de0aeb209bb29e/href">https://medium.com/media/d79f9458af4a1c4157de0aeb209bb29e/href</a></iframe><p>Program.cs ye aşağıdaki kodu yazıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*cuhFcrKNzGFvdkp6ho4RfQ.png" /></figure><p><strong>Release Mode</strong></p><p>Benchmark testlerini sadece Release modda yapabiliyoruz. Debug modda debug işlemlerini yapabilmemiz için debug kodları da bulunur ve kod optimizasyonu yapılmaz. Release modda ise debug kodları bulunmaz ve kod optimize edilir. Bundan dolayı testleri Release modda yapıyoruz.</p><p><strong>Sonuç</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-gIqPjtgWW6VpxVfUTf8w.png" /></figure><p>Sonuç olarak .NET 5.0 da ve .NET 6.0 için 10.000 kayıt String birleştirme işleminde Stopwatch’a göre çok fark olmasa da StringBuilder işlemi Stopwatch’a göre daha düşük değerde çıktı. Bununda sebebi Stopwatch’ta anlık bilgisayarın durumuna göre aldığımızdan. Benchmarkta ise aynı işlem verdiğimiz değerlere göre birden fazla kez çalıştırılıp ortalaması alındığından daha sağlıklı sonuç aldık. Ayrıca bellek kullanımlarınıda görebildik.</p><p><strong>BenchmarkDotNet Raporlama</strong></p><p>Benchmark işleminin ardından bize raporda oluşturdu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*QgYAGvjVqsTX_8XsvWZ07A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PbamhDeC54Zk8NGs-4Ma_Q.png" /></figure><p>Projenin Github Linki: <a href="https://github.com/NihatCelik/BenchmarkDotNetExample">https://github.com/NihatCelik/BenchmarkDotNetExample</a></p><ul><li><a href="https://benchmarkdotnet.org/articles/overview.html">Overview</a></li><li><a href="https://www.ilkayilknur.com/benchmarkdotnet-ile-performans-ve-memory-benchmarking">BenchmarkDotNet ile Performans ve Memory Benchmarking</a></li><li><a href="https://devnot.com/2017/benchmarkdotnet-ile-metotlarin-calisma-hizini-test-edin/">BenchmarkDotNet ile Metotların Çalışma Hızını Test Edin</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b4ca41dd415" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/benchmarkdotnet-kullan%C4%B1m%C4%B1-ve-string-vs-stringbuilder-k%C4%B1yaslamas%C4%B1-3b4ca41dd415">BenchmarkDotNet Kullanımı ve String vs StringBuilder Kıyaslaması</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>