<?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 Emrah Turan on Medium]]></title>
        <description><![CDATA[Stories by Emrah Turan on Medium]]></description>
        <link>https://medium.com/@emrahturan?source=rss-1c4798f79ca9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VIM7I9QjVLlxPBJ7ZlRnew.jpeg</url>
            <title>Stories by Emrah Turan on Medium</title>
            <link>https://medium.com/@emrahturan?source=rss-1c4798f79ca9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:27:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@emrahturan/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[Adapter Design Pattern]]></title>
            <link>https://emrahturan.medium.com/adapter-design-pattern-2132944aa3c6?source=rss-1c4798f79ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2132944aa3c6</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[adapter-design-pattern]]></category>
            <dc:creator><![CDATA[Emrah Turan]]></dc:creator>
            <pubDate>Sun, 05 Nov 2023 21:02:41 GMT</pubDate>
            <atom:updated>2024-01-03T07:54:57.434Z</atom:updated>
            <content:encoded><![CDATA[<p>The Adapter Design Pattern is a design pattern used to make two different interfaces work together seamlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snQKnNWuJWk4coIUI38dJw.jpeg" /></figure><p>Let’s consider that in our application, there is an identity scanning module. Suppose our existing module has become dysfunctional due to changes in the identity system, and we need to integrate the new identity scanning module developed by ABC Company into the project.</p><p>In our current system, the identity scanning process is performed using the “scan()” function of the “CustomScanner” class, which implements the “IdScannerProtocol” protocol.</p><pre>protocol IdScannerProtocol {<br>    func scan()<br>}<br><br>final class CustomScanner: IdScannerProtocol {<br>    func scan() {<br>        print(&quot;id scanned&quot;)<br>    }<br>}</pre><p>In our application designed according to SOLID principles, the “scanner” variable is defined as an “IdScannerProtocol” and is created from a class that implements this protocol.</p><pre>let scanner: IdScannerProtocol = CustomScanner()<br>scanner.scan()</pre><p>The identity scanning module obtained from ABC Company performs the scanning process using the “scanner()” function.</p><pre>class ABCScanner {<br>    func scanner() {<br>        print(&quot;id scanned&quot;)<br>    }<br>}</pre><p>Since our application performs identity scanning according to the “IdScannerProtocol” protocol, we need to make this new module we received from the outside compatible with the “IdScannerProtocol.” This is where the Adapter Design Pattern comes into play.</p><pre>class ABCScannerAdapter: IdScannerProtocol {<br>    private let abcScanner: ABCScanner<br><br>    init(abcScanner: ABCScanner) {<br>        self.abcScanner = abcScanner<br>    }<br><br>    func scan() {<br>        abcScanner.scanner()<br>    }<br>}</pre><p>Our adapter is ready, and all we need to do is use the “ABCScannerAdapter” class instead of “CustomScanner.” This way, we can seamlessly integrate ABC Company’s identity scanning module into our existing system.</p><pre>//let scanner: IdScannerProtocol = CustomScanner()<br>let scanner: IdScannerProtocol = ABCScannerAdapter(abcScanner: ABCScanner())<br>scanner.scan()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2132944aa3c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID Prensipleri Nedir?]]></title>
            <link>https://emrahturan.medium.com/solid-prensipleri-nedir-b62a06f16397?source=rss-1c4798f79ca9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b62a06f16397</guid>
            <category><![CDATA[solid-prensipleri]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[single-responsibility]]></category>
            <category><![CDATA[liskov-substitution]]></category>
            <category><![CDATA[dependency-inversion]]></category>
            <dc:creator><![CDATA[Emrah Turan]]></dc:creator>
            <pubDate>Sun, 21 Feb 2021 11:39:03 GMT</pubDate>
            <atom:updated>2024-01-03T07:54:41.961Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>SOLID</strong> kavramını ilk olarak üniversitede duymuştum. Udemy’de aldığım kurslarda, girdiğim iş mülakatlarında hep bu kavramla karşılaştım. Profesyonel iş hayatına adım atmamla birlikte SOLID prensiplerinin önemini, neden bu prensipleri iyi bir şekilde öğrenmem gerektiğini daha iyi anladım.</p><p>SOLID prensipleri ilk olarak Robert C. Martin tarafından <a href="https://fi.ort.edu.uy/innovaportal/file/2032/1/design_principles.pdf">makalesinde</a> tanıtıldı. Bu makalede yer alan ilkelerin amacı yazdığımız kodun okunabilir, anlaşılabilir ve geliştirilebilir hale getirmektir. SOLID kelimesi ise makalede yer alan 5 temel prensipin baş harflerinin bir araya gelmesiyle oluşmuştur.</p><ul><li><strong>S</strong>ingle Responsibility Principle</li><li><strong>O</strong>pen-Closed Principle</li><li><strong>L</strong>iskov Substitution Principle</li><li><strong>I</strong>nterface Segregation Principle</li><li><strong>D</strong>ependency Inversion Principle</li></ul><p><strong>Single Responsibility Principle<br></strong>Tek sorumluluk prensibi, bir sınıfın ya da fonksiyonun tek bir görevi olmasını belirtir. Örnek olarak veritabanı işlemi yapan bir fonksiyonun aynı zamanda loglama yapması bu ilkeye aykırıdır.</p><p><strong>Open-Closed Principle<br></strong>Açık-Kapalı prensibi, sınıfların genişletilmeye açık ve değişikliğe kapalı olmasını belirtir. Bu ilkede sınıfdaki mevcut koda dokunmadan yeni işlevler kazandırılabilmesinden bahsediliyor. Mevcut kodu değiştirdiğinizde farkında olmadan farklı bir yeri etkilemiş olma riskiniz olabiliyor.</p><p>Aşağıdaki örnekte basit bir şekilde çalışanları modelledim. Bu yapıda çalışanlar Employee protokolünden türüyor. Developer ve TeamLeader sınıflarında bulunan getDetails fonksiyonu özelleştirilebilir yapıdadır. Yeni bir çalışan tipi geldiğinde ise Employee protokolünden türemiş bir sınıf oluşturarak sisteme dahil edilebilecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*BcmgnshcNCLHEOlHdTo9tw.png" /><figcaption>Open-Closed Principle</figcaption></figure><p><strong>Liskov Substitution Principle<br></strong>Liskov Yerine geçme prensibi, alt sınıfların temel sınıflarının yerine geçmesi gerektiğini belirtir.</p><p>Aşağıdaki örnekte loglama için bir protocol yazılmıştır. TxtLogger ve DbLogger sınıfları LoggerService isimli protocol aracılığıyla türetilmiştir. Loglama yapacak olan Logger sınıfının log isimli metodu ise parametre olarak LoggerService tipinde bir parametre almaktadır. Loglama için hangi yöntemi kullanmak istiyorsak ilgili sınıfı parametre olarak vermemiz yeterli olacaktır. Liskov prensibini düşündüğümüzde alt sınıfların(TxtLogger veya DbLogger) temel sınıflarının(LoggerService) yerine geçtiğini daha net göreceksiniz.</p><figure><img alt="Liskov Substitution Principle" src="https://cdn-images-1.medium.com/max/814/1*fJrzpiGN6cQ5EHn9slgw7Q.png" /><figcaption>Liskov Substitution Principle</figcaption></figure><p><strong>Interface Segregation Principle<br></strong>Arayüz ayırma prensibi, bir arayüze gereğinden fazla yetenek eklenmemesi gerektiğini belirtir.</p><p>Bu senaryomuzda bir banka düşünelim. Bireysel müşterileri A ve B kartlarını, Ticari müşterileri ise C kartını alabilsin. CreditCardApplication protokolü kullanılarak türetilecek bireysel ve ticari müşterilere ait sınıflarda kendinde olmaması gereken özellikler de yer almış olacak. Bireysel müşteri sınıfını IndividualCreditCardApplication protokolünden, ticari müşterileri ise CommercialCreditCardApplication protokolünden türettiğimizde daha okunabilir ve her biri kendi görevini yapan sınıflar oluşturabileceğiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*14jZDqVDM12u5MVrWYLPRg.png" /><figcaption>Interface Segregation Principle</figcaption></figure><p><strong>Dependency Inversion Principle</strong><br>Bağımlılığın ters çevrilmesi prensibi, sınıflar arası bağımlılığın en az inmesini, aralarındaki bağın soyut sınıflar üzerinden olması gerektiğini belirtir.</p><p>Bu senaryoyu incelediğimizde RestaurantA sınıfı TarhanaSoup sınıfına doğrudan bağımlı olduğunu görüyoruz. Bu durum kodun karışmasına ve yönetiminin zorlaşmasına sebep olacaktır. TarhanaSoup sınıfında bir değişiklik yapıldığında ya da yeni bir çorba tipi geldiğinde RestaurantA sınıfında değişiklik yapmamız gerekecek.</p><p>RestaurantB sınıfını ise Soup tipinde bir parametre alacak şekilde hazırlandı. LentilSoup sınıfında bir değişiklik yaptığımızda ya da yeni bir çorba tipi geldiğinde RestaurantB sınıfının hiçbirinden haberi olmayacak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*q1VLOiwt1yhlbrXrSygpNQ.png" /><figcaption>Dependency Inversion Principle</figcaption></figure><p>Bir sonraki yazımda görüşmek üzere..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b62a06f16397" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>