<?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 Can Kayı on Medium]]></title>
        <description><![CDATA[Stories by Can Kayı on Medium]]></description>
        <link>https://medium.com/@cankayi?source=rss-1744ebd33828------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eGmunX-RJqNcPj4t</url>
            <title>Stories by Can Kayı on Medium</title>
            <link>https://medium.com/@cankayi?source=rss-1744ebd33828------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:54:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cankayi/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[Redis 101]]></title>
            <link>https://medium.com/multinetinventiv/redis-101-34fda9c632b1?source=rss-1744ebd33828------2</link>
            <guid isPermaLink="false">https://medium.com/p/34fda9c632b1</guid>
            <category><![CDATA[türkçe]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Can Kayı]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 08:23:33 GMT</pubDate>
            <atom:updated>2023-07-14T08:23:33.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jed-UVwaIqf16oq5f8ATDQ.png" /></figure><p>Redis, açılımı Remote Dictionary Server (Uzak Sözlük Sunucusu) olan, cache tabanlı, key-value veritabanı olarak kullanılan açık kaynaklı bir teknolojidir. Redis, ana bellekte (RAM) çalışır ve hızlı okuma/yazma işlemleri için optimize edilmiştir.</p><p>Redis, birçok farklı kullanım senaryosu için uygun bir veritabanıdır. Örneğin, oturum yönetimi(session management), mesajlaşma(message queues), sıralama(sorting), önbellekleme(cache management) ve gerçek zamanlı veri analizi(real time data analysis) gibi uygulamalar için kullanılabilir. Veri yapısı olarak, string, hash, list, set ve sorted set veri tiplerini destekler.</p><p><strong>Redis Neden Kullanılmalı?</strong></p><p>Redis’in kullanım amacı aslında T-SQL veya NoSQL tipindeki veritabanlarının sorgu çalıştırma, diskten okuma ve sonuç alma işlemlerini hızlandırmak ve basitleştirmektir. Tablo mantığından uzak, tamamen key-value yapısına bağlı bu sistem aynı zamanda clustering ve imaging özelliğine de sahiptir. Normalde MSSQL üzerinden çalıştırdığımız bir sorgu sonucunun gelmesinden yaklaşık 100 kat daha hızlı çalışır, bunun sebebi bilgilerin diskte değil memoryde tutulmasıdır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*WhZ1PlrFiKmS8N1vCoKmnQ.png" /></figure><p><strong>Redis Kurulumu</strong></p><p>Redis’i Windows makineler üzerinde kurmak için aşağıda gösterildiği gibi <a href="https://github.com/microsoftarchive/redis/releases">bu adresten</a> “Assets” kısmındaki .msi installer veya zip halini indirmemiz gerekiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*f2PZcgkMEMYQ-K5tlBLX8A.png" /></figure><p>Msi installer üzerinden yüklenen dizine veya zip içerisinden ilk olarak redis-server.exe yi çalıştırıp Redis’in ayağa kalkmasını sağlıyoruz. Sonra da redis-cli.exe yi çalıştırarak komut girdi uygulamasını açıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*PZ4-ZipIyRvCq7MYFPjPeA.png" /></figure><p>Redis’in ayakta olup olmadığını test edebilmek için CLI üzerinden “ping” komutunu çalıştırırsak sonucunun “PONG” olarak geldiğini görmemiz yeterli.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*f-kJtwWAXeeEr2vFyf0r2Q.png" /></figure><p>Örneğin, login bilgilerinin tutulması için ufak bir konsol örneği yapabiliriz. Anahtar olarak “userid”, “username” ve “token” tuttuğumuzu hayal edelim. “set” komutu ile aşağıdaki gibi <strong>set &lt;key&gt; &lt;value&gt;</strong> halinde kullanılabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*c3-xN-aNOzaPEnJVq0vklw.png" /></figure><p>Anahtarlarımızı oluşturduktan sonra Redis cache üzerinde kaç anahtarımızın olduğunu görmek için <strong>keys * </strong>komutunu çalıştırabiliriz. Anahtarlarımızın tekil oalrak değerlerini görmek istersek <strong>get &lt;key&gt;</strong> komutuyla görebiliriz.</p><p>Redis hakkında daha çok komut örneği için <a href="https://redis.io/commands/">bu sayfayı</a> kullanabilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*a6m0tTFUjw1nkX9Ldt_5pA.png" /></figure><p><strong>Redis Windows Servis Kurulumu</strong></p><p>Diyelim ki Redis’i <strong>cmd</strong> üzerinden çalıştırmak yerine Windows Service olarak hizmet edecek şekilde makinemizde konfigürasyon yapmak istiyoruz. Bunun için indirdiğimiz Redis dosyaları içinde konfigürasyon dosyaları mevcut. Dosya dizini aşağıda belirtilmiştir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*KjQLme53iUMre6ThBqe8ew.png" /></figure><p>Bu dizine Administrator olarak <strong>cmd</strong> üzerinden gidersek ve <strong>redis-server — service-install redis.windows-service.conf — loglevel verbose </strong>komutunu çalıştırırsak aşağıdaki gibi işletim sistemimizin <strong>“Services”</strong> kısmında Redis’i görebilmeliyiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*5zqovVZsvIrhgC4WZAWHvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gA7Z7m9vMjZixH2ZNJrIw.png" /></figure><p>Servisimiz kurulduktan sonra ilgili port üzerinden erişim sağlayabiliriz.</p><p><strong>Redis .NET üzerinde nasıl kullanılır</strong></p><p>Redis’i .NET projesi üzerinde çalıştırmak için aşağıdaki gibi projemize <strong>StackExchange.Redis</strong> adlı <strong>NuGet Package</strong>’ı yüklememiz gereklidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voZ6p9dg5AvDuOmZz2cXPQ.png" /></figure><p>Sonrasında Redis’in windows makinemiz üzerindeki servisine erişebilmek için eski .NET projelerinde <strong>web.config</strong>, yeni .NET projelerinde ise <strong>appsetting.json</strong> dosyamızı solution üzerinden açarak aşağıdaki gibi Redis adresimizi portuyla birlikte eklememiz gerekmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*dKXIBNs2qPrtC-F4k-Ty7A.png" /></figure><p>Sonrasında Redis bağlantısını projemizle kurmak için örnek olarak CacheService isminde bir class oluşturabiliriz.</p><pre>public class CacheService : ICacheService<br>    {<br>        private IDatabase _db;<br><br>        public CacheService()<br>        {<br>            ConfigureRedis();<br>        }<br><br>        private void ConfigureRedis()<br>        {<br>            _db = ConnectionHelper.Connection.GetDatabase();<br>        }<br><br>        public T GetData&lt;T&gt;(string key)<br>        {<br>            var value = _db.StringGet(key);<br><br>            if (!string.IsNullOrEmpty(value))<br>            {<br>                return JsonConvert.DeserializeObject&lt;T&gt;(value);<br>            }<br><br>            return default;<br>        }     <br><br>        public bool SetData&lt;T&gt;(string key, T value, DateTimeOffset expirationTime)<br>        {<br>            TimeSpan expiryTime = expirationTime.DateTime.Subtract(DateTime.Now);<br><br>            var isSet =_db.StringSet(key, JsonConvert.SerializeObject(value), expiryTime);<br><br>            return isSet;<br>        }<br><br>        public object RemoveData(string key)<br>        { <br>            bool _isKeyExist = _db.KeyExists(key);<br>            if (_isKeyExist == true)<br>            {<br>                return _db.KeyDelete(key);<br>            }<br>            return false;<br>        }<br>    }</pre><p>Bu sınıfta <strong>ConfigureRedis()</strong> metodu ile Redis servisine bağlanmak için gereken konfigürasyon verimiz okunur. Redis’in yüklediğimiz kendi frameworkü üzerinden aşağıdaki gibi bağlantı kurulur.</p><pre> public class ConnectionHelper<br>    {<br>        static ConnectionHelper()<br>        {<br>            ConnectionHelper.lazyConnection = new Lazy&lt;ConnectionMultiplexer&gt;(() =&gt;<br>            {<br>                return ConnectionMultiplexer.Connect(ConfigurationManager.AppSetting[&quot;RedisURL&quot;]);<br>            });<br>        }<br><br>        private static Lazy&lt;ConnectionMultiplexer&gt; lazyConnection;<br><br>        public static ConnectionMultiplexer Connection<br>        {<br>            get<br>            {<br>                return lazyConnection.Value;<br>            }<br>        }<br>    }</pre><p><strong>ConnectionMultiplexer.Connect</strong> metodu Redis frameworküne ait bir metoddur. Bağlantı kurulduktan sonra yukarıda belirtilen <strong>CacheService</strong> classından <strong>GetData()</strong>, <strong>SetData()</strong> ve <strong>RemoveData()</strong> metodları implemente ettiğimiz yere göre referansı olan her yerde kullanılabilir hale gelmektedir.</p><p>Sonuç olarak Redis, yüksek performanslı ve ölçeklenebilir bir veritabanı olarak, birçok uygulama tarafından tercih edilen bir araçtır. Özellikle önbellek yönetimi, mesaj kuyrukları, oturum yönetimi ve gerçek zamanlı bildirimler gibi senaryolarda kullanımı oldukça yaygındır. Bununla birlikte, Redis’in bellek sınırlamaları, disk desteğinin sınırlı olması, karmaşık sorgulara uygun olmaması ve öğrenme eğrisinin olması gibi bazı dezavantajları da vardır. Ancak, doğru senaryolarda kullanıldığında, performansı ve ölçeklenebilirliği nedeniyle Redis, geliştiricilerin uygulamalarının performansını ve ölçeklenebilirliğini artırmak için oldukça yararlı bir araçtır.</p><p><strong>Referanslar</strong></p><ul><li><a href="https://github.com/microsoftarchive/redis/releases">Releases · microsoftarchive/redis</a></li><li><a href="https://redis.io/commands/">Commands</a></li><li><a href="https://linuxiac.com/redis-as-cache/">Redis as Cache: How it Works and Why to Use it</a></li></ul><p><a href="https://medium.com/u/1744ebd33828">Can Kayı</a> <a href="https://medium.com/u/8e1d48bce088">Mehmet Yürek</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34fda9c632b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/multinetinventiv/redis-101-34fda9c632b1">Redis 101</a> was originally published in <a href="https://medium.com/multinetinventiv">inventiv</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring Code Smells: Data Clumps]]></title>
            <link>https://medium.com/multinetinventiv/refactoring-code-smells-data-clumps-1d9823c7198e?source=rss-1744ebd33828------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d9823c7198e</guid>
            <category><![CDATA[data-clumps]]></category>
            <category><![CDATA[code-smells]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[english]]></category>
            <dc:creator><![CDATA[Can Kayı]]></dc:creator>
            <pubDate>Fri, 22 Apr 2022 13:38:52 GMT</pubDate>
            <atom:updated>2022-12-21T10:52:04.477Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfTqHp-Aec0M2wsRttL4XA.jpeg" /></figure><p>A code smell means, badly maintained but healthily compiled source code from a subjective perspective. It is mainly not causing any problems when the code smell is implemented, it will cause problems after new code is added to the source code. Software developers unknowingly may implement code smells into the source code and if they are not fixed, they may cause bigger problems on development basis.</p><p><strong>Introduction to Bloaters</strong></p><p>We can categorize code smells into five different branches:</p><ul><li>Bloaters</li><li>Object-Orientation Abusers</li><li>Change Preventers</li><li>Dispensables</li><li>Couplers</li></ul><p>This article will focus on Bloaters branch as a code smell. In British slang, Bloater means “fat or greedy person”. In coding Bloaters may look like long methods, large classes(god objects), data clumps, long parameter list and primitive obsession.</p><p>Long methods and large classes cause problems for developers in the long run, they reduce readability and they increase the complexity of the method or the class. For developers it gets harder to understand what the method is actually doing or why the class is actually created for. Also the availability to reuse of the method or the class is less possible when new code is added.</p><p>Long parameter list means if developers have some related properties to pass as parameters to methods, those properties should be readable and reusable as an object. For example; if we have a start date and an end date as parameters, they should be passed as a “Date” object.</p><p>Primitive obsession is a behavior of categorizing objects on primitive values instead of creating classes for a context data. For example; imagine a class named Employee which has properties for Engineer, Salesman and type(to define that Employee is whether an Engineer or a Salesman). If there is going to be a third role, we must add it to the class with a new type. To fix this complexity, we can create 3 different classes like Employee-Engineer-Salesman. Engineer and Salesman can inherit an EmployeeType property from Employee class and we can set EmployeeType on their constructors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*iSG8Z_cveLTLd3Fh9LObJA.png" /><figcaption>Primitive Obsession Solution</figcaption></figure><p>Finally we arrive to our main subject, Data Clumps. This means that some identical variables or parameters can be grouped into objects for easier reusability and readability. This problem occurs when “copypasta programming” is used in software development.</p><p>To prevent Data Clumps, there are a few refactoring methods we can apply to our code, as mentioned before, these refactoring methods can be applied by a subjective look so if the developer feels that the code is hard to read, reach or reuse it is recommended to use these methods. The code should always be simplified because as long as the development continues, it will be harder to reverse the complexity. As many said, if you can’t explain something as simple as it is, you may not exactly know what it is.</p><p><strong>Extract Class</strong></p><p>First refactoring method to prevent Data Clumps is Extract Class. This method is required when we have a class using methods that is actually related to another concept. For example, we have a class named Shape which implements two different methods inside, Draw() and LogError().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b31924929d585ee9c45570ea2f5690ed/href">https://medium.com/media/b31924929d585ee9c45570ea2f5690ed/href</a></iframe><p>The problem here is the LogError() implementation is irrelevant with the Shape class because logging an error can be used in many situations except Shape and if we want to log an error for something else, we have to define it again or use it inside Shape and logging an error from accessing Shape class is too irrelevant.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45efe087239df8428a0b451007e150f6/href">https://medium.com/media/45efe087239df8428a0b451007e150f6/href</a></iframe><p>So the solution here is to define another class named Logger and access it inside Shape class to log errors. With this change, we can separate the responsibilities of our classes. Also this refers to Single Responsibility Principle(SRP).</p><p><strong>Introduce Parameter Object</strong></p><p>Introduce Parameter Object has a meaning of converting many similar parameters to a parameter object. Imagine we have a Mail class which implements two methods of SendEmail().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12a21f629f86364ff48fac20b1706ddb/href">https://medium.com/media/12a21f629f86364ff48fac20b1706ddb/href</a></iframe><p>The problem here is that we have too many parameters used in method which are relevant to each other.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c1da6243b0ef0caea1f3bc42153845f/href">https://medium.com/media/9c1da6243b0ef0caea1f3bc42153845f/href</a></iframe><p>To solve this, we can create a struct included by the properties which we need as parameters to send a mail. By applying this refactoring method, we prevent code duplication and reduce the complexity of parameters. Also we have more readable code.</p><p><strong>Preserve Whole Object</strong></p><p>This can be defined in many forms like the repetition of collecting an object’s methods or properties to fill another method’s parameters instead of sending the whole object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e627cd7bb60bf2a6435171321822381/href">https://medium.com/media/7e627cd7bb60bf2a6435171321822381/href</a></iframe><p>The issue above is that we define two extra variables to send the parameters to WithinRange() instead of sending the Room object as a parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efef112d6a3fc62082be6c1d7a2608bb/href">https://medium.com/media/efef112d6a3fc62082be6c1d7a2608bb/href</a></iframe><p>With this fix, if WithinRange() method needs another parameter within Room object we provide it without adding extra parameters.</p><p>Martin Fowler says;</p><blockquote>“Whenever two or three values are gathered together, turn them into an object.”</blockquote><p>As a result, people have different perspectives and measuring about code smells but we need to prevent the complexity as developers. Code Smells may happen to exist in every code we write, it is our experience how to prevent it.</p><p><strong>References</strong></p><ul><li><a href="https://www.jetbrains.com/help/resharper/Refactorings__Extract_Class.html">Extract Class refactoring | ReSharper</a></li><li><a href="https://refactoring.guru/refactoring/smells">Code Smells</a></li><li><a href="https://martinfowler.com/bliki/DataClump.html">bliki: DataClump</a></li><li><a href="https://github.com/RefactoringGuru/refactoring-examples/blob/main/interactive/java/preserve-whole-object.md">refactoring-examples/preserve-whole-object.md at main · RefactoringGuru/refactoring-examples</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d9823c7198e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/multinetinventiv/refactoring-code-smells-data-clumps-1d9823c7198e">Refactoring Code Smells: Data Clumps</a> was originally published in <a href="https://medium.com/multinetinventiv">inventiv</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>