<?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 Ercan Çavuşoğlu on Medium]]></title>
        <description><![CDATA[Stories by Ercan Çavuşoğlu on Medium]]></description>
        <link>https://medium.com/@ercancavusoglu2020?source=rss-b10e78ebc4d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9r_jX58PpIFJpB9rm8QfMA.jpeg</url>
            <title>Stories by Ercan Çavuşoğlu on Medium</title>
            <link>https://medium.com/@ercancavusoglu2020?source=rss-b10e78ebc4d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:12:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ercancavusoglu2020/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[Dify AI ile Yapay Zeka Projelerine Vites Attırma]]></title>
            <link>https://medium.com/enuygun-wingie-tech/dify-ile-yapay-zeka-projelerinize-h%C4%B1z-verin-kodsuz-uygulama-geli%C5%9Ftirme-5f5a317a0353?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f5a317a0353</guid>
            <category><![CDATA[dify-ai]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 19:23:21 GMT</pubDate>
            <atom:updated>2025-01-16T11:10:56.306Z</atom:updated>
            <content:encoded><![CDATA[<p>Yapay zeka, hayatımızın her alanında hızla yerini alıyor ve iş süreçlerimizi dönüştürüyor. Ancak, yapay zeka tabanlı uygulamalar geliştirmek genellikle karmaşık ve zaman alıcı bir süreç olarak görülüyor. Dify, bu süreci basitleştirerek kod yazmadan yapay zeka uygulamaları oluşturmanıza olanak tanıyan açık kaynaklı bir LLM (Large Language Model) uygulama geliştirme platformu sunuyor.</p><p><a href="https://dify.ai/">Dify: Leading Agentic Workflow Builder</a></p><h3>Dify AI Nedir ve Neden Kullanılmalı?</h3><p>Dify, kullanıcıların jeneratif(üretken) yapay zeka uygulamalarını oluşturmasını ve işletmesini sağlayan bir platformdur. Görsel iş akışı düzenleme, canlı düğüm hata ayıklama ve modüler DSL(Domain-Specific Language) gibi özellikleriyle, yapay zeka uygulamalarınızı hızlı ve verimli bir şekilde geliştirmenize yardımcı olur.</p><p><strong>Dify ile Neler Yapabilirsiniz?</strong></p><ul><li><strong>Chatbot Geliştirme</strong>: Dify, chatbot geliştirme sürecini hızlandırıyor. Kullanıcılar, NLP API’lerini entegre ederek ve veri girişlerini ayarlayarak, hızlıca bir chatbot oluşturabilirler.</li><li><strong>Veri Analizi</strong>: Dify, veri analizi projelerinde kullanılarak, veri toplama, veri işleme ve veri görselleştirme süreçlerini hızlandırıyor.</li><li><strong>Otomaşyon</strong>: Dify, iş süreçlerini otomatikleştirme projelerinde kullanılarak, veri girişlerini, API entegrasyonlarını ve çıktılarını ayarlayarak, otomasyon süreçlerini hızlandırıyor.</li></ul><p><strong>Dify’in Temel Özellikleri</strong></p><ul><li><strong>Görsel İş Akışı Düzenleme:</strong> Karmaşık kodlarla uğraşmadan, görsel bir arayüz üzerinden yapay zeka uygulamalarınızı tasarlayabilirsiniz.</li><li><strong>Canlı Düğüm Hata Ayıklama:</strong> Gerçek zamanlı hata ayıklama özelliği sayesinde, uygulamalarınızın performansını anında izleyebilir ve iyileştirebilirsiniz.</li><li><strong>Modüler DSL:</strong> Esnek ve modüler bir dil ile uygulamalarınızı oluşturabilir, ihtiyaçlarınıza göre özelleştirebilirsiniz.</li><li><strong>Yerel Kod Çalışma Zamanı:</strong> Uygulamalarınızı yerel ortamınızda çalıştırarak, performans optimizasyonu yapabilirsiniz.</li><li><strong>Entegrasyon Kolaylığı:</strong> Google Arama ve DALL-E Çizimi gibi birinci taraf araçların yanı sıra, OpenAPI ve Swagger spesifikasyonları kullanarak özel araçları da entegre edebilirsiniz.</li></ul><p><strong>Başlangıç: Dify ile İlk Adımlar</strong></p><p>Dify ile çalışmaya başlamak oldukça kolay. İşte önerilen başlangıç adımları:</p><ol><li><strong>Kurulum:</strong> Platform, Docker Compose veya aaPanel gibi popüler araçlarla kolayca kurulabilir. <br><a href="https://docs.dify.ai/getting-started/install-self-hosted/docker-compose">https://docs.dify.ai/getting-started/install-self-hosted/docker-compose</a></li><li><strong>Model Seçimi:</strong> Dify, OpenAI, Hugging Face gibi sağlayıcıları destekliyor. Projenizin ihtiyaçlarına uygun bir model seçerek başlayabilirsiniz.</li><li><strong>Örnek Projeler:</strong> Dify dokümantasyonunda yer alan örnek projelerden ilham alabilirsiniz.</li></ol><p><strong>İpucu:</strong> İlk projelerinizde önceden tanımlı modelleri kullanmak, platforma alışmanız açısından faydalı olacaktır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubAfBsb0pVRedOdafFDAkg.png" /><figcaption>Örnek templatelerden de faydalanabilirsiniz.</figcaption></figure><h3>Gerçek Hayattan Örneklerle Dify Kullanımı</h3><h3>1. Sohbet Asistanı Oluşturma</h3><p>Bir müşteri hizmetleri sohbet asistanı geliştirdiğinizi düşünün. Dify’nin sunduğu araçlarla bunu nasıl yapabileceğinizi görelim:</p><ul><li><strong>Adım 1:</strong> Dify’nin OpenAI modeli entegrasyonunu etkinleştirerek dil modelinizi seçin.</li><li><strong>Adım 2:</strong> Sıkça sorulan soruları Notion veya Google Sheets üzerinden içe aktararak bilgi tabanınızı oluşturun.</li><li><strong>Adım 3:</strong> İş akışı yönetimini kullanarak asistanın yanıtlarını düzenleyin, örneğin:</li><li>Müşteri sipariş sorgusu yaptıysa, sipariş durumu bilgilerini çek.</li><li>Yanıt verilemeyen bir soru varsa, bir müşteri temsilcisine yönlendir.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IzbVLQnv5AAbtfvO.png" /><figcaption>İster doğrudan chatbot seçerek oluşturabilirsiniz</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0LF3tdR0mXLEhvZ5d3kGg.png" /><figcaption>İsterseniz daha gelişmiş Chatflow ile chatbot yapabilirsiniz.</figcaption></figure><p><strong>Sonuç:</strong> Dify’nin bu özellikleriyle yalnızca birkaç saat içinde işlevsel bir sohbet asistanı oluşturabilirsiniz.</p><h3>2. Dinamik İçerik Yönlendirme</h3><p>Bir e-ticaret sitesi için dinamik ürün öneri sistemi kurmak istiyorsunuz. Dify’nin bu süreçte nasıl yardımcı olabileceğine bakalım:</p><ul><li><strong>Adım 1:</strong> Platform üzerinden ürün verilerinizi yükleyin. Örneğin, “en popüler ürünler” veya “ilgili ürünler” kategorilerini belirleyin.</li><li><strong>Adım 2:</strong> Bir bilgi tabanı oluşturun ve ürün bilgilerini buraya bağlayın.</li><li><strong>Adım 3:</strong> Uygulama orkestrasyon araçlarını kullanarak, kullanıcının göz attığı ürünlere göre öneriler sunan bir iş akışı oluşturun.</li></ul><p><strong>Örnek Kullanım:</strong> Bir kullanıcı “kış montu” aradığında, platform “en çok satan botları” da önerir.</p><h3>3. Otomatik Veri Analizi</h3><p>Bir finansal raporlama aracı oluşturduğunuzu düşünün. Dify burada da işinizi kolaylaştırabilir:</p><ul><li><strong>Adım 1:</strong> Google Sheets veya Excel tablolarını platforma entegre edin.</li><li><strong>Adım 2:</strong> Yapay zeka modelini eğiterek, geçmiş verilerden trend analizi yapmasını sağlayın.</li><li><strong>Adım 3:</strong> Sonuçları görselleştirerek bir web uygulaması veya API üzerinden kullanıcılara sunun.</li></ul><p><strong>Fayda:</strong> Bu sistem, verilerdeki gizli trendleri hızlıca bulmanıza yardımcı olur ve karar alma süreçlerini hızlandırır.</p><h3>Dify’nin Öne Çıkan Araçları ile Daha Fazlasını Başarın</h3><h3>1. Workflow Yönetimi</h3><p><strong>Kullanım Senaryosu:</strong> Bir çağrı merkezi için çok aşamalı bir iş akışı.</p><ul><li><strong>Örnek:</strong> Gelen çağrıları konuya göre sınıflandıran ve gerekli departmana yönlendiren bir sistem kurabilirsiniz.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHKeY47HUyXCn5Rc0j_8nw.gif" /><figcaption>Workflow kurmak bu kadar basit</figcaption></figure><h3>2. Tools Entegrasyonu</h3><p><strong>Kullanım Senaryosu:</strong> Google ve Bing’den veri çeken bir araştırma asistanı.</p><ul><li><strong>Örnek:</strong> “Son 24 saatte yayınlanan teknolojik haberleri bul” şeklinde bir uygulama geliştirebilirsiniz.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AzI_cxjFUL6BXvQKNil1Ng.png" /><figcaption>Çok sayıda tool entegrasyonu mevcut</figcaption></figure><h3>3. Test ve İzleme</h3><p><strong>Kullanım Senaryosu:</strong> Uygulamanızın performansını gerçek zamanlı olarak takip etmek.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M3rR7NedNiqtvindz8MQSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zpjs7Rift1rWIj2Z9Jg4pw.png" /></figure><ul><li><strong>Örnek:</strong> Dify’nin izleme araçlarıyla API çağrılarının hızını ve kullanıcı geri dönüşlerini analiz edin.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1tF9M3cjhoX-34L4.png" /><figcaption>Dify API ile projelerinizde fark yaratın.</figcaption></figure><h3>Dify ile Verimliliği Artırmanın İpuçları</h3><ol><li><strong>Ekibinizle İş Birliği Yapın:</strong> Ekip üyelerini projeye davet ederek görev paylaşımı yapın.</li><li><strong>Modelleri Test Edin:</strong> Birden fazla modeli test ederek projeniz için en uygun olanı seçin.</li><li><strong>Otomasyonu Kullanın:</strong> İş akışlarınızdaki tekrar eden görevleri otomatikleştirin.</li></ol><h3>Dify Kullanırken Dikkat Edilmesi Gerekenler</h3><p>Dify, birçok avantaj sunsa da, kullanırken dikkat edilmesi gereken bazı noktalar vardır.</p><ul><li><strong>Güvenlik</strong>: API entegrasyonları ve veri işleme süreçlerinde güvenlik önlemlerini ihmal etmemelisiniz.</li><li><strong>Veri Kalitesi</strong>: AI modellerinin performansı, kullanılan verilerin kalitesine bağlıdır. Veri temizleme ve doğrulama süreçlerine özen göstermelisiniz.</li><li><strong>Ölçeklenebilirlik</strong>: Dify, küçük ve orta ölçekli projeler için idealdir. Ancak, büyük ölçekli projelerde performans sorunları yaşanabilir. Bu nedenle, projenizin büyüklüğünü göz önünde bulundurmalısınız.</li></ul><h3>Sonuç: Dify ile Potansiyelinizi Maksimize Edin</h3><p>Dify, yapay zeka uygulama geliştirme sürecini basitleştirerek, kod yazmadan hızlı ve etkili çözümler üretmenize olanak tanır. Eğer siz de yapay zeka projelerinizi hızlandırmak ve iş süreçlerinizi dönüştürmek istiyorsanız, Dify’yi deneyerek kendi uygulamalarınızı oluşturabilirsiniz.</p><p>Unutmayın, yapay zeka dünyasında her geçen gün yeni fırsatlar ortaya çıkıyor. Dify gibi araçlar sayesinde, bu fırsatları değerlendirerek projelerinizi bir adım öteye taşıyabilirsiniz.</p><p>Wingie Enuygun ekibinin bir parçası olmak ister misin? Açık pozisyonlarımızı <a href="https://apply.workable.com/wingieenuygun/">Wingie Enuygun Kariyer</a> sayfamızda, <a href="https://www.enuygun.com/kariyer/">web sitemizde</a> ve <a href="https://www.linkedin.com/company/wingieenuygungroup/">LinkedIn hesabımızda</a> bulabilirsin.💚<br>Bizle ilgili daha fazla bilgiye ulaşmak için <a href="https://www.linkedin.com/company/wingieenuygungroup/">LinkedIn hesabımızı</a> takip et!</p><p>👉🏻Tüm makalelerimiz için <a href="https://medium.com/enuygun-wingie-product">tıkla</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f5a317a0353" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enuygun-wingie-tech/dify-ile-yapay-zeka-projelerinize-h%C4%B1z-verin-kodsuz-uygulama-geli%C5%9Ftirme-5f5a317a0353">Dify AI ile Yapay Zeka Projelerine Vites Attırma</a> was originally published in <a href="https://medium.com/enuygun-wingie-tech">Wingie Enuygun Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cursor AI ile Ekip İletişimini ve Üretkenliği Artırma]]></title>
            <link>https://medium.com/enuygun-wingie-tech/cursor-ai-ile-ekip-i%CC%87leti%C5%9Fimini-ve-%C3%BCretkenli%C4%9Fi-art%C4%B1rma-fb9e6243dada?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb9e6243dada</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cursor-ai]]></category>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Thu, 19 Dec 2024 17:12:51 GMT</pubDate>
            <atom:updated>2025-01-06T14:53:32.615Z</atom:updated>
            <content:encoded><![CDATA[<p>Yazılım dünyasında hepimizin hayali nedir? Daha az çabayla daha fazla üretmek, değil mi? İşte tam da bu noktada Cursor AI devreye giriyor ve ekibimizin iş yapma şeklini adeta bir üst seviyeye taşıyor. Biz yazılımcılar olarak yaşayan, nefes alan ürünler ortaya çıkarmak istiyoruz ve Cursor AI, bu süreçte hem iletişimimizi güçlendiriyor hem de üretkenliğimizi artırıyor. 😊</p><h3>Cursor AI Nedir ve Ne Yapar?</h3><p>Cursor AI, kod yazarken size destek veren, sorunlarınızı çözmek için önerilerde bulunan ve bir anlamda sizin ikinci beyniniz gibi çalışan bir yapay zeka aracıdır. Kimi zaman “Bu kodu nasıl optimize ederim?” diye kara kara düşünürken, kimi zaman da karmaşık bir algoritmayı anlamaya çalışırken Cursor AI, elini taşın altına koyar ve “Birlikte hallederiz!” der. 💪</p><p>Peki, bu harika aracı nasıl kullanabiliriz? Hadi birlikte bakalım:</p><p><a href="https://www.cursor.com/features">Features | Cursor - The AI Code Editor</a></p><h3>1. Daha Hızlı ve Etkili Kodlama</h3><p>Yazılım dünyasında zaman altın değerinde. Cursor AI, kod önerileriyle sizi hızlandırırken, aynı zamanda temiz ve düzenli bir kod yazmanızı sağlar. Örneğin, bir fonksiyonun performansını artırmak istiyorsunuz ama nereden başlayacağınızı bilemiyorsunuz. Cursor AI burada devreye girip size en iyi uygulamaları sunuyor. Hem vakitten tasarruf hem de kaliteli bir iş! 🙌</p><h4>Pratik Örnek:</h4><pre>// Orijinal Kod<br>function calculateSum(arr) {<br>    let sum = 0;<br>    for (let i = 0; i &lt; arr.length; i++) {<br>        sum += arr[i];<br>    }<br>    return sum;<br>}<br><br>// Cursor AI Önerisiyle<br>const calculateSum = (arr) =&gt; arr.reduce((sum, num) =&gt; sum + num, 0);</pre><h3>2. İletişim ve İşbirliğinde Güçlenme</h3><p>Ekip içinde herkesin aynı dili konuşması her zaman kolay olmayabilir. Cursor AI, dokümantasyon hazırlamaktan tutun da karmaşık konuları basitçe açıklamaya kadar birçok konuda destek sağlar. Örneğin, “Bu modülün işleyişini bir dökümana dökebilir misin?” dediğinizde, Cursor AI sizin için bunu zahmetsizce yapar. Hatta, “Ben bu kısmı anlamadım” diyen ekip arkadaşınızın sorularına bile yanıt bulabilir. 🤝</p><h3>3. Hataları Bulma ve Çözme</h3><p>“Hata var, panik yok!” diye bir sloganımız var, değil mi? Cursor AI ile bu sloganın hakkını veriyoruz. Hataları tespit etmek ve çözmek Cursor AI sayesinde çok daha kolay hale geliyor. Bir log çıktısında gömülü olan o kritik hatayı Cursor AI birkaç saniyede bulup size öneriler sunabiliyor. “Oooo, bu iş tam bizlik!” dedirtiyor. 😎</p><h4>Debugging Örneği:</h4><p>Bir hata mesajı aldığınızda:</p><pre>TypeError: Cannot read property &#39;length&#39; of undefined</pre><p>Cursor AI size şu adımları önerir:</p><ol><li>Değişkeni kontrol et (tanımlı mı?)</li><li>console.log ile hata noktalarını izle.</li><li>Alternatif bir hata yönetimi yapısı kur (ör. try-catch).</li></ol><h3>4. Kod Kalitesini Artırma</h3><p>Cursor AI sadece hız konusunda yardımcı olmakla kalmaz, aynı zamanda kodunuzun kalitesini de artırmaya odaklanır. Kodunuzu analiz ederek potansiyel hata kaynaklarını, optimizasyon fırsatlarını ve best practices (en iyi uygulamalar) önerilerini sunar. Bu, yalnızca işinize hız katmakla kalmaz, aynı zamanda ekip içindeki kod kalitesini standartlaştırmaya da yardımcı olur. Üstelik bu süreç, zaman içinde daha az hatalı ve daha sürdürülebilir bir yazılım geliştirmeye yol açar.</p><p><strong>Pratik Örnek:</strong></p><pre>// Orijinal Kod<br>function fetchData() {<br>  return fetch(&#39;url&#39;)<br>    .then(response =&gt; response.json())<br>    .catch(error =&gt; console.error(&#39;Error:&#39;, error));<br>}<br><br>// Cursor AI Önerisiyle<br>const fetchData = async () =&gt; {<br>  try {<br>    const response = await fetch(&#39;url&#39;);<br>    return await response.json();<br>  } catch (error) {<br>    console.error(&#39;Error:&#39;, error);<br>  }<br>};</pre><p>Yukarıdaki örnekte, Cursor AI asenkron işleme geçişi önererek, modern JavaScript ile daha verimli ve hatasız bir çözüm sunmuş oluyor.</p><p>Kullanımı da oldukça basit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGWUhY97MVJIlI-1D0b-qQ.png" /></figure><h3>5. Ekip İçindeki Zamanı Verimli Kullanma</h3><p>Cursor AI, kodlama sürecinde zaman kazandıran önerilerde bulunmanın yanı sıra, aynı zamanda ekip içindeki koordinasyonu ve zaman yönetimini de geliştirebilir. Ekip üyeleri birbirlerinin yazdığı kodu anlamada zorlanabilir veya benzer hataları tekrar edebilir. Cursor AI, ekip üyelerinin birbirleriyle daha verimli çalışabilmesi için gereksiz zaman kayıplarını engeller ve daha hızlı bir iş akışı oluşturur.</p><p><strong>Örnek:</strong></p><ul><li>“Birlikte çalışırken kodu daha iyi anlama” — Ekip arkadaşlarınızın yazdığı kodu analiz edip hızlıca anlamanızı sağlayan açıklamalar ve yorumlar ekler.</li><li>“Kodda tekrarlanan hataları engelleme” — Aynı hataların defalarca yapılmasını engelleyerek, sürekli iyileştirilen kodların oluşturulmasına olanak sağlar.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8B-mj42pWPNpHg2FVurDgg.png" /><figcaption>Daha da verimli mod : Composer 🔥🔥</figcaption></figure><h3>6. Yapay Zeka ile Sınırsız Eğitim ve Gelişim</h3><p>Cursor AI, sadece yazılımla ilgili değil, aynı zamanda kişisel gelişim açısından da faydalıdır. Geliştiriciler, her zaman daha iyi ve etkili yazılım yazmak isterler. Cursor AI, sürekli öğrenme ve gelişim fırsatları sunar. AI, size kod yazarken rehberlik ederken, aynı zamanda yeni teknolojiler hakkında bilgi edinmenizi sağlar. Bu süreç, ekip üyelerinin sürekli olarak kendilerini geliştirmelerine yardımcı olur.</p><p><strong>Örnek:</strong></p><ul><li>Cursor AI, yeni teknolojiler ve kütüphaneler hakkında önerilerde bulunabilir.</li><li>Geliştiricilere kod yazma tarzları hakkında geri bildirim sunarak daha temiz ve verimli kod yazmalarını teşvik eder.</li></ul><h3>7. Proje Yönetiminde Destek</h3><p>Cursor AI, proje yönetimi süreçlerinde de büyük bir yardımcı olabilir. Kod yazmanın ötesinde, AI’a proje planlaması, takvim oluşturma veya görev yönetimi gibi konularda da yardımcı olması için yönlendirmelerde bulunabilirsiniz. Kodlama dışında zaman kazanmak isteyen ekipler için bu tür görevler de AI tarafından ele alınabilir.</p><p><strong>Örnek:</strong></p><ul><li>“Proje takvimini oluştur” veya “Öncelikli görevleri belirle” gibi komutlarla proje yönetimini kolaylaştırabilir.</li></ul><h3>8. Geri Bildirim Kültürünü Destekleme</h3><p>Ekip içinde güçlü bir geri bildirim kültürü oluşturmak, başarının önemli bir parçasıdır. Cursor AI, yazılım geliştirme sürecine dahil olan her ekip üyesine anında geri bildirim sunabilir. Bu, hem yazılım kalitesini artırır hem de ekip içindeki iletişimi geliştirir. Ekip üyeleri, birbirlerine sürekli olarak yapıcı geribildirimler sunabilir ve bu da tüm ekip için verimliliği artırır.</p><p><strong>Örnek:</strong></p><ul><li>Yazılım hataları ve potansiyel iyileştirme alanlarını göstermek, ekip üyelerinin daha hızlı gelişmesini sağlar.</li></ul><h3>Cursor AI’ı Kullanırken Dikkat Edilmesi Gerekenler</h3><p>Tabii ki her güçlü aracın sorumlulukları da beraberinde getirdiğini unutmamak lazım. Cursor AI’ı kullanırken şunlara dikkat etmeliyiz:</p><ul><li><strong>Fazla bağımlı olmamak:</strong> Cursor AI harika bir yardımcıdır, ama son karar ve kontrol her zaman sizin elinizde olmalıdır.</li><li><strong>Yapıcı eleştiriler yapmak:</strong> AI’ın önerilerini sorgulayarak kullanın. Sizi her zaman en doğru çözüme yönlendiremeyebilir.</li><li><strong>Ekip içi paylaşımı artırmak:</strong> Cursor AI’dan öğrendiklerinizi ekibinizle paylaşarak birlikte büyüyün.</li></ul><h3>Best Practices:</h3><ul><li>AI çıktısını mutlaka test edin.</li><li>Dokümantasyonu Cursor AI ile düzenli olarak güncelleyin.</li><li>Ekip içi eğitimlerde Cursor AI önerilerini paylaşarak bilgi transferi sağlayın.</li></ul><h3>Sonuç</h3><p>Cursor AI, yazılım geliştirme sürecinde ekibin verimliliğini artırmakla kalmaz, aynı zamanda ekibin daha sağlıklı bir işbirliği ve iletişim içinde çalışmasına olanak tanır. Teknolojiyle dost olan ekipler sadece daha hızlı yazılım üretmekle kalmaz, aynı zamanda daha kaliteli işler ortaya koyar ve sürekli gelişir. Cursor AI ile bir adım önde olursunuz, çünkü teknoloji sizin en güçlü iş arkadaşınız olur. 💡</p><p>Wingie Enuygun ekibinin bir parçası olmak ister misin? Açık pozisyonlarımızı <a href="https://apply.workable.com/wingieenuygun/">Wingie Enuygun Kariyer</a> sayfamızda, <a href="https://www.enuygun.com/kariyer/">web sitemizde</a> ve <a href="https://www.linkedin.com/company/wingieenuygungroup/">LinkedIn hesabımızda</a> bulabilirsin.💚<br>Bizle ilgili daha fazla bilgiye ulaşmak için <a href="https://www.linkedin.com/company/wingieenuygungroup/">LinkedIn hesabımızı</a> takip et!</p><p>👉🏻Tüm makalelerimiz için <a href="https://medium.com/enuygun-wingie-product">tıkla</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb9e6243dada" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enuygun-wingie-tech/cursor-ai-ile-ekip-i%CC%87leti%C5%9Fimini-ve-%C3%BCretkenli%C4%9Fi-art%C4%B1rma-fb9e6243dada">Cursor AI ile Ekip İletişimini ve Üretkenliği Artırma</a> was originally published in <a href="https://medium.com/enuygun-wingie-tech">Wingie Enuygun Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservice Demo Init]]></title>
            <link>https://ercancavusoglu2020.medium.com/microservice-demo-init-bf82c9c2e492?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf82c9c2e492</guid>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 07:01:46 GMT</pubDate>
            <atom:updated>2022-06-30T15:28:19.775Z</atom:updated>
            <content:encoded><![CDATA[<pre>git clone git@github.com:GoogleCloudPlatform/microservices-demo.git<br>cd microservices-demo  <br>minikube start --cpus=4 --memory 4096 --disk-size 32g<br>kubectl apply -f release/kubernetes-manifests.yaml<br>kubectl port-forward deployment/frontend 8082:8080<br></pre><pre>## Install istioctl</pre><pre>cd istio-1.14.1/<br>export PATH=$PWD/bin:$PATH<br>istioctl install<br>kubectl label namespace default istio-injection=enabled<br>kubectl apply -f samples/addons/<br>kubectl get pods</pre><pre>## Monitoring tools active<br>kubectl port-forward svc/kiali 20001 -n istio-system<br>kubectl port-forward svc/grafana -n istio-system 3000:3000<br>kubectl port-forward svc/prometheus -n istio-system 9090:9090<br></pre><pre># see pod crash at kiali and inject service mesh</pre><pre>kubectl delete pod adservice-77d5cd745d-79vpb<br>kubectl get pods<br>kubectl delete pod --all<br>kubectl get pods -n istio-system</pre><pre># inject service again<br>kubectl apply -f release/kubernetes-manifests.yaml</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf82c9c2e492" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Patterns — 3]]></title>
            <link>https://ercancavusoglu2020.medium.com/design-patterns-3-367f8aa3aa4?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/367f8aa3aa4</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 19:49:09 GMT</pubDate>
            <atom:updated>2020-12-07T19:49:09.899Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns — 3</h3><p><strong><em>Behavioral Design Pattern</em></strong></p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\ChainOfResponsibility;<br><br><strong>class </strong>Expense<br>{<br>    <strong>public </strong>$detail;<br>    <strong>public </strong>$amount;<br>}<br><br><strong>abstract class </strong>ExpenseHandlerBase<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>ExpenseHandlerBase */<br>    </em><strong>protected </strong>$successor;<br><br>    <strong>abstract public function </strong>handleExpense(Expense $expense);<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $successor<br>     * </em><strong><em>@return </em></strong><em>ExpenseHandlerBase<br>     */<br>    </em><strong>public function </strong>setSuccessor($successor)<br>    {<br>        $this-&gt;successor = $successor;<br>        <strong>return </strong>$this;<br>    }<br>}<br><br><strong>class </strong>Manager <strong>extends </strong>ExpenseHandlerBase<br>{<br>    <strong>public function </strong>handleExpense(Expense $expense)<br>    {<br>        <strong>if </strong>($expense-&gt;amount &lt;= 100) {<br>            <strong>echo </strong>&quot;manager onayladı&quot;;<br>        } <strong>elseif </strong>($this-&gt;successor !== <strong>null</strong>) {<br>            $this-&gt;successor-&gt;handleExpense($expense);<br>        }<br>    }<br>}<br><br><strong>class </strong>VicePresident <strong>extends </strong>ExpenseHandlerBase<br>{<br>    <strong>public function </strong>handleExpense(Expense $expense)<br>    {<br>        <strong>if </strong>($expense-&gt;amount &gt; 100 &amp;&amp; $expense-&gt;amount &lt;= 1000) {<br>            <strong>echo </strong>&quot;başkan yardımcısı onayladı&quot;;<br>        } <strong>elseif </strong>($this-&gt;successor !== <strong>null</strong>) {<br>            $this-&gt;successor-&gt;handleExpense($expense);<br>        }<br>    }<br>}<br><br><strong>class </strong>President <strong>extends </strong>ExpenseHandlerBase<br>{<br>    <strong>public function </strong>handleExpense(Expense $expense)<br>    {<br>        <strong>if </strong>($expense-&gt;amount &gt; 1000) {<br>            <strong>echo </strong>&quot;başkan onayladı&quot;;<br>        }<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $manager = <strong>new </strong>Manager();<br>        $vicePresident = <strong>new </strong>VicePresident();<br>        $president = <strong>new </strong>President();<br><br>        $manager-&gt;setSuccessor($vicePresident);<br>        $vicePresident-&gt;setSuccessor($president);<br><br>        $expense = <strong>new </strong>Expense();<br>        $expense-&gt;amount = 100;<br>        $expense-&gt;detail = &quot;Gezi&quot;;<br><br>        $manager-&gt;handleExpense($expense);<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Command Design Pattern</em></strong></p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\Command;<br><br><strong>class </strong>StockManager<br>{<br>    <strong>private </strong>$_name = &quot;Laptop&quot;;<br>    <strong>private </strong>$_quantity = 10;<br><br>    <strong>public function </strong>buy()<br>    {<br>        <strong>echo </strong>sprintf(&quot;Stock : %s, %s bought!&quot;, $this-&gt;_name, $this-&gt;_quantity);<br>    }<br><br>    <strong>public function </strong>sell()<br>    {<br>        <strong>echo </strong>sprintf(&quot;Stock : %s, %s sold!&quot;, $this-&gt;_name, $this-&gt;_quantity);<br>    }<br>}<br><br><strong>interface </strong>OrderInterface<br>{<br>    <strong>public function </strong>execute();<br>}<br><br><strong>class </strong>BuyStock <strong>implements </strong>OrderInterface<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>StockManager $_stockManager */<br>    </em><strong>private </strong>$_stockManager;<br><br>    <strong>public function </strong>__construct(StockManager $stockManager)<br>    {<br>        $this-&gt;_stockManager = $stockManager;<br>    }<br><br>    <strong>public function </strong>execute()<br>    {<br>        $this-&gt;_stockManager-&gt;buy();<br>    }<br>}<br><br><strong>class </strong>SellStock <strong>implements </strong>OrderInterface<br>{<br>    <strong>private </strong>$_stockManager;<br><br>    <strong>public function </strong>__construct(StockManager $stockManager)<br>    {<br>        $this-&gt;_stockManager = $stockManager;<br>    }<br><br>    <strong>public function </strong>execute()<br>    {<br>        $this-&gt;_stockManager-&gt;sell();<br>    }<br>}<br><br><strong>class </strong>StockController<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>OrderInterface[] */<br>    </em><strong>protected </strong>$_orders = [];<br><br>    <strong>public function </strong>takeOrder(OrderInterface $order)<br>    {<br>        $this-&gt;_orders[] = $order;<br>    }<br><br>    <strong>public function </strong>placeOrders()<br>    {<br>        <strong>foreach </strong>($this-&gt;_orders <strong>as </strong>$order) {<br>            $order-&gt;execute();<br>        }<br><br>        <strong>unset</strong>($this-&gt;_orders);<br>    }<br>}<br><br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $stockManager = <strong>new </strong>StockManager();<br>        $buyStock = <strong>new </strong>BuyStock($stockManager);<br>        $sellStock = <strong>new </strong>SellStock($stockManager);<br><br>        $stockController = <strong>new </strong>StockController();<br><br>        $stockController-&gt;takeOrder($buyStock);<br>        $stockController-&gt;takeOrder($sellStock);<br>        $stockController-&gt;takeOrder($buyStock);<br><br>        $stockController-&gt;placeOrders();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Mediator Design Pattern</em></strong></p><pre><strong>&lt;?php<br><br></strong># Farklı sistemleri birbiriyle görüştürmek<br># Uçaklarla kuleler arasında iletişim gibi<br># Burada öğrencilere soru soran öğretmen ve öğrenci ilişkisi var<br><br><strong>namespace </strong>Behavioral\Mediator;<br><br><strong>abstract class </strong>CourseMember<br>{<br>    <strong>protected </strong>$mediator;<br><br>    <strong>public function </strong>__construct(Mediator $mediator)<br>    {<br>        $this-&gt;mediator = $mediator;<br>    }<br>}<br><br><strong>class </strong>Teacher <strong>extends </strong>CourseMember<br>{<br>    <strong>public </strong>$name;<br><br>    <strong>public function </strong>recieveQuestion(<strong>string </strong>$question, Student $student)<br>    {<br>        <strong>echo </strong>sprintf(&quot;Teacher recieved a question from %s,%s&quot;, $student-&gt;name, $question);<br>    }<br><br>    <strong>public function </strong>sendNewImageUrl(<strong>string </strong>$url)<br>    {<br>        <strong>echo </strong>sprintf(&quot;Teacher changed slide : %s&quot;, $url);<br>        $this-&gt;mediator-&gt;updateImage($url);<br>    }<br><br>    <strong>public function </strong>answerQuestion(<strong>string </strong>$answer, Student $student)<br>    {<br>        <strong>echo </strong>sprintf(&quot;Teacher answered question %s,%s&quot;, $student-&gt;name, $answer);<br>    }<br><br>}<br><br><strong>class </strong>Student <strong>extends </strong>CourseMember<br>{<br>    <strong>public </strong>$name;<br><br>    <strong>public function </strong>recieveImage(<strong>string </strong>$url)<br>    {<br>        <strong>echo </strong>sprintf(&quot;%s received image : %s&quot;, $url, $this-&gt;name);<br>    }<br><br>    <strong>public function </strong>receiveAnswer(<strong>string </strong>$answer)<br>    {<br>        <strong>echo </strong>sprintf(&quot;Student received answer %s&quot;, $answer);<br>    }<br>}<br><br># Karar veren yer<br><strong>class </strong>Mediator<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>Teacher */<br>    </em><strong>public </strong>$teacher;<br>    <em>/**</em><strong><em>@var </em></strong><em>Student[] */<br>    </em><strong>public </strong>$students;<br><br>    <strong>public function </strong>updateImage(<strong>string </strong>$url)<br>    {<br>        <strong>foreach </strong>($this-&gt;students <strong>as </strong>$student) {<br>            $student-&gt;recieveImage($url);<br>        }<br>    }<br><br>    <strong>public function </strong>sendQuestion(<strong>string </strong>$question, Student $student)<br>    {<br>        $this-&gt;teacher-&gt;recieveQuestion($question, $student);<br>    }<br><br>    <strong>public function </strong>sendAnswer(<strong>string </strong>$answer, Student $student)<br>    {<br>        $student-&gt;receiveAnswer($answer);<br>    }<br>}<br><br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $mediator = <strong>new </strong>Mediator();<br><br>        $teacher = <strong>new </strong>Teacher($mediator);<br>        $teacher-&gt;name = &quot;Engin&quot;;<br><br>        $mediator-&gt;teacher = $teacher;<br><br>        $student1 = <strong>new </strong>Student($mediator);<br>        $student1-&gt;name = &quot;Derin&quot;;<br><br><br>        $student2 = <strong>new </strong>Student($mediator);<br>        $student2-&gt;name = &quot;Salih&quot;;<br><br>        $mediator-&gt;students = [$student1, $student2];<br><br>        $teacher-&gt;sendNewImageUrl(&quot;slide1.jpg&quot;);<br>        $teacher-&gt;recieveQuestion(&quot;is it true?&quot;, $student2);<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Memento Design Pattern</em></strong></p><pre><strong>&lt;?php<br></strong><em>/**<br> * Bir nesne değişikliğe uğratıldıktan sonra istenildiğinde geri getirmek için çıkarılmış<br> */<br><br></em><strong>namespace </strong>Behavioral\Memento;<br><br><strong>class </strong>Book<br>{<br>    <strong>public </strong>$title;<br>    <strong>public </strong>$author;<br>    <strong>public </strong>$isbn;<br>    <strong>public </strong>$lastEdited;<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $title<br>     * </em><strong><em>@return </em></strong><em>Book<br>     */<br>    </em><strong>public function </strong>setTitle($title)<br>    {<br>        $this-&gt;title = $title;<br>        $this-&gt;setLastEdited();<br>        <strong>return </strong>$this;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $author<br>     * </em><strong><em>@return </em></strong><em>Book<br>     */<br>    </em><strong>public function </strong>setAuthor($author)<br>    {<br>        $this-&gt;author = $author;<br>        $this-&gt;setLastEdited();<br>        <strong>return </strong>$this;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $isbn<br>     * </em><strong><em>@return </em></strong><em>Book<br>     */<br>    </em><strong>public function </strong>setIsbn($isbn)<br>    {<br>        $this-&gt;isbn = $isbn;<br>        $this-&gt;setLastEdited();<br>        <strong>return </strong>$this;<br>    }<br><br>    <strong>public function </strong>setLastEdited()<br>    {<br>        $this-&gt;lastEdited = <strong>new </strong>\DateTime();<br>    }<br><br>    <strong>public function </strong>createUndo(): BookMemento<br>    {<br>        <strong>return new </strong>BookMemento(<br>            $this-&gt;title,<br>            $this-&gt;author,<br>            $this-&gt;isbn,<br>            $this-&gt;lastEdited<br>        );<br>    }<br><br>    <strong>public function </strong>restoreFromUndo(BookMemento $memento)<br>    {<br>        $this-&gt;title = $memento-&gt;title;<br>        $this-&gt;author = $memento-&gt;author;<br>        $this-&gt;isbn = $memento-&gt;isbn;<br>        $this-&gt;lastEdited = $memento-&gt;lastEdited;<br>    }<br><br>    <strong>public function </strong>showBook()<br>    {<br>        <strong>return </strong>sprintf(<br>            &quot;%s, %s, %s edited %s&quot;,<br>            $this-&gt;title,<br>            $this-&gt;author,<br>            $this-&gt;isbn,<br>            $this-&gt;lastEdited-&gt;format(&quot;Y-m-d H:i:s&quot;)<br>        );<br>    }<br><br><br>}<br><br><strong>class </strong>BookMemento<br>{<br>    <strong>public </strong>$title;<br>    <strong>public </strong>$author;<br>    <strong>public </strong>$isbn;<br>    <strong>public </strong>$lastEdited;<br><br>    <em>/**<br>     * BookMemento constructor.<br>     * </em><strong><em>@param </em></strong><em>$title<br>     * </em><strong><em>@param </em></strong><em>$author<br>     * </em><strong><em>@param </em></strong><em>$isbn<br>     * </em><strong><em>@param </em></strong><em>$lastEdited<br>     */<br>    </em><strong>public function </strong>__construct($title, $author, $isbn, $lastEdited)<br>    {<br>        $this-&gt;title = $title;<br>        $this-&gt;author = $author;<br>        $this-&gt;isbn = $isbn;<br>        $this-&gt;lastEdited = $lastEdited;<br>    }<br>}<br><br><strong>class </strong>CareTaker<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>BookMemento */<br>    </em><strong>public </strong>$memento;<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $book = <strong>new </strong>Book();<br>        $book<br>            -&gt;setTitle(&quot;Sefiller&quot;)<br>            -&gt;setAuthor(&quot;V.Hugo&quot;)<br>            -&gt;setIsbn(&quot;123456&quot;);<br>        <strong>echo </strong>$book-&gt;showBook();<br>        <strong>echo </strong>&quot;\n&quot;;<br><br>        $history = <strong>new </strong>CareTaker();<br>        $history-&gt;memento = $book-&gt;createUndo();<br><br>        $book<br>            -&gt;setIsbn(&quot;1111&quot;)<br>            -&gt;setAuthor(&quot;Victor Hugo&quot;);<br>        <strong>echo </strong>$book-&gt;showBook();<br>        <strong>echo </strong>&quot;\n&quot;;<br><br>        $book-&gt;restoreFromUndo($history-&gt;memento);<br>        <strong>echo </strong>$book-&gt;showBook();<br>        <strong>echo </strong>&quot;\n&quot;;<br><br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();<br><br># Output:<br><br># Sefiller, V.Hugo, 123456 edited 2020-12-06 04:31:15<br># Sefiller, Victor Hugo, 1111 edited 2020-12-06 04:31:15<br># Sefiller, V.Hugo, 123456 edited 2020-12-06 04:31:15</pre><p><strong><em>Observer</em></strong></p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\Observer;<br><br><strong>class </strong>ProductManager<br>{<br>    <strong>public </strong>$observers = [];<br><br>    <strong>public function </strong>updatePrice()<br>    {<br>        <strong>echo </strong>&quot;Product price changed&quot;;<br>        $this-&gt;notify();<br>    }<br><br>    <strong>public function </strong>attach(AbstractObserver $observer)<br>    {<br>        $this-&gt;observers[$observer-&gt;id] = $observer;<br>    }<br><br>    <strong>public function </strong>detach(AbstractObserver $observer)<br>    {<br>        <strong>unset</strong>($this-&gt;observers[$observer-&gt;id]);<br>    }<br><br>    <strong>private function </strong>notify()<br>    {<br>        <strong>foreach </strong>($this-&gt;observers <strong>as </strong>$observer) {<br>            $observer-&gt;update();<br>        }<br>    }<br>}<br><br><strong>abstract class </strong>AbstractObserver<br>{<br>    <strong>public </strong>$id;<br><br>    <strong>abstract public function </strong>update();<br>}<br><br><strong>class </strong>CustomerObserver <strong>extends </strong>AbstractObserver<br>{<br>    <strong>public function </strong>update()<br>    {<br>        <strong>echo </strong>&quot;Msg to customer&quot;;<br>    }<br>}<br><br><strong>class </strong>EmployeeObserver <strong>extends </strong>AbstractObserver<br>{<br>    <strong>public function </strong>update()<br>    {<br>        <strong>echo </strong>&quot;Msg to employee&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $productManager = <strong>new </strong>ProductManager();<br>        $employee = <strong>new </strong>EmployeeObserver();<br>        $employee-&gt;id = 1;<br>        $productManager-&gt;attach($employee);<br><br>        $employee2 = <strong>new </strong>CustomerObserver();<br>        $employee2-&gt;id = 2;<br>        $productManager-&gt;attach($employee2);<br><br>        $productManager-&gt;detach($employee2);<br><br>        $productManager-&gt;updatePrice();<br><br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p>State</p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\State;<br><br><strong>class </strong>ModifiedState <strong>implements </strong>StateInterface<br>{<br>    <strong>public function </strong>doAction(Context $context)<br>    {<br>        <strong>echo </strong>&quot;State: Modified&quot;;<br>        $context-&gt;state = $this;<br>    }<br><br>    <strong>public function </strong>__toString()<br>    {<br>        <strong>return </strong>&quot;Modified&quot;;<br>    }<br>}<br><br><strong>class </strong>DeletedState <strong>implements </strong>StateInterface<br>{<br>    <strong>public function </strong>doAction(Context $context)<br>    {<br>        <strong>echo </strong>&quot;State: Deleted&quot;;<br>        $context-&gt;state = $this;<br>    }<br><br>    <strong>public function </strong>__toString()<br>    {<br>        <strong>return </strong>&quot;Deleted&quot;;<br>    }<br>}<br><br><strong>class </strong>AddedState <strong>implements </strong>StateInterface<br>{<br>    <strong>public function </strong>doAction(Context $context)<br>    {<br>        <strong>echo </strong>&quot;State: Added&quot;;<br>        $context-&gt;state = $this;<br>    }<br><br>    <strong>public function </strong>__toString()<br>    {<br>        <strong>return </strong>&quot;Added&quot;;<br>    }<br>}<br><br><strong>class </strong>Context<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>StateInterface */<br>    </em><strong>public </strong>$state;<br>}<br><br><strong>interface </strong>StateInterface<br>{<br>    <strong>public function </strong>doAction(Context $context);<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $context = <strong>new </strong>Context();<br>        $modifiedState = <strong>new </strong>ModifiedState();<br>        $modifiedState-&gt;doAction($context);<br><br>        $deletedState = <strong>new </strong>DeletedState();<br>        $deletedState-&gt;doAction($context);<br><br>        <strong>echo </strong>$context-&gt;state-&gt;__toString().&quot;\n&quot;;<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p>Strategy</p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\Strategy;<br><br><strong>abstract class </strong>CreditCalculatorBase<br>{<br>    <strong>abstract public function </strong>calculate();<br>}<br><br><strong>class </strong>Before2010Calculator <strong>extends </strong>CreditCalculatorBase<br>{<br>    <strong>public function </strong>calculate()<br>    {<br>        <strong>echo </strong>&quot;2010 öncesi müşteriler için hesaplandı&quot;;<br>    }<br>}<br><br><strong>class </strong>After2010Calculator <strong>extends </strong>CreditCalculatorBase<br>{<br>    <strong>public function </strong>calculate()<br>    {<br>        <strong>echo </strong>&quot;2010 sonrası müşteriler için hesaplandı&quot;;<br>    }<br>}<br><br><strong>class </strong>CustomerManager<br>{<br>    <em>/** </em><strong><em>@var </em></strong><em>CreditCalculatorBase */<br>    </em><strong>public </strong>$creditCalculatorBase;<br><br>    <strong>public function </strong>saveCredit()<br>    {<br>        $this-&gt;creditCalculatorBase-&gt;calculate();<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $customerManager = <strong>new </strong>CustomerManager();<br>        $customerManager-&gt;creditCalculatorBase = <strong>new </strong>Before2010Calculator();<br>        $customerManager-&gt;saveCredit();<br><br>        $customerManager2 = <strong>new </strong>CustomerManager();<br>        $customerManager2-&gt;creditCalculatorBase = <strong>new </strong>After2010Calculator();<br>        $customerManager2-&gt;saveCredit();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p>Template</p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\Template;<br><br><strong>abstract class </strong>ScoringAlgorithm<br>{<br>    <strong>abstract public function </strong>calculateBaseScore(<strong>int </strong>$hits);<br><br>    <strong>abstract public function </strong>calculateReduction(\DateInterval $time);<br><br>    <strong>abstract public function </strong>calculateOverallScore($score, $reduction);<br><br>    <strong>public function </strong>generateScore(<strong>int </strong>$hits, \DateInterval $time)<br>    {<br>        $score = $this-&gt;calculateBaseScore($hits); # skor heseplanır<br><br>        $reduction = $this-&gt;calculateReduction($time); # kırılacak puan hesaplanır<br><br>        <strong>return </strong>$this-&gt;calculateOverallScore($score, $reduction);<br>    }<br>}<br><br><strong>class </strong>MensScoringAlgorithm <strong>extends </strong>ScoringAlgorithm<br>{<br>    <strong>public function </strong>calculateBaseScore(<strong>int </strong>$hits)<br>    {<br>        <strong>return </strong>$hits * 100;<br>    }<br><br>    <strong>public function </strong>calculateReduction(\DateInterval $time)<br>    {<br>        <strong>return </strong>$time-&gt;format(&#39;s&#39;) / 5;<br>    }<br><br>    <strong>public function </strong>calculateOverallScore($score, $reduction)<br>    {<br>        <strong>return </strong>$score - $reduction;<br>    }<br>}<br><br><strong>class </strong>WomansScoringAlgorithm <strong>extends </strong>ScoringAlgorithm<br>{<br>    <strong>public function </strong>calculateBaseScore(<strong>int </strong>$hits)<br>    {<br>        <strong>return </strong>$hits * 100;<br>    }<br><br>    <strong>public function </strong>calculateReduction(\DateInterval $time)<br>    {<br>        <strong>return </strong>$time-&gt;format(&#39;s&#39;) / 3;<br>    }<br><br>    <strong>public function </strong>calculateOverallScore($score, $reduction)<br>    {<br>        <strong>return </strong>$score - $reduction;<br>    }<br>}<br><br><strong>class </strong>ChildrensScoringAlgorithm <strong>extends </strong>ScoringAlgorithm<br>{<br>    <strong>public function </strong>calculateBaseScore(<strong>int </strong>$hits)<br>    {<br>        <strong>return </strong>$hits * 80;<br>    }<br><br>    <strong>public function </strong>calculateReduction(\DateInterval $time)<br>    {<br>        <strong>return </strong>$time-&gt;format(&#39;s&#39;) / 2;<br>    }<br><br>    <strong>public function </strong>calculateOverallScore($score, $reduction)<br>    {<br>        <strong>return </strong>$score - $reduction;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $d1 = <strong>new </strong>\DateTime(&quot;2012-07-08 11:14:15.638276&quot;);<br>        $d2 = <strong>new </strong>\DateTime(&quot;2012-07-08 11:14:16.889342&quot;);<br>        $timespan = $d2-&gt;diff($d1);<br><br>        $algorithm = <strong>new </strong>MensScoringAlgorithm();<br>        <strong>echo </strong>$algorithm-&gt;generateScore(8, $timespan);<br><br>        $womanAlgorithm = <strong>new </strong>WomansScoringAlgorithm();<br>        <strong>echo </strong>$womanAlgorithm-&gt;generateScore(8, $timespan);<br><br>        $childrenAlgorithm = <strong>new </strong>ChildrensScoringAlgorithm();<br>        <strong>echo </strong>$childrenAlgorithm-&gt;generateScore(8, $timespan);<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p>Visitor Design Pattern</p><pre><strong>&lt;?php<br><br>namespace </strong>Behavioral\Visitor;<br><br><strong>class </strong>OrganisationalStructure<br>{<br>    <strong>public </strong>$employee;<br><br>    <strong>public function </strong>__construct(EmployeeBase $firstEmployee)<br>    {<br>        $this-&gt;employee = $firstEmployee;<br>    }<br><br>    <strong>public function </strong>accept(VisitorBase $visitor)<br>    {<br>        $this-&gt;employee-&gt;accept($visitor);<br>    }<br>}<br><br><strong>abstract class </strong>EmployeeBase<br>{<br>    <strong>public </strong>$name;<br>    <strong>public </strong>$salary;<br><br>    <strong>abstract public function </strong>accept(VisitorBase $visitor);<br>}<br><br><strong>class </strong>Manager <strong>extends </strong>EmployeeBase<br>{<br>    <strong>public </strong>$subordinates;<br><br>    <strong>public function </strong>__construct()<br>    {<br>        $this-&gt;subordinates = [];<br>    }<br><br>    <strong>public function </strong>accept(VisitorBase $visitor)<br>    {<br>        $visitor-&gt;visit($this);<br><br>        <strong>foreach </strong>($this-&gt;subordinates <strong>as </strong>$employee) {<br>            $employee-&gt;accept($visitor);<br>        }<br>    }<br>}<br><br><strong>class </strong>Worker <strong>extends </strong>EmployeeBase<br>{<br>    <strong>public function </strong>accept(VisitorBase $visitor)<br>    {<br>        $visitor-&gt;visit($this);<br>    }<br>}<br><br><strong>abstract class </strong>VisitorBase<br>{<br>    <strong>abstract public function </strong>visit(EmployeeBase $worker);<br>}<br><br><strong>class </strong>PayrollVisitor <strong>extends </strong>VisitorBase<br>{<br>    <strong>public function </strong>visit(EmployeeBase $worker)<br>    {<br>        <strong>echo </strong>sprintf(&quot;%s maaş ödemesi gerçekleşti %s&quot;, $worker-&gt;name, $worker-&gt;salary) . &quot;\n&quot;;<br>    }<br>}<br><br><strong>class </strong>PayriseVisitor <strong>extends </strong>VisitorBase<br>{<br>    <strong>public function </strong>visit(EmployeeBase $worker)<br>    {<br>        <strong>echo </strong>sprintf(&quot;%s maaş artışı gerçekleşti %s&quot;, $worker-&gt;name, $worker-&gt;salary * 1.1) . &quot;\n&quot;;<br>    }<br>}<br><br><strong>class </strong>PayBonusVisitor <strong>extends </strong>VisitorBase<br>{<br>    <strong>public function </strong>visit(EmployeeBase $worker)<br>    {<br>        <strong>echo </strong>sprintf(&quot;%s prim ödemesi gerçekleşti %s&quot;, $worker-&gt;name, $worker-&gt;salary * 0.1) . &quot;\n&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $manager1 = <strong>new </strong>Manager();<br>        $manager1-&gt;name = &quot;Manager1&quot;;<br>        $manager1-&gt;salary = 1000;<br><br>        $manager2 = <strong>new </strong>Manager();<br>        $manager2-&gt;name = &quot;Manager2&quot;;<br>        $manager2-&gt;salary = 900;<br><br>        $worker = <strong>new </strong>Worker();<br>        $worker-&gt;name = &quot;worker1&quot;;<br>        $worker-&gt;salary = 400;<br><br>        $worker2 = <strong>new </strong>Worker();<br>        $worker2-&gt;name = &quot;worker2&quot;;<br>        $worker2-&gt;salary = 400;<br><br>        $manager1-&gt;subordinates = [$manager2, $worker, $worker2];<br><br>        $organisationalStructure = <strong>new </strong>OrganisationalStructure($manager1);<br><br>        $payRollVisitor = <strong>new </strong>PayrollVisitor();<br>        $payRiseVisitor = <strong>new </strong>PayriseVisitor();<br>        $payBonusVisitor = <strong>new </strong>PayBonusVisitor();<br><br>        $organisationalStructure-&gt;accept($payRollVisitor);<br>        $organisationalStructure-&gt;accept($payRiseVisitor);<br>        $organisationalStructure-&gt;accept($payBonusVisitor);<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=367f8aa3aa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Patterns — 2]]></title>
            <link>https://ercancavusoglu2020.medium.com/design-patterns-2-f2dbd4328de6?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2dbd4328de6</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 19:48:38 GMT</pubDate>
            <atom:updated>2020-12-07T19:48:38.749Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns — 2</h3><p><strong>2. Structural Design Patterns (Yapısal Tasarım Kalıpları)</strong></p><p><strong><em>Adapter Pattern</em></strong></p><pre><strong>&lt;?php<br>namespace </strong>Structural\Adapter;<br><br><strong>interface </strong>LogInterface<br>{<br>    <strong>public function </strong>log(<strong>string </strong>$message);<br>}<br><br><strong>class </strong>GrayLogger <strong>implements </strong>LogInterface<br>{<br>    <strong>public function </strong>log(<strong>string </strong>$message)<br>    {<br>        <strong>echo </strong>&quot;Graylogger&quot;;<br>    }<br>}<br><br><strong>class </strong>EnuygunLoggerBundle<br>{<br>    <strong>public function </strong>logMessage(<strong>string </strong>$message)<br>    {<br>        <strong>echo </strong>&quot;EnuygunLogger:&quot; . $message;<br>    }<br>}<br><br><strong>class </strong>EnuygunLoggerBundleAdapter <strong>implements </strong>LogInterface<br>{<br>    <strong>public function </strong>log(<strong>string </strong>$message)<br>    {<br>        $logger = <strong>new </strong>EnuygunLoggerBundle();<br>        $logger-&gt;logMessage($message);<br>    }<br>}<br><br><strong>class </strong>ProductManager<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>LogInterface */<br>    </em><strong>protected </strong>$logger;<br><br>    <em>/**<br>     * ProductManager constructor.<br>     * </em><strong><em>@param </em></strong><em>LogInterface $logger<br>     */<br>    </em><strong>public function </strong>__construct(LogInterface $logger)<br>    {<br>        $this-&gt;logger = $logger;<br>    }<br><br>    <strong>public function </strong>save()<br>    {<br>        $this-&gt;logger-&gt;log(&quot;Loglama başladı&quot;);<br>        <strong>echo </strong>&quot;Save&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $productManager = <strong>new </strong>ProductManager(<strong>new </strong>EnuygunLoggerBundleAdapter());<br>        $productManager-&gt;save();<br><br>        $productManager1 = <strong>new </strong>ProductManager(<strong>new </strong>GrayLogger());<br>        $productManager1-&gt;save();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Bridge Design Pattern</em></strong></p><p>…</p><pre><strong>&lt;?php<br><br>namespace </strong>Structural\Bridge;<br><br><strong>abstract class </strong>MessageSenderBase<br>{<br>    <strong>public function </strong>save()<br>    {<br>        <strong>echo </strong>&quot;saved&quot;;<br>    }<br><br>    <strong>abstract public function </strong>send(Body $body);<br>}<br><br><strong>class </strong>Body<br>{<br>    <strong>public </strong>$title;<br>    <strong>public </strong>$text;<br>}<br><br><strong>class </strong>SmsSender <strong>extends </strong>MessageSenderBase<br>{<br>    <strong>public function </strong>send(Body $body)<br>    {<br>        <strong>echo </strong>$body-&gt;text . &quot; was send wia SmsSender&quot;;<br>    }<br>}<br><br><strong>class </strong>EMailSender <strong>extends </strong>MessageSenderBase<br>{<br>    <strong>public function </strong>send(Body $body)<br>    {<br>        <strong>echo </strong>$body-&gt;text . &quot; was send wia EMailSender&quot;;<br>    }<br>}<br><br><strong>class </strong>CustomerManager<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>MessageSenderBase $messageSender */<br>    </em><strong>protected </strong>$messageSender;<br><br>    <em>/**<br>     * CustomerManager constructor.<br>     * </em><strong><em>@param </em></strong><em>MessageSenderBase $messageSender<br>     */<br>    </em><strong>public function </strong>__construct(MessageSenderBase $messageSender)<br>    {<br>        $this-&gt;messageSender = $messageSender;<br>    }<br><br>    <strong>public function </strong>updateCustomer($body)<br>    {<br>        $this-&gt;messageSender-&gt;send($body);<br>        <strong>echo </strong>&quot;Güncellendi&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $customerManager2 = <strong>new </strong>CustomerManager(<strong>new </strong>EMailSender());<br>        $body2 = <strong>new </strong>Body();<br>        $body2-&gt;title = &quot;Üyelik onayla&quot;;<br>        $customerManager2-&gt;updateCustomer($body2);<br><br>        $customerManager = <strong>new </strong>CustomerManager(<strong>new </strong>SmsSender());<br>        $body = <strong>new </strong>Body();<br>        $body-&gt;title = &quot;Üyelik ok&quot;;<br>        $customerManager-&gt;updateCustomer($body);<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Composite Design Pattern</em></strong></p><p>….</p><pre><strong>&lt;?php<br><br>namespace </strong>Structural\Composite;<br><br><strong>use </strong>ArrayIterator;<br><br><strong>interface </strong>PersonInterface<br>{<br>}<br><br><strong>class </strong>Employee <strong>implements </strong>PersonInterface<br>{<br>    <strong>public </strong>$name;<br>    <strong>public </strong>$subOrdinates;<br><br>    <strong>public function </strong>__construct(<strong>string </strong>$name = &quot;&quot;)<br>    {<br>        $this-&gt;subOrdinates = <strong>new </strong>ArrayIterator();<br>        $this-&gt;name = $name;<br>    }<br><br>    <strong>public function </strong>getSubOrdinates()<br>    {<br>        <strong>return </strong>$this-&gt;subOrdinates;<br>    }<br><br>    <strong>public function </strong>addSubOrdinate(PersonInterface $person)<br>    {<br>        $this-&gt;subOrdinates-&gt;append($person);<br>    }<br><br>    <strong>public function </strong>removeSubOrdinate(PersonInterface $person)<br>    {<br>        $this-&gt;subOrdinates-&gt;offsetUnset($person);<br>    }<br><br>    <strong>public function </strong>getSubOrdinate(<strong>int </strong>$index)<br>    {<br>        $this-&gt;subOrdinates-&gt;offsetGet($index);<br>    }<br>}<br><br><strong>class </strong>StakeHolders <strong>extends </strong>Employee<br>{<br>    <strong>public </strong>$name;<br><br>}<br><br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $employee1 = <strong>new </strong>Employee(&quot;Alex&quot;);<br>        $employee2 = <strong>new </strong>Employee(&quot;Hagi&quot;);<br>        $employee3 = <strong>new </strong>Employee(&quot;Sergen&quot;);<br><br>        $employee1-&gt;addSubOrdinate($employee2);<br>        $employee1-&gt;addSubOrdinate($employee3);<br><br>        $employee4 = <strong>new </strong>Employee(&quot;Emre&quot;);<br>        $employee10 = <strong>new </strong>StakeHolders(&quot;Paydaş Terim&quot;);<br>        $employee2-&gt;addSubOrdinate($employee4);<br>        $employee2-&gt;addSubOrdinate($employee10);<br><br>        $employee5 = <strong>new </strong>Employee(&quot;Selçuk&quot;);<br>        $employee1-&gt;addSubOrdinate($employee5);<br><br>        <strong>foreach </strong>($employee1-&gt;getSubOrdinates() <strong>as </strong>$employee) {<br>            <strong>echo </strong>$employee-&gt;name;<br><br>            <strong>foreach </strong>($employee-&gt;getSubOrdinates() <strong>as </strong>$employee1Items) {<br>                <strong>echo </strong>$employee1Items-&gt;name;<br>            }<br>        }<br><br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Decorator Design Pattern</em></strong></p><pre><strong>&lt;?php<br>namespace </strong>Structural\Decorator;<br><br><strong>abstract class </strong>CarBase<br>{<br>    <strong>public </strong>$make;<br>    <strong>public </strong>$type;<br>    <strong>public </strong>$hirePrice;<br>}<br><br><strong>class </strong>PersonalCar <strong>extends </strong>CarBase<br>{<br>}<br><br><strong>class </strong>CommercialCar <strong>extends </strong>CarBase<br>{<br>}<br><br><strong>abstract class </strong>CarDecoratorBase <strong>extends </strong>CarBase<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>CarBase */<br>    </em><strong>protected </strong>$carBase;<br><br>    <em>/**<br>     * CarDecoratorBase constructor.<br>     * </em><strong><em>@param </em></strong><em>CarBase $carBase<br>     */<br>    </em><strong>public function </strong>__construct(CarBase $carBase)<br>    {<br>        $this-&gt;carBase = $carBase;<br>    }<br>}<br><br><strong>class </strong>SpecialOffer <strong>extends </strong>CarDecoratorBase<br>{<br>    <strong>public function </strong>getHirePrice()<br>    {<br>        <strong>return </strong>$this-&gt;carBase-&gt;hirePrice * 0.9;<br>    }<br>}<br><br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $personalCar = <strong>new </strong>PersonalCar();<br>        $personalCar-&gt;hirePrice = 2000;<br>        $personalCar-&gt;make = &quot;Fiat&quot;;<br>        $personalCar-&gt;type = &quot;Sedan&quot;;<br><br>        $SpecialOffer = <strong>new </strong>SpecialOffer($personalCar);<br>        <strong>echo </strong>$SpecialOffer-&gt;getHirePrice();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Facade Design Pattern</em></strong></p><p>…</p><pre><strong>&lt;?php<br>namespace </strong>Structural\Facade;<br><br><strong>interface </strong>LogInterface<br>{<br>    <strong>public function </strong>log();<br>}<br><br><strong>class </strong>Logging <strong>implements </strong>LogInterface<br>{<br>    <strong>public function </strong>log()<br>    {<br>        <strong>echo </strong>&quot;Logged&quot;;<br>    }<br>}<br><br><strong>interface </strong>CacheInterface<br>{<br>    <strong>public function </strong>cache();<br>}<br><br><strong>class </strong>Caching <strong>implements </strong>CacheInterface<br>{<br>    <strong>public function </strong>cache()<br>    {<br>        <strong>echo </strong>&quot;Cached&quot;;<br>    }<br>}<br><br><strong>interface </strong>AuthorizeInterface<br>{<br>    <strong>public function </strong>checkUser();<br>}<br><br><strong>class </strong>Authorize <strong>implements </strong>AuthorizeInterface<br>{<br>    <strong>public function </strong>checkUser()<br>    {<br>        <strong>echo </strong>&quot;User Checked&quot;;<br>    }<br>}<br><br>#SONRADAN EKLEDİK DİYELİM<br><strong>interface </strong>ValidateInterface<br>{<br>    <strong>public function </strong>validate();<br>}<br><br><strong>class </strong>CreditCardValidate <strong>implements </strong>ValidateInterface<br>{<br>    <strong>public function </strong>validate()<br>    {<br>        <strong>echo </strong>&quot;Card Validated&quot;;<br>    }<br>}<br><br><br><strong>class </strong>CrossCuttingConcernsFacade<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>LogInterface */<br>    </em><strong>public </strong>$logging;<br>    <em>/**</em><strong><em>@var </em></strong><em>CacheInterface */<br>    </em><strong>public </strong>$cache;<br>    <em>/**</em><strong><em>@var </em></strong><em>AuthorizeInterface */<br>    </em><strong>public </strong>$authorize;<br>    <em>/**</em><strong><em>@var </em></strong><em>ValidateInterface */<br>    </em><strong>public </strong>$validate;<br><br>    <em>/**<br>     * </em><strong><em>@</em></strong><em>TODO Use Dependency Injection<br>     *<br>     * CustomerManager constructor.<br>     */<br>    </em><strong>public function </strong>__construct()<br>    {<br>        $this-&gt;logging = <strong>new </strong>Logging();<br>        $this-&gt;cache = <strong>new </strong>Caching();<br>        $this-&gt;authorize = <strong>new </strong>Authorize();<br>        $this-&gt;validate = <strong>new </strong>CreditCardValidate();<br>    }<br>}<br><br><strong>class </strong>CustomerManager<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>CrossCuttingConcernsFacade */<br>    </em><strong>protected </strong>$crossCuttingConcernsFacade;<br><br>    <em>/**<br>     * CustomerManager constructor.<br>     * </em><strong><em>@param </em></strong><em>CrossCuttingConcernsFacade $crossCuttingConcernsFacade<br>     */<br>    </em><strong>public function </strong>__construct(CrossCuttingConcernsFacade $crossCuttingConcernsFacade)<br>    {<br>        $this-&gt;crossCuttingConcernsFacade = $crossCuttingConcernsFacade;<br>    }<br><br>    <strong>public function </strong>save()<br>    {<br>        $this-&gt;crossCuttingConcernsFacade-&gt;logging-&gt;log();<br>        $this-&gt;crossCuttingConcernsFacade-&gt;cache-&gt;cache();<br>        $this-&gt;crossCuttingConcernsFacade-&gt;authorize-&gt;checkUser();<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $customerManager = <strong>new </strong>CustomerManager(<strong>new </strong>CrossCuttingConcernsFacade());<br>        $customerManager-&gt;save();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Proxy Design Pattern</em></strong></p><pre><strong>&lt;?php<br><br>namespace </strong>Structural\Proxy;<br><br><strong>abstract class </strong>CreditBase<br>{<br>    <strong>abstract public function </strong>calculate();<br>}<br><br><strong>class </strong>CreditManager <strong>extends </strong>CreditBase<br>{<br>    <strong>public function </strong>calculate()<br>    {<br>        $result = 1;<br>        <strong>for </strong>($i = 1; $i &lt; 3; $i++) {<br>            sleep(1);<br>            $result *= $i;<br>        }<br><br>        <strong>return </strong>$result;<br>    }<br>}<br><br><strong>class </strong>CreditManagerProxy <strong>extends </strong>CreditBase<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>CreditManager */<br>    </em><strong>protected </strong>$creditManager = null;<br>    <strong>protected </strong>$cachedValue;<br><br>    <em>/**<br>     * CreditManagerProxy constructor.<br>     * </em><strong><em>@param </em></strong><em>$creditManager<br>     */<br>    </em><strong>public function </strong>__construct(CreditManager $creditManager)<br>    {<br>        $this-&gt;creditManager = $creditManager;<br>    }<br><br>    <strong>public function </strong>calculate()<br>    {<br>        <strong>if </strong>($this-&gt;creditManager === <strong>null</strong>) {<br>            $this-&gt;cachedValue = $this-&gt;creditManager-&gt;calculate();<br>        }<br><br>        <strong>return </strong>$this-&gt;cachedValue;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $creditManager = <strong>new </strong>CreditManagerProxy(<strong>new </strong>CreditManager());<br>        <strong>echo </strong>$creditManager-&gt;calculate();<br>        <strong>echo </strong>$creditManager-&gt;calculate();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2dbd4328de6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Patterns PHP — 1]]></title>
            <link>https://ercancavusoglu2020.medium.com/design-patterns-php-1-f94a03f8b876?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f94a03f8b876</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Sun, 06 Dec 2020 20:45:30 GMT</pubDate>
            <atom:updated>2020-12-07T20:21:50.171Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns PHP — 1</h3><p>Bu yazımda mühendislikte önemli yeri olan design pattern’leri tek bi çatı altında örneklerle anlamlı hale getirmek istedim. Meslek hayatına yeni başlamış, kendini bu konularda geliştirmek isteyen, kullanmaya kullanmaya unutmuş olan veya kendini yetersiz gören meslektaşlarıma faydası olması dileğiyle paylaşıyorum. Hatalarımı, eksiklerimi yorumlarda paylaşırsanız memnun olurum.</p><p>Tarihçesinden biraz bahsetmem gerekirse, <strong>Prof. Cristopher Alexander</strong>, inşaat profesörü olarak makaleler yayımlayan bir kişi olarak binaların tasarım sorunları, mimari problemlerine dikkat çeken kişi olmuş. 1977 yılında yayımladığı ve baş yazarı olduğu “<strong>A Pattern Language</strong>” ile design patternlerinde fikir babası olmuştur.</p><p>Yazılım dünyasındaki dönemin önemli kişileri de bu patternlerin kendileri içinde ihtiyaç olduğunu fark etmişlerdir. 1990&#39;larda C.Alexander’ın fikirlerini yazılımda kullanmaya başlamışlar. <strong>Gang of Four</strong> diye bilinen grup üyeleri <a href="https://en.wikipedia.org/wiki/Erich_Gamma"><strong>Erich Gamma</strong></a>,<a href="https://en.wikipedia.org/w/index.php?title=Richard_Helm&amp;action=edit&amp;redlink=1"> <strong>Richard Helm</strong></a>,<a href="https://en.wikipedia.org/wiki/Ralph_Johnson"> <strong>Ralph Johnson</strong></a> and<a href="https://en.wikipedia.org/wiki/John_Vlissides"> <strong>John Vlissides</strong></a> kafa kafaya vererek 1995 yılında <strong><em>Design Patterns: Elements Of Reusable Object-Oriented Software</em></strong><em> kitabını yayımlamışlardır.</em></p><p><strong>Peki niçin ortaya çıkmış ?</strong><br>- Amerikayı yeniden keşfetmemek için<br>- Yeniden kullanılabilir, değiştirilebilir özellikle nesne yönelimli programlama yapabilmek için<br>- OOP prensiblerinin daha anlaşılabilir olması için<br>- Sınıf kalıtımı yerine toplamayı tercih etmek için<br>- Arayüzlerle programlama yapmak için (uygulamalara değil)<br>- Değişen kavramı özetlemek, uyum sağlatmak için<br>- Var olan sistem ve tasarımı daha iyi anlamak için<br>- Ortak dile sahip olmak için</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*8sRz5CQj7uqEZT7RenrXOw.png" /></figure><p><strong>Bize ne faydası var ?</strong></p><p>Resimde göreceğiniz üzere Design Patterns ’ler yazılım dünyasında ileriye gitmek için tam orta noktada bulunmakta. Dolayısıyla ileriye doğru attığınız her adımda size faydası olacaktır.</p><p>Sürekli yaşanan sorunların üzerinde uzun uzun düşünüldükten sonra üretilmiş çözümler diye tanımlamasını yapabiliriz. Temiz, anlaşılır ve karmaşıklıklar artıkça kolay yönetilir kodlar yazmak için clean-code, object-oriented, solid, dry gibi yöntemlerin artık yetmediği noktalarda, başlangıçta biraz daha zaman harcayıp ilerleyen süreçlerde rahatlamamız için faydası olan patternlerdir diyebiliriz ayrıca.</p><p>Design Patterns’ler genel kullanım şekli olarak 3 başlık altında toparlanmıştır. Burada sayı artabilir. Yeni bir kategori varsa ve göremediysem orada benim eksiğim olabilir. Yorumlarda yazarsanız memnun olurum. Genel kabul görmüş pattern kategorileri bunlardır. Hadi başlayalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuuGnrCTfIUSOWjqTaVnQw.png" /></figure><p><strong>Creational Design Patterns (Oluşturucu Tasarım Kalıpları)<br></strong>Bu kategorideki patternler nesnenin nasıl oluşturulacağı hakkındaki problemlere çözüm olması için ortaya çıkarılmıştır. Bazı durumlarda çok fazla nesne üretmek beklenmeyen performans kaybı yaratabilir, yada çok sayıda constructer propertysi tanımlanmış bi nesneye sadece istediklerimizi tanımlatmak isteyebiliriz, veya cloneladığımız nesnenin propertylerinden birini değiştirdiğimizde clonelanan nesnede de aynı şekilde değiştiğini görebiliriz. Bu gibi istenmeyen ve belki ekipçe saatlerimizi harcayıp çözeceğimiz problem/fix olarak çıkabilecek durumları önlemek için oluşturulmuş hazır çözümlerdir diye tanımlayabiliriz bu kısmı.</p><p><strong><em>Singleton Pattern (Object)<br></em></strong>Her noktadan erişim noktalarına sahip yalnızca tek bir örneğe sahip bir sınıf diye tanımlayabiliriz. Kelime anlamı olarak tekil demektir. İlgili nesneden bir tane oluşsun istediğimiz zaman kullanabiliriz. Kullanım yerleri olarak connection pool, configuration manager vb. örnek gösterebiliriz.</p><pre><strong>?php<br></strong><br><strong>namespace </strong>Creational\Singleton;<br><br><strong>class </strong>CustomerManager<br>{<br>    <strong>protected static </strong><em>$customerManager</em>;<br><br>    <strong>protected function </strong>__construct()<br>    {<br>    }<br><br>    <strong>protected function </strong>__clone()<br>    {<br>    }<br><br>    <strong>public static function </strong>createAsSingleton(): <strong>self<br>    </strong>{<br>        <strong>if </strong>(<strong>static</strong>::<em>$customerManager </em>=== <strong>null</strong>) {<br>            <strong>static</strong>::<em>$customerManager </em>= <strong>new static</strong>();<br>        }<br><br>        <strong>return static</strong>::<em>$customerManager</em>;<br>    }<br><br>    <strong>public function </strong>save()<br>    {<br>        <strong>echo </strong>&quot;Save&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        # Call to private CustomerManager::__construct() from invalid context<br>        # $customerManager = new CustomerManager(); <br><br>        $customerManager = CustomerManager::<em>createAsSingleton</em>();<br>        $customerManager-&gt;save();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Builder Pattern (Object)</em></strong></p><p>…</p><pre><strong>&lt;?php<br><br>namespace </strong>Creational\Builder;<br><br><strong>class </strong>ProductViewModel<br>{<br>    <strong>public </strong>$id;<br>    <strong>public </strong>$categoryName;<br>    <strong>public </strong>$productName;<br>    <strong>public </strong>$unitPrice;<br>    <strong>public </strong>$discountedPrice;<br>    <strong>public </strong>$discountApplied;<br>}<br><br><strong>abstract class </strong>ProductBuilder<br>{<br>    <strong>abstract public function </strong>getProductData();<br><br>    <strong>abstract public function </strong>applyDiscount();<br><br>    <strong>abstract public function </strong>getModel();<br>}<br><br><strong>class </strong>NewCustomerProductBuilder <strong>extends </strong>ProductBuilder<br>{<br>    <strong>protected </strong>$model;<br><br>    <strong>public function </strong>__construct()<br>    {<br>        $this-&gt;model = <strong>new </strong>ProductViewModel();<br>    }<br><br>    <strong>public function </strong>getProductData()<br>    {<br>        $this-&gt;model-&gt;id = 1;<br>        $this-&gt;model-&gt;categoryName = &quot;Meşrubat&quot;;<br>        $this-&gt;model-&gt;productName = &quot;Şalgam&quot;;<br>        $this-&gt;model-&gt;unitPrice = 12;<br>    }<br><br>    <strong>public function </strong>applyDiscount()<br>    {<br>        $this-&gt;model-&gt;discountedPrice = $this-&gt;model-&gt;unitPrice * 0.9;<br>        $this-&gt;model-&gt;discountApplied = <strong>true</strong>;<br>    }<br><br>    <strong>public function </strong>getModel()<br>    {<br>        <strong>return </strong>$this-&gt;model;<br>    }<br>}<br><br><strong>class </strong>OldCustomerProductBuilder <strong>extends </strong>ProductBuilder<br>{<br>    <strong>protected </strong>$model;<br><br>    <strong>public function </strong>__construct()<br>    {<br>        $this-&gt;model = <strong>new </strong>ProductViewModel();<br>    }<br><br>    <strong>public function </strong>getProductData()<br>    {<br>        $this-&gt;model-&gt;id = 1;<br>        $this-&gt;model-&gt;categoryName = &quot;Meşrubat&quot;;<br>        $this-&gt;model-&gt;productName = &quot;Şalgam&quot;;<br>        $this-&gt;model-&gt;unitPrice = 12;<br>    }<br><br>    <strong>public function </strong>applyDiscount()<br>    {<br>        $this-&gt;model-&gt;discountedPrice = $this-&gt;model-&gt;unitPrice;<br>        $this-&gt;model-&gt;discountApplied = <strong>false</strong>;<br>    }<br><br>    <strong>public function </strong>getModel()<br>    {<br>        <strong>return </strong>$this-&gt;model;<br>    }<br>}<br><br><strong>class </strong>ProductDirector<br>{<br>    <strong>public function </strong>generateProduct(ProductBuilder $productBuilder)<br>    {<br>        $productBuilder-&gt;getProductData();<br>        $productBuilder-&gt;applyDiscount();<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $ProductDirector = <strong>new </strong>ProductDirector();<br>        $ProductDirector-&gt;generateProduct(<strong>new </strong>NewCustomerProductBuilder());<br><br>        $ProductDirector2 = <strong>new </strong>ProductDirector();<br>        $ProductDirector2-&gt;generateProduct(<strong>new </strong>OldCustomerProductBuilder());<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Prototype (Object)</em></strong></p><p>…</p><pre><strong>&lt;?php<br><br>namespace </strong>Creational\Prototype;<br><br><strong>abstract class </strong>Person<br>{<br>    <strong>abstract public function clone</strong>();<br><br>    <strong>protected </strong>$id;<br>    <strong>protected </strong>$firstname;<br>    <strong>protected </strong>$lastname;<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getId()<br>    {<br>        <strong>return </strong>$this-&gt;id;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $id<br>     * </em><strong><em>@return </em></strong><em>Person<br>     */<br>    </em><strong>public function </strong>setId($id)<br>    {<br>        $this-&gt;id = $id;<br>        <strong>return </strong>$this;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getFirstname()<br>    {<br>        <strong>return </strong>$this-&gt;firstname;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $firstname<br>     * </em><strong><em>@return </em></strong><em>Person<br>     */<br>    </em><strong>public function </strong>setFirstname($firstname)<br>    {<br>        $this-&gt;firstname = $firstname;<br>        <strong>return </strong>$this;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getLastname()<br>    {<br>        <strong>return </strong>$this-&gt;lastname;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $lastname<br>     * </em><strong><em>@return </em></strong><em>Person<br>     */<br>    </em><strong>public function </strong>setLastname($lastname)<br>    {<br>        $this-&gt;lastname = $lastname;<br>        <strong>return </strong>$this;<br>    }<br>}<br><br><strong>class </strong>Customer <strong>extends </strong>Person<br>{<br>    <strong>protected </strong>$city;<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getCity()<br>    {<br>        <strong>return </strong>$this-&gt;city;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $city<br>     * </em><strong><em>@return </em></strong><em>Customer<br>     */<br>    </em><strong>public function </strong>setCity($city)<br>    {<br>        $this-&gt;city = $city;<br><br>        <strong>return </strong>$this;<br>    }<br><br>    <strong>public function clone</strong>()<br>    {<br>        <strong>return clone </strong>$this;<br>    }<br>}<br><br><strong>class </strong>Employee <strong>extends </strong>Person<br>{<br>    <strong>protected </strong>$salary;<br><br>    <em>/**<br>     * </em><strong><em>@return </em></strong><em>mixed<br>     */<br>    </em><strong>public function </strong>getSalary()<br>    {<br>        <strong>return </strong>$this-&gt;salary;<br>    }<br><br>    <em>/**<br>     * </em><strong><em>@param </em></strong><em>mixed $salary<br>     * </em><strong><em>@return </em></strong><em>Employee<br>     */<br>    </em><strong>public function </strong>setSalary($salary)<br>    {<br>        $this-&gt;salary = $salary;<br><br>        <strong>return </strong>$this;<br>    }<br><br>    <strong>public function clone</strong>()<br>    {<br>        <strong>return clone </strong>$this;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $customer = <strong>new </strong>Customer();<br>        $customer<br>            -&gt;setId(1)<br>            -&gt;setFirstname(&quot;Ercan&quot;)<br>            -&gt;setLastname(&quot;Cavusoglu&quot;);<br><br>        $newCustomer = $customer-&gt;clone();<br>        $newCustomer-&gt;setFirstname(&quot;Apple&quot;);<br><br>        <strong>echo </strong>$customer-&gt;getFirstname();<br>        <strong>echo </strong>$newCustomer-&gt;getFirstname();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Factory Method Pattern (Class)</em></strong></p><p>….</p><pre><strong>&lt;?php<br><br>namespace </strong>Creational\Factory;<br><br><strong>interface </strong>LoggerFactoryInterface<br>{<br>    <strong>public function </strong>createLogger();<br>}<br><br><strong>interface </strong>LoggerInterface<br>{<br>    <strong>public function </strong>log();<br>}<br><br><strong>class </strong>MonologLoggerFactory <strong>implements </strong>LoggerFactoryInterface<br>{<br>    <strong>public function </strong>createLogger()<br>    {<br>        <strong>return new </strong>MonologLogger();<br>    }<br>}<br><br><strong>class </strong>LoggerFactory <strong>implements </strong>LoggerFactoryInterface<br>{<br>    <strong>public function </strong>createLogger()<br>    {<br>        <strong>return new </strong>GrayLogger();<br>    }<br>}<br><br><strong>class </strong>GrayLogger <strong>implements </strong>LoggerInterface<br>{<br>    <strong>public function </strong>log()<br>    {<br>        <strong>echo </strong>&quot;Grayloggera logla&quot;;<br>    }<br>}<br><br><strong>class </strong>MonologLogger <strong>implements </strong>LoggerInterface<br>{<br>    <strong>public function </strong>log()<br>    {<br>        <strong>echo </strong>&quot;Dosyaya logla&quot;;<br>    }<br>}<br><br><strong>class </strong>CustomerManager<br>{<br>    <strong>protected </strong>$loggerFactory;<br><br>    <strong>public function </strong>__construct(LoggerFactoryInterface $loggerFactory)<br>    {<br>        $this-&gt;loggerFactory = $loggerFactory;<br>    }<br><br>    <strong>public function </strong>save()<br>    {<br>        $this-&gt;loggerFactory-&gt;createLogger();<br>        <strong>echo </strong>&quot;geri kalan işler&quot;;<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $manager = <strong>new </strong>CustomerManager(<strong>new </strong>LoggerFactory());<br>        $manager-&gt;save();<br><br>        $manager2 = <strong>new </strong>CustomerManager(<strong>new </strong>MonologLoggerFactory());<br>        $manager2-&gt;save();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><p><strong><em>Abstract Factory Pattern (Object)</em></strong></p><p>….</p><pre><strong>&lt;?php<br><br>namespace </strong>Creational\AbstractFactory;<br><br><strong>abstract class </strong>Logging<br>{<br>    <strong>abstract public function </strong>log(<strong>string </strong>$message);<br>}<br><br><strong>class </strong>GrayLogger <strong>extends </strong>Logging<br>{<br>    <strong>public function </strong>log(<strong>string </strong>$message)<br>    {<br>        <strong>echo </strong>&quot;Grayloggera logla&quot; . $message;<br>    }<br>}<br><br><strong>class </strong>MonologLogger <strong>extends </strong>Logging<br>{<br>    <strong>public function </strong>log(<strong>string </strong>$message)<br>    {<br>        <strong>echo </strong>&quot;Dosyaya logla&quot; . $message;<br>    }<br>}<br><br><strong>abstract class </strong>Caching<br>{<br>    <strong>abstract public function </strong>cache(<strong>string </strong>$data);<br>}<br><br><strong>class </strong>MemCache <strong>extends </strong>Caching<br>{<br>    <strong>public function </strong>cache(<strong>string </strong>$data)<br>    {<br>        <strong>echo </strong>&quot;Cached with memcache &quot; . $data;<br>    }<br>}<br><br><strong>class </strong>RedisCache <strong>extends </strong>Caching<br>{<br>    <strong>public function </strong>cache(<strong>string </strong>$data)<br>    {<br>        <strong>echo </strong>&quot;Cached with redis &quot; . $data;<br>    }<br>}<br><br><strong>abstract class </strong>CrossCuttingConcernsFactory<br>{<br>    <strong>abstract public function </strong>createLogger();<br><br>    <strong>abstract public function </strong>createCaching();<br>}<br><br><strong>class </strong>Factory1 <strong>extends </strong>CrossCuttingConcernsFactory<br>{<br>    <strong>public function </strong>createLogger()<br>    {<br>        <strong>return new </strong>GrayLogger();<br>    }<br><br>    <strong>public function </strong>createCaching()<br>    {<br>        <strong>return new </strong>MemCache();<br>    }<br>}<br><br><strong>class </strong>Factory2 <strong>extends </strong>CrossCuttingConcernsFactory<br>{<br>    <strong>public function </strong>createLogger()<br>    {<br>        <strong>return new </strong>MonologLogger();<br>    }<br><br>    <strong>public function </strong>createCaching()<br>    {<br>        <strong>return new </strong>RedisCache();<br>    }<br>}<br><br><strong>interface </strong>ManagerInterface<br>{<br>}<br><br><strong>class </strong>ProductManager <strong>implements </strong>ManagerInterface<br>{<br>    <em>/**</em><strong><em>@var </em></strong><em>Caching */<br>    </em><strong>private </strong>$caching;<br>    <em>/**</em><strong><em>@var </em></strong><em>Logging */<br>    </em><strong>private </strong>$logging;<br><br>    <strong>public function </strong>__construct(CrossCuttingConcernsFactory $crossCuttingConcernsFactory)<br>    {<br>        $this-&gt;caching = $crossCuttingConcernsFactory-&gt;createCaching();<br>        $this-&gt;logging = $crossCuttingConcernsFactory-&gt;createLogger();<br>    }<br><br>    <strong>public function </strong>getAll()<br>    {<br>        $this-&gt;caching-&gt;cache(&quot;data&quot;);<br>        $this-&gt;logging-&gt;log(&quot;logged&quot;);<br>    }<br>}<br><br><strong>class </strong>Program<br>{<br>    <strong>public function </strong>run()<br>    {<br>        $manager = <strong>new </strong>ProductManager(<strong>new </strong>Factory1());<br>        $manager-&gt;getAll();<br><br>        $manager2 = <strong>new </strong>ProductManager(<strong>new </strong>Factory2());<br>        $manager2-&gt;getAll();<br>    }<br>}<br><br>$program = <strong>new </strong>Program();<br>$program-&gt;run();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f94a03f8b876" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES PERCOLATE QUERY KULLANIMI]]></title>
            <link>https://ercancavusoglu2020.medium.com/es-percolate-query-kullanimi-28ca4ff22eaf?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/28ca4ff22eaf</guid>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Thu, 28 Feb 2019 11:23:22 GMT</pubDate>
            <atom:updated>2024-12-22T16:59:28.070Z</atom:updated>
            <content:encoded><![CDATA[<p>Bu yazımda elasticsearch de çok popüler bir özellik olan Percolate Query’den bahsedeceğim.</p><p>Yazımın amacı çok kişinin kullandığı bir yapı olmadığı için bilgi haznesi kısıtlı bir konu. Toparlamak istedim. Türkçe döküman hiç göremedim.Belki faydası olabilir diye yazıyorum.</p><p>Versiyon 2 de bunun ismi percolator olarak geçiyordu ama yeni version(5.0dan itibaren) ismi değişti.</p><p>N.ş.a. dökümanı veri yapısına(mapping) göre tasarlar ve bir dizinde(index) saklarız.</p><p>Daha sonra bu belgeleri almak istediklerinde, search API’sı aracılığıyla sorguları tanımlarlar.</p><p>Percolate query ise bunun tam tersi mantıkta çalışır.</p><p>Önce sorguları bir dizine depolar ve sonra Percolate API’si aracılığıyla — bu sorguları almak için belgeleri(documents) tanımlarsınız.</p><p>Şimd bunun mantığı nasıl çalışıyor biraz detaylandıralım.</p><p><strong>Kurulum</strong></p><p>Eğer hali hazırda sisteminize bir ES kurulumu yapmadıysanız bu <a href="https://www.elastic.co/guide/en/elasticsearch/reference/5.2/_installation.html">linkten</a> yapabilirsiniz. Veya işletim sisteminiz farklıysa ona uygun araştırma yaparsanız zibilyon tane makale bulabilirsiniz.</p><p>Kurulum için bu <a href="http://www.agiratech.com/elasticsearch-percolator-query-implementation-in-ruby/">linkten</a> faydalanabilirsiniz, ruby ile anlatıyor</p><p><strong>Gel gelelim nedir bu Percolate query!</strong></p><p>Percolate API, Elasticsearch’te belgelerimizi alert ve monitoring için kullanabileceğimiz yaygın olarak kullanılan bir yardımcı programdır.Bunun en kısa tanımı ise tersten arama (search in reverse)dır.</p><p>Elasticsearch genellikle querylerin sonuçlarının dökümanlarda olup olmamasına bağlı olarak bir sonuç döndürür.</p><p>Resim olarak ifade etmek gerekirse, görüldüğü şekilde biz dökümanımızı göndeririz, o sorgular ve bize uygun gördüğü eşleşen queryleri geri döndürür. Sistem gayet açık sarih :)</p><p>Tamam da ne işimize yarıyor bu query diyecekseniz, yapılabileceklerin listesi bunlar;</p><ul><li>Price alert</li><li>Price monitoring</li><li>News alert</li><li>Stock alert</li><li>Logs monitoring</li><li>Hayal edebildiğiniz diğer yapılar</li></ul><p>Ufak ufak örneklendirmeye başlıyorum</p><p>İlk olarak index oluşturalım</p><p>Şimdi burada bi index oluşturduk ve mappingini verdik. Bunu direk sense veya kibananın dev tools’uyla çalıştırabiliriz. Indeximiz hazır içerisine percolate datamızı ekleyelim şimdi.</p><p>Datamızı da ekledik percolate indeximize. (Yukarıdaki queryimiz bi bool querydir yani içerisine must,should,must_not gibi sectionlar alabilir.Should = OR ,Must=AND,must_not=NOT şeklinde çalışıyor. Burada dedik ki, çıkış yeri istanbul , varış yeri giresun,tarihi 2017–05–11, ve ücreti 1000 dahil 1000 den küçükleri getirsin. En sondada meta etiketlerine de kimin arattığını tutabildik.)</p><p>Şimdi ona nasıl ulaşacağımıza bakalım.</p><p>Diyelim ki bu percolate imizde birden fazla eşleşen query bulduk, sorgumuzda şu kişinin yaptığı sorguyu getir demek istersek aşağıdaki mantığı kurmamız gerekiyor.</p><blockquote><em>GET /bus-price-alert/notification/_percolate<br>{<br> “doc”:{<br> “origin”:”ISTANBUL”,<br> “destination”:”GİRESUN”,<br> “date”: “2017–05–11”<br> },<br> “query”: {<br> “term”: {<br> “meta.username”: “ercan_cavusoglu”<br> }<br> }<br>}</em></blockquote><p>yada direk ercan_cavusoglunun tüm percolate lerini getir demek istersek</p><p>GET üzerinden ulaşmak istersek percolateimize aşağıdaki query işimizi görür.</p><blockquote><em>GET /bus-price-alert/notification/1</em></blockquote><p>Toplam percolate sayımızı bulmak içinse aşağıdaki kodu çalıştırmamız yeterli.</p><blockquote><em>GET /bus-price-alert/notification/_percolate/count<br>{<br> “doc” : {<br> “origin”:”ISTANBUL”,<br> “destination”:”GİRESUN”,<br> “date”: “2017–06–11”<br> },<br> “filter”:{<br> “match”:{<br> “meta.username”:”ercan_cavusoglu”<br> }<br> }<br>}</em></blockquote><p>Dönen sonuçları direk ES de çalıştırdığımız anda ilgili sonuçları listelelememiz yeterlidir.</p><p>Percolate queryin tüm olayı bu.</p><p>Bu konu hakkında başka kaynaklara da göz atmanızda fayda var. Aşağıda yararlandığım kaynakları bulabilirsiniz.</p><p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html</a><br><a href="https://www.slideshare.net/MaximShelest/use-cases-for-elastic-search-percolator">https://www.slideshare.net/MaximShelest/use-cases-for-elastic-search-percolator</a><br><a href="https://qbox.io/blog/elasticsesarch-percolator">https://qbox.io/blog/elasticsesarch-percolator</a><br><a href="https://qbox.io/blog/birdwatch-twitter-analysis-with-elasticsearch">https://qbox.io/blog/birdwatch-twitter-analysis-with-elasticsearch</a><br><a href="http://www.gembalabs.com/2015/04/15/elasticsearch-tutorial-what-is-percolation/">http://www.gembalabs.com/2015/04/15/elasticsearch-tutorial-what-is-percolation/</a><br><a href="http://www.tutel.me/c/programming/tag/elasticsearch-percolate">http://www.tutel.me/c/programming/tag/elasticsearch-percolate</a><br><a href="https://speakerdeck.com/javanna/whats-new-in-percolator">https://speakerdeck.com/javanna/whats-new-in-percolator</a><br><a href="https://speakerdeck.com/mvgroningen/distributed-percolator-in-elasticsearch">https://speakerdeck.com/mvgroningen/distributed-percolator-in-elasticsearch</a><br><a href="https://www.slideshare.net/martijnvg/distributed-percolator-adammeetup20131?next_slideshow=1">https://www.slideshare.net/martijnvg/distributed-percolator-adammeetup20131?next_slideshow=1</a><br><a href="http://pdf.th7.cn/down/files/1411/Elasticsearch%20Server,%202nd%20Edition.pdf">http://pdf.th7.cn/down/files/1411/Elasticsearch%20Server,%202nd%20Edition.pdf</a><br><a href="https://amsterdam.luminis.eu/2016/10/13/using-the-new-elasticsearch-5-percolator/">https://amsterdam.luminis.eu/2016/10/13/using-the-new-elasticsearch-5-percolator/</a><br><a href="https://www.youtube.com/watch?v=RAJiFK1bHO0">https://www.youtube.com/watch?v=RAJiFK1bHO0</a><br><a href="https://www.elastic.co/blog/elasticsearch-percolator-continues-to-evolve">https://www.elastic.co/blog/elasticsearch-percolator-continues-to-evolve</a><br><a href="https://www.elastic.co/blog/when-and-how-to-percolate-1">https://www.elastic.co/blog/when-and-how-to-percolate-1</a><br><a href="https://www.elastic.co/blog/when-and-how-to-percolate-2">https://www.elastic.co/blog/when-and-how-to-percolate-2</a><br><a href="https://www.elastic.co/blog/percolator">https://www.elastic.co/blog/percolator</a><br><a href="http://blog.weetech.co/2015/05/learning-elasticsearch-percolator.html">http://blog.weetech.co/2015/05/learning-elasticsearch-percolator.html</a></p><p><em>Originally published at </em><a href="https://medium.com/@devredisibirak/es-percolate-query-kullanimi-95c7cd287447"><em>https://medium.com</em></a><em> on February 28, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28ca4ff22eaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RABBITMQ’DA CONSUMER OLUŞTURMA]]></title>
            <link>https://ercancavusoglu2020.medium.com/rabbitmqda-consumer-olu%C5%9Fturma-89e9ce637a5b?source=rss-b10e78ebc4d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/89e9ce637a5b</guid>
            <dc:creator><![CDATA[Ercan Çavuşoğlu]]></dc:creator>
            <pubDate>Wed, 20 Feb 2019 06:29:13 GMT</pubDate>
            <atom:updated>2020-12-06T19:17:52.751Z</atom:updated>
            <content:encoded><![CDATA[<p>Rabbitmq tarafında queue oluşturmanın yolunu anlatacağım kısaca. Ubuntu ile yazılmıştır. Diğer OS ler için komutlar değişebilir.</p><p>Örnek bi consumer dosyası nasıl olmalı, ondan başlıyorum.</p><p><strong>rabbitconsumer.conf</strong></p><blockquote>[program:consumer_adınız]<br>command=rabbitmq-cli-consumer -i -e “/projenizin yolu/console your_command_name” -c /etc/supervisor/consumer_config/consumer_ornek_dosya.conf<br>process_name=%(program_name)s_%(process_num)02d<br>numprocs=5<br>autostart=true<br>user=www-data<br>stdout_logfile_maxbytes = 1MB<br>stdout_logfile_backups = 2<br>stderr_logfile_maxbytes = 1MB<br>stderr_logfile_backups = 2</blockquote><p><strong>consumer_ornek_dosya.conf</strong></p><blockquote>[rabbitmq]<br>host = CHANGE<br>username = CHANGE<br>password = CHANGE<br>vhost=/<br>port=5672<br>queue=kuyruk-isminiz<br>compression=Off<br>[prefetch]<br>count=3<br>global=Off<br>[logs]<br>error = /var/log/supervisor/consumer_ornek_dosya_error.log<br>info = /var/log/supervisor/consumer_ornek_dosya_info.log</blockquote><p>Yukarıdaki CHANGE alanlarını kendi ayarlarınızla değiştiriniz.</p><blockquote>touch consumer_ornek_dosya_error.log<br>chmod -R 0777 consumer_ornek_dosya_error.log<em> </em>touch consumer_ornek_dosya_info.log<br>chmod -R 0777 consumer_ornek_dosya_info.log</blockquote><p>Bunları ayarladıktan ve rabbitmq manager da exchange ve queue tanımlayıp birbirine bind ettikten sonra aşağıdaki kodları denemeniz yeterli olacaktır.</p><p>Rabbitmq servisini yeniden başlatmak için</p><blockquote>service rabbitmq-server restart<br>systemctl restart rabbitmq-server</blockquote><p>Supervisorları yeniden başlatmak için</p><blockquote>supervisorctl restart all</blockquote><p>Rabbitmq başlatmak için</p><p>Yapılan değişiklikleri görmek için; yeni consumer eklenince vs izlemek için</p><p>Yapılan değişiklerle yeniden yüklemek için</p><p><em>Originally published at </em><a href="https://medium.com/@devredisibirak/rabbitmqda-consumer-olu%C5%9Fturma-862431ca93fb"><em>https://medium.com</em></a><em> on February 20, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89e9ce637a5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>