<?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 Muhammed Turabi Sancak on Medium]]></title>
        <description><![CDATA[Stories by Muhammed Turabi Sancak on Medium]]></description>
        <link>https://medium.com/@muhammedturabisancak?source=rss-f13be6b45385------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IXe8WbODs_8LA8O4</url>
            <title>Stories by Muhammed Turabi Sancak on Medium</title>
            <link>https://medium.com/@muhammedturabisancak?source=rss-f13be6b45385------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:26:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammedturabisancak/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 Widget Tree #1 — Widget Nedir? Flutter Ekranı Nasıl Oluşturur?]]></title>
            <link>https://medium.com/@muhammedturabisancak/flutter-widget-tree-1-widget-nedir-flutter-ekran%C4%B1-nas%C4%B1l-olu%C5%9Fturur-5eaac17e1dc5?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eaac17e1dc5</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 12:01:06 GMT</pubDate>
            <atom:updated>2026-06-21T12:01:06.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zr9z0eZzZnwmRt5mq4uHfg.png" /></figure><p>Flutter öğrenmeye başlayan hemen hemen herkes ilk gün şu cümleyi duyar:</p><blockquote>Everything is a Widget.</blockquote><p>İlk bakışta bu cümle oldukça anlaşılır görünür. Sonuçta ekrana yazı yazdırmak için Text, bir buton eklemek için ElevatedButton, sayfa düzeni oluşturmak için ise Column, Row veya Scaffold kullanıyoruz.</p><p>Peki gerçekten her şey bir widget mı?</p><p>Daha da önemlisi, bir Text widget&#39;ı gerçekten ekrana yazı mı çizer?</p><p>İlk başta çoğumuzun cevabı <strong>evet</strong> olur. Çünkü aşağıdaki kodu yazdığımızda ekranda gerçekten “Merhaba Flutter” yazısını görürüz.</p><pre>Text(&quot;Merhaba Flutter&quot;)</pre><p>Ancak Flutter’ın çalışma mantığı düşündüğümüzden biraz farklıdır. Aslında bu satır ekrana hiçbir şey çizmez. Evet, yanlış okumadınız. Text widget&#39;ı tek başına ekrana yazı yazamaz. Bu satır yalnızca Flutter’a şunu söyler:</p><blockquote><em>“Bu noktada ‘Merhaba Flutter’ yazan bir metin olmalı.”</em></blockquote><p>İşte Widget Tree konusunu anlamaya başlamanın ilk adımı tam olarak budur.</p><h3>Flutter’dan Önce UI Nasıl Geliştiriliyordu?</h3><p>Flutter’ın neden widget tabanlı bir mimari kullandığını anlayabilmek için önce geleneksel UI geliştirme yaklaşımına kısa bir göz atalım.</p><p>Android tarafında yıllarca uygulamalar XML dosyaları ve View yapıları kullanılarak geliştirildi.</p><p>Örneğin ekranda bulunan bir yazıyı değiştirmek istediğimizde önce o nesneyi bulur, daha sonra üzerinde işlem yapardık.<br>TextView title = findViewById(R.id.title);<br>title.setText(&quot;Merhaba&quot;);</p><pre>TextView title = findViewById(R.id.title);<br>title.sebtText(&quot;Merhaba&quot;);</pre><p>Burada yaptığımız işlem oldukça basittir. Önce ekrandaki gerçek nesneyi buluyoruz. Ardından o nesnenin metnini değiştiriyoruz. Yani doğrudan ekranda bulunan UI elemanına müdahale ediyoruz. Aynı mantık iOS tarafında da geçerlidir.</p><p>Aynı mantık iOS tarafında da geçerlidir.</p><pre>label.text = &quot;Merhaba&quot;</pre><p>Bu yaklaşımda geliştirici sürekli olarak mevcut UI üzerinde değişiklik yapar. Süreç kabaca şu şekilde ilerler:</p><pre>UI elemanını bul<br>        ↓<br>Özelliğini değiştir<br>        ↓<br>Ekranı güncelle</pre><p>Bu yaklaşım <strong>Imperative UI (Emir Vererek UI Oluşturma)</strong> olarak adlandırılır.</p><p>Çünkü geliştirici bilgisayara adım adım ne yapması gerektiğini söyler.</p><ul><li>Git bu yazıyı bul.</li><li>Metnini değiştir.</li><li>Rengini değiştir.</li><li>Gizle.</li><li>Tekrar göster.</li></ul><p>Yani sürekli olarak mevcut ekran üzerinde işlem yapılır.</p><h3>Flutter Farklı Düşünüyor</h3><p>Flutter ise bu yaklaşımı tamamen değiştirdi. Flutter hiçbir zaman bize şunu söylemez:</p><blockquote><em>Git ekrandaki yazıyı bul ve değiştir.</em></blockquote><p>Bunun yerine çok daha farklı bir soru sorar:</p><blockquote><em>“Ekran şu anda nasıl görünmeli?”</em></blockquote><p>İşte Flutter’ın en önemli tasarım kararlarından biri budur. Flutter’a tek tek hangi nesnenin nasıl değişeceğini söylemeyiz. Onun yerine ekranın son halini tarif ederiz.</p><p>Örneğin:</p><pre>Column(<br>  children: [<br>    Text(&quot;Merhaba&quot;),<br>    ElevatedButton(<br>      onPressed: () {},<br>      child: Text(&quot;Devam Et&quot;),<br>    ),<br>  ],<br>)</pre><p>Bu kod Flutter’a şu talimatı vermez:</p><ul><li>Önce bir yazı oluştur.</li><li>Sonra altına bir buton ekle.</li></ul><p>Bunun yerine sadece şunu söyler:</p><blockquote><em>“Ben ekranın bu şekilde görünmesini istiyorum.”</em></blockquote><p>Nasıl oluşturulacağı, nasıl yerleştirileceği ve nasıl çizileceği ise tamamen Flutter’ın sorumluluğundadır. Bu yaklaşıma <strong>Declarative UI (Tanımlayıcı UI)</strong> adı verilir. Yani geliştirici olarak artık şu soruyla ilgilenmeyiz:</p><blockquote><em>“Ekranı nasıl değiştireceğim?”</em></blockquote><p>Onun yerine şu soruya cevap veririz:</p><blockquote><em>“Ekran şu anda nasıl görünmeli?”</em></blockquote><p>İşte Flutter’ın widget sistemi de tam olarak bu düşüncenin üzerine kurulmuştur.</p><h3>Widget Gerçekte Nedir?</h3><p>Buraya kadar widget’ların ekranı oluşturmak için kullanıldığını gördük.Fakat burada çok önemli bir yanılgı vardır.Çoğu Flutter geliştiricisi widget’ı, ekranda gördüğü gerçek nesne olarak düşünür.</p><p>Örneğin aşağıdaki kodu tekrar ele alalım.</p><pre>Text(&quot;Merhaba Flutter&quot;)</pre><p>Bu kod gerçekten ekrandaki yazının kendisi midir?</p><p>Hayır.</p><p>Bu kod yalnızca Flutter’a verilen bir tariftir. Yani Flutter’a şunu söyler:</p><pre>Burada &quot;Merhaba Flutter&quot; yazan bir metin olmalı.</pre><p>Benzer şekilde aşağıdaki widget’a bakalım.</p><pre>Container(<br>  width: 120,<br>  height: 120,<br>  color: Colors.red,<br>)</pre><p>Bu kod da ekrana doğrudan kırmızı bir kutu çizmez.</p><p>Sadece Flutter’a şu bilgileri verir:</p><ul><li>Genişlik 120 piksel olsun.</li><li>Yükseklik 120 piksel olsun.</li><li>Rengi kırmızı olsun.</li></ul><p>Yani widget aslında yalnızca özellikleri taşıyan bir tanımdır. Flutter bu tanımı alır ve daha sonra ekrana nasıl çizileceğine kendisi karar verir.</p><h3>Widget Neden “Configuration Object” Olarak Tanımlanır?</h3><p>Flutter dokümantasyonunda widget’lar için sık sık şu ifadeyi görürsünüz:</p><blockquote><strong><em>Widgets are immutable configuration objects.</em></strong></blockquote><p>İlk bakışta bu cümle oldukça teknik gelebilir. Aslında anlatmak istediği şey oldukça basittir. Bir widget’ın görevi ekrana bir şey çizmek değildir. Widget’ın görevi Flutter’a <strong>“Nasıl görünmesini istediğimizi”</strong> söylemektir.</p><p>Örneğin aşağıdaki Text widget&#39;ını inceleyelim.</p><pre>Text(<br>  &quot;Merhaba Flutter&quot;,<br>  style: TextStyle(<br>    fontSize: 24,<br>    color: Colors.blue,<br>    fontWeight: FontWeight.bold,<br>  ),<br>)</pre><p>Burada Flutter’a verilen bilgiler şunlardır:</p><ul><li>Yazılacak metin</li><li>Yazı boyutu</li><li>Yazı rengi</li><li>Yazı kalınlığı</li></ul><p>Yani widget yalnızca bir konfigürasyon taşır. Gerçek çizim işlemini yapan yapı widget değildir. Bu yüzden widget’lara <strong>configuration object</strong> denir.</p><h3>Widget Neden Immutable’dır?</h3><p>Flutter dokümantasyonunda widget’lar için sıkça şu ifadeyi görürsünüz:</p><blockquote><strong><em>Widgets are immutable configuration objects.</em></strong></blockquote><p>Buraya kadar widget’ın bir <strong>configuration object</strong> olduğunu öğrendik. Peki neden <strong>immutable (değiştirilemez)</strong> olmak zorunda?</p><p>Bunu küçük bir örnek üzerinden düşünelim. Aşağıdaki widget oluşturulduktan sonra:</p><pre>const Text(&quot;Merhaba Flutter&quot;)</pre><p>onun içerisindeki metni sonradan değiştiremeyiz. Örneğin aşağıdaki gibi bir kullanım Flutter’da mümkün değildir.</p><pre>final text = const Text(&quot;Merhaba Flutter&quot;);<br><br>// Böyle bir kullanım yoktur.<br>text.data = &quot;Merhaba&quot;;</pre><p>Çünkü Flutter’da oluşturulan bir widget’ın özellikleri daha sonradan değiştirilmez. Bunun yerine ihtiyaç duyulan yeni özelliklerle <strong>yeni bir widget oluşturulur. </strong>Örneğin ilk durumda Flutter’a şu tarif verilir:</p><pre>const Text(&quot;Merhaba Flutter&quot;)</pre><p>Daha sonra metin değiştiğinde ise mevcut widget değiştirilmez. Bunun yerine Flutter’a yeni bir tarif gönderilir.</p><pre>const Text(&quot;Merhaba&quot;)</pre><p>İlk bakışta bu yaklaşım verimsiz gibi görünebilir.</p><blockquote><em>“Her değişiklikte yeni widget oluşturuluyorsa Flutter nasıl bu kadar hızlı çalışıyor?”</em></blockquote><p>Aslında bu, Flutter’ın en güçlü tasarım kararlarından biridir. Bu sorunun cevabı ise Widget Tree’nin arkasında çalışan <strong>Element Tree</strong> ve <strong>Render Tree</strong> yapılarında saklıdır. Bu yapıları serimizin ikinci bölümünde detaylı olarak inceleyeceğiz.</p><h3>Widget Tree’ye İlk Bakış</h3><p>Artık widget’ın ne olduğunu biliyoruz.</p><p>Peki uygulamamızdaki onlarca hatta yüzlerce widget Flutter tarafından nasıl organize ediliyor?</p><p>Cevap oldukça basit. Flutter, yazdığımız tüm widget’ları hiyerarşik bir yapı içerisinde tutar. Bu yapıya <strong>Widget Tree</strong> adı verilir.</p><p>Örneğin aşağıdaki ekranı ele alalım.</p><pre>Scaffold(<br>  appBar: AppBar(<br>    title: const Text(&quot;Ana Sayfa&quot;),<br>  ),<br>  body: Center(<br>    child: const Text(&quot;Merhaba Flutter&quot;),<br>  ),<br>)</pre><p>Flutter bu kodu bizim gördüğümüz gibi satır satır değil, bir ağaç yapısı olarak değerlendirir.</p><pre>Scaffold<br>├── AppBar<br>│   └── Text<br>└── Center<br>    └── Text</pre><p>Aslında Flutter’da yazdığımız her ekran, birbirinin içine yerleşmiş widget’lardan oluşan büyük bir ağaçtır. İşte bu yapıya <strong>Widget Tree</strong> denir. Bu yazıda yalnızca Widget Tree’nin ne olduğunu ve neden var olduğunu öğrendik.Ancak Flutter’ın asıl sihri burada başlamıyor.</p><p>Asıl ilginç kısım, Flutter’ın bu Widget Tree’yi nasıl yönettiği ve her değişiklikte neden tüm ekranı yeniden çizmeden bu kadar yüksek performans sunabildiğidir.</p><h3>Sonuç</h3><p>Bu yazıda Flutter’ın en temel kavramlarından biri olan <strong>Widget</strong> kavramını incelemeye çalıştık.</p><p>Özetlemek gerekirse;</p><ul><li>Flutter, <strong>Imperative UI</strong> yerine <strong>Declarative UI</strong> yaklaşımını benimser.</li><li>Widget, ekranda gördüğümüz gerçek nesne değildir.</li><li>Widget, kullanıcı arayüzünün nasıl görünmesi gerektiğini tarif eden bir <strong>configuration object</strong>’tir.</li><li>Widget’lar <strong>immutable</strong> yapıdadır ve değiştirilmek yerine yeniden oluşturulurlar.</li><li>Flutter’da yazdığımız her ekran, birbirinin içine yerleşmiş widget’lardan oluşan bir <strong>Widget Tree</strong> olarak temsil edilir.</li></ul><p>Ancak bu noktada hâlâ cevaplanması gereken önemli bir soru var.</p><blockquote><strong><em>Flutter her değişiklikte yeni widget’lar oluşturuyorsa bunu performans kaybı yaşamadan nasıl başarabiliyor?</em></strong></blockquote><p>İşte bu sorunun cevabı, Widget Tree’nin arkasında çalışan <strong>Element Tree</strong> ve <strong>Render Tree</strong> yapılarında gizli. Serinin bir sonraki bölümünde, Flutter’ın görünmeyen tarafına geçecek ve Widget Tree’nin arkasında neler olduğunu birlikte inceleyeceğiz.</p><h3>Serinin Devamında</h3><p>Bir sonraki yazıda şu konulara değineceğiz:</p><ul><li>Widget Tree, Element Tree ve Render Tree arasındaki farklar</li><li>Flutter neden üç farklı ağaç yapısı kullanıyor?</li><li>Build süreci nasıl çalışıyor?</li><li>setState() çağrıldığında arka planda neler oluyor?</li><li>Flutter neden her build işleminde yeni widget oluşturmasına rağmen yüksek performans sunabiliyor?</li></ul><h3>Teşekkürler</h3><p>Buraya kadar okuduğunuz için teşekkür ederim. Umarım bu yazı Flutter’ın en temel kavramlarından biri olan <strong>Widget</strong> konusunu daha anlaşılır hale getirmiştir. Eğer yazıyı faydalı bulduysanız, serinin devamını kaçırmamak için beni Medium üzerinden takip edebilirsiniz.</p><p>Ayrıca yazıda yer alan tüm örnek kodları ve bu seri için hazırladığım demo projeleri <a href="https://github.com/muhammedturabisancak">GitHub</a> hesabımda paylaşacağım. İncelemek veya katkıda bulunmak isterseniz beklerim.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eaac17e1dc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oracle SQL 101 — Learning to Look at Data the Right Way]]></title>
            <link>https://medium.com/@muhammedturabisancak/oracle-sql-101-learning-to-look-at-data-the-right-way-c67839c1f1c6?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/c67839c1f1c6</guid>
            <category><![CDATA[oracle-sql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-design]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 12:44:00 GMT</pubDate>
            <atom:updated>2025-12-21T12:44:00.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcAJal67qmFtNM8X_7J01w.png" /></figure><h3>Oracle SQL 101 — Learning to Look at Data the Right Way</h3><p>SQL is often taught as “memorizing commands.” If SELECT, WHERE, GROUP BY… work, it’s considered sufficient.</p><p>But the main thing to gain when learning Oracle SQL is this:</p><p><em>How to look at data and how to query it.</em></p><p>This article is not about “What is SQL?” This article is an introduction to the Oracle SQL way of thinking.</p><h3>What is Oracle SQL, and What Does It Solve?</h3><p><a href="https://www.oracle.com/tr/">Oracle Database</a> is a relational database used for high-volume, critical, and enterprise data.</p><p>With Oracle SQL:</p><ul><li>You analyze millions of lines of data</li><li>You generate reports</li><li>You prepare decision support data</li></ul><p>But first you need to adopt this mindset:</p><p><em>SQL = It’s not about selecting data, it’s about filtering data in the right context.</em></p><h3>1. Starting with SELECT * (The Biggest Starting Mistake)</h3><p><strong>90% of beginners start with SQL like this:</strong></p><pre>SELECT *<br>FROM employees;</pre><p>This query:</p><ul><li>works</li><li>returns results</li><li>but is not educational</li></ul><p>Because:</p><ul><li>You don’t know which column you need</li><li>You don’t recognize the data</li><li>You’re pulling everything unnecessary</li></ul><p><strong>The right habit:</strong></p><pre>SELECT<br>    employee_id,<br>    first_name,<br>    last_name,<br>    hire_date<br>FROM employees;</pre><p>What you’re doing here:</p><ul><li>conscious choice</li><li>data recognition</li><li>query based on need</li></ul><p><em>Being good at Oracle SQL starts with selecting few but correct columns.</em></p><h3>2. WHERE: The Most Critical Part of SQL</h3><p>SQL written without WHERE is generally meaningless.</p><p><strong>Simple example:</strong></p><pre>SELECT employee_id, salary<br>FROM employees;</pre><p>This is just “viewing the data.” The real SQL starts here:</p><pre>SELECT employee_id, salary<br>FROM employees<br>WHERE salary &gt; 10000;</pre><p>But in Oracle SQL, WHERE is not just a filter, it is a logical expression.</p><p><strong>Multiple conditions:</strong></p><pre>SELECT employee_id, salary, department_id<br>FROM employees<br>WHERE salary &gt; 10000<br>  AND department_id = 50;</pre><p>Burada artık şu soruyu cevaplıyorsun:</p><p><em>“50 numaralı departmanda, maaşı 10.000’den yüksek olanlar kimler?”</em></p><h3>3. Text Comparisons and LIKE Logic</h3><p>String comparisons are very common in Oracle.</p><pre>SELECT first_name, last_name<br>FROM employees<br>WHERE last_name = &#39;KING&#39;;</pre><p>But most of the time, an exact match isn’t enough:</p><pre>SELECT first_name, last_name<br>FROM employees<br>WHERE last_name LIKE &#39;K%&#39;;</pre><p>What does this mean?</p><ul><li>Last names starting with K</li></ul><p><strong>Multiple characters:</strong></p><pre>WHERE last_name LIKE &#39;%SON&#39;;</pre><p>Important detail:</p><ul><li>String comparisons in Oracle can be case-sensitive.</li><li>In real life, it is usually written as follows:</li></ul><pre>WHERE UPPER(last_name) LIKE &#39;K%&#39;;</pre><h3>4. The NULL Truth (The Most Critical Issue in Oracle SQL)</h3><p>The biggest mistake beginners make:</p><pre>WHERE commission_pct = NULL;</pre><p>This query never works (it does not return any results).</p><p><strong>Correct usage in Oracle SQL:</strong></p><pre>WHERE commission_pct IS NULL;</pre><p>NULL check:</p><pre>SELECT employee_id, commission_pct<br>FROM employees<br>WHERE commission_pct IS NOT NULL;</pre><p><em>NULL is not a value.</em></p><p><em>NULL = unknown / absent / not entered</em></p><p>Without understanding NULL in Oracle SQL:</p><ul><li>accurate counting</li><li>accurate summation</li><li>accurate reporting</li><li>cannot be achieved.</li></ul><h3>5. ORDER BY: Making Data Readable</h3><p>SQL results do not have to be returned in order.</p><pre>SELECT employee_id, salary<br>FROM employees;</pre><p>The order of this query may be meaningless.</p><p>Ranking:</p><pre>SELECT employee_id, salary<br>FROM employees<br>ORDER BY salary DESC;</pre><p>Multiple fields:</p><pre>ORDER BY department_id, salary DESC;</pre><p>Here:</p><ul><li>first the department</li><li>then the salary is listed</li></ul><p>In Oracle SQL, readable output starts with the correct order.</p><h3>6. DISTINCT: Reading Data Cleanly</h3><p>If the same values are repeated:</p><pre>SELECT department_id<br>FROM employees;</pre><p>To singularize:</p><pre>SELECT DISTINCT department_id<br>FROM employees;</pre><p>But be careful:</p><pre>SELECT DISTINCT department_id, job_id<br>FROM employees;</pre><p>Here, DISTINCT:</p><ul><li>is not applied to a single column</li><li>but to the entire row</li></ul><p>This distinction is very critical for beginners.</p><h3>7. 3 Essential Questions to Ask When Writing SQL</h3><p>Even at the Oracle SQL 101 level, you should ask yourself the following questions:</p><p>1. What data do I need?</p><p>2. Under what conditions should I select this data?</p><p>3. Would this output be meaningful if presented to someone?</p><p>If these questions do not exist:</p><ul><li>SQL works</li><li>but does not produce values</li></ul><h4>Mini Exercise — Oracle SQL 101 (Fundamental Reinforcement)</h4><p>In this exercise, we will write queries using Oracle Database logic on a human resources table.</p><figure><img alt="Table = Oracle_101" src="https://cdn-images-1.medium.com/max/965/1*4yVeZjWSZeu8QpEC6TjpqA.png" /></figure><p><strong>QUESTION:</strong></p><p>Write an SQL query that lists employees who meet the following conditions simultaneously:</p><p>Requirements:</p><p>1.Salary must be greater than 7000</p><p>2.Department must be 10 or 50</p><p>3.Include those with a commission of NULL</p><p>4.The output will only include the following columns:</p><ul><li>first_name</li><li>last_name</li><li>salary</li><li>department_id</li></ul><p>5.Results:</p><ul><li>First sorted by department (ascending)</li><li>Then sorted by salary (descending)</li></ul><p><strong>SOLUTION — Oracle SQL Query</strong></p><pre>SELECT<br>    first_name,<br>    last_name,<br>    salary,<br>    department_id<br>FROM oracle_101<br>WHERE salary &gt; 7000<br>  AND (department_id = 10 OR department_id = 50)<br>  AND commission_pct IS NULL<br>ORDER BY department_id ASC, salary DESC;</pre><p>Line by Line Explanation</p><pre>SELECT first_name, last_name, salary, department_id</pre><ul><li>-&gt; We only select the desired columns</li></ul><pre>FROM oracle_101</pre><ul><li>-&gt; The table from which we obtained the data</li></ul><pre>WHERE salary &gt; 7000<br>  AND (department_id = 10 OR department_id = 50)<br>  AND commission_pct IS NULL</pre><ul><li>&gt; Salary filter</li><li>&gt; The OR condition is correctly connected with parentheses (without parentheses, the logic would be broken)</li><li>&gt; NULL check (= NULL would be incorrect)</li></ul><pre>ORDER BY department_id ASC, salary DESC;</pre><ul><li>&gt; First the department</li><li>&gt; Then those with higher salaries within the same department</li></ul><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*Cr37ZCQeERu1gtyeE3V2yw.png" /></figure><h4>in Conclusion</h4><p>At the core of working with data at an enterprise level lies not only storing the data, but also being able to query and interpret it correctly. The most common mistake made when learning SQL is to approach the language solely at the syntax level and ignore the context of the data.</p><p>At this point, Oracle Database is not just a database system; it is a platform that fosters good data reading habits and forces developers to take ownership of the results of their queries. The true power of Oracle SQL comes from consciously and consistently combining the basic structures (SELECT, WHERE, NULL checks, sorting, and deduping).</p><p>In this article, we aimed to establish a solid foundation within the scope of Oracle SQL 101. In the next article, Oracle SQL 201, we will take Oracle SQL usage to an advanced level by further deepening the filtering logic through more realistic scenarios.</p><h3>Stay Connected</h3><p>If you found this article useful, you can follow my Medium profile to stay informed about future publications related to MicroStrategy, data analytics, and BI culture.</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c67839c1f1c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MicroStrategy: Not Just a Dashboard, a Strategy Tool — 2]]></title>
            <link>https://medium.com/@muhammedturabisancak/microstrategy-not-just-a-dashboard-a-strategy-tool-2-0c6b2436428a?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c6b2436428a</guid>
            <category><![CDATA[microstrategy]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 07:41:10 GMT</pubDate>
            <atom:updated>2025-11-30T07:41:10.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*vH8BT9L502pqauaQ.jpg" /></figure><h3>MicroStrategy: Not Just a Dashboard, a Strategy Tool — 2</h3><p><strong>Metadata Logic, Object Architecture, Intelligent Cube, Cache and Real Corporate Scenarios</strong></p><p>In the previous section, I explained MicroStrategy’s basic architecture, data modelling structure, and corporate usage advantages.</p><p>In this section, I want to take a closer look at MicroStrategy’s strongest areas. In particular, I will discuss in detail how the metadata engine, object hierarchy, Intelligent Cube, cache mechanism, and performance optimisation work in real life.</p><p>This article is intended as a guide for those who wish to understand MicroStrategy not superficially, but how it truly operates behind the scenes.</p><h3>1. How does the MicroStrategy Metadata Engine work?</h3><p>One of MicroStrategy’s most important structures is the metadata layer.</p><p>This is because all projects, objects, relationships and security rules are stored here.</p><h4>What does metadata provide?</h4><ul><li>Managing the entire structure from a single centre</li><li>An automatic reflection of a change I make across hundreds of reports</li><li>Standardisation of developer–analyst coordination</li><li>A common logic across projects</li></ul><h4>What is stored in metadata?</h4><ul><li>bles and columns</li><li>Attributes</li><li>Facts</li><li>Metrics</li><li>Prompts</li><li>Security roles</li><li>Dashboard templates</li><li>Intelligent Cube definitions</li><li>Join rules and relationships</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-my1mnAA5K1AIEhi.png" /></figure><h3>2. MicroStrategy Object Architecture</h3><p>Everything in MicroStrategy progresses in layers.</p><p>Thanks to this structure, any changes made are directly reflected down to the application layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eVho-gK4LyXFvdVx.png" /></figure><h4>2.1. Schema Objects (Model Layer)</h4><p>In this layer, I am interpreting the database tables.</p><ul><li>Attributes</li><li>Facts</li><li>Hierarchies</li><li>Transformations</li></ul><p>These objects form the basis for all other objects.</p><h4>2.2. Application Objects (Business Logic Layer)</h4><p>I am establishing the business logic in this layer.</p><ul><li>Metrics</li><li>Filters</li><li>Prompts</li><li>Custom Groups</li><li>Templates</li></ul><h4>2.3. Reports &amp; Documents (Presentation Layer)</h4><p>The dashboards seen by the end user are located here:</p><ul><li>Grid Reports</li><li>Graph Reports</li><li>Interactive Documents</li><li>Dossier (modern page-based format)</li></ul><p>These three layers are independent of each other but also work completely in sync.</p><p>Even a single change I make to an attribute can automatically reflect across hundreds of dashboards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*8AcSD9ycWYiCOF2h.gif" /></figure><h3>3. Intelligent Cube Logic</h3><p>Intelligent Cube is one of MicroStrategy’s most powerful features, offering in-memory analytics.</p><p>What he did was very simple, but its impact was huge:</p><ul><li>I am running SQL once</li><li>Data is being loaded into memory</li><li>Users perform all interactions using this preloaded data</li></ul><p><strong>Advantages it offers:</strong></p><ul><li>Millisecond-level turnaround</li><li>Reducing the heavy reporting load</li><li>Stable performance in multi-user environments</li><li>Speed in slice–dice–drill operations</li></ul><p><strong>Where is it used?</strong></p><ul><li>In datasets exceeding millions of rows</li><li>In management dashboards</li><li>In daily operational reports</li><li>On frequently used screens</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/0*f4l9y7q9GESVJVLU.jpg" /></figure><h3>4. MicroStrategy Cache Structure</h3><p>Cache is one of the most critical components of MicroStrategy performance.</p><p>There are three types of cache in MicroStrategy:</p><h4>4.1. Report Cache</h4><p>Stores the results of the report’s execution.</p><h4>4.2. Element Cache</h4><p>Stores attribute elements such as City and Product.</p><h4>4.3. Object Cache</h4><p>Enables metadata objects to load quickly.</p><p><strong>Result:</strong></p><p>A report may take 10 seconds to run the first time, but only 0.3 seconds on the second run.</p><h3>5. Performance Optimisation</h3><p>I touched upon this in the first section, but I would like to delve deeper here.</p><p>Performance is shaped by three main headings:</p><h4>5.1. Data Model Optimisation</h4><ul><li>Establishing correct attribute–fact relationships</li><li>Simplifying join rules</li><li>Paying attention to lookup table design</li></ul><h4>5.2. Cache &amp; Intelligent Cube Strategies</h4><ul><li>Frequently used reports to cube</li><li>Less frequently changed reports to cache</li><li>Incremental fetch for intensive queries</li></ul><h4>5.3. Intelligence Server Settings</h4><ul><li>Governance settings</li><li>Thread management</li><li>Memory management</li><li>Connection pooling</li></ul><h3>In conclusion</h3><p>The most critical aspect of performing data analytics at an enterprise scale is not merely storing the data; it is managing this data with the right architecture, a consistent model, and a well-structured metadata strategy.</p><p>From this perspective, MicroStrategy is not merely a visualisation tool; with its metadata-centric structure, object hierarchy, Intelligent Cube architecture, cache mechanism, and performance optimisations, it is a fully-fledged enterprise Business Intelligence platform.</p><p>The common thread among all the components discussed in this section is this:MicroStrategy does not merely analyse data; it offers an end-to-end approach in terms of data consistency, security, performance, and governance.The platform’s true power is particularly evident in structures with large user bases, complex data models, and high-performance reporting requirements.</p><p>Looking at its pros and cons together, I can say that MicroStrategy is an extremely powerful and sustainable solution for organisations with large data infrastructures.It may seem complex at first for small-scale projects; however, once you understand its metadata-based architecture, it is very clear that it offers a stable, secure, and scalable structure in the long term.</p><h3>Stay Connected</h3><p>If you found this article useful, you can follow my Medium profile to stay informed about future publications related to MicroStrategy, data analytics, and BI culture.</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c6b2436428a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MicroStrategy: Not Just a Dashboard, a Strategy Tool]]></title>
            <link>https://medium.com/@muhammedturabisancak/microstrategy-not-just-a-dashboard-a-strategy-tool-815d1d02a7ad?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/815d1d02a7ad</guid>
            <category><![CDATA[microstrategy-developer]]></category>
            <category><![CDATA[microstrategy]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 08:18:13 GMT</pubDate>
            <atom:updated>2025-11-09T08:18:13.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*5y2sAai36QY2TdOo.jpg" /></figure><h3>1.MicroStrategy’s Basic Definition</h3><p>MicroStrategy is a metadata-driven decision support platform that delivers enterprise-scale Business Intelligence (BI) and data analytics solutions.</p><p>It is not merely a tool for creating graphics, but an end-to-end system that transforms data from its source into meaningful insights.</p><p>The difference from traditional BI tools is that MicroStrategy not only visualises the data layer, but also <strong>manages data modelling</strong>, <strong>security</strong>, <strong>performance</strong> and <strong>user interaction</strong> on a single platform.</p><p>In short:</p><p><em>MicroStrategy is an enterprise analytics platform that enables you to build the strategy behind the data.</em></p><h3>2.Why use MicroStrategy and its advantages?</h3><h4>2.1.Corporate Scale and Reliability</h4><p>MicroStrategy is designed for large corporate organisations with big data infrastructures, not for small start-ups.<br>It can analyse tables containing millions of rows in seconds and optimises server load with cache management.</p><ul><li>Caching Engine: Stores the results of previously executed queries.</li><li>Incremental Fetch: Dashboards only re-fetch changed data, which significantly improves performance.</li><li>Load Balancing &amp; Cluster Architecture: Ensures load distribution in multi-user environments. (For example, when a sales report is first run, it takes 12 seconds, but after the cache is enabled, it returns results in 0.7 seconds on the second run.)</li></ul><h4>2.2.Broad Compatibility with Data Sources</h4><p>MicroStrategy can work with dozens of different data sources:</p><ul><li>Oracle Database</li><li>Microsoft SQL Server</li><li>Snowflake</li><li>PostgreSQL</li><li>SAP Hana</li><li>Excel, CSV, Google BigQuery, REST APIs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f-u0Ut9jF4UA_9M_.png" /></figure><p>It offers Direct SQL Execution or In-memory Cube options for each source.<br>This flexibility enables the system to be used for both ‘real-time dashboards’ and ‘snapshot analysis’.</p><h4>2.3.Data Modelling Capability</h4><p>MicroStrategy’s operating logic is based on a layered object structure (object-oriented architecture).<br>This structure manages the entire process, from raw data to the end-user dashboard, with a structured hierarchy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*sDLTfpY1dJ-t7l7r.gif" /></figure><p><strong>Schema Objects:</strong></p><p>This is the layer where raw tables in the database are made meaningful.<br>Here, Attributes, Facts, Hierarchies and Transformations are defined.<br>For example, City is an attribute, while Sales_Amount is a fact.<br>These objects form the backbone of MicroStrategy’s data model.</p><p><strong>Application Objects</strong></p><p>In this layer, business layer components such as Metrics, Filters, Prompts, and Templates are created using schema objects.<br>This allows analysts to define ‘which data to display and how to display it’.</p><p><strong><em>For example, a metric:</em></strong></p><pre>Revenue Growth = (Current_Year_Sales - Previous_Year_Sales) / Previous_Year_Sales</pre><p><strong>Reports and Documents</strong></p><p>The final stage consists of the dashboards presented to the user.This layer visualises all sub-objects together in the form of<strong> Grid Reports</strong>, <strong>Graph Reports</strong> or <strong>Interactive Documents</strong>.</p><p><em>MicroStrategy’s strength lies in its ability to run these three layers independently yet synchronously.This means that a single change in the data model can be automatically reflected across hundreds of dashboards.</em></p><h4>2.4.Security and Authorisation</h4><p>The most important requirement for corporate use is role-based access control.MicroStrategy integrates with LDAP and Active Directory to determine which dashboard and which level of data users can access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/0*JvY41TgY0_LxsQoZ.png" /></figure><ul><li>Object-Level Security: Which reports can be accessed?</li><li>Row-Level Security: Which rows can be viewed?</li><li>Column-Level Security: Which columns will be visible to the user?</li></ul><p><em>For example, a regional manager can only see the sales data for their own region, while the general manager can see the total for all regions.</em></p><h4>2.5.Rich Visualisation and Dashboard Features</h4><p>MicroStrategy’s Visualisation Layer is designed not only to create graphics, but also to provide an interactive analysis environment.</p><ul><li><strong>Drill-down:</strong> Moving from a higher level to a more detailed level (e.g. Year → Month → Day).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*15c0fRhdqXTTbD9N" /></figure><ul><li><strong>Prompt: </strong>An interactive tool that enables the user to enter a data filter.</li><li><strong>Dynamic Text:</strong> Dynamically changes the dashboard content based on the selected data.</li><li><strong>Document and Dossier:</strong> Presents reports in a page-based or modern ‘storyboard’ structure.</li></ul><p>Example:</p><p><em>When a user selects ‘Region = Marmara’ on a sales dashboard, all other graphs are redrawn based solely on the Marmara region.<br>All these operations are performed in the background using real-time SQL generation.</em></p><h4>2.6.Analytical Functions and Advanced Calculations</h4><p>MicroStrategy supports not only basic operations such as summing and averaging, but also advanced analytical functions:</p><ul><li>Moving Average</li><li>Rank, Percentile</li><li>Running Total</li><li>Conditional Metrics (e.g., ‘mark if sales increase exceeds 10%’)</li><li>Level Metrics (e.g., calculating ‘total by region’ instead of ‘average by city’)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/0*onGIPAVy5yAtp22M" /></figure><p>These hide the complexity of SQL and bring analytics to the level of business logic.</p><h4>2.7.Performance Optimisation</h4><p>MicroStrategy performance is managed at three levels:</p><ul><li>Data model (index and join optimisation)</li><li>Cache (storage of report results)</li><li>Intelligence Server settings (query threading, connection pooling, in-memory cube)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/0*3v2lkQW-unVHQHd4.png" /></figure><p>Thanks to this combination of optimisations, even queries involving hundreds of thousands of lines are returned to the user within seconds.</p><h3>3.Disadvantages of MicroStrategy</h3><h4>3.1.Learning Curve Difficulty</h4><p>MicroStrategy has a robust architecture, so it may take some time to learn initially.Even creating a simple dashboard requires understanding attribute–metric relationships, dataset structure, and the metadata layer.For a beginner, concepts such as schema objects, metrics, transformations, and intelligent cubes may seem complex at first.</p><p><em>I’ve been working with it for a year and there’s still so much I don’t know :)</em></p><p>MicroStrategy does not work on the principle of ‘opening it up and drawing graphs with a few clicks’; you must first understand the model.<br>Although this provides an advantage in the long term, it requires a ‘learning process’ in the short term.</p><h4>3.2.It may appear complex to basic users.</h4><p>MicroStrategy’s interface is more technical and information-dense than tools such as Power BI or Tableau.Menus, report objects and prompts may seem complex, particularly for end users without a technical background.</p><ul><li>The dashboard editor offers numerous options (e.g. metric-level, threshold, selectors).</li><li>Even for simple reports, it may be necessary to understand the metadata hierarchy.</li></ul><p>For this reason, large organisations generally prefer a usage model divided into ‘developer–analyst–observer’ roles.</p><h4>3.3.More Classic Visualisation Compared to Competitor</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/0*-jp9hIQbRFkaif_p.png" /></figure><p>MicroStrategy’s strength lies in its data model, not the modernity of its visualisation.Competitors such as Power BI, Tableau, or Looker Studio offer more vibrant, modern UI/UX components and animated graphics.</p><p>MicroStrategy’s visuals are functional but remain somewhat ‘corporate and classic’ in terms of design.Therefore, designers who want to create aesthetically focused dashboards may sometimes feel constrained.</p><p><em>MicroStrategy appears minimalist but is profound in its engineering; it prioritises data accuracy over visual extravagance.</em></p><h4>3.4. Server and Infrastructure Management Requires Technical Knowledge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/0*ATonLEt5RPBOXwVm.png" /></figure><p>MicroStrategy is an enterprise server platform rather than a desktop tool.<br>This naturally requires advanced technical knowledge in areas such as deployment, security configuration, and cache management.</p><ul><li>Steps such as Intelligence Server installations, repository connections, port settings, and cluster configurations require expertise.</li><li>For this reason, large organisations typically have a BI admin team.</li></ul><p><em>Therefore, MicroStrategy is not a ‘self-service BI’ tool; it is an enterprise solution that can scale with the right configuration.</em></p><h4>3.5.Can be overly corporate in small projects</h4><p>MicroStrategy is a platform designed to serve thousands of users.Therefore, it may be overly complex or heavy for small-scale, simple data analysis projects.</p><ul><li>Processes such as server setup, metadata repository, and security configuration can create unnecessary costs for small teams.</li><li>If a team of 3–4 people requires monthly reports, lightweight solutions such as Power BI or Looker may be more practical.</li></ul><h3>4.MicroStrategy vs Other BI Tools (Power BI, Tableau, Qlik)</h3><p>There are numerous BI (Business Intelligence) tools in the world of data analytics.The three most commonly compared are generally MicroStrategy, Power BI and Tableau.Although each has a robust ecosystem, their target user base and architectural approaches are quite different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/0*pabF4hQHkxMA2Y7y.jpg" /></figure><h4>MicroStrategy:</h4><p><strong>Data Model:</strong> Metadata-based, reusable, multi-layered structure (schema + application + semantic layer).</p><ul><li><strong>Performance: </strong>High speed even with large user bases, thanks to Intelligent Cubes and caching.</li><li><strong>Security:</strong> Enterprise-grade (LDAP, Row-Level Security, Object-Level Security).</li><li><strong>Visualization: </strong>Classic and stable; prioritizes data accuracy over design.</li><li><strong>Scalability: </strong>Optimized for millions of rows and hundreds of concurrent users.</li><li><strong>User Profile: </strong>Enterprise BI teams focused on governance and security.</li><li><strong>Maintenance &amp; Administration: </strong>Requires metadata repository, server setup, and cache management.</li></ul><h4><strong>Power BI</strong></h4><ul><li><strong>Data Model: </strong>Simple but limited; built with Power Query and DAX formulas.</li><li><strong>Performance: </strong>Can slow down in Direct Query mode; dataset size limitations exist.</li><li><strong>Security: </strong>Basic RLS via Microsoft 365 integration; limited advanced options.</li><li><strong>Visualization: </strong>Modern and user-friendly; easy to build visuals quickly.</li><li><strong>Scalability: </strong>Medium; best for small to mid-sized organizations.</li><li><strong>User Profile: </strong>Data analysts and business users; self-service BI oriented.</li><li><strong>Maintenance &amp; Administration: </strong>Relatively simple; tied to Microsoft 365 infrastructure.</li></ul><h4><strong>Tableau</strong></h4><ul><li><strong>Data Model: </strong>Visualization-focused; lightweight modeling in the background.</li><li><strong>Performance: </strong>Fast with extracts, but may lag with very large datasets.</li><li><strong>Security: </strong>User-based RLS through Tableau Server; moderate level.</li><li><strong>Visualization: </strong>Very flexible, design-oriented, excellent for data storytelling.</li><li><strong>Scalability: </strong>Medium to high; great for visually intensive environments.</li><li><strong>User Profile: </strong>Visualization-focused analysts and UX-driven teams.</li><li><strong>Maintenance &amp; Administration: </strong>Requires Tableau Server or Cloud environment management.</li></ul><h3>In conclusion</h3><p>The most important prerequisite for performing data analytics at an enterprise scale is not merely storing the data, but being able to interpret it using a properly structured strategy.In this sense, MicroStrategy is not just a visualisation tool; it is a comprehensive Business Intelligence platform in terms of data consistency, security, performance, and governance.</p><p>When considering its pros and cons, we can say that MicroStrategy is an extremely powerful solution for organisations working with large data structures that prioritise security and scalability.It may be complex for small-scale projects; however, it is a long-term and sustainable investment for teams seeking to establish an enterprise data culture.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, you can follow my Medium profile to stay informed about future posts on MicroStrategy, data analytics, and BI culture.<br>In my next article, I will explain step by step how MicroStrategy is used in practice — connecting to data sources, creating metrics, designing dashboards, and optimising performance.</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=815d1d02a7ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart — Final vs Const]]></title>
            <link>https://medium.com/@muhammedturabisancak/dart-final-vs-const-425b3fc0ce7f?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/425b3fc0ce7f</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 14:07:40 GMT</pubDate>
            <atom:updated>2025-09-24T14:08:14.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*FFsw_kvBwogXxaFUSKy4LA.png" /></figure><h3>Dart — Final vs Const</h3><p>The Flutter ecosystem is built around the idea of <strong>immutability</strong>. On the screen, every “widget tree” is constantly being rebuilt. In this cycle:</p><ul><li><strong>Reducing errors</strong>: We prevent values from being accidentally changed.</li><li><strong>Readable and predictable code</strong>: We explicitly mark values as fixed, making it clear that “this value won’t change.”</li><li><strong>Performance</strong>: By marking compile-time constants with const, Flutter can reduce widget rebuild costs and reuse the same const instance thanks to <strong>canonicalization</strong>.</li><li><strong>Memory management</strong>: We minimize unnecessary object creation.</li></ul><p>In short, Flutter’s rule can be summarized like this:</p><ul><li>If the value is known at <strong>compile time</strong>, use <em>const</em>.</li><li>If the value is assigned only once but determined at <strong>runtime</strong>, use <em>final</em>.</li></ul><p><strong>Quick examples:</strong></p><pre>// Known at compile time: const<br>const appTitle = &#39;MyApp&#39;;       // compile-time constant<br>const padding = EdgeInsets.all(16);<br><br>// Determined at runtime but never changes afterwards: final<br>final now = DateTime.now();<br>final controller = TextEditingController();</pre><p><strong>In the UI:</strong></p><pre>// Value will never change → const widget<br>const Text(&#39;Hello&#39;); // Won’t rebuild, same instance reused<br><br>// Value comes at runtime but won’t change afterwards → final<br>final title = ModalRoute.of(context)!.settings.name ?? &#39;Home&#39;;</pre><h3>Final</h3><p><em>final</em> represents variables that can be <strong>assigned only once</strong> and cannot be reassigned afterwards.<br>Important: The value doesn’t have to be known at <strong>compile-time</strong>, it can also be determined at <strong>runtime</strong>.</p><h4>Key characteristics</h4><ul><li><strong>Single assignment</strong>: A <em>final</em> variable can only be assigned once. A second assignment will cause a compile-time error.</li><li><strong>Runtime constant</strong>: The value can come from APIs, be generated with <em>DateTime.Now()</em>, or depend on user interaction.</li><li><strong>Reference immutability</strong>: <em>final</em> locks the reference itself. The referenced object may still change (e.g., <em>List.add</em>).</li><li><strong>Late initialization</strong>: With <em>late final</em>, you can assign the value later (e.g., in <em>initState</em>). If you try to read before assignment, you’ll get a <em>LateInitializationError</em>.</li><li><strong>Lazy init</strong>: Top-level or <em>static final</em> variables are initialized only when first used (avoids unnecessary early cost).</li></ul><h4><strong>Where to use it?</strong></h4><ul><li>Objects created only once, like controllers, focus nodes, or animations: TextEditingController, FocusNode, AnimationController, etc.</li><li>Runtime values : DateTime.now(), Platform.isIOS, ModalRoute.of(context), service locations / DI results.</li><li>In class fields for immutability: final ensures values won’t change for the lifetime of an object (value-object design, copyWith patterns).</li></ul><h4>Code examples</h4><p><strong>1) Local variable (runtime-determined but immutable afterwards)</strong></p><pre>void main() {<br>  final now = DateTime.now(); // runtime<br>  print(now);<br><br>  // now = DateTime(2020); // Error: final cannot be reassigned<br>}</pre><p><strong>2) Class fields</strong></p><pre>class User {<br>  final String id;<br>  final DateTime createdAt;<br><br>  User({required this.id, required this.createdAt});<br>}<br><br>final user = User(id: &#39;u1&#39;, createdAt: DateTime.now());<br>// user.id = &#39;u2&#39;; // Error: final field cannot be changed</pre><p><strong>3) late final</strong></p><pre>class _HomeState extends State&lt;Home&gt; {<br>  late final TextEditingController _ctrl;<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    _ctrl = TextEditingController(text: &#39;Hello&#39;); // single assignment<br>  }<br><br>  @override<br>  void dispose() {<br>    _ctrl.dispose();<br>    super.dispose();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return TextField(controller: _ctrl);<br>  }<br>}</pre><p><strong>4) “Reference is fixed, object is mutable” trap</strong></p><pre>final items = &lt;int&gt;[1, 2];<br>items.add(3);         // Content of the object can change<br>// items = [1, 2, 3, 4]; // Error: final reference cannot be reassigned</pre><h4>Performance &amp; readability notes</h4><ul><li><em>final</em> is a declaration of intent: “This value won’t change.” It improves code readability and safety.</li><li>By itself, <em>final</em> does <strong>not</strong> optimize widget rebuilds. For that, you need <em>const</em> (canonicalization).</li><li>Still, <em>final</em> significantly reduces the risk of accidental reassignment errors.</li></ul><h4>Common mistakes</h4><ul><li><strong>Forgetting <em>late final</em> assignment</strong>: If you read before assigning, you’ll get a runtime error.</li><li><strong>Unnecessary <em>var</em> in class fields</strong>: If a field won’t change, declare it as <em>final</em> to make your intent explicit.</li></ul><h3>Const</h3><p><em>const</em> defines compile-time constants — values that are known and fixed at compile time. Objects created with <em>const</em> are canonicalized: the same const expression will share the same instance.</p><h4>Key characteristics</h4><ul><li><strong>Compile-time constant</strong>: The value must be computable at compile time.</li><li><strong>Deep immutability</strong>: The content of a <em>const</em> object (and its nested values) cannot be changed.</li><li><strong>All fields must be <em>final</em></strong>: If a class has a <em>const</em> constructor, all its fields must be declared <em>final</em>.</li></ul><h4>Where to use it?</h4><ul><li><strong>Constant values:</strong> Strings, numbers, booleans, and known compile-time values like Color, EdgeInsets, Duration, etc.</li><li><strong>Constant collections:</strong> Lists, maps, and sets that never change throughout the app.</li><li><strong>Widget tree building blocks:</strong> Examples include const Text(‘…’), const SizedBox(height: 12), const Icon(Icons.home).</li><li><strong>Default parameter values &amp; switch/case labels</strong>: Must be compile-time constants.</li></ul><h4>Code examples</h4><p><strong>1) Simple constants</strong></p><pre>const appName = &#39;MyApp&#39;;<br>const maxRetries = 3;<br>const timeout = Duration(seconds: 5);<br>const brandBlue = Color(0xFF1565C0);</pre><p><strong>2) Constant collections</strong></p><pre>const roles = &lt;String&gt;[&#39;admin&#39;, &#39;editor&#39;, &#39;viewer&#39;];<br>// roles.add(&#39;guest&#39;); // Compile-time error: const collection cannot be modified<br><br>const config = {<br>  &#39;apiBase&#39;: &#39;https://example.com&#39;,<br>  &#39;retry&#39;: 3,<br>};</pre><p><strong>3) Flutter: const widgets</strong></p><pre>Widget build(BuildContext context) {<br>  return const Padding(<br>    padding: EdgeInsets.all(16),<br>    child: Column(<br>      children: [<br>        Text(&#39;Hello&#39;),          // const context: child is also const<br>        SizedBox(height: 12),<br>        Icon(Icons.star),<br>      ],<br>    ),<br>  );<br>}</pre><p><strong>4) const constructor in your own class</strong></p><pre>class PriceTag extends StatelessWidget {<br>  final String text;<br>  final EdgeInsets padding;<br><br>  const PriceTag({super.key, required this.text, this.padding = const EdgeInsets.all(8)});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Padding(<br>      padding: padding,<br>      child: Text(text),<br>    );<br>  }<br>}<br><br>// Usage:<br>const PriceTag(text: &#39;Free&#39;); // compile-time constant</pre><p><strong>When </strong><strong>const cannot be used</strong></p><pre>// const now = DateTime.now(); // Error: runtime value<br>// const ctrl = TextEditingController(); // Error: no const constructor</pre><h4>Common mistakes</h4><ul><li>Trying to make runtime values <em>const</em> (e.g., <em>DateTime.now(), Random() </em>→ Use <em>final</em> instead.</li><li>Creating a class without a <em>const</em> constructor → Cannot use it in <em>const</em> expressions.</li><li>Having non-final fields in a <em>const</em> constructor class → All fields must be <em>final</em>.</li><li>Using unnecessary new or var when <em>const</em> could be used.</li></ul><h3>Differences between final and const</h3><p>In Flutter/Dart, the core distinction is:</p><ul><li><em>const</em> = compile-time constant</li><li><em>final</em> = runtime constant</li></ul><p>Both can only be assigned once, but they differ in <strong>when</strong> and <strong>how deeply</strong> they are fixed.</p><h4>When are they constant?</h4><ul><li><strong>final</strong>: For values that are only known at runtime but won’t change afterward. Examples: DateTime.now(), API responses, TextEditingController.</li><li><strong>const</strong>: For values that are guaranteed to be known at compile time. Examples: const Duration(seconds: 5), const EdgeInsets.all(16), const Text(‘Hello’).</li></ul><pre>final now = DateTime.now();        // runtime constant<br>const timeout = Duration(seconds: 5); // compile-time constant</pre><h4>Depth of immutability</h4><ul><li><strong>final</strong>: Freezes the reference itself, but the object it points to can still change (mutable).</li><li><strong>const</strong>: Provides deep immutability — neither the reference nor the content can change.</li></ul><pre>final list = &lt;int&gt;[1, 2];<br>list.add(3);      // content is mutable<br>// list = [1,2,3]; // cannot reassign reference<br><br>const fixed = &lt;int&gt;[1, 2];<br>// fixed.add(3);   // content is immutable</pre><h4>Quick decision guide</h4><ul><li>If it’s known at compile time → use <strong>const</strong></li><li>If it’s assigned once but known at runtime → use<strong> final</strong></li><li>If all fields in a class should never change → mark them <strong>final</strong> (and if you want a const constructor, all fields must be <strong>final</strong>)</li><li>Collections: Entirely fixed → <strong>const […]</strong></li><li>Runtime-created but should remain immutable → <strong>final + List.unmodifiable(…)</strong></li></ul><h3>In conclusion</h3><p>In Dart/Flutter projects, using <strong>final</strong> and <strong>const</strong> correctly makes your code both <strong>more readable</strong> and <strong>more performant</strong>.<br> Remember: If the value is known at <strong>compile time</strong>, use <strong>const</strong>.<br> If it’s determined only once at <strong>runtime</strong>, use <strong>final</strong>.</p><p>Once you understand one, the other naturally falls into place, and you’ll build a more predictable architecture within your widget tree.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, don’t forget to follow me on Medium for more content on Swift, clean coding tips, and practical examples!</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=425b3fc0ce7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart — Null Safety]]></title>
            <link>https://medium.com/@muhammedturabisancak/dart-null-safety-9f2fde62ca50?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f2fde62ca50</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 16:22:49 GMT</pubDate>
            <atom:updated>2025-09-07T16:22:49.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfGHOU9Etns56GtFPGAMGw.png" /></figure><h3><strong>Dart — Null Safety</strong></h3><p>When writing code in Dart, we often encounter a common problem: null values. If a variable unexpectedly becomes null, it causes the application to throw an error at runtime. This error is known in the software world as a “null pointer exception” and is often one of the most frustrating problems.</p><p><strong>For example:</strong></p><pre>void main() {<br>  String name <br>  print(name.length); // Compilation error<br>}</pre><p>In the code above, we did not assign any value to the <em>name</em> variable. When we try to get its<em> .length</em> information, the compiler throws an error. To catch these situations during the compilation phase, before the code is even run, Dart introduced the null safety feature with version 2.12.</p><h4><strong>Why is Null Safety Important?</strong></h4><ul><li>More secure code: You see runtime errors while writing code.</li><li>A clearer type system: Saying “string” means this variable can never be null.</li><li>Performance: The compiler can optimize when it knows that the variable always holds a value.</li></ul><p><strong>Simple Example:</strong></p><pre>void main() {<br>  String name = &quot;Turabi&quot;;   // Non-nullable: cannot be null<br>  // name = null;          // Compilation error<br><br>  String? surname = null;  // Nullable: may be null<br>  surname = &quot;Sancak&quot;;      // It has gained value now.<br>}</pre><p>In the example above:</p><ul><li>String name → non-nullable → must always hold a value</li><li>String? surname → nullable → either holds a value or remains null</li></ul><h3>Nullable and Non-nullable Variables</h3><p>The two most important concepts in null safety are nullable and non-nullable.</p><ul><li>Non-nullable variable: Its value can never be null. By default, all variables in Dart are like this.</li><li>Nullable variable: Its value can be null. For this, <strong>?</strong> is added to the end of the type.</li></ul><p><strong>Non-nullable Example:</strong></p><pre>void main() {<br>  String name = &quot;Turabi&quot;; <br>  print(ad.toUpperCase()); //Works: TURABI<br><br>  // name = null; // Error: String cannot be null<br>}</pre><p>Here, the variable name must always carry a value. The compiler does not allow null assignment.</p><p><strong>Nullable Example:</strong></p><pre>void main() {<br>  String? surname = null; // may be null<br>  print(surname);         // null<br><br>  surname = &quot;Sane&quot;;     <br>  print(surname);         // Sane<br>}</pre><p>Since we are using String here, the last name can be either a String or null.</p><h4>Where Do We Use It in Real Life?</h4><ul><li>Optional information: The user may not always enter a last name → String? last name.</li><li>External data sources: Fields from the API may be empty → int? yas.</li><li>Values to be filled in later: Starts as null initially, values will be assigned later.</li></ul><h3>Null Checking Methods</h3><p>If a variable is defined as potentially null (String?), we must be careful when performing operations on it. This is because direct calls can cause runtime errors. Here are the main control methods offered by Dart:</p><h4>1. ?. — Null-aware Access (Secure Access)</h4><p>If a variable is not null, it performs the operation on the right; if it is null, it directly returns null.</p><pre>void main() {<br>  String? name = &quot;Leroy&quot;;<br>  print(name?.toUpperCase()); // LEROY<br><br>  name = null;<br>  print(name?.toUpperCase()); // null<br>}</pre><p><strong>Why do we use it?</strong></p><ul><li>A variable can be null, but it is used only if we want to perform an operation on it when it is not null.</li><li>It does not throw an error when it is null; it simply returns null.</li></ul><p><strong>Advantages:</strong></p><ul><li>It’s safe → the app won’t crash.</li><li>It’s short to read → name?.toUpperCase()</li></ul><p><strong>Disadvantages:</strong></p><ul><li>In the null case, it only returns null; it does not provide an alternative value.</li><li>If you don’t want to see null in the output, that alone won’t be enough.</li></ul><h4>2. ?? — Null Coalescing (Default Value)</h4><p>If the value is null, it uses the value after the ?? operator.</p><pre>void main() {<br>  String? message;<br><br>  print(message ?? &quot;Empty message&quot;); // Empty message<br>  mesaj = &quot;Hi&quot;;<br>  print(message ?? &quot;Empty message&quot;); // Hi<br>}</pre><p>This example demonstrates how Dart’s null safety feature allows us to explicitly manage null values and write safe code using operators like ??.</p><p><strong>Why do we use it?</strong></p><ul><li>If we want to use a default value in case of null.</li><li>It is ideal for assigning a “default” value if no value is received from the user.</li></ul><p><strong>Advantages:</strong></p><ul><li>When it’s null, it puts control entirely in your hands.</li><li>It is easy to read.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>You must always specify a default value.</li><li>Sometimes the default value may be “wrong router”.</li></ul><h4>3. ??= — Null assignment (assigns if null)</h4><p>Only assigns a new value if the variable is null.</p><pre>void main() {<br>  String? city;<br>  city ??= &quot;Liverpool&quot;; <br>  print(city); // Liverpool<br><br>  city??= &quot;Istanbul&quot;; <br>  print(city); // Liverpool(because it was not null, it did not change)<br>}</pre><p>“Only if it is null, assign the initial value.”</p><p><strong>Why do we use it?</strong></p><ul><li>If you want a variable to be assigned a value only if it is null, otherwise leave it as it is.</li><li>It is especially useful for initialization.</li></ul><p><strong>Advantages:</strong></p><ul><li>It performs both control and assignment in a single line.</li><li>Default value assignment scenarios are very short.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>When used too often, it can reduce readability.</li><li>It is always suitable for “initial value assignment,” but not suitable for subsequent updates.</li></ul><h4>4. ! — Null Assertion (Forced Usage)</h4><p>You’re telling the compiler “I’m sure it’s not null.” If you’re wrong, you’ll get an error at runtime.</p><pre>void main() {<br>  String? name = &quot;Teoman&quot;;<br>  print(name!.toUpperCase()); // TEOMAN<br><br>  name = null;<br>  print(name!.toUpperCase()); // Error: Null check operator used on null value<br>}</pre><p><strong><em>Important Warning: Last resort. Try other safe methods first.</em></strong></p><p><strong>Why do we use it?</strong></p><ul><li>The compiler thinks a value could be null, but you say, “I’m sure it’s not null.”</li></ul><p><strong>Advantages:</strong></p><ul><li>You can use it directly without writing unnecessary if or ??.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>If you make a mistake → runtime error → your application crashes.</li><li>It should only be used in scenarios where you are 100% certain.</li></ul><h4>5. Null Check with the if Statement</h4><p>One of the most fundamental methods is the classic if condition. If the variable is not null, the Dart compiler treats the variable as non-nullable within that block. This is called flow analysis.</p><pre>void main() {<br>  String? name;<br><br>  if (name != null) {<br>    // In this block, the name is now accepted as a String (non-nullable).<br>    print(name.toUpperCase());<br>  } else {<br>    print(&quot;The name contains a null value.&quot;);<br>  }<br>}</pre><p>The compiler does not require the ! operator because it detects the null check.</p><p><strong>Why do we use it?</strong></p><ul><li>The most classic and most readable method.</li><li>In more complex scenarios (when multiple operations are to be performed), if is clearer.</li></ul><p><strong>Advantages:</strong></p><ul><li>When the compiler sees if (x != null), it considers x to be non-nullable within that block (flow analysis).</li></ul><p><strong>Disadvantages:</strong></p><ul><li>It may seem too long in very simple situations.</li></ul><h3>late Usage</h3><p>When you declare a variable as non-nullable in Dart, the compiler immediately asks you to provide a value. But in some cases, you have to determine the variable’s value later. This is where the late keyword comes into play.</p><h4>1. What is late?</h4><ul><li>late means “I’m not initializing this variable now, but I will definitely assign a value to it before using it.”</li><li>You promise the compiler: “Yes, it’s empty now, but I’ll definitely fill it later.”</li></ul><h4>2. Error Scenario Without late</h4><pre>void main() {<br>  String token; // Non-nullable<br>  print(token); // Error: The non-nullable local variable &#39;token&#39; must be assigned before it can be used.<br>}</pre><p>The compiler throws an error when it sees that the token variable is used without being assigned a value.</p><h4>3. Solution with late</h4><pre>void main() {<br>  late String token; // It&#39;s empty now, I&#39;ll assign a value later.<br><br>  token = &quot;gs1905&quot;;  // Value assigned<br>  print(token);      // gs1905<br>}</pre><p>This time you won’t get an error because by using late, you promised Dart that you would “definitely assign a value before using it.”</p><h4>4. Error Scenario with late</h4><p>If you don’t keep your word and use the late variable without assigning it:</p><pre>void main() {<br>  late String token;<br>  print(token); // Runtime Error: LateInitializationError<br>}</pre><p>In this case, the application crashes during runtime.</p><h4>5. When is “late” used?</h4><p><strong>Usable:</strong></p><ul><li>Asynchronous operations: For example, fetching a value from an API and then assigning it.</li><li>Widget lifecycle (Flutter): Assigning a controller in initState.</li><li>Dependency injection: In situations where it is guaranteed that the value will be provided later.</li></ul><p><strong>Unusable:</strong></p><ul><li>Where the value is truly optional (you should use String? for this).</li><li>If there is a possibility of being null.</li></ul><h4>6. late vs String? Comparison</h4><pre>// late<br>late String name; <br>// You&#39;re saying: “This variable won&#39;t be null, but I&#39;ll give it a value later.”<br><br>// nullable<br>String? surname; <br>// You&#39;re saying: “This variable can be null, or it can have a value.”</pre><p>Difference:</p><ul><li>late → you’re guaranteeing it won’t be null.</li><li>? → You’re not guaranteeing it, it could be null.</li></ul><h3>In conclusion</h3><p>Null safety is one of Dart’s most powerful features and significantly reduces the error rate in modern application development. By incorporating the possibility of a variable being null into the type system, it provides a safer experience both at compile time and at runtime.</p><p>Knowing the difference between String and String?, using control methods such as ?., ??, ??=, !, and if in the right places makes your code more robust and understandable. Especially in large projects, null safety helps you prevent unexpected crashes.</p><p>Remember: Null safety is actually the answer to this question</p><p>→ “Does this variable always hold a value, or could it be null?”</p><p>When you ask this question correctly and answer it correctly, null safety is not a complex obstacle for you; it will be an indispensable helper for writing safe and clean code.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, don’t forget to follow me on Medium for more content on Swift, clean coding tips, and practical examples!</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f2fde62ca50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UITableView vs UICollectionView]]></title>
            <link>https://medium.com/@muhammedturabisancak/uitableview-vs-uicollectionview-c4c750deab34?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4c750deab34</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 12:31:53 GMT</pubDate>
            <atom:updated>2025-08-28T12:31:53.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*4ZYkKn5xYpSJCbh_YyrK9w.jpeg" /></figure><p>One of the most common requirements when developing mobile applications is the display of data. Sometimes you need to display 10 lines of information to the user on the settings screen, sometimes you need to display hundreds of products in a table in an e-commerce app, and sometimes you need to create an infinitely scrollable chat list in a messaging app. At this point, there are two powerful tools we can use on the iOS side: <strong>UITableView</strong> and <strong>UICollectionView</strong>.</p><p>Although these two components appear to serve the same purpose, they actually address different needs. UITableView is a simple and efficient “list” solution that has stood the test of time, while UICollectionView is a modern structure designed for more flexible, grid-based, and complex layouts.</p><h4>UITableView</h4><p>If your goal is simply to display data line by line, this is the fastest and simplest solution.</p><ul><li>WhatsApp chat lists, iMessage conversations, Telegram groups… They are all actually single-column vertical TableViews.</li><li>Email and To-Do Lists: Gmail inbox, Todoist, Apple Reminders, and other to-do apps.</li><li>Settings Screen: Apple’s Settings app is 100% built on TableView. Sections, rows, headers, and footers.</li></ul><p><em>The important point here is: If the user will be scrolling in a single axis (vertical) and the design isn’t too complex, TableView will be more than sufficient.</em></p><pre>import UIKit<br><br>final class FruitsViewController: UIViewController {<br>    <br>    private let tableView = UITableView()<br>    private let fruits = [&quot;Apple&quot;, &quot;Pear&quot;, &quot;Banana&quot;, &quot;Strawberry&quot;, &quot;Watermelon&quot;]<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        title = &quot;Fruits&quot;<br>        <br>        // Add TableView to the view<br>        view.addSubview(tableView)<br>        tableView.frame = view.bounds<br>        tableView.dataSource = self<br>        tableView.delegate   = self<br>        <br>        // Register default cell type<br>        tableView.register(UITableViewCell.self, forCellReuseIdentifier: &quot;cell&quot;)<br>    }<br>}<br><br>// MARK: - DataSource &amp; Delegate<br>extension FruitsViewController: UITableViewDataSource, UITableViewDelegate {<br>    <br>    // Number of rows in section<br>    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {<br>        fruits.count<br>    }<br>    <br>    // Configure each cell<br>    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {<br>        let fruit = fruits[indexPath.row]<br>        let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;, for: indexPath)<br>        <br>        var config = cell.defaultContentConfiguration()<br>        config.text = fruit<br>        config.secondaryText = &quot;Is this your favorite fruit?&quot;<br>        cell.contentConfiguration = config<br>        return cell<br>    }<br>    <br>    // Handle row selection<br>    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {<br>        print(&quot;\(fruits[indexPath.row]) selected&quot;)<br>        tableView.deselectRow(at: indexPath, animated: true)<br>    }<br>}</pre><p>With this example, you can quickly create a classic “line-by-line list” screen.</p><h4>UICollectionView</h4><p>UICollectionView was introduced by Apple in iOS 6.0 (2012). Until then, we only had UITableView, which was limited to single-column vertical lists. But the mobile app world was changing: grid-based apps like Instagram, multi-column product lists in e-commerce apps, and horizontal swipeable “story” bars were emerging. That’s why UICollectionView was developed to meet these flexible needs.</p><ul><li>With the standard UICollectionViewFlowLayout, you can create both vertical and horizontal lists, as well as grid layouts.</li><li>If you need more, you can write your own layout. This allows you to build anything from Pinterest-style “masonry” layouts to carousel views.</li><li>With iOS 13’s Compositional Layout, it’s now much easier to use multiple different layouts on the same screen (such as a horizontal bar at the top and a grid of products at the bottom).</li><li>Photo/Media Galleries: Instagram profile grid, Apple Photos app.</li><li>E-Commerce Applications: Trendyol, Hepsiburada, Amazon product listings.</li><li>Calendar / Custom Views: Day-by-day calendar screens in grid format.</li></ul><p>The key point here is this: if you want to have different layouts on the screen (for example, both a horizontal scroll bar and a vertical grid), or if you need multi-column views, TableView won’t work → you should use CollectionView.</p><pre>import UIKit<br><br>final class ColorsViewController: UIViewController {<br>    <br>    private var collectionView: UICollectionView!<br>    private let colors: [UIColor] = [.systemRed, .systemBlue, .systemGreen, .systemOrange, .systemPink, .systemTeal]<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        title = &quot;Colors&quot;<br>        <br>        // Define layout<br>        let layout = UICollectionViewFlowLayout()<br>        layout.minimumInteritemSpacing = 10<br>        layout.minimumLineSpacing = 10<br>        let itemWidth = (view.bounds.width - 30) / 2<br>        layout.itemSize = CGSize(width: itemWidth, height: 100)<br>        layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)<br>        <br>        // Create collection view<br>        collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)<br>        collectionView.backgroundColor = .systemBackground<br>        collectionView.dataSource = self<br>        collectionView.delegate   = self<br>        collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: &quot;cell&quot;)<br>        <br>        view.addSubview(collectionView)<br>    }<br>}<br><br>// MARK: - DataSource &amp; Delegate<br>extension ColorsViewController: UICollectionViewDataSource, UICollectionViewDelegate {<br>    <br>    // Number of items in section<br>    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {<br>        colors.count<br>    }<br>    <br>    // Configure each item<br>    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {<br>        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: &quot;cell&quot;, for: indexPath)<br>        cell.contentView.backgroundColor = colors[indexPath.item]<br>        cell.contentView.layer.cornerRadius = 12<br>        return cell<br>    }<br>    <br>    // Handle item selection<br>    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {<br>        print(&quot;Color selected: \(colors[indexPath.item])&quot;)<br>    }<br>}</pre><p>With this example, we have created a two-column grid. Simple screens such as Instagram profile grids are created using this logic.</p><h4>Similarities Between UITableView and UICollectionView</h4><p>At first glance, UITableView and UICollectionView may seem like components from different worlds. One is a single-column list, the other a grid/based flexible structure. But when you get down to the nitty-gritty, you realize that they actually work on very similar principles.</p><p><strong>1. Delegate &amp; DataSource Logic</strong></p><p>There are two critical protocols in both components:</p><ul><li><em>DataSource</em> → How many cells will be displayed, and what data will each cell contain?</li><li><em>Delegate</em> → What did the user click on, what will the cell size be, how will interactions be managed?</li></ul><p>So, if there is a UITableViewDataSource in TableView, there is also a UICollectionViewDataSource in CollectionView. Similarly, delegates also perform similar tasks.</p><p><strong>UITableView</strong></p><pre>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {<br>    fruits.count<br>}</pre><p><strong>UICollectionView</strong></p><pre>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {<br>    colors.count<br>}</pre><p><strong>2. Reusable Cell</strong></p><ul><li>Both reuse cells: dequeueReusableCell.</li><li>This allows you to display thousands of items smoothly and efficiently.</li><li>The same reuseIdentifier logic applies.</li></ul><p><strong>UITableView</strong></p><pre>let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;, for: indexPath)</pre><p><strong>UICollectionView</strong></p><pre>let cell = collectionView.dequeueReusableCell(withReuseIdentifier: &quot;cell&quot;, for: indexPath)</pre><p>Both lines do the same thing: maintain performance by reusing a previously created cell.</p><p><strong>3. Using IndexPath</strong></p><ul><li>Both address cells with IndexPath.</li><li>indexPath.row is used in TableView, while indexPath.item is used in CollectionView.</li><li>So the concept is the same: each cell is represented by a unique indexPath.</li></ul><p><strong>UITableView</strong></p><pre>func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {<br>    print(&quot;Row \(indexPath.row) selected&quot;)<br>}</pre><p><strong>UICollectionView</strong></p><pre>func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {<br>    print(&quot;Item \(indexPath.item) selected&quot;)<br>}</pre><p>Both work the same way: when the user taps, you are given the relevant indexPath.</p><p><strong>4. Self-Sizing (Automatically Resizing Cells):</strong></p><ul><li>Auto Layout allows cells to automatically resize based on their content.</li><li>This feature is supported in both TableView (tableView.rowHeight = UITableView.automaticDimension) and CollectionView (estimatedItemSize).</li></ul><p><strong>5. Additional Views (Headers &amp; Footers)</strong></p><ul><li>There is a section-based header/footer view in TableView.</li><li>CollectionView has more flexible supplementary views (header, footer, badge).</li><li>The logic is the same: “out-of-cell” views to enrich the list.</li></ul><p><strong>6. Pull-to-Refresh Support</strong></p><ul><li>UIRefreshControl can be added to both TableView and CollectionView.</li></ul><p><strong>7. Prefetching</strong></p><ul><li>Starting with iOS 10, both support prefetchDataSource.</li><li>Scrolling becomes smoother with content prepared in advance for long lists.</li></ul><p><strong>8. They are ScrollView-based</strong></p><ul><li>Both UITableView and UICollectionView are actually subclasses of UIScrollView.</li><li>Therefore, they inherit all scroll features such as zooming, contentOffset, and scroll delegate.</li></ul><h4>Differences between UITableView and UICollectionView</h4><p>At first glance, UITableView and UICollectionView may seem like components from completely different worlds. One is a simple single-column list, while the other is a flexible, grid-based structure with multiple columns. However, upon closer inspection, we see that these differences actually reveal which needs they fulfill. Although both structures share the same fundamental principles, there are significant differences in their use cases and the capabilities they offer.</p><p><strong>1. Layout</strong></p><ul><li>UITableView → Only supports a single column and vertical scrolling.</li><li>UICollectionView → Much more flexible: single column, multiple columns (grid), horizontal scrolling, even custom layouts (like Pinterest).</li></ul><p>So TableView is limited, while CollectionView stands out with its flexibility.</p><p><strong>2. Cell Types</strong></p><ul><li>UITableView → Uses the UITableViewCell class.</li><li>UICollectionView → Uses the UICollectionViewCell class.It also supports additional views such as supplementary views (header/footer/badge) and decoration views.</li></ul><p><strong>3. Additional Views</strong></p><ul><li>UITableView → Only simple section headers and footers are available.</li><li>UICollectionView → Much richer: Different supplementary views such as section-based headers/footers, background decorations, and badges can be added.</li></ul><p><strong>4. Delegate &amp; DataSource Differences</strong></p><ul><li>TableView → <em>numberOfRowsInSection</em>, <em>cellForRowAt</em></li><li>CollectionView → <em>numberOfItemsInSection</em>, <em>cellForItemAt</em></li></ul><p><strong>5. Code Differences</strong></p><p><strong>UITableView — Cell creation</strong></p><pre>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {<br>    let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;, for: indexPath)<br>    cell.textLabel?.text = &quot;Row \(indexPath.row)&quot;<br>    return cell<br>}</pre><p><strong>UICollectionView — Cell creation</strong></p><pre>func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {<br>    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: &quot;cell&quot;, for: indexPath)<br>    cell.contentView.backgroundColor = .systemBlue<br>    return cell<br>}</pre><h4>When Should We Use Which One?</h4><p>One of the most critical questions when developing for iOS is: “Should I use UITableView or UICollectionView on this screen?”</p><p>Because both structures solve the listing task, but making the right choice based on the usage scenario saves you time and makes your application more efficient.</p><p><strong>When to Use UITableView</strong></p><p>If you are creating a single-column, vertically scrollable list.</p><ul><li>Content is usually text-based (settings, message list, to-do list).</li><li>If you need to quickly set up a screen (prototypes or simple screens).</li><li>A simple section-based distinction is sufficient.</li></ul><p>Example: WhatsApp chat list, iOS Settings screen.</p><p><strong>When to Use UICollectionView</strong></p><ul><li>If you need a multi-column grid layout.</li><li>If you’re going to make a horizontally scrollable list (story bars, carousel).</li><li>If different layouts are required on the same screen (horizontal bar at the top, grid in the middle, full-width card at the bottom).</li><li>If you’re going to display visually-heavy content (gallery, product catalog).</li><li>If you want a more modern, flexible look.</li></ul><p>Example: Instagram profile grid, Trendyol product list, Apple Photos.</p><h4>In conclusion</h4><p>UITableView and UICollectionView are the two structures iOS developers will use most in their daily work. Which one you choose depends entirely on your screen design, needs, and user experience.</p><p>Remember: Switching from TableView to CollectionView isn’t difficult, because both work on the same basic principles. Once you learn one, you adapt to the other very quickly.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, don’t forget to follow me on Medium for more content on Swift, clean coding tips, and practical examples!</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4c750deab34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classes and Structures in Swift: Which to Use and When]]></title>
            <link>https://medium.com/@muhammedturabisancak/classes-and-structures-in-swift-which-to-use-and-when-41c3b530acab?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c3b530acab</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 09:30:38 GMT</pubDate>
            <atom:updated>2025-08-10T09:33:29.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*TpLK9o_V7EDrW6Bntnz2Iw.png" /></figure><p>At first glance, classes and structures in Swift appear similar: you can add properties to both, write methods, and implement protocols. However, as you delve into the details, you will see that these two structures operate fundamentally differently; the wrong choice can significantly impact your code’s performance and maintenance costs. In this article, we will explore what classes and structures are, their similarities and differences, and when to choose one over the other, using examples.</p><h3>Class :</h3><ul><li>Reference Type</li><li>When you create an object and assign it to another variable, you share the <strong>reference</strong> to the same object.</li><li>Inheritance support; can be derived from another class.</li><li>It is stored in a heap in memory.</li><li>Memory management is performed using ARC (Automatic Reference Counting).</li></ul><p><strong>Example</strong>:</p><pre>class Car {<br>    var brand: String<br>    var speed: Int<br><br>    init(brand: String, speed: Int) {<br>        self.brand = brand<br>        self.speed = speed<br>    }<br><br>    func displayInfo() {<br>        print(&quot;Brand: \(brand), Speed: \(speed) km/h&quot;)<br>    }<br>}<br><br>let car1 = Car(brand: &quot;BMW&quot;, speed: 220)<br>let car2 = car1 // Points to the same object<br>car2.speed = 250<br><br>car1.displayInfo() // Brand: BMW, Speed: 250 km/h</pre><p>Here, <strong>car1</strong> and <strong>car2</strong> are pointing to the <strong>same car</strong>.</p><h3>Struct:</h3><ul><li>Value Type</li><li>If you assign a struct to another variable, a completely <strong>independent</strong> copy is created.</li><li>It does not support inheritance; it only gains abilities through protocols.</li><li>It is usually stored on the stack in memory.</li><li>ARC is not used; it is managed with the copy operation.</li></ul><p><strong>Example:</strong></p><pre>struct Car {<br>    var brand: String<br>    var speed: Int<br><br>    func displayInfo() {<br>        print(&quot;Brand: \(brand), Speed: \(speed) km/h&quot;)<br>    }<br>}<br><br>var car1 = Car(brand: &quot;Audi&quot;, speed: 200)<br>var car2 = car1 // Creates a copy<br>car2.speed = 240<br><br>car1.displayInfo() // Brand: Audi, Speed: 200 km/h<br>car2.displayInfo() // Brand: Audi, Speed: 240 km/h</pre><p>Here, <strong>car1</strong> and <strong>car2</strong> are <strong>two completely different cars</strong>.</p><h3>Similarities between Classes and Structures</h3><p>Classes and structs in Swift share many common features. That’s why they often appear to be the same thing to beginners. However, these similarities are only superficial; the real differences become apparent in the background.</p><p>Here are the basic similarities:</p><h4>1. They can define properties:</h4><p>Both can define properties to store data.</p><pre>struct UserStruct {<br>    var name: String<br>    var age: Int<br>}<br><br>class UserClass {<br>    var name: String<br>    var age: Int<br><br>    init(name: String, age: Int) {<br>        self.name = name<br>        self.age = age<br>    }<br>}</pre><h4>2. Method They Can Write:</h4><p>Both can define methods to access properties or perform operations.</p><pre>struct CalculatorStruct {<br>    func sum(a: Int, b: Int) -&gt; Int {<br>        return a + b<br>    }<br>}<br><br>class CalculatorClass {<br>    func sum(a: Int, b: Int) -&gt; Int {<br>        return a + b<br>    }<br>}</pre><h4>3. They can be started with Initializer:</h4><p>Classes and structs can use initializers to initialize their data.</p><pre>struct PointStruct {<br>    var x: Int<br>    var y: Int<br>}<br><br>class PointClass {<br>    var x: Int<br>    var y: Int<br><br>    init(x: Int, y: Int) {<br>        self.x = x<br>        self.y = y<br>    }<br>}</pre><h4>4. They can implement protocols:</h4><p>Both can enforce the rules defined by the protocol.</p><pre>protocol Drivable {<br>    func drive()<br>}<br><br>struct CarStruct: Drivable {<br>    func drive() {<br>        print(&quot;Driving a struct car&quot;)<br>    }<br>}<br><br>class CarClass: Drivable {<br>    func drive() {<br>        print(&quot;Driving a class car&quot;)<br>    }<br>}</pre><h4>5. New Features Can Be Added with Extensions:</h4><p>You can add new features without changing the existing code.</p><pre>extension String {<br>    func reversedText() -&gt; String {<br>        return String(self.reversed())<br>    }<br>}<br><br>print(&quot;Hello&quot;.reversedText()) // &quot;olleH&quot;</pre><p>Classes and structures appear very similar, with support for properties, methods, initializers, protocols, and extensions. However, this similarity is only superficial. The real differences lie in memory management, copying behavior, and inheritance support. Let us now examine the differences.</p><h3>Class and Struct Differences:</h3><p>Although classes and structures appear similar on the surface, their underlying working mechanisms are very different. These differences directly affect which one to choose in which situation.</p><h4>1. Value Type vs Reference Type:</h4><ul><li>Struct → Value Type: A completely new copy is created during copying.</li><li>Class → Reference Type: During copying, a reference to the same object is made.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GXoMWqljArmbjB0ReNioag.gif" /></figure><p><strong>Example</strong>:</p><pre>struct MyStruct {<br>    var number: Int<br>}<br><br>class MyClass {<br>    var number: Int<br>    init(number: Int) {<br>        self.number = number<br>    }<br>}<br><br>var struct1 = MyStruct(number: 10)<br>var struct2 = struct1<br>struct2.number = 20<br><br>var class1 = MyClass(number: 10)<br>var class2 = class1<br>class2.number = 20<br><br>print(&quot;Struct1:&quot;, struct1.number) // 10<br>print(&quot;Struct2:&quot;, struct2.number) // 20<br><br>print(&quot;Class1:&quot;, class1.number)   // 20<br>print(&quot;Class2:&quot;, class2.number)   // 20</pre><p>When creating independent copies, the class shares the same reference.</p><h4>2. Memory Allocation:</h4><ul><li>Structures are generally stored on the stack → faster access, automatic cleanup.</li><li>Stored on the class heap → more flexible, but managed by ARC.</li></ul><p>Note: Although this difference may not be noticeable in small projects, it significantly affects performance in applications that work with large amounts of data.</p><h4>3. ARC (Automatic Reference Counting):</h4><ul><li>When Class is used, Swift ARC tracks when objects are deleted.</li><li>Struct ARC is not used; copies are kept on the stack and automatically deleted when they go out of scope.</li></ul><h4>4. Inheritance:</h4><ul><li>A class can inherit from another class.</li><li>Struct cannot inherit; it can only implement protocols.</li></ul><pre>class Animal {<br>    func sound() {<br>        print(&quot;Animal sound&quot;)<br>    }<br>}<br><br>class Dog: Animal {<br>    override func sound() {<br>        print(&quot;Bark&quot;)<br>    }<br>}<br><br>let dog = Dog()<br>dog.sound() // Bark</pre><p>Such an inheritance structure is not possible in Struct.</p><h4>5. Mutability:</h4><ul><li>Struct variables are mutable if defined with var, and immutable if defined with let.</li><li>In Class, if there are properties, their values can be changed, even if they are defined with reference let.</li></ul><p><strong>Example</strong>:</p><pre>struct Point {<br>    var x: Int<br>}<br><br>class Location {<br>    var x: Int<br>    init(x: Int) {<br>        self.x = x<br>    }<br>}<br><br>var p1 = Point(x: 5)<br>p1.x = 10 // OK<br><br>let p2 = Point(x: 5)<br>// p2.x = 10 It cannot be changed because it is defined with struct let.<br><br>let loc1 = Location(x: 5)<br>loc1.x = 10 // Even if there is a reference let in Class, the property can be changed.</pre><h3>When to Use Which One</h3><p><strong>Short Rule: </strong>Default: Start with Struct.</p><p><strong>Where should you use struct?</strong></p><ol><li>Simple/medium-scale data models (DTO, ViewModel, Value Object)</li><li>Immutable or easily controllable mutability</li><li>Safe sharing in multithreaded (concurrency) code</li></ol><p><strong>Where should you choose Class?</strong></p><ol><li>Inheritance, if really necessary</li><li>If you are managing shared state</li><li>Life cycle (deinit), resource management</li></ol><h4>Common Mistakes and How to Avoid Them:</h4><ol><li><strong>Start everything with class:</strong></li></ol><ul><li>Side effects, uncertain sharing, and testing difficulties.</li><li><strong>Suggestion</strong>: Start with Struct; if necessary, convert to class.</li></ul><p><strong>2. Uncontrolled large copies in Struct:</strong></p><ul><li>Unnecessary copy costs for very large payloads.</li><li><strong>Suggestion:</strong> Large internal data (e.g., Data, Array) is already Copy-on-Write; perform actual measurements. Use a reference wrapper if necessary.</li></ul><p><strong>3. Retain cycles/leaks in Class:</strong></p><ul><li>Capturing the self powerfully in closures.</li><li><strong>Suggestion</strong>: Learn the [weak self] / [unowned self] patterns.</li></ul><p><strong>4. Expecting mutation in Struct, but keeping it with let:</strong></p><ul><li>Makes the struct immutable.</li><li><strong>Suggestion</strong>: Return immutable data externally; return new copies internally using mutating methods.</li></ul><p><strong>In conclusion</strong></p><p>In Swift, the choice between struct and class can have different consequences in terms of memory management, performance, and data sharing. Therefore, this choice should be considered not only as a matter of style, but also as a technical and architectural decision.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, don’t forget to follow me on Medium for more content on Swift, clean coding tips, and practical examples!</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c3b530acab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Basics: The Real Difference Between let and var Explained with Examples]]></title>
            <link>https://medium.com/icommunity/swift-basics-the-real-difference-between-let-and-var-explained-with-examples-0b08b4e46c20?source=rss-f13be6b45385------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b08b4e46c20</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Muhammed Turabi Sancak]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 12:58:37 GMT</pubDate>
            <atom:updated>2025-08-05T15:59:24.641Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IAKD92BCIZDd7Qd96542JQ.png" /></figure><p>Like most people new to Swift, I initially learned the difference between var and let as “one is a variable, the other is a constant.” However, as I continued to develop, I realized that this difference actually affects the security, readability, and even performance of the code.</p><p>In this article, I want to share what I’ve learned and the points I’ve noticed about using var and let in Swift in a simple way.</p><h4>var and let: What exactly do they do?</h4><p><em>var</em>: Used for definitions whose values may change.</p><pre>var score = 10<br>score += 5</pre><p>The number of operations performed by the user is used for dynamic data such as a counter or location information.</p><p><em>let</em>: For constants that will not change after being defined</p><pre>let pi = 3.14<br>let name = &quot;Turabi&quot;</pre><p>You cannot change the value of a variable defined with let later on. This also prevents it from being accidentally overwritten.</p><h4>When to Use Which One?</h4><p>My approach is as follows:</p><p>“Start with let first. If it really needs to be changed, then use var.”</p><p>This makes the code safer and cleaner. It also helps you avoid unnecessary use of var.</p><p><strong>Preferred situations for using let:</strong></p><ul><li>User information that will not change (ID number, year of birth)</li><li>Data received from the API but not updated within the application</li><li>Content generated by calculations and remaining fixed</li></ul><p><strong>Preferred situations for using var:</strong></p><ul><li>Variable values such as scores, counters, and time</li><li>Text entered by the user, search bar data</li><li>In-app states (e.g., @<a href="http://twitter.com/State">State</a> in SwiftUI)</li></ul><p><strong>A Small Example:</strong></p><pre>let identityNumber = &quot;12345678900&quot;<br>var currentCity = &quot;Erzurum&quot;</pre><p>Here, the ID number is fixed, but the city information may change over time. Even such a simple difference means a lot in terms of application logic.</p><h4>So, is let always really fixed?</h4><p>This part requires some attention. If you are working with a class (i.e., reference type) object, even if you define it with let, the object’s content may change.</p><pre>class Person {<br>    var name: String<br>    init(name: String) { self.name = name }<br>}<br><br>let person = Person(name: &quot;Turabi&quot;)<br>person.name = &quot;Muhammed&quot; // Valid<br>// person = Person(name: &quot;Sancak&quot;) // Error!</pre><p>cThe only constant here is the person’s reference. But the name inside can change.</p><p>If you want both the structure and the content to remain unchanged, you should use struct and let:</p><pre>struct Book {<br>    let title: String<br>}<br><br>let book = Book(title: &quot;1984&quot;)<br>book.title = &quot;The Art of War&quot; // Error</pre><h4>In conclusion</h4><p>Just as it affects how the code is understood, in some cases it can also determine how it works directly.</p><p>Especially in structures such as struct and class, the choice between var and let can produce different results at runtime. Therefore, it should be considered not just a style preference, but also a technical decision.</p><p><strong>Let’s Stay Connected</strong></p><p>If you found this article useful, don’t forget to follow me on Medium for more content on Swift, clean coding tips, and practical examples!</p><p>I also share my code examples, projects, and experimental work on my <a href="https://github.com/muhammedturabisancak">GitHub account </a>— feel free to stop by and say hello!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b08b4e46c20" width="1" height="1" alt=""><hr><p><a href="https://medium.com/icommunity/swift-basics-the-real-difference-between-let-and-var-explained-with-examples-0b08b4e46c20">Swift Basics: The Real Difference Between let and var Explained with Examples</a> was originally published in <a href="https://medium.com/icommunity">iCommunity</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>