<?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 Hilmiberkayozdemir on Medium]]></title>
        <description><![CDATA[Stories by Hilmiberkayozdemir on Medium]]></description>
        <link>https://medium.com/@hilmiberkayozdemir?source=rss-9177ee0fee81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0p3e5TMSot-OJPyLM3VZuA@2x.jpeg</url>
            <title>Stories by Hilmiberkayozdemir on Medium</title>
            <link>https://medium.com/@hilmiberkayozdemir?source=rss-9177ee0fee81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:55:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hilmiberkayozdemir/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[Flutter Design Patterns Factory Pattern Part 1: Pizza Store Example]]></title>
            <link>https://hilmiberkayozdemir.medium.com/flutter-design-patterns-factory-pattern-part-1-pizza-store-example-650e6b3fc94e?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/650e6b3fc94e</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Sun, 17 Mar 2024 14:49:35 GMT</pubDate>
            <atom:updated>2024-03-17T14:49:35.583Z</atom:updated>
            <content:encoded><![CDATA[<p>Design patterns are <strong>proven solutions</strong> for common software development problems that help programmers write cleaner, more flexible, and reusable code.</p><p><strong>Faster coding:</strong> Instead of building everything from scratch, you can use these proven solutions to solve problems quickly.</p><p><strong>Cleaner code:</strong> Design patterns promote well-structured and easy-to-understand code.</p><p><strong>Less work later:</strong> Code built with design patterns is <strong>easier to modify</strong> and update in the future.</p><p>Give me six hours to chop down a tree and I will spend the first four sharpening the axe. <em>— Abraham Lincoln</em></p><h4>Types of Design Patterns:</h4><ul><li>Structural Patterns: You may have already used them in your projects most of the time, as many are pre-built into the Flutter core.</li><li>Behavioral Patterns: These offer excellent solutions, especially in today’s mobile development landscape. It’s also useful to explore real project use cases with these patterns.</li></ul><p><strong>Structural Patterns: </strong>If you’re responsible for an SDK, you should prioritize reusability. In Flutter, you can select these patterns for your SDK project. When developers initialize your SDK, they can use the builder pattern to customize functionalities as needed. Simple Factory Pattern: Imagine a pizza store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IX2BxtQiP-M86ztys0L9Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4h1H6RrQhCPw0F0XMpBILQ.png" /></figure><p>What do we do in this pizza restaurant? Knowing the business well leads to better development. What actions do we, and the customers, take in the pizza store?</p><h4>Actors:</h4><ul><li>Customer: Orders the pizza</li><li>Chef: Creates the pizza (making pizza)</li></ul><h4>Questions?</h4><ol><li>What are the types of pizza?</li><li>What actions are needed to make a pizza?</li></ol><h4>Answers</h4><ol><li>Cheese Pizza, Clam Pizza, Veggie Pizza</li><li>Prepare, bake, cut, box.</li></ol><p>So, if you are a skilled developer and the owner of the pizza store wants to add a new pizza as a new category or style, you need to be quick, right? Or if there is a problem with your actions, you just need to fix your actions or add new actions in one go, in one location, right? For these two considerations, we can use the awesome <strong>factory pattern.</strong></p><blockquote><strong>These questions save your life before start code!</strong></blockquote><h3>Lets Code!</h3><p>If you are good student when you in highschool you now that. In math you should write before start what I need what we going to do for get the result.</p><p>So In the code we will start in <strong>interfaces</strong>:</p><blockquote><strong>I’m using I as first letter if the class is interface</strong></blockquote><h4>IPizza:</h4><blockquote><strong>Remember it we writing actions of pizza at here</strong></blockquote><pre>abstract class IPizza {<br> void prepare();<br> void box();<br> void cut();<br> void bake();<br>}</pre><h4>IPizzaStore</h4><blockquote><strong>Remember it customer action in the store was ordering pizza</strong></blockquote><pre>import ‘i_pizza.dart’;<br>abstract class IPizzaStore {<br> IPizza orderPizza(String type);<br>}</pre><h4>IPizzaFactory</h4><blockquote><strong>Remember it cheff action in the store was create(make) a pizza.</strong></blockquote><pre>import ‘i_pizza.dart’;<br>abstract class IPizzaFactory {<br> IPizza createPizza(String type);<br>}</pre><p>So In the code we can continue with pizza <strong>categories </strong>:</p><pre>import ‘../interfaces/i_pizza.dart’;<br>class CheesePizza implements IPizza {<br> @override<br> void box() {<br> print(‘Pack the cheese pizza’);<br> }<br>@override<br> void prepare() {<br> print(&#39;Prepare cheese pizza&#39;);<br> }<br>@override<br> void cut() {<br> print(&#39;Cut cheese pizza&#39;);<br> }<br>@override<br> void bake() {<br> print(&#39;Bake cheese pizza&#39;);<br> }<br>}</pre><pre>import ‘../interfaces/i_pizza.dart’;<br>class ClamPizza implements IPizza {<br> @override<br> void box() {<br> print(‘Pack the Clam pizza’);<br> }<br>@override<br> void prepare() {<br> print(&#39;Prepare Clam pizza&#39;);<br> }<br>@override<br> void cut() {<br> print(&#39;Cut Clam pizza&#39;);<br> }<br>@override<br> void bake() {<br> print(&#39;Bake Clam pizza&#39;);<br> }<br>}</pre><pre>import ‘../interfaces/i_pizza.dart’;<br>class PepperoniPizza implements IPizza {<br> @override<br> void box() {<br> print(‘Pack the Pepperonipizza’);<br> }<br>@override<br> void prepare() {<br> print(&#39;Prepare Pepperoni pizza&#39;);<br> }<br>@override<br> void cut() {<br> print(&#39;Cut Pepperonipizza&#39;);<br> }<br>@override<br> void bake() {<br> print(&#39;Bake Pepperoni pizza&#39;);<br> }<br>}</pre><h4>Now its time to create factories.</h4><p>You are going to create a new style of making pizza you dont need to write another code. Now Our Factory Is Ready As You Can See.</p><pre>// This pizzeria needs a factory to make Istanbul style pizza:<br>// thick base, thick sauce and lots of cheese and butter.<br>import &#39;../interfaces/i_pizza.dart&#39;;<br>import &#39;../interfaces/i_pizza_factory.dart&#39;;<br>import &#39;../pizza/cheese_pizza.dart&#39;;<br>import &#39;../pizza/clam_pizza.dart&#39;;<br>class IstanbulPizzaFactory implements IPizzaFactory {<br>  @override<br>  IPizza createPizza(String type) {<br>    late final IPizza pizza;<br>    if (type.contains(&#39;cheese&#39;)) {<br>      pizza = CheesePizza();<br>    } else if (type.contains(&#39;clam&#39;)) {<br>      pizza = ClamPizza();<br>    }<br>// These are cascade operations mean if you use that dont return me<br>// Just make a change in current object.<br>    pizza<br>      ..bake()<br>      ..cut()<br>      ..prepare()<br>      ..box();<br>    return pizza;<br>  }<br>}</pre><pre>// If I Want to create different type of factory(different style of pizza)<br>// This pizzeria needs a factory to make Ankara style pizza:<br>//  Ankara customers don&#39;t like clam pizza they want pepperoni<br>//! And price of box very expensive in ankara<br>import ‘../interfaces/i_pizza.dart’;<br>import ‘../interfaces/i_pizza_factory.dart’;<br>import ‘../pizza/cheese_pizza.dart’;<br>import ‘../pizza/clam_pizza.dart’;<br>class AnkaraPizzaFactory implements IPizzaFactory {<br> @override<br> IPizza createPizza(String type) {<br> late final IPizza pizza;<br> if (type.contains(&#39;cheese&#39;)) {<br> pizza = CheesePizza();<br> } else if (type.contains(&#39;pepperoni&#39;)) {<br> pizza = PepperoniPizza();<br> }<br>// These are cascade operations mean if you use that dont return me<br>// Just make a change in current object.<br> pizza<br> ..bake()<br> ..cut()<br> ..prepare();<br> // ..box(); we remowe box action in this factory its expensive :D<br> return pizza;<br> }<br>}</pre><p>Now lets create Stores.</p><pre>import ‘../interfaces/i_pizza.dart’;<br>import ‘../interfaces/i_pizza_factory.dart’;<br>import ‘../interfaces/i_pizza_store.dart’;<br>class IstanbulPizzaStore implements IPizzaStore {<br> final IPizzaFactory pizzaFactory;<br>IstanbulPizzaStore(this.pizzaFactory);<br>@override<br> IPizza orderPizza(String type) {<br> final pizza = pizzaFactory.createPizza(type);<br> return pizza;<br> }<br>}</pre><pre>// Edge Case<br>// Now lets see the results? We want to create a pizza from <br>// Ankara and order in Istanbul<br>import &#39;factories/ankara_pizza_factory.dart&#39;;<br>import &#39;store/istanbul_pizza_store.dart&#39;;<br>void main() {<br> final pizzaFactory = AnkaraPizzaFactory();<br> final pizzaStore = IstanbulPizzaStore(pizzaFactory)<br> ..orderPizza(‘pepperoni’);<br> print(pizzaStore);<br>}</pre><h4>Result:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J74rRbH6L5rasYt1UMBS_g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=650e6b3fc94e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Yazılım Geliştiriciliğin Geleceği: Google Project IDX — Yeni Nesil IDE]]></title>
            <link>https://hilmiberkayozdemir.medium.com/yaz%C4%B1l%C4%B1m-geli%C5%9Ftiricili%C4%9Fin-gelece%C4%9Fi-google-project-idx-yeni-nesil-ide-f84b46f97893?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f84b46f97893</guid>
            <category><![CDATA[ide]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[new-generation-ide]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[idx]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 10:11:12 GMT</pubDate>
            <atom:updated>2024-02-01T10:11:12.661Z</atom:updated>
            <content:encoded><![CDATA[<h3>Yazılım Geliştiriciliğin Geleceği: Google Project IDX — Yeni Nesil IDE</h3><h4>Giriş</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Akr5KvYgyRdFgO3c.jpg" /></figure><h3><strong>Google IDX ve yeni nesil IDE’ler Nedir Ne Vaat Ediyor?</strong></h3><p>IDX, ‘<strong>Get to work quickly, wherever you are</strong>’ ve ‘ <strong>Let’s make the development workflow better, together</strong>’ gibi sloganlarla karşılıyor. Yani IDX, nerede olursanız olun, codebase’inizi bıraktığınız gibi herhangi bir ortamda çalıştırmanızı ve paylaşımlı çalışma alanı ile sorunsuz bir şekilde ekibinizle app geliştirmenizi vaat ediyor.</p><h4>IDX Nedir.</h4><p>IDX, Google Cloud’da çalışan, web tabanlı, entegre bir geliştirme ortamıdır.</p><h4>IDX’nin Özellikleri</h4><ul><li>Her yerden erisilebilen tek bir workspace.</li><li>IDX AI: Copilottan daha guclu bir AI.</li><li>GitHub içe aktarma: Kendi uygulamalarınızı veya GitHub’dan bir projeyi import edebilirsin.</li><li>Android emülatörleri ve IOS simülatörleri: Flutter uygulamanızı geliştirmeniz de debugda asiri hiz katiyor.</li><li>Çalışma Alanı Paylaşımı: Ekibinizi davet edin ve çalışma alanındaki terminal üzerinden aynı VM erişimini sağlayın.</li><li>Tam VM çalışma alanı: Yapılandırılabilir ve değiştirebilirsiniz.</li><li>Uzantılar: Burada tüm vscode özelliklerini neredeyse kullanabiliyoruz.</li></ul><h4>Girizgah</h4><p>Bu sabah erkenden kalktım, kahvemi yudumlarken yakın bir Android developer <a href="https://medium.com/u/6e7cb5cd60f2">Erol Kaftanoğlu</a> arkadaşımın tweeti üzerine dün akşam beta’ya çıkan Project IDX’i incelemeye karar verdim. Bunu yaparken de analizlerimi ve düşüncelerimi burada kaleme aldım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWzFbd63vlO8cVLmyVNx-g.png" /></figure><h4>Hatalar: Experimental Version</h4><p>Öncelikle IDX’e girdiğimizde bizi henüz bitmemiş bir web app karşılıyor. Defalarca hatalar aldım. Fakat ben size hataları avoid edip bir şekilde çözüp var olan özellikleri anlatmaya çalışacağım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lNpOKs_ReN8bmCkbm5G7zw.png" /></figure><h3>Hadi başlayalım!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jJX_PN9tDMKpQLIGh384A.png" /></figure><p>Bizi burada wait list karşılıyor fakat şanslıyız ki ben daha önce waitliste başvurduğum için bugün beraber bu new generation IDE’yi inceleyebileceğiz.</p><h4>Dashboard</h4><p>Şimdi dashboardimizi inceleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DrT_q0l6OPbjlST0erKpUQ.png" /></figure><ul><li>Experimental sürümüde sadece 2 workspace oluşturabilirsiniz başlangıç olarak.</li><li>IDX şu anda sadece</li><li>Angular, NextJS, Flutter, Gemini, Astro, Go, Python Flask, Node Express teknolojilerini bu yeni nesil IDE’de bizimle buluşturuyor.</li></ul><blockquote>Bu arada meraklılar için Project IDX angular ile yazılmış.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*eZ678qAnlSXyQbQINn1ekw.png" /></figure><h4>Proje Clonelayarak Workspace olusturma.</h4><p>Ben incelememe bu hafta tasarladığım high level design mobile application architecture’umu clonelayarak devam edeceğim.</p><blockquote>Bir küçük eleştirim var. <strong>ULAN GOOGLE SEN CLONELADIĞIM REPONUN HANGİ DİLDE OLDUĞUNU ANLAMIYOR MUSUN LAN!</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*RsMCBOoMsekKIrcR8teJXg.png" /></figure><p>Ben bu checkbox’i işaretlemeden cloneladığımda kasten bana <strong>HTML</strong> projesi açtı….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*msRsxHgOGOIbRvv3Vhdokg.png" /></figure><p>Neyse devam edelim…</p><p>Kodlama ekranında önce bizi şöyle bir ekran karşılıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRJVInkUCZt_520D6rQYvQ.png" /></figure><p>IDX flutter versiyonu dart sdk 3.1.2 olduğundan dolayı versiyon düşüreceğiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*NVKWII7s8M00HHTCH4bQEA.png" /></figure><p>Kurduğum mimaride rest ve local db clientleri ayrı submodule içerdiği için melos ile tek seferde tüm paketlerimi packagelerini get edip generate edilcek tarafıda melos ile kolayca çözdüm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*PPbxZ-SDp4tF5LqGPoFiBQ.png" /></figure><blockquote><strong>Melosla ilgili başka bir makale daha yazacağım!</strong></blockquote><p>Evet artık app’i run etmeye hazırız!</p><p>Projede bir problem yaşadım ve generated klasörünü bilgisayarımdan eklemek istedim burada bize şöyle bir kolaylık sağlamışlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*CMvanl2sjo2lMXMDKXPecg.png" /></figure><p>Buradan dosyalarımı yükleyebiliyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPEZe2ODONE3Dx1mlYcFqg.png" /></figure><p>Kendi projemizi clone etmek şuan için çok buglu sanırım. En iyisi IDX üzerinden oluşturduğum test appinde gidelim.</p><h4>IDX Üzerinden Proje Oluşturma</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yGi0q07yiIibcWe3yrnpig.png" /></figure><p>Evet burada proje bize hali hazırda run edilmiş ve android web hazırda açık olarak geliyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_wXC-2-SvHOsmYCMlCDZw.png" /></figure><p>iOS içinse önce preview’i enable etmeniz gerek.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qF2pSeOcSckuezhuDGe2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dq_G39Jiy6gSwXFuwgZ36Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oylSH0qp5H9mP18c86W2Aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9wbZI_eVtc3szPQJbVqag.png" /></figure><p>Yani bunun kahrini o kadar çok çektim ki, IDX her ne kadar şuan tam çalışmasa da ileride new generation IDE’ler sayesinde ne kadar rahat edeceğimizi görebildim.</p><p>Simdi IDX ile IDX InAppWebView mobile app’i yapacagim.</p><h4>AI</h4><p>Bunu hemen IDX AI ile yapmak isterdim ama her zamanki gibi ülkemizde yaşamak çok kolaymış gibi bir de böyle bir problem daha yaratıyorlar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ekq6GmliF55IdkwpB-XLCQ.png" /></figure><p>Bu olaydan gerçekten nefret ediyorum. <strong>Teşekkürler Google!</strong></p><p>Neyse Gelecekte düzelirecektir kullanımlar için şunu göstermek isterim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXkfOEw19xzaLRiYTPaY3A.png" /></figure><p>Yeni nesil IDElerde buradaki gibi kendi özelleştirilmiş gemini modelinizi API key girerek bağlayabiliyorsunuz.</p><h4>Proje</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ay7fHCfiIZJ3z477SxLukg.png" /></figure><p>Projede basitçe IDX tanıtım sitesini url vererek web view bir app oluşturduk.</p><p>Kodlama Deneyimleri:</p><ul><li>Oldukça hızlı bir şekilde reload oluyor ekran androidte ve ioste ancak web için aynısını söyleyemem sürekli hot restart oldugunda baya geç kendine geliyor.</li><li>Hata loglarını okumak biraz tuhaf burada çünkü mesela android &amp; ios üzerinde çalışırken configuration hatası alabilirsin minSdk version, info.plist… etc</li><li>Kodlama deneyimi bunlar dışında vscode ile çok benzer zaten</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/0*amLWB36LlUBk81LO.jpg" /></figure><h3>Sonuç</h3><p>Öncelikle, birden fazla platformu bu kadar hızlı hata ayıklayabilmek inanılmaz keyifli. Windows’ta iOS çalıştırabilmek ve kod tabanına asla zarar vermemek harika. Bence gelecekteki geliştirme ortamlarımız kesinlikle bu şekilde olacak.</p><p>Aslında, şu anda teknoloji devleri Facebook, Meta, X, Google ve Microsoft, geliştirmelerini bu gibi ortamlarda yapıyorlar. Çünkü meselaFacebook’un tamamını çalıştırmak için 512 GB RAM’e ihtiyacınız var.</p><p>Meta geliştiricisinin bilgisayarı çalındığını düşünelim. Ne olacak? Facebook kodları sızacak mı? Meta’da buna benzer bir sistem kullanıyor ve bu sayede bilgisayar çalındığında dışarıdan erişilemez hale geliyor.</p><p>Yakın gelecekte, çoğumuz böyle bir sistem üzerinden geliştirme yapacağız. Bu, inanılmaz heyecan verici bir şey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f84b46f97893" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Man In The Middle Saldirisi nedir? SSL Pinning Nedir? Flutter’da uygulama guvenligi nasil saglanir?]]></title>
            <link>https://hilmiberkayozdemir.medium.com/man-in-the-middle-saldirisi-nedir-ssl-pining-nedir-flutterda-uygulama-guvenligi-nasil-saglanir-b84cd936ff3c?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/b84cd936ff3c</guid>
            <category><![CDATA[ssl-pinning]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-security]]></category>
            <category><![CDATA[flutter-app-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Fri, 15 Dec 2023 23:26:00 GMT</pubDate>
            <atom:updated>2023-12-15T23:35:47.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*lRONwOb80ofJvbqU1JkpfQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*KQbtROls_3OLiPnwJQUUnQ.jpeg" /></figure><h4><strong>Man-in-the-Middle</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*kH4WNihBxsA4utOW.png" /></figure><p><strong>Man-in-the-Middle</strong> (MitM) saldırısı, bir saldırganın iletişimdeki iki taraf arasına sızarak veri akışını gizlice kesip, değiştirebildiği bir siber güvenlik tehdididir. Bu saldırıda, saldırgan genellikle iki tarafın da kendisiyle iletişim kurduğunu düşünmesini sağlayarak, gönderilen bilgileri ele geçirir veya manipüle eder. Örneğin, bir kullanıcı ile bir banka arasındaki internet bağlantısına müdahale ederek, kullanıcının banka bilgilerini çalabilir veya işlemleri değiştirebilir. MitM saldırıları, genellikle güvensiz ağ bağlantıları kullanılarak veya güvenlik açıklarından faydalanarak gerçekleştirilir ve kişisel verilerin, şifrelerin ve diğer hassas bilgilerin çalınmasına yol açabilir. Bu yüzden güvenli iletişim protokolleri ve şifreleme teknikleri, bu tür saldırılara karşı önemli bir savunma hattı oluşturur.</p><h4>SSL Pinning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*p2wwR7VuCe-AOQrS.png" /></figure><p><strong>SSL Pinning,</strong> güvenli internet iletişimini sağlamak için kullanılan bir tekniktir. <strong>SSL (Secure Sockets Layer)</strong> ve TLS (Transport Layer Security), veri iletişimini şifreleyerek internet üzerinden güvenli bir şekilde bilgi aktarımı yapılmasını sağlar. SSL Pinning, bu güvenlik mekanizmasının bir parçasıdır ve özellikle <strong>mobil uygulama</strong>ların güvenliğini artırmak için kullanılır.</p><p><strong>SSL Pinning,</strong> bir uygulamanın sadece belirli SSL sertifikalarını veya genel anahtarları kabul etmesi anlamına gelir. Bu teknik sayesinde, uygulama sadece önceden tanımlanmış ve güvenilen sunucularla güvenli bir bağlantı kurabilir. Bu, ortadaki adam (man-in-the-middle) saldırılarına karşı ekstra bir koruma sağlar. <strong>Çünkü bir saldırgan, geçerli bir SSL sertifikası</strong> sunsa bile, uygulama yalnızca belirli,<strong> önceden tanımlanmış</strong> sertifikalarla bağlantı kuracaktır.</p><p>SSL Pinning’in uygulanması, <strong>uygulama geliştiricileri</strong> tarafından yapılır. Geliştiriciler, uygulamanın güvenliğini artırmak için uygulamanın belirli SSL sertifikaları veya anahtarları “pine” (sabitler) yapar. Bu işlem, uygulamanın sadece belirli sunucularla güvenli bir bağlantı kurmasını ve diğer <strong>potansiyel güvenli olmayan bağlantıları reddetmesini sağlar.</strong></p><p><em>Özetle, SSL Pinning, internet üzerinden güvenli veri iletişimini sağlamak için kullanılan önemli bir güvenlik yöntemidir ve özellikle mobil uygulamaların güvenliğini artırmak için etkili bir yol sunar.</em></p><h4>Flutter Uygulamama Nasil SSL Pinning Ekleyebilirim?</h4><p>Flutter <strong>Security Context:</strong></p><p>Bir uygulamanin internet üzerinde kiminle konuştuğunu bilmek için kullandığı özel bir günlüğü gibi düşünün SecurityContext&#39;i. Bu günlükte, uygulamanin gerçekten güvendiği sunucularla mı konuştuğunu yoksa başkasıyla mı konuştuğunu kontrol etmesine yardımcı olan &#39;gizli kodlar&#39; (bunlara sertifikalar denir) bulunur.</p><p>Uygulamaniz, bir sunucuyla güvenli bir şekilde (örneğin gizli mesajlar göndererek) konuşurken, her şeyin güvende olduğundan emin olmak için bu günlüğü kullanır. Eğer bilgisayarınız gizli mesajları gönderen tarafsa (yani bir sunucu olarak hareket ediyorsa), diğerlerine doğru bilgisayarla konuştuklarını göstermek için kendi gizli kodunu da bu günlükte tutar.</p><p>Yani, SecurityContext, bilgisayarların konuşmalarını güvende tutarken doğru arkadaşla konuşup konuşmadıklarından emin olmalarına yardımcı olan güvenilir bir günlük gibidir.</p><p>Biz once security contextimizi set edecegiz.</p><p><strong>HTTP Ornegi:</strong><br>Sertifikamiz Bu Diyelim:</p><pre>const _certificate = &quot;&quot;&quot;<br>-----BEGIN CERTIFICATE-----<br>MIIF2zCCBMOgAwIBAgIQCoVsIwoArDevEGZIVZsZVDANBgkqhkiG9w0BAQsFADA8<br>MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g<br>UlNBIDIwNDggTTAxMB4XDTIzMDIyMzAwMDAwMFoXDTIzMTAxODIzNTk1OVowGzEZ<br>MBcGA1UEAwwQKi50aGVtb3ZpZWRiLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEP<br>ADCCAQoCggEBANQOhd2TCirITiFP5YTB/np0qmVAbiMrcg3t13qH4BZTlQBMwS7j<br>q2nuwBr/8zZTEVfnYSyebsvt6IdQjizfFd3LDtXMkCkQE66I0hGRbUnXYcR5dC2C<br>HeuTE0ZLeNlYfIwP0rJaA6L/SpCo4JCnuTCdfS2QkEGfXcSpdUE3xjnCDa5YK81f<br>u46nMGmhHhsHNhGB+x2PRxz8DFOlYzWYUjBpr+hJIjM48KIGyK55IT53I1PWuzX9<br>+Y8hCcQmah+JcCqWh4ezhEuDBN0JybnNAXtt+5zXGpk8B9w4sqShd8N6zKNHCxOM<br>KE06Pc0/tntcAxseky7YY2N6o5uuN21I+tECAwEAAaOCAvgwggL0MB8GA1UdIwQY<br>MBaAFIG4DmOKiRIY5fo7O1CVn+blkBOFMB0GA1UdDgQWBBTx0VmTK8/zl5mNJbdv<br>v9wIUvYunjArBgNVHREEJDAighAqLnRoZW1vdmllZGIub3Jngg50aGVtb3ZpZWRi<br>Lm9yZzAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUF<br>BwMCMDsGA1UdHwQ0MDIwMKAuoCyGKmh0dHA6Ly9jcmwucjJtMDEuYW1hem9udHJ1<br>c3QuY29tL3IybTAxLmNybDATBgNVHSAEDDAKMAgGBmeBDAECATB1BggrBgEFBQcB<br>AQRpMGcwLQYIKwYBBQUHMAGGIWh0dHA6Ly9vY3NwLnIybTAxLmFtYXpvbnRydXN0<br>LmNvbTA2BggrBgEFBQcwAoYqaHR0cDovL2NydC5yMm0wMS5hbWF6b250cnVzdC5j<br>b20vcjJtMDEuY2VyMAwGA1UdEwEB/wQCMAAwggF9BgorBgEEAdZ5AgQCBIIBbQSC<br>AWkBZwB2AK33vvp8/xDIi509nB4+GGq0Zyldz7EMJMqFhjTr3IKKAAABhn6p4zsA<br>AAQDAEcwRQIgdNNjNLBOg3tQH6Xj7OIS4c2yiOrLpYXwniJ8GwZpP18CIQDXJ0PL<br>xCrhGOB7iPY6hXRie83kGcZjDYRpHo6gaUnypAB1ALNzdwfhhFD4Y4bWBancEQlK<br>eS2xZwwLh9zwAw55NqWaAAABhn6p4yoAAAQDAEYwRAIgBNRx6sfLBMoDxXigYnBq<br>1URIu/uD41gpeTcLFCVHEboCIEnR2tepXct7q59pTlaEG5KLEr0C2tRf4lpJ0wZP<br>12cDAHYAtz77JN+cTbp18jnFulj0bF38Qs96nzXEnh0JgSXttJkAAAGGfqnjBwAA<br>BAMARzBFAiBDABwqD/RywJiaN2bp//MiRlPNPL7vkg3gaFXqcGmmogIhAJNfE/AI<br>KkgcOY/1uX/jLl1BsUFPLZKpNeMmCJYeKgQ9MA0GCSqGSIb3DQEBCwUAA4IBAQCc<br>ZMcsFM61a8YhtbRIIfmvnBJi4VtEyZ1SY7FAD3Uv61ZX3M0RTKeFAN8e4riUClAH<br>d3b+d5YnvSrvP1nHraveNmJg2M9yxBtsm/dZ6Q6EBO0TdYc19F2G8Oddyth5TPNi<br>wR2h/VEguHh6HeeAmD59okVnyOi5CymaM8xkLO/12fagIOEMuERQq2n+YZ9AWvTn<br>1Gyny1Y/Tcyt6jauLpMsVBrSLPWvLWT/PBL87TX106E3k8IAMDM4F1vG+EFk09FT<br>DJvR70AALzDvhhFNPnz2J498BEYXm2LixxQhOfG4N7U89bl7gz/i1v3XslaAQx8h<br>Q8V+Pm7ggCU74+18i++m<br>-----END CERTIFICATE-----<br>&quot;&quot;&quot;;</pre><p>Custom Http Client Olustururken Sertifikamizi Set Edecegiz.</p><pre>  static Future&lt;HttpClient&gt; customHttpClient({<br>    bool isTestMode = false,<br>  }) async {<br>    SecurityContext context = SecurityContext(withTrustedRoots: false);<br>    try {<br>      List&lt;int&gt; bytes = [];<br><br>      if (isTestMode) {<br>        bytes = utf8.encode(_certificate);<br>      } else {<br>        bytes = (await rootBundle.load(&#39;assets/ssl_pinning_certificate2.pem&#39;))<br>            .buffer<br>            .asUint8List();<br>      }<br>      context.setTrustedCertificatesBytes(bytes);<br>    } on TlsException catch (e) {<br>      if (e.osError?.message != null &amp;&amp;<br>          e.osError!.message.contains(&#39;CERT_ALREADY_IN_HASH_TABLE&#39;)) {<br>        log(&#39;createHttpClient() - cert already trusted! Skipping.&#39;);<br>      } else {<br>        log(&#39;createHttpClient().setTrustedCertificateBytes EXCEPTION: $e&#39;);<br>        rethrow;<br>      }<br>    } catch (e) {<br>      log(&#39;unexpected error $e&#39;);<br>      rethrow;<br>    }<br>    HttpClient httpClient = HttpClient(context: context);<br>httpClient.badCertificateCallback = (X509Certificate cert, String host, int port) {<br>    // Güvenli olmayan sertifikaları reddetmek için daha güvenli bir kontrol ekleyin<br>    // Örneğin, belirli bir sertifikanın parmak izi ile eşleşip eşleşmediğini kontrol edebilirsiniz<br>    // return myTrustedFingerprint == sha256.convert(cert.der).toString();<br>    return false; // Sadece belirli durumlarda true döndürmek için güncelleyin<br>};<br><br>    return httpClient;<br>  }</pre><p>Simdi ise instance’imizin cagirilacagi IOClienti olusturup dondurecek fonksiyonu yazdik.</p><pre> static Future&lt;http.Client&gt; createLEClient({bool isTestMode = false}) async {<br>    IOClient client = IOClient(await customHttpClient(isTestMode: isTestMode));<br>    return client;<br>  }</pre><p>Burada artik instanceimizi initiliaze edip custom clientimizi kullanabiliriz.</p><pre>class SSLPinning {<br>  static Future&lt;http.Client&gt; get _instance async =&gt;<br>      _clientInstance ??= await createLEClient();<br><br>  static http.Client? _clientInstance;<br><br>  static http.Client get client =&gt; _clientInstance ?? http.Client();<br><br>  static Future&lt;void&gt; init() async {<br>    _clientInstance = await _instance;<br>  }</pre><p>Main’de initiliaze etmemiz gerekiyor. Tek bir instance olusturacagiz.</p><pre>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Firebase.initializeApp();<br>  await SSLPinning.init();<br>  di.init();<br>  runApp(MyApp());<br>}</pre><p>Bunun icinde di’de yani dependency injection kisminda singleton patterini ekleyecegiz.</p><pre>  locator.registerLazySingleton(() =&gt; SSLPinning.client);</pre><p>Artik bu client ile yapacagimiz isteklerle appimiz daha guvenli.</p><p>DIO Ornegi:</p><pre>import &#39;dart:io&#39;;<br><br>import &#39;package:crypto/crypto.dart&#39;;<br>import &#39;package:dio/dio.dart&#39;;<br>import &#39;package:dio/io.dart&#39;;<br><br>void main() async {<br>  final dio = Dio();<br><br>  // TODO: Her zaman en güncel parmak izine güncelleyin.<br>  // openssl s_client -servername pinning-test.badssl.com \<br>  //    -connect pinning-test.badssl.com:443 &lt; /dev/null 2&gt;/dev/null \<br>  //    | openssl x509 -noout -fingerprint -sha256<br>  final fingerprint =<br>      // &#39;en-son-sha256-hex-ee5ce1dfa7a53657c545c62b65802e4272 ile güncelleyin&#39;;<br>      // şöyle görünmeli:<br>      &#39;ee5ce1dfa7a53657c545c62b65802e4272878dabd65c0aadcf85783ebb0b4d5c&#39;;<br><br>  // Sadece root sertifikası güvenilir olduğu için hiçbir sertifikaya güvenmeyin<br>  dio.httpClientAdapter = IOHttpClientAdapter(<br>    createHttpClient: () {<br>      final client = HttpClient(<br>        context: SecurityContext(withTrustedRoots: false),<br>      );<br>      // Burada ara / kök sertifikayı test edebilirsiniz. Biz sadece yok sayıyoruz.<br>      client.badCertificateCallback = (cert, host, port) =&gt; true;<br>      return client;<br>    },<br>    validateCertificate: (cert, host, port) {<br>      // Sertifikanın parmak izinin beklediğimizle eşleşip eşleşmediğini kontrol edin<br>      // Kesinlikle _bir_ sertifika gerekiyor<br>      if (cert == null) return false;<br>      // İstediğiniz şekilde doğrulayın. Burada sadece<br>      // parmak izinin OpenSSL SHA256 ile eşleşip eşleşmediğini kontrol ediyoruz.<br>      final f = sha256.convert(cert.der).toString();<br>      print(f);<br>      return fingerprint == f;<br>    },<br>  );<br><br>  Response? response;<br><br>  // Normalde bu sertifika kabul edilirdi, ancak başlangıçta tüm<br>  // sertifikalar reddedilir ve yine de kontrol edilir.<br>  response = await dio.get(&#39;https://sha256.badssl.com/&#39;);<br>  print(response.data);<br>  response = null;<br><br>  // Normalde bu sertifika, hostunun sertifikada kapsanmaması nedeniyle reddedilir.<br>  response = await dio.get(&#39;https://wrong.host.badssl.com/&#39;);<br>  print(response.data);<br>  response = null;<br><br>  try {<br>    // Bu sertifikanın parmak izi aynı değil.<br>    response = await dio.get(&#39;https://bad.host.badssl.com/&#39;);<br>    print(response.data);<br>  } on DioException catch (e) {<br>    print(e.message);<br>    print(response?.data);<br>    dio.close(force: true);<br>  }<br>}<br></pre><blockquote>Eeee makale bitti ama sen hala claplemedin?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*fYbHaQSnMw5048sXHZpJpQ.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b84cd936ff3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Riverpod Testing  ✅]]></title>
            <link>https://hilmiberkayozdemir.medium.com/flutter-riverpod-testing-7a1ef8104f03?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a1ef8104f03</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[riverpod]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Wed, 21 Jun 2023 20:43:37 GMT</pubDate>
            <atom:updated>2023-06-21T20:43:37.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5s4uWnCq_X-SwohbTP70AQ.jpeg" /></figure><p>Prepare to be amazed by the groundbreaking enhancements that come with the highly anticipated release of Riverpod 2.0, revolutionizing the way we write Flutter apps! 🔥</p><p>Say goodbye to tedious manual labor, as the new @riverpod syntax takes center stage, empowering us with the incredible ability to effortlessly generate providers on the fly using the mighty build_runner. Imagine the possibilities of dynamic and flexible provider generation, unlocking a realm of endless opportunities for seamless app development.</p><p>But that’s not all! Brace yourself for a mind-blowing advancement in asynchronous initialization, thanks to the extraordinary AsyncNotifier class. This game-changing addition offers an exceptionally ergonomic API, catapulting your coding experience to new heights. Gone are the days of struggling with clunky StateNotifier implementations. With AsyncNotifier, you’ll experience a world of effortless and elegant asynchronous initialization, ensuring your app’s performance remains unparalleled.</p><p>Riverpod 2.0 has arrived, revolutionizing the Flutter landscape and paving the way for an era of exhilarating app development. Embrace the power, embrace the excitement, and unlock a whole new level of productivity with these cutting-edge features. The possibilities are limitless, and the journey is just beginning!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOgBeIghBSjwlPtvBCY2KQ.jpeg" /></figure><p>But hold on tight, because when it comes to writing tests, things can get a little tricky 😬. It’s no secret that getting them up and running smoothly can be quite the challenge.</p><p>⚡️And if we dare to level up our code by replacing the old and faithful StateNotifier with the mighty AsyncNotifier, we’re in for a surprise! Brace yourself, because those trusty old tests based on StateNotifier will no longer cut it. It’s time to adapt and conquer!⚡️</p><p>So, in this exhilarating article, we’re embarking on a thrilling journey to master the art of writing unit tests for AsyncNotifier subclasses. 🚀</p><p>Hold onto your seats as we unravel the secrets of:</p><p>🔧 Working our magic with ProviderContainer and gracefully overriding providers within our tests. 👂 Setting up a mesmerizing provider listener using the enchanting ProviderSubscription. 🧪 Verifying that the listener dances to the rhythm using the incredible mocktail package.</p><p>But beware, brave adventurers! Along the way, we’ll encounter a few treacherous gotchas that may challenge our skills. Fear not, for we shall conquer them together! And remember, testing with listeners versus streams will reveal the true power and advantages that lie within! 💪</p><p>By the triumphant finale of this epic article, you’ll emerge with not just a better understanding but also a shining template that will pave your way to test-writing glory with Riverpod. Prepare to unleash the warrior within and conquer the realm of unit testing! 🔥🛡️</p><h3>LETS GO!</h3><h3><strong>Example: We have an AsyncNotifer subclass.</strong></h3><h4><strong>AuthController:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0nJnTumxN2I3hdww4ECmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wcUTMMZ38RojKq27qrbAbg.png" /></figure><h4>AuthRepository:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fj8FEKuLgzfDmGM0TCTIA.png" /></figure><p>I’m going to show you all code but I think, some how you are not getting here if you don’t understand that basics.</p><h4><strong>Why we are using unit tests?</strong></h4><p>I want to keep it simple with this list.</p><ul><li>Detecting Bugs Early</li><li>Facilitating Code Refactoring</li><li>Improving Code Quality</li><li>Enabling Collaboration</li><li>Boosting Confidence in Code Changes</li></ul><p>We check the results and verify that our current actions produce the expected outcomes. If something changes, we can address it accordingly.</p><p>Now, let’s take a deeper dive into our code. We are utilizing Mocktail and making use of the Listener class to observe subclasses. What does this Listener class provide, and how does it work?</p><p>The purpose of the Listener class is to listen to the states. It allows us to track and react to changes in the state of our application. By observing these state changes, we can take appropriate actions and ensure that our code responds correctly.</p><p>By using the Listener class, we can effectively manage and handle the various states within our application. It helps us stay informed about any updates or modifications to the state and enables us to perform specific actions based on those changes.</p><p>In summary, the Listener class plays a crucial role in keeping track of state changes, allowing us to respond accordingly and maintain the desired behavior of our code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*WQEWflx4HChDoWJq65gbvA.png" /></figure><p>When we use Listener we want types and we are using these types to check the previous and next states of the defined Type.</p><p>Now we are Mocking MockAuthRepository like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CwV0jDN6lPUBeCuBWKDlfw.png" /></figure><p>If you are using riverpod like me we need to use ProviderContainer to override our controllers and repositories inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJ_Oo30csWcbiQHQy15NFQ.png" /></figure><p>Now how riverpod initializes and verifies works you can check this code.</p><p>Steps:</p><ul><li>Create an instance of MockAuthRepository</li><li>Create the ProviderContainer with the mock auth repository instance</li><li>We override the AuthRepository inside the makeProviderContaniner() function.</li><li>Create a listener with our state which return from the controller provider.</li><li>Listen to the provider and call [listener] whenever its value changes</li><li>Now our container listens to the provider and its state. Verify here we are checking the previous and next state status.</li><li>At here we are using our verification methods.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wsRq8lIYGLi6F4-5-ZJcEw.png" /></figure><h3>Verify Methods and examples of verifying methods.</h3><p>In this example we are calling signInAnonymously() function then we are checking that states with verify functions.</p><ul><li>verifyInOrder(): The verifyInOrder() method verifies that a sequence of method invocations happened in a specific order on one or more mocked objects. It allows you to assert that certain operations were performed in the expected sequence.</li><li>verify(): The verify() method is used to check if a specific method was called on a mocked object with the expected arguments. It ensures that a certain method invocation occurred during the test.</li><li>verifyNoMoreInteractions(): The verifyNoMoreInteractions() method ensures that no further method calls occurred on mocked objects beyond the ones explicitly verified. It checks that all expected interactions were captured and there were no additional or unexpected calls.</li><li>verifyNever(): The verifyNever() method asserts that a specific method was never called on a mocked object. It confirms that the specified method was not invoked during the execution of the test.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwUEFzjuYzDSpykRQjbUCQ.png" /></figure><p>Full code sign-in testing from Andrea’s documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnkAc3wzVUzfNtJcOm1snw.png" /></figure><h3>Sources:</h3><p><a href="https://codewithandrea.com/articles/unit-test-async-notifier-riverpod/">https://codewithandrea.com/articles/unit-test-async-notifier-riverpod/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a1ef8104f03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Version Control — Git Cheat Sheet]]></title>
            <link>https://hilmiberkayozdemir.medium.com/version-control-git-cheat-sheet-5000cc6dbf95?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/5000cc6dbf95</guid>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 04:47:05 GMT</pubDate>
            <atom:updated>2023-01-04T04:47:05.097Z</atom:updated>
            <content:encoded><![CDATA[<h3>Version Control — Git Cheat Sheet</h3><p>Have you ever accidentally deleted something on your device and wished you could undo your mistake? Wouldn’t it be great if you had a time machine to go back and undo your mistake? While humans can’t yet to travel back in time, programmers working on projects can do something quite like it. They do this using a system called version control. As a programmer, you’ll be working with many files in your project and it’s important to keep track of the changes being made. Version control is a system that records all changes and modifications to files for tracking purposes, and is essential to your day-to-day development activities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lK1TY05ZEvC9zi3_T78P8A.png" /></figure><blockquote><strong><em>Time machine Paint (By dall-e)</em></strong></blockquote><p>In this article you will become familiar with version control and how it relates to development. You’ll get to explore popular methods of version tracking using version control technologies like Git and GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/0*FwL99WV3Oh6BoB1O.png" /></figure><h3>What is git?</h3><p>Git is a tool used by programmers to track and manage changes to their code. It helps multiple people work on the same codebase and keeps a record of all the changes made. Git is especially useful for managing software development projects, but it can be used for any type of file. It is fast, reliable, and works well with team-based projects.</p><h3>Install Git</h3><h4>Ubuntu</h4><p>Open terminal and code the scripts</p><pre>$ sudo apt-get install git-all</pre><h4>Mac OS</h4><p>Install <a href="https://brew.sh/">homebrew</a> if you don’t already have it, then:</p><pre>$ brew install git</pre><h4>Windows</h4><p><a href="https://git-scm.com/download/win">Download link</a></p><h3>Before Tutorial:</h3><p>You must comprehend the significance of these terms to effectively utilize version control in your work as a programmer.</p><h3>Glossary</h3><p>mkdir = Creates directory.</p><p>cd = Shows your home directory</p><p>cd &lt;folder&gt; = Change to a specific directory</p><p>ls = Shows a listing of all files in the current directory</p><p>rm -f &lt;file&gt; = Force a removal without confirmation</p><p>rm -i &lt;file&gt; = Will display prompt before removal</p><p>config = means configuration for git</p><p>git: an open source, distributed version-control system</p><p>GitHub: a platform for hosting and collaborating on Git repositories commit: a Git object, a snapshot of your entire repository compressed into a SHA</p><p>branch: a lightweight movable pointer to a commit</p><p>clone: a local version of a repository, including all commits and branches remote: a common repository on GitHub that all team member use to exchange their changes</p><p>fork: a copy of a repository on GitHub owned by a different user pull request: a place to compare and discuss the differences introduced on a branch with reviews, comments, integrated tests, and more</p><p>HEAD: representing your current working directory, the HEAD pointer can be moved to different branches, tags, or commits when using git checkout</p><p>Workspace: What you see in your editor and where you make your changes.</p><p>Staging Area: A snapshot of your working tree at a particular point in development.</p><p>Local Repository: Your copy of a project, initialized as a Git repository.</p><p>Remote Repository: The shared copy of the repo that lives on a remote server.</p><h4>Github Workflow:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQ1q04jKHnsBIYJwrx_34g.png" /></figure><h3>Step 1: Make the directory where you want to use Git</h3><p>In this article I want to show this example with flutter project.</p><pre>$ mkdir flutter_vc_tutorial<br>$ cd flutter_vc_tutorial<br>$ flutter create .</pre><p>For flutter example. We need to keep some secrets in our app for example API keys we have some methods for keep this data we should create .gitignore file for this.</p><p>Flutter creates this file for us, we should use this files in our git projects.</p><pre># Miscellaneous<br>*.class<br>*.log<br>*.pyc<br>*.swp<br>.DS_Store<br>.atom/<br>.buildlog/<br>.history<br>.svn/<br>migrate_working_dir/<br><br># IntelliJ related<br>*.iml<br>*.ipr<br>*.iws<br>.idea/<br><br># The .vscode folder contains launch configuration and tasks you configure in<br># VS Code which you may wish to be included in version control, so this line<br># is commented out by default.<br>#.vscode/<br><br># Flutter/Dart/Pub related<br>**/doc/api/<br>**/ios/Flutter/.last_build_id<br>.dart_tool/<br>.flutter-plugins<br>.flutter-plugins-dependencies<br>.packages<br>.pub-cache/<br>.pub/<br>/build/<br><br># Symbolication related<br>app.*.symbols<br><br># Obfuscation related<br>app.*.map.json<br><br># Android Studio will place build artifacts here<br>/android/app/debug<br>/android/app/profile<br>/android/app/release</pre><p><strong>Why flutter ignore this directories and files?</strong></p><p>As you can see this files this files can generate by flutter again no need to share them and this file storage sizes can be more than 100 mb. GitHub has a strict file limit of 100MB.</p><h3>Step 2: Setup “config”</h3><pre>$ git config --global user.name &quot;hilmi berkay&quot;<br>$ git config --global user.email &quot;berkay.ozdemir@etiya.com&quot;</pre><p>Check your config</p><pre>$ git config --list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Mtrc08b0F3BuHkxzKJs9A.png" /></figure><h3>BONUS:</h3><pre>$ git config - global color.ui auto</pre><p>Enables helpful colorization of command line output.</p><h3>Step 3: Initial the Git</h3><pre>$ git init</pre><p>Generate a hidden directory “.git” in your directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I32PJ5kkT2wxPIVd9_stBA.png" /></figure><p>Git and gitignore is hidden file type so you should use this in finder.</p><blockquote>CMD+SHIFT+ . (DOT)</blockquote><h3>Step 4: All important git executions</h3><p>If you want to continue one existing project in github:</p><pre>$ git clone [url]</pre><p>Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits</p><h4>Branches:</h4><p>Branches are an important part of working with Git. Any commits you make will be made on the branch you’re currently “checked out” to. Use git status to see which branch that is.</p><pre>$ git branch [branch-name]</pre><p>Creates a new branch.</p><pre>$ git checkout [branch-name]</pre><p>Switches to the specified branch and updates the working directory.</p><pre>$ git merge [branch]</pre><p>Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation.</p><pre>$ git branch -d [branch-name]</pre><p>Deletes the specified branch.</p><h4>Synchronize changes:</h4><p>Synchronize your local repository with the remote repository on GitHub.com</p><pre>$ git fetch</pre><p>Downloads all history from the remote tracking branches.</p><pre>$ git merge</pre><p>Combines remote tracking branch into current local branch.</p><pre>$ git push</pre><p>Uploads all local branch commits to GitHub.</p><pre>$ git pull</pre><p>Updates your current local working branch with all new commits from the corresponding remote branch on GitHub.<strong> <em>git pull</em></strong><em> </em>is a combination of <strong><em>git fetch</em></strong> and <strong><em>git merge.</em></strong></p><h4>Make Changes:</h4><p>Browse and inspect the evolution of project files:</p><pre>$ git log</pre><p>Lists version history for the current branch.</p><pre>$ git log --follow [file]</pre><p>Lists version history for a file, including renames.</p><pre>$ git diff [first-branch]...[second-branch]</pre><p>Shows content differences between two branches.</p><pre>$ git show [commit]</pre><p>Outputs metadata and content changes of the specified commit.</p><pre>$ git add [file]<br></pre><p>Snapshots the file in preparation for versioning.</p><pre>$ git commit -m &quot;[descriptive message]&quot;</pre><p>Records file snapshots permanently in version history.</p><h4>Redo commits:</h4><p>Erase mistakes and craft replacement history.</p><pre>$ git reset [commit]</pre><p>Undoes all commits after [commit], preserving changes locally.</p><pre>$ git reset --hard [commit]</pre><p>Discards all history and changes back to the specified commit.</p><p><strong>CAUTION! Changing history can have nasty side effects. If you need to change commits that exist on GitHub (the remote), proceed with caution. If you need help, reach out at github.community or contact support.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pv2ssInxG6VQiQE1A34dhw.png" /></figure><blockquote><strong>(Crowded aquarium by-dall-e)</strong></blockquote><p><strong>We’re all in that crowded aquarium. We must learn to live together.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5000cc6dbf95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Persistence with Isar and Hydrated BLoC-Part 1]]></title>
            <link>https://hilmiberkayozdemir.medium.com/flutter-persistence-with-isar-and-hydrated-bloc-part-1-a575f01cf41a?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/a575f01cf41a</guid>
            <category><![CDATA[isar]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[to-do-list-app]]></category>
            <category><![CDATA[bloc]]></category>
            <category><![CDATA[persistence]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Sat, 26 Nov 2022 03:18:34 GMT</pubDate>
            <atom:updated>2022-11-26T03:18:34.302Z</atom:updated>
            <content:encoded><![CDATA[<p>Even today, it is widespread to have no data connection if you are in a subway or a plane or if you visit your village, which has no Wi-Fi and a terrible cell signal. You shouldn’t let bad connections cripple your application!</p><h3>How do we prevent this?</h3><p>One month ago, I developed react native application, and the company I am working with used the redux_offline package for this persistence property. We will use two essential dart packages. The first is a state management solution <a href="https://pub.dev/packages/hydrated_bloc">hydrated bloc</a> is an extension to the bloc state management library, which automatically persists and restores bloc states. The second is a local database solution, the <a href="https://pub.dev/packages/isar">Isar package</a>, which provides highly secure and easy implementation properties with generated collection models.</p><h4>Hydrated Bloc</h4><p>Regular Blocs always extend the Bloc class. Persisting state of the Bloc requires a different super class — HydratedBloc. Of course, our work doesn’t end there. Let’s first talk about how and when the state is persisted and restored.</p><p>Restoration of the Bloc’s state happens when the Bloc is first created. This makes sense. After all, you wouldn’t want the Bloc to restore its previous state while running the app. For this reason, we will modify the initialState property not always to return the initial state but to try getting the state from the storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fhm4ZWK1bPrkaJx5.png" /></figure><h4>Isar</h4><p>Isar is a super fast, robust database for Flutter. Isar is highly scalable and supports asynchronous query operations, multi-entry indexes on queries, and JSON type. Isar is also explicitly made for Flutter, which supports all platforms that support flutter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*upp0p1TAM561eZge" /></figure><h3>Our Goal</h3><p>Create an application that needs persistence, and we will use the packages we introduced in this article. This app is very important for people who need to manage their life&#39;s stress and want to increase productivity. Eisenhower matrix helped me too many times before.</p><blockquote>The urgent are not important, and the important are never urgent.”</blockquote><blockquote>D. D. Eisenhower</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*GnwZTxrwME3TQ0HO.png" /></figure><p>Project purpose: We are going to develop the Todo application but which is <br>inspired by the Eisenhower matrix.</p><p>Our models: Activity, Theme, Task, Goal, Meeting, Notes</p><p>UI Design:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xpYSOFjXMjUaJNpjJTong.png" /></figure><p>From Dribble: <a href="https://dribbble.com/shots/18475404-TaskMan">https://dribbble.com/shots/18475404-TaskMan</a></p><h4>Workflow</h4><p>1-Setup packages</p><p>2-Generate Models</p><p>3-Implement Design Language System,</p><p>4-Implement UI</p><p>5-Implement hydrated_bloc and tests -TDD- (First Test)</p><p>6- Backend API with Golang for syncing all operations with DB.</p><p>6-Improvements.</p><p>7-Release in stores</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a575f01cf41a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter- Freezed Paketinin kullanımı.]]></title>
            <link>https://hilmiberkayozdemir.medium.com/flutter-freezed-paketinin-kullan%C4%B1m%C4%B1-f52e7a1da8c?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f52e7a1da8c</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[freezed]]></category>
            <category><![CDATA[pubdev]]></category>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 14:28:19 GMT</pubDate>
            <atom:updated>2022-10-22T21:04:15.883Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter- Freezed Paketi.</h3><p>Bu makaleyi okuduğunuzda Flutter uygulamalarınızda nasıl kolay bir şekilde undo &amp; redo fonksiyonalitesi ekleyebiliceğinizi öğreneceksiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*a6mILWJGFgP4NshLJxVsCg.gif" /></figure><p>Bugünlerde komunitelerde ve youtube videolarını izlerken sıkça immutable kodlama teknikleri ile ilgili tartışmalar sıklaşmaya başladı. Immutabilite bir nesnenin oluşturulduktan sonra değişmemesi gerektiği fikridir. Nesneler ve sınıflar için bu, içerdikleri tüm değişkenleride içerir. Ve değişmez nesneler kullanarak, pek de belirli olmayan bazı olumsuz etkilerden kaçınabiliriz. Bu tarz, programlamayı daha işlevsel bir paradigma ile düşünmeyi gerektirir.</p><p>Değişken nesnelerle çalışırken, tamsayılar listesindeki bir<em> .sort</em> fonksiyonunu büyükten küçüğe doğru çağırırken, yani [3,2,1], bu çok açık olmayan bir olumsuz etkinin klasik bir örneğidir. Şimdi listeyi değiştiren ve döndüren bir method kullanarak bir <em>newList</em> yapalım. Görünüşe göre <em>newList</em> doğru gibi görünsede, orijinal <em>mutableList</em>’imizi yazdırmaya çalıştığımızda, oluşturduğumuzdan farklı çıkıyor sonuç. Bunu yapmanın sonucu, Hem <em>mutableList</em> hem de <em>newList</em> sırasının artan sırada olmasıdır, yani [1,2,3].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwC0CKPbaVrhOVZ7MY5N8A.png" /></figure><p>Bu makale sizin immutable programlamayı daha iyi anlamanızı ve olumsuz etkilerini bir Flutter appi ile gösterip ardından Freezed paketi ile bundan nasıl kurtulup çözüme ulaşacağınızın örneğini yapıp öğretmeyi amaçlamaktadır.</p><h3>Bu sorulara cevap bulacaksınız.</h3><ul><li>Freeze paketi nedir neden kullanılır <strong>Freezed Package?</strong></li><li>Kodunuza nasıl undo ve redo gibi geri al, ileri al fonksionalitelerini eklerim?</li><li>Nasıl mutable kod yazabilirim?</li><li>Immutable kodumu nasıl yeniden düzenler mutable code yapabilirim?</li></ul><h4><strong>Freezed nedir?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*y5avJHMme4hKs3LqXXzpZA.gif" /><figcaption><a href="https://pub.dev/packages/freezed">https://pub.dev/packages/freezed</a></figcaption></figure><p>Freezed dart programlama dilinde çoğunlukla modeller olmak üzere veri sınıflarımızı oluşturan bir code generate(kod oluşturma) paketidir. Hatalı kod varsa generate(üretim-oluşturma) yapmaycağı için bir ton hatalı kod yazmanızı engeller. Dart harika bir dil fakat model tanımlamak bazen sıkıcı olabiliyor. Güzel bir model sınıfı oluşturmak için şu adımları yapmamız gerekiyor</p><blockquote>#Contrusctor tanımlamak ve özelliklerini eklemek</blockquote><blockquote># toString, operator ==, ve hasCode larını @override etmek</blockquote><blockquote>#copyWith methodunu ekleyip ileri safalarda clone objeler üretmek</blockquote><blockquote>#serilizazyonu ve deserilizasyonu sağlamak</blockquote><p>Ve dart bazı önemli gelişmeleride kaçırmış durumda örnek olarak union tipler ve patternleri eşleştirme.</p><p>Tüm bunları yapmak freeze olmadan yüzlerce satır tutucağından okumayı ve hatalarla karşılaşma ihtimalimizi arttırıcakken freeze bizim için bu implementasyonu güzel bir şekilde sağlamakta.</p><p>Freezed olmadan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/0*OcJzCaKaEjbAQTC6.png" /></figure><p>Ve Freezed ile bunu okunabilirliği daha yüksek ve daha kısa şekilde şu şekilde yapabiliyoruz.</p><p>Freezed ile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*zSFspaoTb9BIoj7N.png" /></figure><h3>Minimal Freezed uygulanabilir bir app düşünelim.</h3><ul><li>Bu app listede sınıf objeleri barındırıyor (objelerimiz nested dataya sahip).</li><li>Bu app geri al e ileri al butonlarına sahip ve butonlar ile listedeki sınıf listeleri arasında geçiş yapmamızı sağlayacak.</li><li>Bu app bize kulanıcı arayüzünde mevcut durum için nested dataları ekranda görüntülüyecek.</li></ul><p>Bu class objeleri nested yapıdadır bu örnekte göreceğiniz gibi:</p><pre>List&lt;NestedClass&gt;<br>|-- List&lt;NestedClass&gt;<br>|   |-- List&lt;NestedClass&gt;<br>|   |   |-- List&lt;NestedClass&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*M1GcjGK7NWEOcoQY13bo1A.png" /></figure><p>Bu yeşil renkle çizilmiş app diyagramı UI ile ilgili amaçlanan fonksiyonaliteyi gösterir.</p><p>Özet olarak widgetlar şu amaçlara sahip:</p><ul><li>AppBar hangi sınıf objesinin şu an ekranda gösterileceğini,</li><li>ListViewBuilder ise sınıf objelerinde tutulan dataları ve diplerindeki nested dataları gösterecek,</li><li>Undo ve redo butonlarıysa listede tutulan bu nested datalar arasında geçiş yapmamızı sağlayacak.</li></ul><p><strong>Çalışan demomuz:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*B56S6JluytJ-Oc4DK-8YLg.gif" /></figure><h3><strong>İlk soru problem ne?</strong></h3><p>Sorunu çözerken arkadaşlar sizinde main branchimizde duran sorunun bulunduğu kodu incelemenizi istiyorum buraya linkini bırakıyorum.</p><p><a href="https://github.com/hberkayozdemir/how_to_use_freezed">https://github.com/hberkayozdemir/how_to_use_freezed</a></p><p>Main branchimizde sorunlu olan kodumuz var önce bunu ardında çözümü ve freezed implementasyonunu barındıran <a href="https://github.com/hberkayozdemir/how_to_use_freezed/tree/fix/fix-the-problem-with-freezed-package">https://github.com/hberkayozdemir/how_to_use_freezed/tree/fix/fix-the-problem-with-freezed-package</a> branchine giderek kodları inceleyebilirsiniz.</p><p>Lafı daha fazla uzatmadan soruna geçelim!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*3IQYuVdZL5yGKpd1OYgB8A.png" /></figure><p>Makalede sıkça adı geçen sınıf objelerini burda NestedClass olarak tanımladık. Bu basit classımız name, surname ve yaş değişkenlerini taşıyor. Bu sınıf aynı zamanda children variable yani çocukları (soyun devamı) adında List&lt;NestedClass&gt; değişkenini taşıyor. Bu liste değişkeni bize sınıf objelerinin derin nested dataları barındırmasını sağlıyor. Burada iki metod var addChild ve copyWith, ve NestedClassın initial constructor’u. Burada immutable kod ile ilgili sorun şudur addChild methodu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*2W7dIwnTz9biBHmxzuEXBg.png" /></figure><p>çünkü bir nested class ekleyerek alt değikeni değiştirmeyi hedeflemiş fakat bu modifikasyon mümkün değildir. Immutable kodlamada class initial constrcutoru derlendiğinde initial durumdan geçtikten sonra herhangi bir değişkeni değiştiremezsiniz.</p><p>Tabiki sonuç kısmında göstericeğim gibi Freezed kullanmazsanız :)</p><h3>Sınıf Objeleri</h3><p>Açıklık getirmek için sınıf objelerimizide buraya koydum. Tüm sınıf objelerimiz burada hard coded halde bulunmakta. Tabiki canlıya alınması planlanan bir appte bu şekilde olmaz burası sadece öğrenmemiz için bir makale POC’si (Proof of Concept- Konseptin Kanıtı).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*GeMrw7i4tpLLQtf9HmZzhQ.png" /></figure><p>Tekli sınıf objeleri daha sonra iç içe(nested) olacak.</p><h3>Sınıf Objelerini derinlemesine iç içe hale getirme</h3><p>Burada sınıf objelerimizi iç içe hale getiriyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*toRR5Cor2IusqElXa9Oquw.png" /></figure><p>Canlıdaki bir uygulamanın kodu tamamen farklı olurdu fakat burada aynı süreci uygular:</p><p>Sınıfımızda uygulamanın başlamasından sonra initial hale gelmesiyle birlikte çocuklar listesine bir üye eklemek için method cağırılır. Bu durumda, <strong><em>.addChild</em></strong> methodunu gereğinden fazla vurgulamak için koda en ilkel haliyle bakmanın daha iyi olacağını düşündüm. Bu kod entityleri (oluşan varlıklar) oldukça <strong>hard coded</strong> şekilde sabitler. Bununla birlikte, bu kodta, şu anda olduğu gibi veya daha karmaşık bir biçimde, değişmez kodlama düşüncesini kullanırken <strong><em>.addChild</em></strong> yöntem çağrısını kullanamayacağını, çünkü bu, child değişkenini değiştirmemize neden olacağını görülüyor.</p><h3>Burada Fonksiyonel Programlama Düşüncesi kurallarını uygulamalıyız.</h3><p>Bizim için en çok zorluk çıkaracak sınıf <strong>delete.dart</strong>’tır. Bu sınıfta nesneleri hiyerarşiden kaldırmak için logic’i burada gözden geçirelim.</p><p>Fonksiyonel programlama son günlerde daha da popüler hale geliyor ve bunun sebepleri çok açık. Fonksiyonel programlamada bir datayı modifye etmenin adımları şunlardır:</p><p>Yazarken-kopyala (copy-on-write)</p><blockquote><em>1.Değişmesini önlemek için sınıf objesinin bir kopyasını oluşturur.</em></blockquote><blockquote><em>2.Kopyayı değiştirir.</em></blockquote><blockquote><em>3.Değiştirilmiş kopyayı döner.</em></blockquote><p>Bizim kodumuzda ise bunu şöyle yapabiliriz</p><p>İlk olarak kod, geçirilen hiyerarşi sınıf nesnesini kopyalar. Burada sorunumuz şu ki hiyerarşiyi kopyalasak bile onu derin bir şekilde kopyalayamıyoruz ve kopyalanan hiyerarşideki değişikliklerimiz hiyerarşi sınıfı nesnesinde değişikliklere neden olacak.</p><p>İkinci olarakta kodtaki çocuk nesnesini .<strong><em>remove(nesne)</em></strong> si ile değiştirerek verileri değiştirmeyi hedefler ama bu değişiklikte yine mümkün değil.</p><p>Üçüncüsü, kod kopyalanan ve değiştirilen sınıf nesnesini geri döndürür.</p><pre>NestedClass delete({   required NestedClass object,   required NestedClass hierarchy, }) {   // 1. copy the hierarchy.   final copiedHierarchy = hierarchy;   {     if (object == copiedHierarchy) {       return NestedClass.initial();     }     // 2. modifies.     if (copiedHierarchy.children.contains(object)) {       copiedHierarchy.children.remove(object);     } else {       for (NestedClass child in copiedHierarchy.children) {         delete(object: object, hierarchy: child);       }     }     // 3. returns copied and modified hierarchy     return copiedHierarchy.copyWith(children: [...copiedHierarchy.children]);   } }</pre><p>Özellikle, ‘sığ bir şekilde kopyalama(shallow copy)’ değişkenliği durdurmaz. Freezed paketi ise , sınıf nesnelerini değişmez bir şekilde “derin kopyalama” yapmamızı sağlar.</p><p>Freezed paketi uygularken, gerçekten fonksiyonel bir programlama düşüncesi için farklı bir strateji kullanacağız.</p><p>Geri al düğmesine basmak, yedi sınıf nesnesi listesinde gezinmeyi sağlar. Her sınıf nesnesi diğerlerinden farklı olduğu için butona basarak listeyi kaydırdığımızda UI’da bir değişiklik görmeliyiz. Ancak GIF, kullanıcı arayüzünün her sınıf nesnesi için aynı kaldığını ortaya koymaktadır. Değişken oldukları için sınıf nesneleri beklenmedik bir şekilde değişiyor! Bu tür bir olumsuz etki, yukarıdaki örnek ile aynıdır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*B56S6JluytJ-Oc4DK-8YLg.gif" /></figure><h3>Çözüm zamanı!</h3><h3>Freeze Your Code!</h3><p>Freezed paketinin kullanımı mükemmel gerçekleştiren ve videosunu paylaşan ResoCoder kanalından izleyebilirsiniz</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fv5bfidqOY10%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dv5bfidqOY10&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fv5bfidqOY10%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e935bffae751107c421fef2c2e33a2b0/href">https://medium.com/media/e935bffae751107c421fef2c2e33a2b0/href</a></iframe><p>Zamanınızıda almamak için size generate edeceğiniz modeli doğru biçimde paylaşayım. :)</p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;part &#39;nested_class.freezed.dart&#39;;<a href="http://twitter.com/freezed">@freezed</a><br>class NestedClass with _$NestedClass {<br>  const NestedClass._();<br>  const factory NestedClass({<br>    required String name,<br>    required String surname,<br>    required int age,<br>    required List&lt;NestedClass&gt; children,<br>  }) = _NestedClass;<br>}</pre><h4>Ben nasıl implement ettim</h4><p>5 adımdan oluşuyor:</p><h4>1. Gerekli kütüphanelerimizi pubspec.yaml dosyamıza ekliyoruz.</h4><pre>freezed: ^2.1.1<br>freezed_annotation: ^2.1.0<br>build_runner: ^2.2.1</pre><h4>2. NestedClassımıza inital factoryConsrustoru ekliyoruz.</h4><pre>part &#39;nested_class.freezed.dart&#39;;<br>@freezed <br>class NestedClass with _$NestedClass {   <br>const NestedClass._();  const factory NestedClass({required String name,required String surname,required int age,     required List&lt;NestedClass&gt; children, }) = _NestedClass; <br><br>factory NestedClass.initial() =&gt; const NestedClass(name: &#39;Soy Ağacı&#39;, surname: &#39;Yaş Çizgisi&#39;, age: 500, children: []); <br>}</pre><h4>3. Freezed’i konsol komutunu tetikleyerek çalıştırıyoruz.</h4><pre>dart run build_runner watch --delete-conflicting-outputs</pre><h4>4. loadFamilyTree’de addChild methodlarını .copyWith ‘e dönüştürüyoruz</h4><pre>NestedClass loadFamilyTree() {<br>var newParents1 = parents1.copyWith(children: [     children1,     children2,   ]);    <br>var newParents2 = parents2.copyWith(children: [     children3,     children4,   ]);<br>var newParents3 = parents3.copyWith(children: [     children5,     children6,   ]);<br>var newGrandParents1 = grandParents1.copyWith(children: [     newParents1,     newParents2,     newParents3,   ]);<br>var newGrandParents2 = grandParents2.copyWith(children: []);<br>var newGreatGrandParents = greatGrandParents.copyWith(children: [     newGrandParents1,     newGrandParents2,   ]);    <br>var newFamilyTree = familyHierarchy.copyWith(children: [     newGreatGrandParents,   ]);    <br>return newFamilyTree; }</pre><p>Şimdi kodumuzu değişmez hale getirelim. Alternatif olarak kullanılan modifikasyon fonksiyonlarını immutable düşünce kullanımını için copyWith ile gerçekleştirdik.</p><h4>5. Delete fonksiyonunu fonksiyonel programlama teknikleri ile değiştiricez.</h4><p>Burada yazarken-kopyala (copy-on-write) tekniği kullanacağız</p><pre>NestedClass delete({<br>required NestedClass object,   required NestedClass hierarchy, }) {   // 1. copy the hierarchy.   <br>NestedClass? copiedHierarchy =       hierarchy.children.contains(object) ? hierarchy : null;  <br> // 2. modifies.  <br> if (copiedHierarchy != null) {    <br>return hierarchy.copyWith(children: [for (var child in hierarchy.children)         if (child != object) child,]);   }   <br> // 3. returns copied and modified hierarchy.return hierarchy.copyWith(children: [for (var child in hierarchy.children) delete(object: object, hierarchy: child),],); }</pre><p><strong>Düşünce için kodlamayı yeniden düşünmek zorunda kaldım</strong></p><p>Burada yeni versiyon çok daha bağımlı oldu <strong><em>.copyWith</em></strong> kullandığımız için.</p><p>Ve bunu çözmek içinde null-able bir sınıf ürettim.Üst sınıf nesnesinin aranan sınıf nesnesini içerip içermediğini kontrol eden bir mantık geliştirdim.</p><pre>// 1. Conditionally copy the hierarchy.<br>NestedClass? copiedHierarchy = hierarchy.children.contains(object) ? hierarchy : null;</pre><p>Daha önce yazdığım copiedHierarchy objesini burada if else koşullarıyla sorgulayarak null bir class objesi varsa silerek değiştiriceğiz</p><pre>// 2. Hiyerarşinin alt üyelerini koşula uyarak değiştirir <br>if (copiedHierarchy != null) {     <br>return hierarchy.copyWith(children: [for (var child in hierarchy.children)        <br> if (child != object) child,]); <br>}</pre><p><strong>Adım Adım Mantık nasıl işledi</strong></p><ol><li><strong>Parent sınıfları koşulla sorgulama : </strong>Parent sınıflarda obje içermiyorsa null döndürdük.</li><li><strong>Dibe indik-</strong>Eğer bir sınıf nesnesi varsa, nesne hariç yeni bir çocuk listesi yapılır. Ardından, en son çocuk listesiyle sınıf nesnesini kopyalayın ve kopyayı döndürün.</li><li><strong>Dibe indik — </strong>Eğer null bir nesne varsa dipte modifiye edilmemiş kopya döndürdük.</li><li><strong>Sürekli Fonksiyon- </strong>Kendi kendini sürekli bir şekilde çağırarak bu işlemi bitene kadar yaptırarak sonuca vardık :).</li></ol><pre>return hierarchy.copyWith(children: [<br>for (var child in hierarchy.children)       <br>// Recursively call method     <br>delete(object: object, hierarchy: child),<br>  ],<br>);</pre><p><strong>Ve sonuç !</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*CmBW2vkzXEh9jvktWCWNBg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f52e7a1da8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Nedir?]]></title>
            <link>https://hilmiberkayozdemir.medium.com/react-native-nedir-85fdd351b5c7?source=rss-9177ee0fee81------2</link>
            <guid isPermaLink="false">https://medium.com/p/85fdd351b5c7</guid>
            <dc:creator><![CDATA[Hilmiberkayozdemir]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 09:38:01 GMT</pubDate>
            <atom:updated>2022-10-22T09:48:55.448Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native nedir?</h3><h4>Şimdi sizin kafanızda iki soru var React Native Nedir ve Neden yazılır.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*JvS3Uk0-sRODByEm61KkUQ.gif" /></figure><h4>React Native nedir ve aslında neden yazılır?</h4><p>Adından da anlaşılacağı üzere aslında react native react js ile ilişkilidir. React.js ve React Native ile play store ve app store üzerinde yayınlayabileceğimiz ve her mobil cihazda çalıştırılabilecek native tabanlı mobil uygulamalar geliştirebiliriz. React js React Native’den tamamen bağımsız bir kütüphanedir. React Js bir java script kütüphanesidir ve kullanıcı arayüzleri oluşturmaya yarar çoğunlukla web geliştirme için kullanılmaktadır. Reacj js aynı zamanda ilk oluşturulan enviromenttir. Eğer React js ile daha önce uğraşmışsanız asıl web supportu veren React DOM kütüphanesine aşinasınızdır. Aslında React DOM olmasa React web için agnostik bir yapıdadır bunun anlamı eğer React DOM olmasa aslında react web platformunun alt yapısını kullanamaz yani web development yapmak istiyorsanız React’ı React DOM ile birlikte kullanırsınız ki bunu React.js sağlar. React bize sadece component ağaçları üretmemiz için stateleri yönetmemizi sağlayan toolları(yardımcı araç) verir ve bunun sonucunu platforma translate edicek React DOM kütüphanesine ihtiyaç duyarız. Öyleyse <strong>React Native </strong>aslında bir React DOM alternatifidir.</p><p>React Native sana jsx kodunda kullanabiliceğin özel önceden üretilmiş React componentleri sağlar ve bu componentler önceden belirlendiği native ios ve android platformlarının UI elementlerine derlenir. React native aslında sadece bu derleme adımında görevlidir. Ek olarakta React Native kullanımı native platformlarda kesin olan API’leri java script kodunuzda kullanmamızı sağlamaktadır örnek olarak tek bir dokunuşla tetikleyebildiğiniz native API’leri, cihazın kamerasını açmak gibi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgnHJWQncBkfEK3zqstfdA.png" /></figure><p><strong>İşte öyleyse son olarak anladıklarımızı aklımızın bir köşesine not edelim.</strong></p><blockquote># React Native aynı React DOM gibidir sadece altındaki platformu web değil native mobil platformlarıdır.</blockquote><blockquote># React Native size native taraftaki(ios- android platformları) tüm componentleri ve bu platformlara erişminizi sağlayacak API’leri sağlar.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85fdd351b5c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>