<?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 Adnan Yağmur on Medium]]></title>
        <description><![CDATA[Stories by Adnan Yağmur on Medium]]></description>
        <link>https://medium.com/@adnanyagmur?source=rss-559f3ea5c268------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FSdW-vuNOxE3ZFSVhq1WfQ.png</url>
            <title>Stories by Adnan Yağmur on Medium</title>
            <link>https://medium.com/@adnanyagmur?source=rss-559f3ea5c268------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 02:32:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adnanyagmur/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[Frontend React + TypeScript Teknik Mülakat Soru Listesi Ve Detaylı Cevapları]]></title>
            <link>https://adnanyagmur.medium.com/frontend-react-typescript-teknik-m%C3%BClakat-soru-listesi-ve-detayl%C4%B1-cevaplar%C4%B1-86f8405aa323?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/86f8405aa323</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 11:44:57 GMT</pubDate>
            <atom:updated>2026-04-16T11:44:57.348Z</atom:updated>
            <content:encoded><![CDATA[<p>Karşılaştığım sorular üzerine ufak bir derleme. Ara ara güncelleyeceğim. Eksik ya da yanlış bir bilgi için bana feedback verirseniz memnun olurum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-xcrNpoi6HFHSz6vOiEcA.png" /></figure><h3>1- useEffect ne zaman çalışır, dependency array nasıl yönetilir?</h3><p>useEffect, component render edildikten sonra çalışır. Yani React önce DOM’u günceller, sonra effect çalışır.</p><h4>Dependency array yoksa</h4><pre>useEffect(() =&gt; {<br>  console.log(&quot;Çalıştı&quot;);<br>});</pre><p>Her render sonrası çalışır.<br>State değişirse tekrar çalışır.<br>Performans problemi yaratabilir.</p><h4>Boş dependency array varsa</h4><pre>useEffect(() =&gt; {<br>  console.log(&quot;Sadece bir kere&quot;);<br>}, []);</pre><p>Sadece ilk mount’ta çalışır.<br> ComponentDidMount gibi davranır.</p><p>Genelde:</p><ul><li>API çağrısı</li><li>Initial setup</li><li>Event listener ekleme</li></ul><p>için kullanılır.</p><h4>Dependency varsa</h4><pre>useEffect(() =&gt; {<br>  console.log(&quot;user değişti&quot;);<br>}, [user]);</pre><p>user değiştiğinde tekrar çalışır.<br> React referans karşılaştırması yapar (primitive vs reference farkı önemli).</p><p><strong>Dipnot:</strong> React, useEffect, useMemo ve useCallback gibi hook’ların dependency array’inde yer alan değerleri === (strict equality) ile karşılaştırır. Primitive tiplerde (string, number, boolean vb.) bu karşılaştırma doğrudan değer üzerinden yapılır; örneğin count 5’ten 6’ya değişirse effect çalışır, ama 5 olarak kalırsa tekrar çalışmaz. Ancak object, array ve function gibi reference tiplerde karşılaştırma değer içeriğine göre değil, hafızadaki referansa (adresine) göre yapılır. Yani { name: &quot;Adnan&quot; } === { name: &quot;Adnan&quot; } false döner çünkü iki farklı obje iki farklı referanstır. Bu nedenle useEffect(() =&gt; {}, [user]) şeklinde bir kullanımda, her render’da setUser({ name: &quot;Adnan&quot; }) ile yeni bir obje oluşturulursa içerik aynı olsa bile referans değiştiği için React bunu değişiklik kabul eder ve effect tekrar çalışır. Bu durum gereksiz render ve effect tetiklenmelerine yol açabilir; bu yüzden reference tiplerde useMemo, useCallback kullanarak referansı sabitlemek ya da dependency olarak primitive bir alt değeri (örneğin user.name) vermek daha sağlıklı olabilir.</p><p><strong>Ek Dipnot (useMemo vs useCallback — önemli detayla birlikte):</strong> Reference tiplerde gereksiz referans değişimini engellemek için useMemo ve useCallback kullanılır. useMemo, bir <strong>değerin (object, array vb.) referansını sabitlemek</strong> için kullanılır; örneğin const user = useMemo(() =&gt; ({ name: &quot;Adnan&quot; }), []) yazıldığında her render’da yeni bir obje oluşturulmaz ve aynı referans korunur. useCallback ise <strong>fonksiyon referansını sabitlemek</strong> için kullanılır; örneğin const handleClick = useCallback(() =&gt; { console.log(&quot;tıklandı&quot;) }, []) tanımlandığında her render’da yeni bir fonksiyon üretilmez. Ancak burada kritik nokta şudur: useCallback ve useMemo referansı tamamen kilitlemez; yalnızca dependency’leri değişmediği sürece aynı referansı döndürür. Eğer dependency array içindeki bir state veya prop değişirse, React yeni bir obje ya da yeni bir fonksiyon üretir ve referans değişir. Ayrıca dependency’leri eksik yazmak “stale closure” problemine yol açabilir; yani referans sabit kalır ama içerideki state güncel olmaz. Özetle: Sabitlemek istediğin şey bir <strong>değer</strong> ise useMemo, bir <strong>fonksiyon</strong> ise useCallback kullanılır; fakat referansın ne zaman değişeceğini dependency array belirler.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>useEffect render sonrası çalışır. Dependency array, effect’in ne zaman tetikleneceğini belirler. Dependency yoksa her render’da, boş array varsa sadece mount’ta, dependency varsa o değer değiştiğinde çalışır. Dependency yönetiminde stale data ve infinite loop riskine dikkat etmek gerekir.</em></blockquote><h3>2- useMemo ne işe yarar, hangi durumda kullanırsın?</h3><p>useMemo, <strong>hesaplanması maliyetli (expensive) bir değeri memoize etmek</strong> için kullanılır.</p><p>Yani dependency’ler değişmediği sürece hesaplamayı tekrar yapmaz, önceki sonucu döner.</p><p>Amaç: Gereksiz hesaplama ve gereksiz re-render’ı önlemek.</p><pre>const computedValue = useMemo(() =&gt; {<br>  return expensiveCalculation(data);<br>}, [data]);</pre><ul><li>data değişmezse</li><li>expensiveCalculation tekrar çalışmaz</li></ul><h4>Hangi Durumda Kullanılır?</h4><blockquote>1- Expensive Calculation Varsa</blockquote><p>Örneğin büyük liste filtreleme:</p><pre>const filteredList = useMemo(() =&gt; {<br>  return bigList.filter(item =&gt; item.active);<br>}, [bigList]);</pre><p>Eğer bigList 10.000 item ise her render’da filtrelemek pahalıdır.</p><blockquote>2- Referans Stabilitesi Problemi (Array / Object)</blockquote><p>React’te object ve array’ler <strong>referans tiptir</strong>.</p><p>Şu kodu düşün:</p><pre>const columns = [<br>  { title: &quot;Name&quot;, key: &quot;name&quot; }<br>];</pre><p>Component her render olduğunda:</p><ul><li>Bu array yeniden oluşturulur.</li><li>Bellekte yeni bir referans oluşur.</li></ul><p>React şuna bakar:<em>“Bu prop öncekiyle aynı mı?”</em></p><p>Ama shallow comparison yapar (=== ile karşılaştırır).</p><p><strong>Yani:</strong></p><pre>[] === [] // false</pre><p>Her seferinde farklıdır.</p><p><strong>Sonuç Ne Olur?</strong></p><p>Eğer bunu bir child component’e prop olarak verirsen:</p><pre>&lt;Table columns={columns} /&gt;</pre><p>Parent’ta alakasız bir state değişse bile:</p><ul><li>Yeni array oluşur</li><li>Child “columns değişti” sanır</li><li>Gereksiz render olur</li></ul><p>Bu özellikle:</p><ul><li>MUI DataGrid</li><li>Ant Design Table</li><li>Büyük form config’leri</li></ul><p>gibi yapılarda performans sorunu çıkarır.</p><p><strong>useMemo Nasıl Çözer?</strong></p><pre>const columns = useMemo(() =&gt; [<br>  { title: &quot;Name&quot;, key: &quot;name&quot; }<br>], []);</pre><p>Ne oldu şimdi?</p><ul><li>Array sadece ilk render’da oluşturulur</li><li>Sonraki render’larda aynı referans kullanılır</li></ul><p>Artık:</p><pre>columns === columns // true (aynı referans)</pre><p>Child gereksiz render olmaz.</p><blockquote>3- React.memo ile Birlikte Kullanım</blockquote><p>React.memo kullanıyoruz ki: <em>“Eğer prop değişmediyse child tekrar render olmasın.”</em></p><p>Ama bazen <strong>prop değişmemiş gibi görünür</strong>, fakat aslında referansı değişmiştir.</p><p>İşte useMemo burada devreye giriyor.</p><p>Önce Çok Basit Bir Senaryo</p><p>Parent component:</p><pre>function Parent() {<br>  const [count, setCount] = useState(0);<br><br>  const data = [1, 2, 3];<br><br>  return (<br>    &lt;&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Artır&lt;/button&gt;<br>      &lt;Child data={data} /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Child component:</p><pre>const Child = React.memo(({ data }) =&gt; {<br>  console.log(&quot;Child render oldu&quot;);<br>  return &lt;div&gt;{data.length}&lt;/div&gt;;<br>});</pre><h3>Şimdi Soru:</h3><p>Butona bastığında ne değişti?</p><ul><li>Sadece count</li><li>data değişmedi gibi görünüyor</li></ul><p>Ama Child yine render olur.</p><p>Neden?</p><p>Kritik nokta array referansı her render’da şu satır tekrar çalışır:</p><pre>const data = [1, 2, 3];</pre><p>Bu ne demek?</p><p>Her render’da:</p><ul><li>Yeni bir array oluşur</li><li>Bellekte yeni adres alır</li></ul><p>Yani React şuna bakar:</p><pre>eski data === yeni data //Cevap: false</pre><p>Bu yüzden React.memo der ki:</p><p><em>“Prop değişmiş” → Child render olur.</em></p><p><strong>Şimdi useMemo ile Düzeltelim</strong></p><pre>const data = useMemo(() =&gt; [1, 2, 3], []);</pre><p>Ne oldu?</p><ul><li>Array sadece ilk render’da oluşturuldu</li><li>Sonraki render’larda aynı referans kullanılıyor</li></ul><p>Artık:</p><pre>eski data === yeni data //Cevap: true</pre><p>Child render olmaz.</p><p><strong>Asıl Mantık (Kafa Açan Kısım)</strong></p><p>React.memo şuna bakar:</p><ul><li>Primitive mi? (string, number) → değere bakar</li><li>Object/array mi? → referansa bakar</li></ul><p>Object ve array’lerde:</p><p><em>Aynı içerik ≠ aynı referans</em></p><p>useMemo’nun yaptığı şey:</p><p><em>Referansı sabitlemek.</em></p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet</strong></blockquote><blockquote><em>useMemo, dependency’ler değişmediği sürece bir hesaplamanın sonucunu cache’ler. Özellikle maliyetli hesaplamalarda veya referans stabilitesi gereken durumlarda kullanılır. Ancak küçük hesaplamalarda gereksizdir ve sadece performans optimizasyonu amacıyla kullanılmalıdır.</em></blockquote><h3>3- useCallback ne işe yarar, ne zaman gereklidir?</h3><p>useCallback, <strong>bir fonksiyonun referansını memoize etmek</strong> için kullanılır.</p><p>Yani:</p><blockquote><em>Dependency’ler değişmediği sürece aynı fonksiyon referansını döner.</em></blockquote><p><strong>Neden Gerekli?</strong></p><p>React’te fonksiyonlar da object’tir.<br> Bu yüzden her render’da yeniden oluşturulurlar.</p><pre>const handleClick = () =&gt; {<br>  console.log(&quot;tıklandı&quot;);<br>};</pre><p>Her render’da:</p><ul><li>Yeni fonksiyon</li><li>Yeni referans</li></ul><p>Bu çoğu zaman problem değildir.<br> Ama bazı durumlarda gereklidir 👇</p><p>Ne Zaman Gerekli?</p><h4>Hangi Durumda Kullanılır?</h4><blockquote>1- React.memo ile Child’a Fonksiyon Gönderirken</blockquote><p>Parent:</p><pre>function Parent() {<br>  const [count, setCount] = useState(0);<br><br>  const handleClick = () =&gt; {<br>    console.log(&quot;clicked&quot;);<br>  };<br><br>  return &lt;Child onClick={handleClick} /&gt;;<br>}</pre><p>Child:</p><pre>const Child = React.memo(({ onClick }) =&gt; {<br>  console.log(&quot;Child render&quot;);<br>  return &lt;button onClick={onClick}&gt;Click&lt;/button&gt;;<br>});</pre><p>Parent’ta sadece count değişse bile:</p><ul><li>handleClick yeniden oluşur</li><li>Referans değişir</li><li>React.memo “prop değişti” sanır</li><li>Child tekrar render olur</li></ul><p><strong>useCallback ile Çözüm:</strong></p><pre>const handleClick = useCallback(() =&gt; {<br>  console.log(&quot;clicked&quot;);<br>}, []);</pre><p>Şimdi:</p><ul><li>Aynı fonksiyon referansı korunur</li><li>Child gereksiz render olmaz</li></ul><blockquote>2- useEffect Dependency Olarak Fonksiyon Kullanırken</blockquote><p>Problem:</p><pre>useEffect(() =&gt; {<br>  fetchData();<br>}, [fetchData]);</pre><p>Eğer fetchData her render’da yeniden oluşuyorsa:</p><ul><li>Effect tekrar çalışır</li><li>Infinite loop olabilir</li></ul><p><strong>useCallback ile:</strong></p><pre>const fetchData = useCallback(() =&gt; {<br>  ...<br>}, []);<br><br>useEffect(() =&gt; {<br>  fetchData();<br>}, [fetchData]);</pre><p>Artık referans sabit.</p><blockquote>3- Performance Kritik Büyük Componentlerde</blockquote><ul><li>Büyük table</li><li>Complex form</li><li>Deep component tree</li></ul><p>Fonksiyon referans değişimi gereksiz re-render zinciri yaratabilir.</p><h4>Ne Zaman Gerekmez?</h4><ul><li>Child memo değilse</li><li>Fonksiyon prop olarak gönderilmiyorsa</li><li>Performance sorunu yoksa</li></ul><h3>useMemo vs useCallback Farkı</h3><pre>| useMemo            | useCallback            |<br>| ------------------ | ---------------------- |<br>| Değer memoize eder | Fonksiyon memoize eder |<br>| Array/object için  | Function için          |</pre><p>useMemo ile useCallback arasındaki fark şudur: <strong>useMemo hesaplanmış bir değeri</strong>, <strong>useCallback ise bir fonksiyonu</strong> memoize eder (referansını sabit tutar). Örneğin const filteredList = useMemo(() =&gt; users.filter(u =&gt; u.active), [users]); kodunda useMemo, users değişmediği sürece filtreleme sonucunu tekrar hesaplamaz; buna karşılık const handleClick = useCallback(() =&gt; console.log(&quot;clicked&quot;), []); kodunda useCallback, fonksiyonun her render’da yeniden oluşmasını engeller ve özellikle React.memo ile optimize edilmiş child component’lere fonksiyon prop gönderirken gereksiz re-render’ı önler.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>useCallback, fonksiyon referansını memoize eder. Özellikle React.memo ile optimize edilmiş child componentlere fonksiyon prop gönderirken veya useEffect dependency olarak fonksiyon kullanırken gereklidir. Gereksiz re-render’ı önlemek için kullanılır ancak her yerde kullanılmamalıdır.</em></blockquote><blockquote><em>useMemo, dependency’ler değişmediği sürece bir hesaplamanın sonucunu cache’ler. Özellikle maliyetli hesaplamalarda veya referans stabilitesi gereken durumlarda kullanılır. Ancak küçük hesaplamalarda gereksizdir ve sadece performans optimizasyonu amacıyla kullanılmalıdır.</em></blockquote><h3>4- useRef ile useState arasındaki fark nedir?</h3><p>Temel Fark:</p><ul><li><strong>useState</strong> → Değer değişirse component yeniden render olur.</li><li><strong>useRef</strong> → Değer değişir ama render olmaz.</li></ul><p>En kritik fark bu.</p><p><strong>useState Örneği (Render Tetikler)</strong></p><pre>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  return (<br>    &lt;&gt;<br>      &lt;p&gt;{count}&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Artır&lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Ne olur?</p><ul><li>Butona basınca setCount çalışır</li><li>React yeniden render eder</li><li>UI güncellenir</li></ul><p>Çünkü state değişti.</p><p><strong>useRef Örneği (Render Tetiklemez)</strong></p><pre>function Counter() {<br>  const countRef = useRef(0);<br><br>  const increase = () =&gt; {<br>    countRef.current++;<br>    console.log(countRef.current);<br>  };<br><br>  return &lt;button onClick={increase}&gt;Artır&lt;/button&gt;;<br>}</pre><p>Ne olur?</p><ul><li>countRef.current artar</li><li>Console’da değer değişir</li><li>Ama ekranda hiçbir şey değişmez</li></ul><p>Çünkü ref değişimi render tetiklemez.</p><p><strong>DOM Erişimi (useRef’in Asıl Gücü)</strong></p><pre>function InputFocus() {<br>  const inputRef = useRef(null);<br><br>  const focusInput = () =&gt; {<br>    inputRef.current.focus();<br>  };<br><br>  return (<br>    &lt;&gt;<br>      &lt;input ref={inputRef} /&gt;<br>      &lt;button onClick={focusInput}&gt;Focus&lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Burada:</p><ul><li>useRef DOM elementine erişmek için kullanılır</li><li>useState ile bunu yapamazsın</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>useState UI’a yansıyacak state’i yönetir ve değiştiğinde component’i yeniden render eder. useRef ise render tetiklemeden mutable bir değer saklar ve genellikle DOM erişimi veya render’a ihtiyaç olmayan değerleri tutmak için kullanılır.</em></blockquote><h3>5- Custom hook nedir, ne zaman yazarsın?</h3><p>Custom hook, React’in mevcut hook’larını (useState, useEffect, useRef vb.) kullanarak yazdığımız, tekrar kullanılabilir özel hook’lardır.</p><p>İsmi mutlaka use ile başlar.</p><p>Amaç:</p><blockquote><em>Ortak logic’i component’lerden ayırmak ve tekrar kullanılabilir hale getirmek.</em></blockquote><h4>Ne Zaman Yazarsın?</h4><blockquote>Aynı Logic Birden Fazla Component’te Kullanılıyorsa</blockquote><p>Örneğin her ekranda window width kontrolü yapıyorsun:</p><pre>function useWindowWidth() {<br>  const [width, setWidth] = useState(window.innerWidth);<br><br>  useEffect(() =&gt; {<br>    const handleResize = () =&gt; setWidth(window.innerWidth);<br>    window.addEventListener(&quot;resize&quot;, handleResize);<br>    return () =&gt; window.removeEventListener(&quot;resize&quot;, handleResize);<br>  }, []);<br><br>  return width;<br>}</pre><p>Artık her component’te:</p><pre>const width = useWindowWidth();</pre><p>Tekrar tekrar aynı kodu yazmazsın.</p><blockquote>API Logic’ini Soyutlamak İstiyorsan</blockquote><p>Mesela fetch logic’i:</p><pre>function useFetch(url) {<br>  const [data, setData] = useState(null);<br><br>  useEffect(() =&gt; {<br>    fetch(url)<br>      .then(res =&gt; res.json())<br>      .then(setData);<br>  }, [url]);<br><br>  return data;<br>}</pre><p>Component sadeleşir:</p><pre>const users = useFetch(&quot;/api/users&quot;);</pre><blockquote>Complex State Yönetimini Temizlemek İçin</blockquote><p>Büyük bir form ya da WebSocket logic’i component’i şişiriyorsa:</p><ul><li>Component UI’a odaklanır</li><li>Hook logic’i yönetir</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Custom hook, React hook’larını kullanarak yazdığımız tekrar kullanılabilir logic kapsülleridir. Aynı state veya side-effect (</em>Side effect, bir fonksiyonun sadece değer hesaplamak dışında dış dünyayı etkileyen bir işlem yapmasıdır.<em>) mantığı birden fazla component’te kullanılıyorsa ya da component içi karmaşık hale geldiyse, bu logic’i soyutlamak için custom hook yazarım. Bu, kod tekrarını azaltır ve component’leri daha temiz hale getirir.</em></blockquote><h3>6- Component’i ne zaman parçalarsın, reusable component nasıl tasarlanır?</h3><h4>Component’i Ne Zaman Parçalarsın?</h4><p><em>1- Çok Büyüdüğünde (Single Responsibility Bozulduğunda)</em></p><p>Bir component:</p><ul><li>Hem veri çekiyor</li><li>Hem form yönetiyor</li><li>Hem modal açıyor</li><li>Hem tablo render ediyor</li></ul><p>→ Bu artık birden fazla sorumluluğa sahiptir.</p><p>Kural:</p><blockquote><em>Bir component tek bir işi yapmalı.</em></blockquote><p><em>2- Aynı UI Parçası Tekrar Ediyorsa</em></p><p>Örneğin:</p><ul><li>5 farklı ekranda aynı UserCard</li><li>Aynı TableHeader</li><li>Aynı EmptyState</li></ul><p>Görüyorsan → reusable yaparsın.</p><p><em>3- Okunabilirlik Azaldığında</em></p><p>150–200 (Bu çok değişkendir compoınentin komplexliğine göre de değişebilir) satırı geçen component’te:</p><ul><li>State’ler kaybolur</li><li>Effect’ler karışır</li><li>Debug zorlaşır</li></ul><p>Bu noktada parçalamak gerekir.</p><p><em>4- Test Edilebilirlik İçin</em></p><p>Küçük component:</p><ul><li>Daha kolay test edilir</li><li>Daha kolay mocklanır</li><li>Daha izole davranır</li></ul><h4>Reusable Component Nasıl Tasarlanır?</h4><p><em>1- Props-Driven Olmalı</em></p><p>Hardcoded değil, dışarıdan kontrol edilebilir olmalı.</p><p>Kötü:</p><pre>&lt;Button text=&quot;Kaydet&quot; /&gt;</pre><p>İçeride click logic sabit.</p><p>İyi:</p><pre>&lt;Button<br>  label=&quot;Kaydet&quot;<br>  onClick={handleSave}<br>  loading={isLoading}<br>/&gt;</pre><p>Component davranışı dışarıdan yönetilir.</p><p><em>2- UI ile Logic Ayrılmalı</em></p><p>Reusable component:</p><ul><li>İş mantığı bilmemeli</li><li>Sadece UI render etmeli</li></ul><p>Örneğin Modal component:</p><ul><li>Sadece aç/kapa ve children render eder</li><li>İçindeki business logic’i bilmez</li></ul><p><em>3- Esnek Olmalı (Composition Pattern)</em></p><p>En güçlü yöntem:</p><pre>&lt;Card&gt;<br>  &lt;Card.Header /&gt;<br>  &lt;Card.Body /&gt;<br>&lt;/Card&gt;<br><br>Ya da:<br><br>&lt;Modal&gt;<br>  &lt;UserForm /&gt;<br>&lt;/Modal&gt;</pre><p>Component içine istediğin şeyi koyabilmelisin.</p><p><em>4- Controlled / Uncontrolled Mantığını Destekleyebilmeli</em></p><p>Örneğin Input:</p><pre>&lt;Input value={value} onChange={setValue} /&gt;</pre><p>State parent’ta olmalı.</p><p>Bu reusable yapıyı güçlendirir.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Component’i, tek sorumluluk prensibi bozulduğunda, tekrar eden UI parçaları oluştuğunda veya okunabilirlik azaldığında parçalarım. Reusable component tasarlarken props-driven, esnek, UI-odaklı ve business logic’ten bağımsız olmasına dikkat ederim. Controlled yapıyı desteklemesi ve composition pattern’e uygun olması önemli kriterlerdir.</em></blockquote><h3>7- Presentational vs Container component farkı nedir?</h3><h4>Presentational Component (UI Component)</h4><p>Sadece <strong>görünümden sorumludur.</strong></p><ul><li>UI render eder</li><li>Props alır</li><li>Event tetikler</li><li>State yönetmez (ya da minimum UI state)</li><li>API çağrısı yapmaz</li><li>Business logic içermez</li></ul><p>Örnek:</p><pre>function UserCard({ user, onDelete }) {<br>  return (<br>    &lt;div&gt;<br>      &lt;h3&gt;{user.name}&lt;/h3&gt;<br>      &lt;button onClick={onDelete}&gt;Sil&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Bu component:</p><ul><li>Veri çekmez</li><li>Redux bilmez</li><li>Nereden geldiğiyle ilgilenmez</li><li>Sadece gösterir</li></ul><h3>Container Component (Logic Component)</h3><p>İş mantığını yönetir.</p><ul><li>API çağırır</li><li>State tutar</li><li>Redux bağlanır</li><li>Data hazırlar</li><li>Event handler yazar</li></ul><p>Örnek:</p><pre>function UserCardContainer({ userId }) {<br>  const { data } = useGetUserQuery(userId);<br><br>  const handleDelete = () =&gt; {<br>    deleteUser(userId);<br>  };<br><br>  return (<br>    &lt;UserCard<br>      user={data}<br>      onDelete={handleDelete}<br>    /&gt;<br>  );<br>}</pre><p>Bu component:</p><ul><li>Veri çekiyor</li><li>Silme işlemi yapıyor</li><li>Logic barındırıyor</li></ul><p>Ama UI render etmiyor — UI’yı presentational component’e bırakıyor.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Presentational component sadece UI render eder ve props ile çalışır. Container component ise veri çekme, state yönetimi ve business logic içerir. Bu ayrım sayesinde logic ile UI birbirinden ayrılır ve kod daha sürdürülebilir hale gelir.</em></blockquote><h3>8- React’te state lifting nedir, hangi durumda yapılır?</h3><p><strong>State’in alt component’ten alınıp ortak bir üst component’e taşınmasıdır.</strong></p><p>Amaç:</p><blockquote><em>Birden fazla component’in aynı veriyi paylaşmasını sağlamak.</em></blockquote><p><strong>Neden Yapılır?</strong></p><p>Eğer iki sibling (kardeş) component aynı veriye ihtiyaç duyuyorsa:</p><ul><li>State’i birinde tutamazsın</li><li>İkisine de erişilebilir bir yere koyman gerekir</li></ul><p>Yani ortak parent’a taşırsın.</p><p><em>Örnek Senaryo</em></p><p>İki component var:</p><ul><li>SearchInput</li><li>UserList</li></ul><p>SearchInput filtreyi değiştiriyor.<br> UserList filtreye göre listeyi gösteriyor.</p><p>Yanlış yaklaşım:</p><p>SearchInput içinde state tutmak.<br>Çünkü UserList o state’e erişemez.</p><p><strong>Doğru Yaklaşım (State Lifting</strong>)</p><p>State’i parent’a alırsın:</p><pre>function UsersPage() {<br>  const [search, setSearch] = useState(&quot;&quot;);<br><br>  return (<br>    &lt;&gt;<br>      &lt;SearchInput value={search} onChange={setSearch} /&gt;<br>      &lt;UserList search={search} /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Burada:</p><ul><li>State parent’ta</li><li>Input değiştiriyor</li><li>Liste kullanıyor</li><li>Tek kaynak var</li></ul><p>İşte bu state lifting’tir.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>State lifting, birden fazla component’in aynı veriyi kullanması gerektiğinde state’i ortak parent component’e taşıma işlemidir. Böylece tek bir source of truth oluşur ve veri senkronizasyonu sağlanır.</em></blockquote><h3>9- TypeScript’te interface ve type farkı nedir?</h3><h3>Ortak Noktaları</h3><p>Hem interface hem type:</p><ul><li>Object tip tanımlamak için kullanılır</li><li>Function tip tanımlayabilir</li><li>Extend edilebilir</li><li>Type safety sağlar</li></ul><pre>interface User {<br>  id: number;<br>  name: string;<br>}</pre><pre>type User = {<br>  id: number;<br>  name: string;<br>};</pre><p>Bu iki kullanım burada aynıdır.</p><h4>Asıl Farklar</h4><p><em>1- Declaration Merging (En Önemli Fark)</em></p><p>interface aynı isimle tekrar tanımlanabilir ve birleşir.</p><pre>interface User {<br>  name: string;<br>}<br><br>interface User {<br>  age: number;<br>}</pre><p>Sonuç:</p><pre>{<br>  name: string;<br>  age: number;<br>}</pre><p>Ama type’ta bu mümkün değildir :</p><pre>type User = { name: string };<br>type User = { age: number }; // HATA</pre><p><em>2- Union ve Primitive Tiplerde type Kullanılır</em></p><p>type daha esnektir:</p><pre>type Status = &quot;success&quot; | &quot;error&quot; | &quot;loading&quot;;</pre><p>Interface bunu yapamaz.</p><p>Aynı şekilde:</p><pre>type ID = string | number;</pre><p>3- Complex Type Manipulation</p><p>Intersection, mapped type, conditional type gibi gelişmiş şeylerde type kullanılır.</p><pre>type Admin = User &amp; {<br>  role: string;<br>};</pre><p><em>4- Extend Etme Şekilleri</em></p><p>Interface:</p><pre>interface Admin extends User {<br>  role: string;<br>}</pre><p>Type:</p><pre>type Admin = User &amp; {<br>  role: string;<br>};</pre><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Interface ve type benzer şekilde object tip tanımlamak için kullanılır ancak interface declaration merging desteklerken type desteklemez. Type union, primitive ve complex type manipülasyonlarında daha esnektir. Genelde object model’lerde interface, union veya advanced tiplerde type tercih edilir.</em></blockquote><h3>10- Generic type nedir, nerede kullanılır?</h3><p>Generic, <strong>tipi sonradan belirlenen parametreli tiptir.</strong></p><p>Yani:</p><blockquote><em>Tipi sabit yazmak yerine, dışarıdan verilen tipe göre çalışan yapı.</em></blockquote><p>Basit mantık:</p><pre>&lt;T&gt;</pre><p>Bu T, bir placeholder’dır.,</p><p><strong>Neden Kullanılır?</strong></p><p>Çünkü aynı yapıyı farklı tiplerle tekrar tekrar yazmak istemeyiz.</p><p><em>Generic Olmadan:</em></p><pre>function getFirstString(arr: string[]): string {<br>  return arr[0];<br>}<br><br>function getFirstNumber(arr: number[]): number {<br>  return arr[0];<br>}</pre><p>Aynı fonksiyonu iki kere yazdık.</p><p><em>Generic ile:</em></p><pre>function getFirst&lt;T&gt;(arr: T[]): T {<br>  return arr[0];<br>}</pre><p>Artık:</p><pre>getFirst&lt;string&gt;([&quot;a&quot;, &quot;b&quot;]);<br>getFirst&lt;number&gt;([1, 2]);</pre><p>Tek fonksiyon → Her tip için çalışır.</p><h4>React’te Nerede Kullanılır?</h4><p><em>1- Reusable Component</em></p><p>Örnek:</p><pre>type TableProps&lt;T&gt; = {<br>  data: T[];<br>  renderRow: (item: T) =&gt; React.ReactNode;<br>};</pre><p>Artık bu tablo:</p><ul><li>User</li><li>Product</li><li>Order</li><li>Complaint</li></ul><p>her şeyi render edebilir.</p><p>Tip güvenli şekilde.</p><p><em>2- API Response Typing</em></p><pre>interface ApiResponse&lt;T&gt; {<br>  data: T;<br>  success: boolean;<br>}</pre><p>Kullanımı:</p><pre>ApiResponse&lt;User&gt;<br>ApiResponse&lt;Product&gt;</pre><p><em>3- Custom Hook Yazarken</em></p><pre>function useFetch&lt;T&gt;(url: string) {<br>  const [data, setData] = useState&lt;T | null&gt;(null);<br>  ...<br>  return data;<br>}</pre><p>Artık:</p><pre>const user = useFetch&lt;User&gt;(&quot;/api/user&quot;);</pre><p>Tip güvenli çalışır.</p><p><strong>Özet Mantık Generic:</strong></p><ul><li>Tekrarı azaltır</li><li>Esnek yapı sağlar</li><li>Type safety bozulmaz</li><li>Reusable component yazarken çok kritiktir</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Generic type, tipi parametre olarak alan ve farklı tiplerle çalışabilen yapılardır. Tekrar eden tip tanımlarını azaltmak ve reusable, type-safe fonksiyonlar veya component’ler yazmak için kullanılır. Özellikle reusable component, API response modeli ve custom hook yazarken tercih edilir.</em></blockquote><h3>11- Union type ve intersection type ne işe yarar?</h3><p>Union demek:</p><blockquote><em>Bu tiplerden </em><strong><em>birisi olabilir</em></strong><em>.</em></blockquote><p>Yani OR mantığı.</p><p>Basit Örnek:</p><pre>type ID = string | number;</pre><p>Bu şu demek:</p><ul><li>ID ya string olabilir</li><li>ya number olabilir</li></ul><p>İkisi birden değil.</p><h4>Pratik Örnek</h4><pre>type Status = &quot;success&quot; | &quot;error&quot; | &quot;loading&quot;;</pre><p>Bu sayede:</p><ul><li>Sadece bu 3 değeri kabul eder</li><li>Type safety sağlar</li></ul><h4>Component Örneği</h4><pre>type ButtonProps = {<br>  size: &quot;small&quot; | &quot;medium&quot; | &quot;large&quot;;<br>};</pre><p>Yanlış değer girersen TypeScript hata verir.</p><h3>Intersection Type ( &amp; )</h3><p>Intersection demek:</p><blockquote><em>Bu tiplerin </em><strong><em>hepsi birden olmalı</em></strong><em>.</em></blockquote><p>Yani AND mantığı.</p><p>Basit Örnek:</p><pre>type User = {<br>  name: string;<br>};<br><br>type Admin = {<br>  role: string;<br>};<br><br>type AdminUser = User &amp; Admin;</pre><p>Artık:</p><pre>{<br>  name: string;<br>  role: string;<br>}</pre><p>İkisini birleştirdi.</p><h3>Temel Fark</h3><pre>| Union ( | )     | Intersection ( &amp; ) |<br>|-----------------|-------------------|<br>| Birisi olabilir | Hepsi olmalı      |<br>| OR mantığı      | AND mantığı       |<br>| Alternatif tip  | Birleştirme       |</pre><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Union type bir değerin birden fazla tipten biri olabileceğini belirtir ve OR mantığıyla çalışır. Intersection type ise birden fazla tipi birleştirir ve tüm özelliklerin birlikte bulunmasını zorunlu kılar, yani AND mantığıyla çalışır.</em></blockquote><h3>12- any kullanmak neden kötü, alternatifin nedir?</h3><p>any demek:</p><blockquote><em>“TypeScript sen karışma, ben her şeyi kabul ediyorum.”</em></blockquote><p>Yani type safety’yi tamamen kapatırsın.</p><p><em>1-Type Safety Kaybolur</em></p><pre>let value: any = &quot;hello&quot;;<br>value = 123;<br>value.toUpperCase(); // runtime error</pre><p>TypeScript hata vermez ❌<br> Ama runtime’da patlar.</p><p>TypeScript’in var olma sebebi zaten bu hataları önlemek.</p><p><em>2-Refactor Güvenliği Kaybolur</em></p><p>Büyük projede bir alanın tipi değiştiğinde:</p><ul><li>any varsa TypeScript seni uyarmıyor</li><li>Production’da bug çıkıyor</li></ul><p>Enterprise projede bu büyük risk.</p><p><em>3- Autocomplete ve IntelliSense Kaybolur</em></p><p>any kullandığında:</p><ul><li>IDE sana yardım edemez</li><li>Property önermez</li><li>Metod hatası yakalayamaz</li></ul><p>Developer experience düşer.</p><h4>Alternatifler Nedir?</h4><p><em>1️- </em><em>unknown (En Doğru Alternatif)</em></p><p>unknown, any gibi her şeyi alır ama kullanmadan önce kontrol zorunludur.</p><pre>let value: unknown = &quot;hello&quot;;<br><br><br>if (typeof value === &quot;string&quot;) {<br>  value.toUpperCase(); // güvenli<br>}</pre><p>Bu type-safe yaklaşımdır.</p><p><em>2- Generic Kullanmak</em></p><pre>function identity&lt;T&gt;(value: T): T {<br>  return value;<br>}</pre><p>any yerine generic yazılır.</p><p><em>3- Union Type Kullanmak</em></p><pre>type ID = string | number;</pre><p>Belirsizliği any ile değil, olası tiplerle çözersin.</p><p><em>4- Doğru Model Tanımlamak</em></p><pre>interface User {<br>  id: number;<br>  name: string;<br>}</pre><p>any yazmak yerine model çıkarırsın.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>any kullanmak TypeScript’in sağladığı type safety’yi devre dışı bırakır ve runtime hatalarına açık hale getirir. Refactor güvenliğini azaltır ve IntelliSense avantajını kaybettirir. Bunun yerine </em><em>unknown, union type, generic veya doğru interface tanımları kullanarak type-safe bir yapı kurmak gerekir.</em></blockquote><h3>13- Redux neden kullanılır, hangi problemi çözer?</h3><h4><strong>Redux Neden Kullanılır?</strong></h4><p>Redux:</p><blockquote><em>Uygulamadaki global state’i merkezi ve öngörülebilir şekilde yönetmek için kullanılır.</em></blockquote><h4>Hangi Problemi Çözer?</h4><p><em>1- Prop Drilling Problemi</em></p><p>Diyelim ki:</p><ul><li>Navbar user bilgisine ihtiyaç duyuyor</li><li>Sidebar da</li><li>Dashboard da</li><li>Settings sayfası da</li></ul><p>Eğer state’i en üst component’te tutup props ile aşağı taşırsan:</p><pre>App<br> └─ Layout<br>     └─ Sidebar<br>         └─ UserInfo</pre><p>Her katmandan prop geçirmek zorunda kalırsın.</p><p>Bu:</p><ul><li>Kod karmaşıklaştırır</li><li>Bakımı zorlaştırır</li></ul><p>Redux bu problemi çözer.</p><p><em>2- Global State İhtiyacı</em></p><p>Örneğin:</p><ul><li>Auth user</li><li>Theme</li><li>Permission</li><li>Dil bilgisi</li><li>Notification state</li></ul><p>Bunlar sayfa bazlı değil, uygulama geneline aittir.</p><p>Redux bunları merkezi store’da tutar.</p><p><em>3- Predictable State Management</em></p><p>Redux’ta:</p><ul><li>State immutable’dır</li><li>Sadece action ile değişir</li><li>Reducer ile nasıl değişeceği bellidir</li></ul><p>Bu sayede:</p><ul><li>State değişimi izlenebilir</li><li>Debug kolaylaşır</li><li>DevTools ile time-travel debugging yapılabilir</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Redux, uygulama genelinde paylaşılan state’i merkezi ve öngörülebilir şekilde yönetmek için kullanılır. Prop drilling problemini çözer ve karmaşık veri akışlarını düzenler. Özellikle büyük ve çok sayfalı uygulamalarda global state yönetimini daha sürdürülebilir hale getirir.</em></blockquote><h3>14- Context API nedir? Ne zaman Context API ne zaman Redux kullanılmalıdır ?</h3><p><strong>Context API Nedir?</strong></p><blockquote><em>React’in kendi içinde bulunan, component ağacı boyunca veri paylaşmayı sağlayan global state mekanizmasıdır.</em></blockquote><p>Amaç:</p><ul><li>Prop drilling’i azaltmak</li><li>Ortak veriyi birden fazla component’e ulaştırmak</li></ul><p>Basit Örnek:</p><pre>const ThemeContext = React.createContext(&quot;light&quot;);<br><br>function App() {<br>  return (<br>    &lt;ThemeContext.Provider value=&quot;dark&quot;&gt;<br>      &lt;Layout /&gt;<br>    &lt;/ThemeContext.Provider&gt;<br>  );<br>}</pre><p>Artık alt component’ler:</p><pre>const theme = useContext(ThemeContext);</pre><p>ile bu değere erişebilir.</p><p>Önemli nokta:</p><p>Context veri taşır.<br> Karmaşık state yönetimi için tasarlanmamıştır.</p><h4>Ne Zaman Context Kullanılır?</h4><p>Şunlar için idealdir:</p><ul><li>Theme (dark/light)</li><li>Dil (i18n)</li><li>Auth user (basit)</li><li>Locale</li><li>UI state (sidebar açık mı?)</li></ul><p>Yani:</p><blockquote><em>Az değişen ve küçük global state’ler için.</em></blockquote><h3>Ne Zaman Redux Kullanılır?</h3><p>Şunlar varsa Redux mantıklı:</p><ul><li>Büyük uygulama</li><li>Çok sayıda global state</li><li>Karmaşık veri akışı</li><li>Async işlemler yoğun</li><li>Cache yönetimi</li><li>Predictable state flow ihtiyacı</li></ul><p>Örneğin:</p><ul><li>CRM</li><li>Fintech dashboard</li><li>Admin panel</li><li>Çok modüllü enterprise app</li></ul><pre>Kritik Farklar<br><br>| Context API             | Redux              |<br>| ----------------------- | ------------------ |<br>| Basit                   | Daha güçlü         |<br>| React built-in          | Harici library     |<br>| Küçük global state      | Büyük global state |<br>| DevTools sınırlı        | Zengin debugging   |<br>| Performans kontrolü zor | Daha optimize yapı |</pre><h3>Performans Konusu</h3><p>Context’te value değiştiğinde:</p><ul><li>Provider altındaki tüm component’ler re-render olabilir.</li></ul><p>Redux’ta ise:</p><ul><li>Sadece ilgili slice’a subscribe olan component render olur.</li></ul><p>Bu büyük projede önemli fark yaratır.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Context API, prop drilling’i önlemek için React’in sunduğu bir global veri paylaşım mekanizmasıdır ve küçük, nadiren değişen state’ler için uygundur. Redux ise karmaşık ve büyük ölçekli uygulamalarda merkezi, öngörülebilir ve performanslı state yönetimi sağlar. Küçük global UI state’lerde Context, karmaşık veri akışlarında Redux tercih edilir.</em></blockquote><h3>15- Redux Toolkit klasik Redux’tan neden daha iyi?</h3><p>Redux Toolkit:</p><blockquote><em>Redux’ın resmi, önerilen ve daha sade kullanım şeklidir.</em></blockquote><p>Ama asıl farkları teknik olarak bakalım:</p><p><em>1- Boilerplate Azaltır</em></p><p>Klasik Redux’ta:</p><ul><li>Action type</li><li>Action creator</li><li>Reducer</li><li>Switch-case</li></ul><p>yazman gerekir.</p><p>Klasik Redux:</p><pre>const ADD_TODO = &quot;ADD_TODO&quot;;<br><br>function addTodo(payload) {<br>  return { type: ADD_TODO, payload };<br>}<br><br>function reducer(state = [], action) {<br>  switch (action.type) {<br>    case ADD_TODO:<br>      return [...state, action.payload];<br>    default:<br>      return state;<br>  }<br>}</pre><p>Çok kod, çok tekrar.</p><p>Redux Toolkit:</p><pre>import { createSlice } from &quot;@reduxjs/toolkit&quot;;<br><br>const todoSlice = createSlice({<br>  name: &quot;todo&quot;,<br>  initialState: [],<br>  reducers: {<br>    addTodo: (state, action) =&gt; {<br>      state.push(action.payload);<br>    },<br>  },<br>});</pre><ul><li>Action otomatik oluşur</li><li>Reducer otomatik oluşur</li><li>Switch-case yok</li></ul><p>Daha temiz.</p><p><em>2- Immer ile Immutable State Kolaylığı</em></p><p>Klasik Redux’ta:</p><pre>return {<br>  ...state,<br>  items: [...state.items, newItem]<br>};</pre><p>RTK’ta:</p><pre>state.items.push(newItem);</pre><p>Arka planda Immer immutable yapıyı korur.</p><p><em>3- configureStore ile Kolay Setup</em></p><p>Klasik Redux’ta:</p><ul><li>combineReducers</li><li>applyMiddleware</li><li>DevTools config</li></ul><p>manuel yapılır.</p><p>RTK’ta:</p><pre>const store = configureStore({<br>  reducer: rootReducer,<br>});</pre><p>DevTools otomatik açık gelir.</p><p><em>4- RTK Query (Büyük Avantaj)</em></p><p>API işlemleri için:</p><ul><li>Loading</li><li>Error</li><li>Cache</li><li>Refetch</li></ul><p>hepsini yönetir.</p><p>5- Daha Az Hata Riski</p><ul><li>Action type string hataları yok</li><li>Immutable hataları yok</li><li>Middleware config kolay</li></ul><pre>Özet Fark<br><br>| Klasik Redux            | Redux Toolkit   |<br>| ----------------------- | --------------- |<br>| Çok boilerplate         | Minimal kod     |<br>| Manual immutable        | Immer ile kolay |<br>| Manuel setup            | configureStore  |<br>| Async için ekstra setup | RTK Query hazır |</pre><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Redux Toolkit, klasik Redux’a göre daha az boilerplate gerektirir, Immer sayesinde immutable state yönetimini kolaylaştırır ve configureStore ile setup sürecini basitleştirir. Ayrıca RTK Query ile API state yönetimini standart hale getirir. Bu yüzden modern Redux projelerinde önerilen yaklaşımdır.</em></blockquote><h3>16- Global state’e ne koyarsın, ne koymazsın?</h3><blockquote><em>Global state’e uygulama genelinde birden fazla yerde ihtiyaç duyulan ve merkezi yönetilmesi gereken veriler konur.</em></blockquote><blockquote><em>Sadece tek component’i ilgilendiren state global’e konmaz.</em></blockquote><h3>Global State’e Ne Konur?</h3><ul><li>Kullanıcı bilgisi</li><li>Token</li><li>Role &amp; permission</li><li>Theme (dark/light)</li><li>Dil (i18n)</li><li>Locale</li><li>Global loading state (bazı durumlarda)</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Global state’e uygulamanın birden fazla yerinde ihtiyaç duyulan ve merkezi yönetilmesi gereken veriler konur; örneğin auth bilgisi, tema, dil veya paylaşılan cache verileri. Sadece tek component’i ilgilendiren UI state’leri ve geçici form verileri ise local state olarak tutulmalıdır. Aksi halde gereksiz karmaşıklık ve performans sorunları oluşabilir.</em></blockquote><h3>17- RTK Query nedir, ne avantaj sağlar?</h3><p>RTK Query:</p><blockquote><em>Redux Toolkit’in içine entegre edilmiş, API veri yönetimi ve caching çözümüdür.</em></blockquote><p>Yani:</p><ul><li>API çağrısı yapar</li><li>Loading / error state yönetir</li><li>Cache tutar</li><li>Otomatik refetch yapar</li><li>State’i store’da yönetir</li></ul><p>Hepsi tek bir sistem içinde.</p><h3>RTK Query Olmadan Ne Yapıyorduk?</h3><p>Klasik yaklaşım:</p><ul><li>async thunk yaz</li><li>loading state tut</li><li>error state tut</li><li>reducer yaz</li><li>cache mantığını elle kur</li><li>refetch logic yaz</li></ul><p>Çok boilerplate ve hata riski var.</p><h4>RTK Query ile</h4><p>Sadece endpoint tanımlarsın:</p><pre>const api = createApi({<br>  reducerPath: &quot;api&quot;,<br>  baseQuery: fetchBaseQuery({ baseUrl: &quot;/api&quot; }),<br>  endpoints: (builder) =&gt; ({<br>    getUsers: builder.query&lt;User[], void&gt;({<br>      query: () =&gt; &quot;/users&quot;,<br>    }),<br>  }),<br>});</pre><p>Kullanım:</p><pre>const { data, isLoading, error } = useGetUsersQuery();</pre><p>Hepsi hazır gelir.</p><h4>Avantajları:</h4><p><em>1- Otomatik Loading &amp; Error State</em></p><p>Manuel state tutmazsın.</p><p><em>2- Built-in Cache Mekanizması</em></p><ul><li>Aynı request tekrar yapılmaz</li><li>Data store’da cache’lenir</li><li>Performans artar</li></ul><p><em>3- Otomatik Refetch</em></p><ul><li>Window focus olunca</li><li>Network geri gelince</li><li>Tag invalidation sonrası</li></ul><p><em>4- Tag-Based Invalidation</em></p><p>Mesela:</p><ul><li>User update ettin</li><li>User list otomatik refetch olur</li></ul><pre>providesTags: [&quot;Users&quot;]<br>invalidatesTags: [&quot;Users&quot;]</pre><p>Manuel refresh yazmazsın.</p><p>5- Merkezi API Layer</p><p>Bütün endpoint’ler tek yerde tanımlı.</p><p>Büyük projede çok büyük avantaj.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>RTK Query, Redux Toolkit’in sunduğu bir veri fetching ve caching çözümüdür. API çağrılarını merkezi bir yapıda tanımlamamızı sağlar, loading ve error state’leri otomatik yönetir ve built-in cache mekanizması sunar. Böylece boilerplate azalır ve veri senkronizasyonu daha öngörülebilir hale gelir.</em></blockquote><h3>18- RTK Query cache mekanizması nasıl çalışır?</h3><p>RTK Query:</p><blockquote><em>Her endpoint + parametre kombinasyonu için store içinde cache tutar.</em></blockquote><p>Yani cache key mantığı vardır.</p><p><em>1- Cache Key Mantığı</em></p><p>Örneğin:</p><pre>useGetUsersQuery()</pre><p>ve:</p><pre>useGetUsersQuery({ page: 1 })</pre><p>Bunlar farklı cache entry’lerdir.</p><p>RTK Query:</p><pre>endpointName + queryArg</pre><p>kombinasyonunu cache key olarak kullanır.</p><p><em>2- İlk Çağrıda Ne Olur?</em></p><ul><li>API request atılır</li><li>Data store’a yazılır</li><li>Cache oluşur</li></ul><p><em>3- Aynı Query Tekrar Çağrılırsa?</em></p><p>Eğer:</p><ul><li>Parametre aynıysa</li><li>Cache süresi dolmadıysa</li></ul><p>→ API tekrar çağrılmaz<br> → Cache’teki data döner</p><p>Bu performans kazancı sağlar.</p><p>4- Cache Süresi (keepUnusedDataFor)</p><p>Varsayılan:</p><pre>keepUnusedDataFor: 60 // saniye</pre><p>Bir component unmount olsa bile:</p><ul><li>60 saniye boyunca cache tutulur</li><li>Aynı query tekrar gelirse API atılmaz</li></ul><p><em>5- Subscription Mantığı</em></p><p>RTK Query her hook kullanımını subscribe eder.</p><p>Örneğin:</p><ul><li>3 component aynı query’i kullanıyorsa</li><li>Tek API çağrısı yapılır</li><li>Hepsi aynı cache’i paylaşır</li></ul><p><em>6- Tag-Based Invalidation (En Güçlü Kısım)</em></p><p>Mesela:</p><pre>getUsers: builder.query({<br>  query: () =&gt; &quot;/users&quot;,<br>  providesTags: [&quot;Users&quot;]<br>})</pre><p>ve :</p><pre>updateUser: builder.mutation({<br>  query: (user) =&gt; ({<br>    url: `/users/${user.id}`,<br>    method: &quot;PUT&quot;,<br>    body: user<br>  }),<br>  invalidatesTags: [&quot;Users&quot;]<br>})</pre><p>Ne olur?</p><ul><li>updateUser çalışır</li><li>“Users” tag invalid olur</li><li>getUsers otomatik refetch olur</li></ul><p>Manuel refresh yazmazsın.</p><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>RTK Query, endpoint adı ve query parametrelerini cache key olarak kullanarak store içinde veri saklar. Aynı parametreyle tekrar çağrı yapıldığında cache’teki veriyi döner. Ayrıca tag-based invalidation mekanizması sayesinde ilgili mutation sonrası otomatik refetch yapabilir. Bu yapı performans ve veri tutarlılığı sağlar.</em></blockquote><h3>19- REST API entegrasyonunda hangi yapıyı kullanırsın? (Axios vs fetch)</h3><h3>Kısa Cevap</h3><ul><li>Küçük / basit projede → fetch</li><li>Büyük / production projede → <strong>Axios</strong></li><li>Redux Toolkit kullanıyorsam → RTK Query (fetchBaseQuery ile)</li></ul><blockquote><strong>Mülakatta Söylenmesi Gereken Özet<br></strong><em>Basit projelerde native fetch yeterlidir ancak production seviyesinde projelerde interceptor, global config ve gelişmiş error handling nedeniyle Axios tercih ederim. Eğer Redux Toolkit kullanıyorsam, RTK Query’nin fetchBaseQuery yapısı çoğu ihtiyacı karşılar ve ekstra HTTP client’a gerek kalmaz.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86f8405aa323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Great Management Illusion: Why We Chose Drucker’s Control Over Deming’s Wisdom]]></title>
            <link>https://adnanyagmur.medium.com/the-great-management-illusion-why-we-chose-druckers-control-over-deming-s-wisdom-345ca4000438?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/345ca4000438</guid>
            <category><![CDATA[drucker-vs-deming]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[system-manager]]></category>
            <category><![CDATA[management-science]]></category>
            <category><![CDATA[agile-product-managment]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 21:54:33 GMT</pubDate>
            <atom:updated>2026-02-19T21:54:33.577Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i664Q-DyM5xD3ROcrR-12Q.png" /></figure><p>The modern management world appears to be built upon the tension between two massive schools of thought: one shaped in the mid-twentieth century and the other evolving through today’s digital transformation. However, this tension isn’t the balanced struggle you might imagine; it is the story of a hollow victory, much like a building whose foundations have rotted as the tectonic plates beneath it shifted.</p><p>On one side stands <strong>Peter Drucker</strong>, the father of modern management, and the <strong>OKR (Objectives and Key Results)</strong> systems that serve as the modern-day masquerade of his <strong>“Management by Objectives” (MBO)</strong> philosophy. On the other side stands <strong>W. Edwards Deming</strong>, the architect of the quality revolution and the man behind Japan’s post-war economic miracle, with his <strong>“System of Profound Knowledge” (SoPK)</strong>.</p><p>Why did the Western world embrace Drucker like a hero while virtually sentencing Deming to exile? The answer lies in the darkest secret of the business world: <strong>The easy way almost always defeats the right way.</strong></p><p>In this article, we dissect the void behind the gleaming dashboards, the souls crushed by OKR-driven ambitions, and the ultimate lie managers tell themselves.</p><p>Two Giants, Two Different Universes</p><p>Peter Drucker and W. Edwards Deming are etched in history as the two fundamental figures who constructed 20th-century management. However, their approaches to organizational complexity represent two entirely different universes.</p><p><strong>Peter Drucker’s World:</strong> With his 1954 work <em>The Practice of Management</em>, Drucker emphasized the necessity for managers to have quantitative goals. According to him, giving a manager a target was enough to focus their energy.</p><ul><li><strong>The Logic:</strong> “Tell them where to go; they’ll figure out how to get there.”</li><li><strong>Control:</strong> Simple and linear.</li><li><strong>Responsibility:</strong> Rests with the individual who accepts the target.</li></ul><p><strong>W. Edwards Deming’s World:</strong> Deming harshly criticized this approach. To him, management by objectives was an “attempt to manage without knowing what to do” and was one of the “deadly diseases” of management.</p><ul><li><strong>The Logic:</strong> “Understand the system, improve the process, and the results will follow.”</li><li><strong>Control:</strong> Statistical and holistic.</li><li><strong>Responsibility:</strong> 94% lies with the management that designed the system.</li></ul><p>This rift remains relevant today. The vast majority of American and Western companies ignore Deming’s systems thinking in favor of Drucker’s goal-oriented control systems. But why?</p><p>The Thermostat Illusion: Why We Think We Are in Control</p><p>One of the most effective metaphors for understanding management styles is the <strong>“thermostat.”</strong> Drucker’s goal-oriented system resembles a classic feedback control loop.</p><p>A manager sets a desired “temperature” (the goal). The system produces output to reach that goal. If there is a gap (variance) between the goal and the current state, the system is pushed to close it.</p><p>Does this model make you feel safe? It should. Because this model:</p><ol><li>Protects the manager’s limited <strong>cognitive capacity</strong>.</li><li>Reduces a complex world into a binary of “target” vs. “actual.”</li><li>Grants the manager a constant mandate for “taking action.”</li></ol><p>However, Deming’s approach enters here and spoils the fun. Deming advocated for <strong>statistical control</strong>. He argued that to understand if a system is “in control,” one must observe the nature of its variation.</p><p>Deming’s famous <strong>Funnel Experiment</strong> proved that interventions (tampering) in a stable system actually worsen performance by increasing variability rather than improving it. In other words, when you constantly fiddle with the thermostat, you don’t heat the room; you just exhaust and destabilize the system.</p><p>The Manager’s Comfort Zone: The Cognitive Ease Trap</p><p>In the modern business world, managers are actors who spend nearly all their time in meetings, subjected to information overload. This is the real reason why Drucker’s ideas and OKR systems dominate: <strong>Cognitive Ease.</strong></p><p>An organization is inherently complex and chaotic. The Drucker-esque approach allows managers to filter this complexity through simple metrics (Key Results), providing an <strong>“illusion of control.”</strong> This creates a “comfort zone” where the manager feels competent and in charge. Consider two paths:</p><ol><li><strong>The Easy Way (Drucker):</strong> Set goals. Watch the dashboard. Demand accountability when there’s a deviation.</li><li><strong>The Right Way (Deming):</strong> Investigate deeply to understand why the system produced this result. Analyze employee psychology and the interdependence of processes. Patiently increase the system’s capacity.</li></ol><p>Psychological research shows that humans tend to prefer simple, linear models (A causes B) over trying to understand uncertain and complex systems. In management, methods that make the manager’s life easier (but don’t necessarily improve the system) have become corporate standards. This can be explained by the <strong>“Pit of Success”</strong> — systems are designed to make the “right thing” difficult, but because people choose the “easy thing,” they remain stuck in the pit.</p><p>Deming’s “System of Profound Knowledge”: Why Is It So Hard?</p><p>Deming’s philosophy is built on four pillars that are notoriously difficult to implement. The interaction between these pillars creates the “profound knowledge” of an organization.</p><ol><li><strong>Appreciation for a System:</strong> Deming defines an organization as a network of interdependent components working toward a common aim. Optimizing components individually usually sub-optimizes the whole. Drucker’s MBO and OKR systems, by focusing units on their own targets, tend to create silos and internal conflict. A manager might say, “My department hit its goal,” while the company goes bankrupt.</li><li><strong>Knowledge about Variation:</strong> Variation exists in every system. Deming distinguished between “common causes” (inherent to the system) and “special causes” (external interventions). Western managers often react to common-cause variation as if it were a special cause, “tampering” with the system and increasing errors.</li><li><strong>Theory of Knowledge:</strong> This asks, “How do we know what we know?” Deming argues management is prediction, and prediction requires theory. Drucker’s model assumes managers already possess this knowledge; Deming demands a constant process of testing and validation.</li><li><strong>Knowledge of Psychology:</strong> People want to find meaning and pride in their work. Deming argued that numerical goals, ranking systems, and performance bonuses kill intrinsic motivation and replace it with fear. Fear, in turn, leads to the manipulation of data and the hiding of real problems.</li></ol><p>The Hidden Cost of MBO and OKRs: Gaming the System</p><p>The biggest criticism of Drucker’s MBO is that focusing on the goal — independent of the process — encourages unethical behavior. Deming’s warning was clear:</p><blockquote>“If a manager sets numerical targets and ties people’s jobs to them, people will meet those targets — even if they have to destroy the company to do it.”</blockquote><p>The Wells Fargo Example: A Systemic Pathology</p><p>The scandal at Wells Fargo is a painful validation of Deming’s theories. Management set an <strong>“Eight is Great”</strong> goal (selling eight products to every customer) and threatened to fire employees who failed.</p><p>The results were predictable:</p><ul><li><strong>Pressure of Numerical Targets:</strong> Employees opened millions of fake accounts without customers’ knowledge just to hit quotas.</li><li><strong>Metric Obsession:</strong> Upper management celebrated the explosion in sales figures while completely ignoring the “method” behind them.</li><li><strong>Culture of Fear:</strong> Employees who tried to blow the whistle were silenced or punished.</li></ul><p>This is the collapse of Drucker’s assumption that “managers know what to do.” Goals given without specifying the method force people to <strong>game the system</strong> rather than improve it.</p><p>The OKR Deadlock: New Name, Old Problem?</p><p>Today, OKR systems are marketed — especially in the tech world — as a modern, agile version of MBO. But from a Deming perspective, OKRs harbor the same fundamental flaws:</p><ul><li><strong>The Hierarchical Cascade Fallacy:</strong> Cascading goals from top to bottom freezes the hierarchy and destroys flexibility.</li><li><strong>The Strategic Vacuum:</strong> Often, OKRs become a “to-do list” rather than an actual strategic choice.</li><li><strong>Bandwidth Issues:</strong> Setting too many OKRs scatters resources and leads to stagnation.</li><li><strong>Lack of Psychological Safety:</strong> Fear of missing targets leads to “sandbagging” — setting safe, uninspired goals.</li></ul><p>Some experts suggest using <strong>SLOs (Service Level Objectives)</strong> and <strong>SLIs (Service Level Indicators)</strong> instead of OKRs. These focus on system health rather than just output, bringing them closer to Deming’s philosophy.</p><p>“Management by Means” (MBM): The Toyota Way and Deming’s Victory</p><p>While Drucker’s MBO reigned in the West, companies like Toyota institutionalized Deming’s principles under <strong>“Management by Means” (MBM).</strong> The difference is night and day:</p><ul><li><strong>Management by Results (MBR/Drucker):</strong> Priority is on financial targets and quotas. Method: Push the numbers (risk of manipulation). Human role: A tool to reach the target.</li><li><strong>Management by Means (MBM/Deming/Toyota):</strong> Priority is on process stability and employee development. Method: Continuously improve the system’s capacity. Human role: An active problem solver improving the system.</li></ul><p>Toyota involves leaders who spend time at the <strong>“Gemba”</strong> (where the work happens) to set goals based on the system’s actual capacity. This builds a structure that is slower to change than Drucker’s centralized model but infinitely more resilient.</p><p>Why Do We Still Choose Drucker?</p><p>If Deming’s methods yield better results (as seen in Toyota or Scania), why do modern managers remain loyal to Drucker? The answer is hidden in neurological and institutional factors:</p><ol><li><strong>Neural Pathways and Habits:</strong> Classroom-based management training stimulates specific parts of the brain (explicit knowledge). Methods like “Toyota Kata” require building new neural pathways through continuous practice — a biologically taxing process.</li><li><strong>Delegation of Responsibility:</strong> By setting numerical targets, managers can shift the blame for failure onto employees (“They didn’t hit the target”). In Deming’s world, failure is 94% the manager’s responsibility. That burden is a source of unbearable stress for many.</li><li><strong>Short-term Expectations:</strong> Financial markets demand quarterly results. Systemic improvement takes time. The “easy way” is to polish the numbers for the next meeting; the “right way” is to rebuild the foundation.</li></ol><p>Conclusion: Is the Easy Defeating the Right a Fate?</p><p>W. Edwards Deming’s “exile” and Peter Drucker’s dominance is not a victory for management science; it is a result of human nature’s tendency to flee complexity and seek short-term comfort.</p><p>Drucker gave managers a <strong>“thermostat”</strong> and a <strong>“control panel,”</strong> providing a sense of security in a chaotic world. Deming offered them a <strong>“laboratory”</strong> and <strong>“never-ending responsibility.”</strong></p><p>But scandals like Wells Fargo show that the cost of the “easy way” is ultimately much higher than the difficulty of the “right way.” Future organizations must blend Drucker’s “focus” and “alignment” with Deming’s “systemic awareness” and “knowledge of variation.”</p><p>Otherwise, they are destined to remain mechanical structures — hitting their targets while losing their souls and resilience. As Deming famously said:</p><blockquote>“Learning is not compulsory… neither is survival.”</blockquote><p>TL;DR (Summary)</p><ul><li><strong>Two Worlds:</strong> Drucker focuses on “results,” Deming on the “system.” Drucker is easy and comfortable; Deming is hard but sustainable.</li><li><strong>The Thermostat Illusion:</strong> Managers think they are in control by tampering with targets, but this usually destabilizes the system (The Funnel Experiment).</li><li><strong>Cognitive Comfort:</strong> OKR and MBO systems are preferred because they filter complexity into simple metrics, providing an “illusion of control.”</li><li><strong>Systemic Pathology:</strong> Goals independent of process (MBO/OKR) force employees to manipulate the system (e.g., Wells Fargo).</li><li><strong>The Future:</strong> A combination of Drucker’s focus and Deming’s systemic wisdom is required. Choosing the easy path kills the organization’s soul in the long run.</li></ul><p><strong>What about you?</strong>Do you see systemic issues in your organization caused by “target obsession”? Do you think a manager can realistically prioritize long-term “system health” over short-term “glitzy results”?</p><p>Let’s discuss in the comments.</p><p><a href="https://x.com/search?q=%23ManagementScience&amp;src=hashtag_click">#ManagementScience</a></p><p><a href="https://x.com/search?q=%23DruckerVsDeming&amp;src=hashtag_click">#DruckerVsDeming</a></p><p><a href="https://x.com/search?q=%23SystemsThinking&amp;src=hashtag_click">#SystemsThinking</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=345ca4000438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modern Yönetimin Büyük Yanılsaması: Neden “Kolay” Her Zaman Kazanır?]]></title>
            <link>https://medium.com/kodcular/modern-y%C3%B6netimin-b%C3%BCy%C3%BCk-yan%C4%B1lsamas%C4%B1-neden-kolay-her-zaman-kazan%C4%B1r-f149b45cf94e?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/f149b45cf94e</guid>
            <category><![CDATA[drucker-vs-deming]]></category>
            <category><![CDATA[modern-yönetim]]></category>
            <category><![CDATA[modern-managment]]></category>
            <category><![CDATA[sistem-düşüncesi]]></category>
            <category><![CDATA[yönetim-bilimi]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 19:54:07 GMT</pubDate>
            <atom:updated>2026-02-20T11:48:07.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i664Q-DyM5xD3ROcrR-12Q.png" /></figure><p>Modern yönetim dünyası, yirminci yüzyılın ortalarında şekillenen ve günümüzde dijital dönüşümle evrilen iki devasa düşünce okulunun gerilimi üzerine kurulu görünüyor. Ancak bu gerilim, sandığınız gibi dengeli bir mücadele değil; zemindeki levhalar kaymış bir bina gibi, temelleri çürük bir zaferin hikayesi.</p><p>Bir yanda modern yönetimin babası sayılan Peter Drucker ve onun “Hedeflerle Yönetim” (MBO) felsefesinin güncel maskeli balosu olan OKR sistemleri; diğer yanda ise kalite devriminin mimarı, Japonya’nın savaş sonrası mucizesinin arkasındaki isim W. Edwards Deming ve onun “Derin Bilgi Sistemi” (SoPK) duruyor.</p><p>Peki, Batı dünyası neden Drucker’ı bir kahraman gibi kucaklarken, Deming’i neredeyse bir sürgüne mahkum etti? Cevap, iş dünyasının en karanlık sırrında saklı: <strong>Kolay olanın, doğru olanı her zaman yenmesi.</strong></p><p>Bu makalede, panellerdeki gösterge tablolarının (dashboard) arkasında yatan boşluğu, OKR hırslarının bitirdiği ruhları ve yöneticilerin kendilerine kurdukları en büyük yalanı masaya yatırıyoruz.</p><h3>İki Dev, İki Farklı Evren</h3><p>Peter Drucker ve W. Edwards Deming, 20. yüzyılın yönetim anlayışını inşa eden iki temel figür olarak tarihe geçmiştir. Ancak bu iki ismin organizasyonel karmaşıklığa yaklaşımı, birbirinden tamamen farklı iki evreni temsil eder.</p><p><strong>Peter Drucker’ın dünyası:</strong>1954 yılında yayımlanan <em>The Practice of Management</em> eseriyle Drucker, yöneticilerin kantitatif hedeflere sahip olmasının gerekliliğini vurguladı. Ona göre bir yöneticiye hedefi vermek, enerjisini odaklaması için yeterliydi.</p><p>Yani:</p><ul><li>“Nereye gideceğini söyle, nasıl gideceğini sen bilirsin.”</li><li>Kontrol basit ve doğrusaldır.</li><li>Sorumluluk, hedefi alan bireydedir.</li></ul><p><strong>W. Edwards Deming’in dünyası:</strong>Deming ise bu yaklaşımı sert bir dille eleştirdi. Ona göre hedeflerle yönetim, “ne yapılacağını bilmeden yönetme girişimi”ydi ve yönetimin “ölümcül hastalıklarından” biriydi.</p><ul><li>“Sistemi anla, süreci iyileştir, sonuçlar kendiliğinden gelecektir.”</li><li>Kontrol istatistiksel ve bütünseldir.</li><li>Sorumluluk %94 oranında sistemi tasarlayan yönetimdedir.</li></ul><p>Bu ayrım, günümüzde hâlâ geçerlidir. Amerikan ve Batılı şirketlerin büyük çoğunluğu, Deming’in sistem düşüncesini görmezden gelerek Drucker’ın hedef odaklı kontrol sistemlerini tercih etmektedir. Peki neden?</p><p>Termostat Yanılsaması: Neden Kontrol Ettiğimizi Sanıyoruz?</p><p>Yönetim yaklaşımlarını anlamak için en etkili metaforlardan biri “termostat” örneğidir. Drucker’ın hedef odaklı sistemi, klasik bir geri besleme kontrol sistemi olan termostata benzer.</p><p>Bir yönetici, istenen bir “sıcaklık” (hedef) belirler. Sistem bu hedefe ulaşmak için çıktı üretir. Eğer hedef ile mevcut durum arasında bir fark (varyans) varsa, sistem bu farkı kapatmak için zorlanır.</p><p>Bu model size güven verir mi? Vermeli. Çünkü bu model:</p><ul><li>Yöneticinin sınırlı bilişsel kapasitesini korur.</li><li>Karmaşık dünyayı “hedef” ve “gerçek” ikilemine indirger.</li><li>Yöneticiye sürekli bir “aksiyon alma” yetkisi verir.</li></ul><p>Ancak Deming’in yaklaşımı bu noktada devreye girer ve oyunu bozar. Deming, istatistiksel kontrolü savunur. Ona göre bir sistemin “kontrol altında” olup olmadığını anlamak için değişkenliğin doğasını gözlemlemek gerekir.</p><p>Deming’in ünlü <strong>Huni Deneyi (Funnel Experiment)</strong>, istikrarlı bir sisteme yapılan müdahalelerin (tampering), sistemi iyileştirmek yerine aslında değişkenliği artırarak performansı kötüleştirdiğini kanıtlamıştır.</p><p>Yani termostatı sürekli kurcaladığınızda, odayı ısıtmazsınız; sadece sistemi yorar ve dengesizleştirirsiniz.</p><h3>Yöneticinin Konfor Alanı: Bilişsel Tasarruf Tuzağı</h3><p>Modern iş dünyasında yöneticiler, zamanlarının neredeyse tamamını toplantılarda geçiren ve aşırı bilgi yüklemesine maruz kalan aktörlerdir. İşte Drucker’ın fikirlerinin ve OKR gibi sistemlerin baskın hale gelmesinin altında yatan gerçek neden budur: <strong>Bilişsel Tasarruf.</strong></p><p>Bir organizasyon, doğası gereği karmaşık ve kaotik bir yapıdır. Drucker’cı yaklaşım, yöneticilerin bu karmaşıklığı basit metriklerle (Key Results) filtreleyerek “kontrol yanılsaması” (illusion of control) elde etmesini sağlar.</p><p>Bu durum, yöneticinin kendisini yetkin ve kontrol sahibi hissettiği bir “konfor alanı” yaratır. İki yol olduğunu düşünelim:</p><p><strong>1. Kolay Yol (Drucker):</strong></p><ul><li>Hedefleri belirle.</li><li>Dashboard’u izle.</li><li>Sapma olduğunda hesap sor.</li></ul><p><strong>2. Doğru Yol (Deming):</strong></p><ul><li>Sistemin neden bu sonucu ürettiğini anlamak için derinlemesine araştırma yap.</li><li>Çalışanların psikolojisini ve süreçlerin birbirine bağımlılığını analiz et.</li><li>Sabırla sistemin kapasitesini artır.</li></ul><p>Psikolojik araştırmalar, insanların belirsiz ve karmaşık sistemleri anlamaya çalışmak yerine, basit ve doğrusal (A sebep olur B) modelleri tercih etme eğiliminde olduğunu göstermektedir.</p><p>Yönetim dünyasında, yöneticinin hayatını kolaylaştıran (fakat sistemi iyileştirmeyen) yöntemler, kurumsal birer standart haline gelmiştir. Bu, “Başarı Çukuru” (Pit of Success) kavramıyla açıklanabilir: Sistemler, doğru olanı zor yapacak şekilde tasarlanmıştır, ancak insanlar kolay olanı seçtiği için çukurun içinde kalırlar.</p><p>Deming’in “Derin Bilgi Sistemi”: Neden Bu Kadar Zor?</p><p>Deming’in yönetim felsefesi, uygulanması oldukça zor olan dört temel sütun üzerine inşa edilmiştir. Bu sütunlar arasındaki etkileşim, organizasyonun “derin bilgisini” oluşturur. Peki, neden bu kadar kaçınılıyor?</p><p>1. Sistem Anlayışı (Appreciation for a System)</p><p>Deming, bir organizasyonu ortak bir amaç doğrultusunda çalışan birbirine bağımlı bileşenler ağı olarak tanımlar. Bir sistemin parçalarını optimize etmek, sistemin bütününü genellikle alt-optimize eder.</p><p>Drucker’ın MBO ve OKR sistemleri ise, doğası gereği birimleri kendi hedeflerine odakladığı için departmanlar arası silolar ve çatışmalar yaratma eğilimindedir. Yönetici, “Benim departmanım hedefine ulaştı” diyebilir ama şirket batmış olabilir.</p><p>2. Varyasyon Bilgisi (Knowledge about Variation)</p><p>Her sistemde değişkenlik vardır. Deming, bu değişkenliği “genel nedenler” (sistemin kendisinden kaynaklanan) ve “özel nedenler” (dışsal müdahaleler) olarak ikiye ayırmıştır.</p><p>Batılı yöneticiler genellikle genel nedenli varyasyonlara (sistemin doğal dalgalanmalarına) birer özel nedenmiş gibi tepki vererek sistemi kurcalarlar. Bu da hataların artmasına yol açar.</p><p>3. Bilgi Teorisi (Theory of Knowledge)</p><p>“Bildiğimizi nasıl biliyoruz?” sorusunu sorar. Deming’e göre yönetim bir tahmin işidir ve tahmin için teori gereklidir. Drucker’ın modeli yöneticilerin halihazırda bu bilgiye sahip olduğunu varsayar, Deming sürekli bir test ve doğrulama süreci talep eder.</p><p>4. Psikoloji Bilgisi</p><p>İnsanlar işlerinden gurur duymak ve bir anlam bulmak ister. Deming, sayısal hedeflerin, sıralama sistemlerinin ve performans primlerinin içsel motivasyonu öldürdüğünü ve yerine korkuyu getirdiğini savunur. Korku ise verilerin manipüle edilmesine ve gerçek sorunların gizlenmesine neden olur.</p><h3>MBO ve OKR’lerin Gizli Maliyeti: Sistemi Oyunlaştırmak</h3><p>Drucker’ın MBO sisteminin en büyük eleştirisi, süreçten bağımsız olarak hedefe odaklanmanın etik olmayan davranışları teşvik etmesidir. Deming’in uyarısı nettir:</p><blockquote><em>“Eğer yönetici sayısal hedefler koyar ve insanların işini buna bağlarsa, insanlar o hedeflere ulaşacaklardır — gerekirse şirketi mahvetmek pahasına.”</em></blockquote><p>Wells Fargo Örneği: Sistemsel Bir Patoloji</p><p>Wells Fargo bankasında yaşanan skandal, Deming’in teorilerinin acı bir kanıtıdır. Banka yönetimi, “Eight is Great” (Her müşteriye sekiz ürün satma) hedefi koymuş ve bu hedefe ulaşamayan çalışanları işten çıkarmakla tehdit etmiştir.</p><p>Sonuçlar ortadadır:</p><ul><li><strong>Sayısal Hedeflerin Baskısı:</strong> Çalışanlar, sadece kotaları dörmak için müşterilerden habersiz milyonlarca sahte hesap açmıştır.</li><li><strong>Metrik Takıntısı:</strong> Üst yönetim, satış rakamlarındaki patlamayı kutlarken, bu rakamların nasıl elde edildiğine dair “yöntem” bilgisini tamamen görmezden gelmiştir.</li><li><strong>Korku Kültürü:</strong> Uyarıda bulunan çalışanlar susturulmuş veya cezalandırılmıştır.</li></ul><p>Bu durum, Drucker’ın “yöneticiler ne yapacaklarını bilir” varsayımının çöküşüdür. Yöntem belirtilmeden verilen hedefler, sistemi iyileştirmek yerine sistemi oyunlaştırmaya (gaming) zorlar.</p><p>OKR’lerin Çıkmazı: Yeni Bir İsim, Eski Bir Sorun mu?</p><p>Günümüzde OKR (Objectives and Key Results) sistemleri, özellikle teknoloji dünyasında MBO’nun daha modern ve çevik bir versiyonu olarak pazarlanmaktadır. Ancak Deming perspektifinden bakıldığında, OKR’ler de aynı temel hataları barındırmaktadır.</p><p>OKR’lerin uygulanmasında karşılaşılan temel sorunlar şunlardır:</p><ul><li><strong>Hiyerarşik Kaskat Yanılgısı:</strong> Hedeflerin tepeden tırnağa “kaskat” şeklinde indirilmesi, organizasyonel hiyerarşiyi dondurur ve esnekliği yok eder.</li><li><strong>Stratejik Boşluk:</strong> Çoğu zaman OKR’ler, gerçek bir stratejik seçimden ziyade sadece “yapmak istediğimiz şeylerin listesi” haline gelir.</li><li><strong>Bant Genişliği Sorunu:</strong> Çok fazla OKR belirlenmesi, odaklanmayı artırmak yerine kaynakların dağılmasına ve stagnasyona yol açar.</li><li><strong>Psikolojik Güvenlik Eksikliği:</strong> Hedeflere ulaşamama korkusu, ekiplerin “güvenli” ve sönük hedefler belirlemesine (sandbagging) neden olur.</li></ul><p>Bazı uzmanlar, OKR’lerin yerine süreç odaklı olan SLO (Service Level Objectives) ve SLI (Service Level Indicators) kullanımını önermektedir. Bu yaklaşım, çıktıyı değil, sistemin sağlığını ölçtüğü için Deming’in felsefesine daha yakındır.</p><h3>“Management by Means” (MBM): Toyota Yolu ve Deming’in Zaferi</h3><p>Drucker’ın MBO felsefesi Batı’da hüküm sürerken, Toyota gibi şirketler Deming’in ilkelerini “Management by Means” (Yöntemlerle Yönetim — MBM) adı altında kurumsallaştırmıştır.</p><p>Bu iki yaklaşım arasındaki fark, gece ile gündüz kadardır:</p><p><strong>Management by Results (MBR/Drucker):</strong></p><ul><li>Öncelik: Finansal hedefler ve kotalar.</li><li>Yöntem: Sayıları zorlamak (Manipülasyon riski).</li><li>İnsan Rolü: Hedefe ulaşmak için kullanılan bir araç.</li></ul><p><strong>Management by Means (MBM/Deming/Toyota):</strong></p><ul><li>Öncelik: Süreç istikrarı ve çalışan gelişimi.</li><li>Yöntem: Sistemin kapasitesini sürekli iyileştirmek.</li><li>İnsan Rolü: Sistemi iyileştiren aktif bir problem çözücü.</li></ul><p>Toyota, hedeflerini belirlerken “Gemba”da (işin yapıldığı yer) vakit geçiren ve sistemin gerçek kapasitesini bilen liderleri sürece dahil eder. Bu, Drucker’ın merkeziyetçi hedef koyma modeline kıyasla çok daha yavaş ancak çok daha dirençli bir yapı inşa eder.</p><h3>Neden Hâlâ Drucker’ı Seçiyoruz?</h3><p>Deming’in yöntemlerinin daha başarılı sonuçlar verdiği (Toyota ve Scania örneklerinde olduğu gibi) açıkken, neden modern yöneticiler hâlâ Drucker’cı yöntemlere sadık kalmaktadır?</p><p>Cevap sadece psikolojik değil, aynı zamanda nörolojik ve kurumsal faktörlerde gizlidir.</p><p>1. Nöral Yollar ve Alışkanlıklar</p><p>Sınıf temelli yönetim eğitimi, beynin belirli bölüllerini (kodlanmış ve açık bilgi) çalıştırır. Deming’in önerdiği “Toyota Kata” gibi yöntemler ise pratik ve sürekli uygulama gerektiren yeni nöral yollar inşa etmeyi gerektirir. Bu da biyolojik olarak zahmetli bir süreçtir.</p><p>2. Sorumluluğun Devri</p><p>Yöneticiler, sayısal hedefler koyarak başarısızlığın sorumluluğunu çalışanlara devredebilirler (“Hedefi tutturamadılar”). Deming’in sisteminde ise başarısızlık %94 oranında yöneticinin sorumluluğundadır çünkü sistemi o tasarlamıştır. Bu sorumluluk duygusu, çoğu yönetici için dayanılmaz bir strese neden olur.</p><p>3. Kısa Vadeli Beklentiler</p><p>Finans piyasaları ve hissedarlar, üç aylık (quarterly) sonuçlar bekler. Deming’in sistemik iyileştirmesi ise zaman alır. “Kolay olan”, bir sonraki toplantıya kadar sayıları “parlatmak” iken; “doğru olan”, sistemin temelini yeniden inşa etmektir.</p><h3>Sonuç: Kolay Olanın Doğru Olanı Yenmesi Bir Kader mi?</h3><p>W. Edwards Deming’in “sürgünde” kalması ve Peter Drucker’ın hakimiyeti, yönetim biliminin bir zaferi değil, insan doğasının karmaşıklıktan kaçma ve kısa vadeli konforu arama eğiliminin bir sonucudur.</p><p>Drucker, yöneticilere bir “termostat” ve bir “kontrol paneli” sunarak onlara modern dünyanın karmaşasında bir güvenlik hissi vermiştir. Deming ise onlara bir “laboratuvar” ve “bitmek bilmeyen bir sorumluluk” teklif etmiştir.</p><p>Ancak Wells Fargo skandalı ve benzeri kurumsal facialar göstermektedir ki, “kolay olanın” maliyeti uzun vadede “doğru olanın” zorluğundan çok daha yüksektir. Geleceğin organizasyonları, Drucker’ın sağladığı “odaklanma” ve “hizalanma” yeteneklerini, Deming’in “sistem bilinci” ve “değişkenlik bilgisi” ile harmanlamak zorundadır.</p><p>Aksi takdirde, sadece hedeflere ulaşan ama bu süreçte ruhunu ve dayanıklılığını kaybeden “mekanik” yapılar olarak kalmaya mahkum olacaklardır.</p><p>“Doğru olan yöntem” zor olsa da, organizasyonun hayatta kalması için tek gerçek yoldur; çünkü Deming’in de dediği gibi:</p><blockquote><em>“Değişmek zorunda değilsiniz, hayatta kalmak zorunlu değildir.”</em></blockquote><p>Kısaca Özet (TL;DR)</p><ul><li><strong>İki Farklı Dünya:</strong> Drucker “sonuçlara”, Deming “sisteme” odaklanır. Drucker kolay ve konforludur, Deming zor ama sürdürülebilirdir.</li><li><strong>Termostat Yanılsaması:</strong> Yöneticiler, hedefleri sürekli kurcalayarak (termostat gibi) kontrol ettiklerini sanırlar, ancak bu genellikle sistemi daha da bozar (Huni Deneyi).</li><li><strong>Bilişsel Konfor:</strong> OKR ve MBO sistemleri, yöneticinin karmaşıklığı basit metriklerle filtreleyip “kontrol yanılsaması” yaşamasını sağladığı için tercih edilir.</li><li><strong>Sistemsel Patoloji:</strong> Wells Fargo örneğinde görüldüğü gibi, süreçten bağımsız hedefler (MBO/OKR), çalışanları sistemi manipüle etmeye ve etik dışı davranışlara iter.</li><li><strong>Gelecek:</strong> Drucker’ın odaklanma yeteneği ile Deming’in sistem bilincinin birleşimi gereklidir. Kolay yolu seçmek, uzun vadede şirketin ruhunu öldürür.</li></ul><p><strong>Peki ya siz?</strong></p><p>Çalıştığınız veya yönettiğiniz organizasyonda “hedef takıntısı” yüzünden sistemsel sorunlar görüyor musunuz? Sizce bir yönetici, kısa vadeli “parlak sonuçlar” yerine uzun vadeli “sistem sağlığı”nı seçebilir mi?</p><p>Düşüncelerinizi yorumlarda belirtin, bu önemli tartışmayı büyütelim.</p><p><a href="https://x.com/search?q=%23Y%C3%B6netimBilimi&amp;src=hashtag_click">#YönetimBilimi</a></p><p><a href="https://x.com/search?q=%23DruckerVsDeming&amp;src=hashtag_click">#DruckerVsDeming</a></p><p><a href="https://x.com/search?q=%23SistemD%C3%BC%C5%9F%C3%BCncesi&amp;src=hashtag_click">#SistemDüşüncesi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f149b45cf94e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kodcular/modern-y%C3%B6netimin-b%C3%BCy%C3%BCk-yan%C4%B1lsamas%C4%B1-neden-kolay-her-zaman-kazan%C4%B1r-f149b45cf94e">Modern Yönetimin Büyük Yanılsaması: Neden “Kolay” Her Zaman Kazanır?</a> was originally published in <a href="https://medium.com/kodcular">Kodcular</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to edit environment variables in React Vite project?]]></title>
            <link>https://medium.com/kodcular/how-to-edit-environment-variables-in-react-vite-project-f628c5a08e0a?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/f628c5a08e0a</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Tue, 05 Aug 2025 16:50:21 GMT</pubDate>
            <atom:updated>2025-08-05T16:50:21.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wyjfjqVXaAgCUnP391XhLw.png" /></figure><blockquote>When building a React project with Vite, managing environment variables correctly is crucial — especially when working with multiple environments like development, staging, and production. In this guide, we’ll explore how to properly define, access, and use environment variables in a React + Vite project.</blockquote><h3>📁 1. Understanding .env Files in Vite</h3><p>Vite supports loading environment variables from special .env files located at the root of your project. Here are the common types:</p><pre>| File Name          | Purpose                                         |<br>| ------------------ | ----------------------------------------------- |<br>| `.env`             | Base variables (shared across all environments) |<br>| `.env.local`       | Machine-specific variables (ignored by Git)     |<br>| `.env.development` | Used only during development                    |<br>| `.env.production`  | Used when building for production               |</pre><p>This structure helps you easily switch configurations based on the environment you’re working in.</p><h3>📝 2. Declaring Environment Variables</h3><p>In Vite, <strong>all environment variables you want to expose to your frontend must start with </strong><strong>VITE_</strong>. This is a security measure to prevent accidental exposure of sensitive data.</p><pre># ✅ Correct<br>VITE_API_URL=https://api.myproject.com<br><br># ❌ Will NOT work<br>API_SECRET_KEY=my-secret</pre><p>⚠️ Only variables prefixed with VITE_ will be available inside your app. Others will be ignored.</p><h3>🔍 3. Accessing Variables in Your Code</h3><p>To access an environment variable in your React components or utility files, use:</p><pre>const apiUrl = import.meta.env.VITE_API_URL;</pre><h4>TypeScript Support</h4><p>To avoid TypeScript errors, add the following to a env.d.ts file in your project:</p><pre>interface ImportMetaEnv {<br>  readonly VITE_API_URL: string;<br>  // add more as needed<br>}<br><br>interface ImportMeta {<br>  readonly env: ImportMetaEnv;<br>}</pre><h3>⚙️ 4. Restart Your Dev Server!</h3><p>Every time you change .env files, make sure to <strong>restart your development server</strong>. Vite only loads .env files on startup.</p><pre># Stop the dev server<br>Ctrl + C<br><br># Restart it<br>npm run dev</pre><h3>🔐 5. Security Warning</h3><p>Environment variables in a frontend project are <strong>not secure</strong> — even if you use .env.local or .env.production. Anything included will be bundled and exposed in the final JavaScript output.</p><p>So never put secrets like:</p><ul><li>Database credentials</li><li>Private API keys</li><li>Admin tokens</li></ul><p>Instead, store those securely in your backend or serverless functions.</p><h3>🔨 6. Using Variables in vite.config.ts</h3><p>You can also use environment variables inside your vite.config.ts:</p><pre>import { defineConfig } from &#39;vite&#39;;<br><br>export default defineConfig({<br>  base: process.env.VITE_PUBLIC_PATH || &#39;/&#39;,<br>});</pre><p>However, in vite.config.ts, you’ll need to use process.env instead of import.meta.env, because it runs in Node.js context.</p><h3>✅ 7. Real-World Example: Fetching Data</h3><p>Let’s say your API URL is different for development and production.</p><blockquote>.env.development:</blockquote><pre>VITE_API_URL=http://localhost:3000/api<br></pre><blockquote>.env.production:</blockquote><pre>VITE_API_URL=https://api.myproject.com</pre><blockquote>App.tsx</blockquote><pre>const App = () =&gt; {<br>  useEffect(() =&gt; {<br>    fetch(`${import.meta.env.VITE_API_URL}/posts`)<br>      .then(res =&gt; res.json())<br>      .then(data =&gt; console.log(data));<br>  }, []);<br><br>  return &lt;div&gt;Hello World&lt;/div&gt;;<br>};</pre><h3>💡 8. Best Practices</h3><ul><li>✅ Use .env.local for machine-specific overrides and <strong>add it to </strong><strong>.gitignore</strong>.</li><li>✅ Group related variables together for readability.</li><li>✅ Create a config.ts file to centralize and document your variables.</li><li>❌ Don’t expose sensitive credentials — frontend is not a safe place.</li><li>❌ Don’t forget to restart your dev server after edits.</li></ul><p>📚 Resources:</p><p><a href="https://vite.dev/guide/env-and-mode.html">Env Variables and Modes</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjqCjflIGH1o%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjqCjflIGH1o&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjqCjflIGH1o%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1135e3c166cd89879ffa0c07d09e964/href">https://medium.com/media/c1135e3c166cd89879ffa0c07d09e964/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f628c5a08e0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kodcular/how-to-edit-environment-variables-in-react-vite-project-f628c5a08e0a">How to edit environment variables in React Vite project?</a> was originally published in <a href="https://medium.com/kodcular">Kodcular</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DOM API NEDİR?]]></title>
            <link>https://medium.com/kodcular/dom-api-nedi%CC%87r-37664be803d4?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/37664be803d4</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[dom]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Mon, 25 Dec 2023 10:41:07 GMT</pubDate>
            <atom:updated>2025-08-06T00:54:48.883Z</atom:updated>
            <content:encoded><![CDATA[<h4>DOM (Belge Nesne Modeli), web geliştiricilerinin sayfa boyutunda programlı bir şekilde manipüle etme yeteneğini sağlayan güçlü bir araçtır. Bu bölümde DOM&#39;un temel özelliklerini anlamaya odaklanacağız.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edxAwYlCiQ11Zk8oqo_oXA.png" /></figure><h4>DOM Kavramı</h4><p>DOM&#39;un Esası: Hiyerarşik Nesne Modeli</p><p>DOM&#39;un temel özelliği, web sayfalarındaki her bir öğeyi bir nesne olarak ele almak ve bu konuları arasında sunulan bir ilişki kurmasıdır. HTML veya XML belgeleri, DOM tarafından bir ağaç yapısı olarak temsil edilir. Onun bir öğesi (öğesi), bir “düğüm” olarak adlandırılır ve bu düğüm, birbirine ebeveyn ve çocuk ilişkilerine bağlıdır. Bu özgün nesne modeli, sayfanın güncelliğini ve özelliklerini programlı bir şekilde manipüle etmek için geliştiricilere olanak tanır.</p><p>DOM&#39;un Görevi: İnteraktivite ve Dinamizm</p><p>Web siteleri artık sadece statik içerik sunan yapılardan çok daha fazlasıdır. Kullanıcıların etkileşimde bulunabileceği, dinamik içerikle dolu ve anlık güncellemelere uyum sağlayabilen web siteleri, DOM&#39;un gücünden beslenir. JavaScript gibi programlama dilleri DOM API aracılığıyla, sayfa içeriği canlı olarak değiştirilebilir, yeni özellikler eklenip çıkartılabilir ve hatta tarayıcıya tepki verilebilir. Böylece kullanıcılar daha zengin ve kişiselleştirilmiş bir web deneyimi yaşarlar.</p><h4><strong>DOM&#39;un Temel Özellikleri</strong></h4><p><strong>DOM Ağacı ve Hiyerarşik Yapı:</strong> DOM, bir ağaç yapısı üzerine kuruludur. En üst düğüm olan “belge” nesnesi, tüm sayfayı temsil eder. Bu nesnenin altında, sayfadaki her öğe (eleman) birer düğüm (düğüm) olarak bulunur. Bu görsel yapı, sayfa sürekliliğini düzenli bir şekilde temsil eder ve programlar tarafından kolayca gezilebilir.</p><p><strong>DOM Node&#39;ları ve NodeList:</strong> DOM&#39;da her öğe bir “node” olarak adlandırılır. Düğümlerin, belirli bir öğenin bileşimi, türü ve diğer özellikleri temsil eder. Örneğin, bir metin içeren bir paragraf bir “Metin” düğümüne sahiptir. Birden fazla düğüm, bir “NodeList” içinde toplanabilir ve bu liste üzerinden çalıştırma üzerinde toplu işlemler yapılabilir.</p><p><strong>Elementlere Erişim ve Seçim:</strong> DOM API, belirli elementlere erişim sağlayan bir dizi yöntemi içerir. getElementById, getElementsByClassName, getElementsByTagNamegibi yöntemler, kararlı ilerlemelere hızlı bir şekilde ulaşmak için kullanılır. Bu özellik, sayfadaki içeriğin belirli bölümlerine göre seçmek ve düzenlemek için oldukça kullanışlıdır.</p><p><strong>Düğüm Manipülasyonu:</strong> DOM, sayfa gücü dinamik olarak değişiklik ve güncelleme için bir dizi yöntem ve özellik sunar. Düğüm ekleme ( appendChild), düğüm silme ( removeChild), düğüm yer değiştirme gibi işlemler, sayfanın dinamik ve etkileşimli olmasını sağlar.</p><p><strong>Özellik ve Stil Değiştirme:</strong> DOM, sayfa üzerindeki öğelerin özelliklerini ve stillerini değiştirmek için metodlar sunar. Özellikle, setAttribute, removeAttribute gibi metodlar öğe özelliklerini düzenleme konusunda güçlü araçlardır. Aynı şekilde, style özelliği aracılığıyla öğelerin stil özellikleri de programlı bir şekilde değiştirilebilir.</p><p><strong>Olaylar ve Etkileşim:</strong> DOM, kullanıcı etkileşimlerine tepki vermek üzere olayları yönetme yeteneği sunar. Örneğin, bir düğmeye tıklanma olayı (click event) yakalanabilir ve bu olaya bir tepki olarak belirli bir işlem gerçekleştirilebilir. Bu özellik, interaktif web sayfalarının temelini oluşturur.</p><h4>Tarayıcılar Arası Uyumlu DOM API</h4><p>DOM API, tarayıcılar arasında genellikle standart bir şekilde uygulanır. Ancak, farklı tarayıcılar arasındaki bazı farklılıklar nedeniyle, web geliştiricileri genellikle tarayıcı uyumluluğunu göz önünde bulundurmalıdır. Bu, projelerin farklı tarayıcılarda doğru şekilde çalışmasını sağlamak için önemlidir.</p><h4>DOM API’nin Programlamada Rolü</h4><p>DOM API, web geliştiricilerine sayfadaki öğelerle etkileşimde bulunma yeteneği sağlar. JavaScript gibi programlama dilleri aracılığıyla kullanılan DOM API metodları, belirli öğeleri seçme, içeriği değiştirme, yeni öğeler ekleme veya var olanları kaldırma gibi işlemleri gerçekleştirmek için kullanılır. Bu, web sayfalarının dinamik ve etkileşimli olmasını sağlar.</p><h4>Basit bir DOM manipülasyonu</h4><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;DOM Manipülasyonu Örneği&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1 id=&quot;baslik&quot;&gt;Merhaba, Dünya!&lt;/h1&gt;<br>    &lt;button id=&quot;degistirBtn&quot;&gt;Başlığı Değiştir&lt;/button&gt;<br><br>    &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><pre>// DOM&#39;da belirli öğeleri seçmek için getElementById kullanılır.<br>const baslikElementi = document.getElementById(&quot;baslik&quot;);<br>const degistirBtn = document.getElementById(&quot;degistirBtn&quot;);<br><br>// Düğmeye tıklandığında başlığı değiştiren bir fonksiyon<br>function baslikDegistir() {<br>    // innerHTML, HTML içeriğini değiştirmek için kullanılır.<br>    baslikElementi.innerHTML = &quot;Merhaba, DOM Manipülasyonu!&quot;;<br>}<br><br>// Düğmeye tıklandığında baslikDegistir fonksiyonunu çağırma<br>degistirBtn.addEventListener(&quot;click&quot;, baslikDegistir);</pre><ol><li>HTML dosyasında &lt;script&gt; etiketi içinde script.js dosyasını ekledik. Bu dosya, JavaScript kodlarımızı içerecek.</li><li>JavaScript dosyasında getElementById metodu ile HTML içindeki belirli öğeleri seçtik. baslikElementi, başlığı temsil eden &lt;h1&gt; öğesini, degistirBtn ise düğmeyi temsil eden &lt;button&gt; öğesini temsil eder.</li><li>baslikDegistir fonksiyonu, düğmeye tıklandığında başlığı değiştirecek. innerHTML özelliği sayesinde başlığın içeriğini güncelliyoruz.</li><li>addEventListener fonksiyonu ile düğmeye tıklanma olayını dinliyoruz. Düğme tıklandığında baslikDegistir fonksiyonu çağrılacak.</li></ol><h4>DOM API’nin Avantajları ve Zorlukları</h4><p>DOM API (Document Object Model Application Programming Interface), web geliştiricilerine sayfalarındaki öğeleri programlı bir şekilde manipüle etme yeteneği sağlar. Ancak, bu güçlü araç kullanılırken karşılaşılan avantajlar ve zorluklar vardır.</p><h4>Avantajlar</h4><p><strong>1. Hızlı ve Etkili İşlemler:</strong> DOM API, web sayfalarındaki öğelere hızlı ve etkili bir şekilde erişim sağlar. Bu, sayfa içeriğini dinamik olarak değiştirme veya güncelleme işlemlerinin hızlı bir şekilde gerçekleştirilmesini mümkün kılar.</p><p><strong>2. İnteraktivite ve Kullanıcı Deneyimi: </strong>DOM API, interaktif web sayfalarının temelini oluşturur. Kullanıcı etkileşimlerine tepki vererek sayfa içeriğini dinamik bir şekilde güncellemek, kullanıcı deneyimini zenginleştirir ve daha etkileşimli bir web sitesi oluşturmanın önünü açar.</p><p><strong>3. Dinamik Sayfalar Oluşturma:</strong> Web sayfalarını statik olmaktan çıkarıp dinamik hale getirmek, kullanıcılara özelleştirilmiş içerikler sunmak için DOM API’nin kullanımı kaçınılmazdır. Bu, modern web uygulamalarının ve dinamik içerikli sitelerin temelini oluşturur.</p><h4>Zorluklar</h4><p><strong>1. Tarayıcı Uyumlu Olma:</strong> Farklı tarayıcılar, DOM API’yi farklı şekillerde uygulayabilir. Bu durum, geliştiricilerin tarayıcı uyumluluğunu gözetmelerini ve projelerini farklı tarayıcılarda test etmelerini gerektirir.</p><p><strong>2. Performans İlişkilendirmeleri:</strong> Büyük ve karmaşık DOM ağaçları, sayfaların yüklenmesi ve işlem sürelerini değiştirebilir. Özellikle büyük uygulamalarda, DOM bozulmaları performans sorunlarına neden olabilir. Bu nedenle etkili ve optimize edilmiş DOM izolasyonlarının sağlanması önemlidir.</p><p>Bu yazı dizisi, DOM API&#39;nin gerçekleştirilebilir, kullanılması ve geliştirilmesi isteyen web geliştiricilerine konu hakkında ön fikir hızlı bilgi edinimini sağlar. . DOM API ile ilgili daha fazla bilgi edinme, bilgi edinme ve uygulamaları geliştirmek için pratik yapmak, geliştiricilerin yeteneklerini geliştirmelerine yardımcı olabileceğiniz kaynakları aşağıda bırakıyorum:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model">Document Object Model (DOM) - Web APIs | MDN</a></li><li><a href="https://www.w3schools.com/jsref/dom_obj_document.asp">HTML DOM Document Object</a></li><li><a href="https://www.geeksforgeeks.org/html-dom-dt-object/?ref=lbp">HTML | DOM DT Object - GeeksforGeeks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37664be803d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kodcular/dom-api-nedi%CC%87r-37664be803d4">DOM API NEDİR?</a> was originally published in <a href="https://medium.com/kodcular">Kodcular</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classes and Objects in Java (Detailed)]]></title>
            <link>https://medium.com/kodcular/classes-and-objects-in-java-detailed-9e9098ffeb04?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e9098ffeb04</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Mon, 08 May 2023 10:56:50 GMT</pubDate>
            <atom:updated>2023-05-08T10:56:50.593Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*D6enwr_bwRPLPagO5A4OoA.png" /></figure><p>Java is one of the most popular programming languages nowadays. It is an object-oriented programming language and hence, it is quite popular in the programming world. The advantages that Java offers in object-oriented programming have made it quite popular among software developers. So, what is object-oriented programming? Knowing about this topic is important to better understand Java.</p><p>Object-oriented programming (OOP) is an important concept in the programming world. OOP allows you to write code based on objects in a more organized way by making it possible to base the code on objects. This approach helps you to solve complex problems more easily and create a more modular codebase.</p><p>Java stands out as a powerful language in object-oriented programming. In Java, everything is done through objects and classes. Classes allow the bringing together of objects with similar properties, while objects are instances of classes. In Java, every object must be an instance of a class.</p><p>For example, let’s say you want to create a car object. Let the car have properties like color, make, model, etc. In Java, you need to create a Car class to define these properties. This class includes the properties and behaviors (methods) of the Car object. The car object, on the other hand, is an instance of the Car class, and corresponds to a real-world car.</p><p>Java’s object-oriented structure makes the code more understandable and less prone to errors. Additionally, the object-oriented approach makes it easier for larger teams to work on programming projects together. Writing the code in a more modular way allows different programmers to work on a specific class or object.</p><p>The general flow of the article is as follows: Classes Objects Inheritance Polymorphism Abstract Classes and Interfaces</p><h3>1-) Classes</h3><h4>Overview of Classes</h4><p>A class can be thought of as a plan or a template that defines the definition of an object. A class defines the properties (variables) and behaviors (methods) of an object. For example, let’s say we create a Car class. The properties of this class could be the car’s color, make, model, etc. Methods can define the car’s behaviors, such as starting it up, stopping it, increasing its speed, etc.</p><p>Classes enable related objects to come together. Therefore, the properties and behaviors of classes apply to objects derived from those classes. An object derived from a class can be thought of as an instance of that class. Objects have the properties of the class and can perform the class’s behaviors.</p><p>Objects are representations of entities in the real world. For example, a Car object can be thought of as a representation of a car in the real world. Situations where objects interact with each other are usually managed by classes that depend on each other. These interactions can occur when different objects communicate with each other, or when one object performs an operation on another.</p><h4>Defining and Using Classes</h4><p>Class definitions are created using a block of code that must include the following attributes:</p><p>Class name: Classes have names, which are typically chosen according to naming conventions.</p><p>Variables: The class’s variables are data types that define the object’s properties. For example, in a Car class, variables like color, make, and model could be defined.</p><p>Methods: The class’s methods are blocks of code that define the object’s behavior. For example, in a Car class, methods like move, brake, and accelerate could be defined.</p><p>Constructor: The class’s constructor determines how objects will be created. This method must have the same name as the class.</p><p>Example of Class Definition:</p><p>The following example shows how a Car class is defined:</p><pre>public class Car {<br>   // Variables<br>   String color;<br>   String make;<br>   int model;<br><br>   // Constructor<br>   public Car(String color, String make, int model) {<br>      this.color = color;<br>      this.make = make;<br>      this.model = model;<br>   }<br><br>   // Methods<br>   public void move() {<br>      System.out.println(&quot;The car is moving...&quot;);<br>   }<br><br>   public void brake() {<br>      System.out.println(&quot;The car is stopping...&quot;);<br>   }<br><br>   public void accelerate(int speed) {<br>      System.out.println(&quot;The car is moving at &quot; + speed + &quot; km/h...&quot;);<br>   }<br>}</pre><p>The code above defines the Car class. The properties (variables) of this class are color, make, and model. The constructor method allows objects to be created. The methods define the behaviors of Car objects.</p><p>The usage of classes is achieved by creating objects from the classes. These objects carry the properties and behaviors of the class and can be used within the program. Once objects are created from the class, they can perform operations using the class’s methods.</p><p>Example of Object Creation:</p><p>The following example demonstrates creating an object from the Car class:</p><pre>public class CarApplication { <br><br>public static void main(String[] args) { <br>// Creating a Car object <br>Car car1 = new Car(&quot;Red&quot;, &quot;BMW&quot;, 2021);<br><br>// Accessing Car properties <br>System.out.println(&quot;Color: &quot; + car1.color); <br>System.out.println(&quot;Make: &quot; + car1.make); <br>System.out.println(&quot;Model: &quot; + car1.model);<br><br>// Using Car methods <br>car1.move(); <br>car1.accelerate(100); <br>car1.brake(); <br>  } <br>}</pre><p>In the code above, an object of the Car class is created within the CarApplication class. This object has color, make, and model properties. In addition, the methods move(), accelerate(), and brake() perform the behaviors of the Car object.</p><h4>Class components (fields, methods, constructors)</h4><p>Classes are structures that define the properties and functions of objects. Within classes, three basic elements called class components are present: fields, methods, and constructors.</p><ol><li><strong>Fields (fields or properties):</strong> Fields are variables that define the properties of a class. A class’s fields carry the properties of the class’s objects and determine the state of the objects. Fields can be defined with access modifiers such as public, private, or protected. Fields can be defined within or outside of the class. The following example shows the fields defined in the Car class:</li></ol><pre>public class Car {<br>   // Variables<br>   public String color;<br>   private String make;<br>   protected int model;<br>   }</pre><p>In the example above, it is shown that the Car class has three different fields named make, model, and color. The make field is defined as public, therefore accessible and changeable by everyone. The model field, on the other hand, is defined as private, meaning it can only be used within the Car class. The color field is defined as protected, so it can be accessed and modified by the subclass of the Car class.</p><p><strong>2. Methods:</strong> Methods are functions that determine the behavior of a class. A class’s methods allow objects to perform operations. Methods can access and use the class’s fields. Like fields, methods can be defined with access modifiers such as public, private, or protected. The following example shows two different methods defined in the Car class:</p><pre>public class Car {<br><br>//Fields <br>public String make; <br>private int model; <br>protected String color;<br><br>//Methods <br>public void move() {<br> System.out.println(&quot;The car is moving...&quot;);<br> }<br><br>public void brake() { <br>System.out.println(&quot;The car is stopping...&quot;);<br> }<br><br>}</pre><p>In the above example, the Car class has two methods named move() and brake(). The move() method sets the object in motion, while the brake() method slows down or stops the object.</p><p><strong>3. Constructors :</strong> The constructors are special methods called during the creation of class objects. Constructors are used to determine the initial state of the object. When an object is created, the constructor is automatically executed and sets the state of the object. Constructors are defined with the same name as the class and have no return value. The following example is an instance of the constructor defined in the Car class:</p><pre>public class Car {<br>// Fields<br>public String brand;<br>private int model;<br>protected String color;<br><br>// Constructor method<br>public Car(String color, String brand, int model) {<br>this.color = color;<br>this.brand = brand;<br>this.model = model;<br>}<br>}</pre><p>In the example above, the founder of the Car class takes color, brand, and model parameters and initializes the brand and model fields of the class. The word “this” is used to access the fields of the class.</p><p><strong>Access modifiers (public, private, protected)</strong></p><p>Access modifiers in Java are used to determine the extent to which a class or a class’s members can be accessed by other classes. There are three main access modifiers in Java: public, private, and protected.</p><ul><li><strong>public:</strong> Public access specifier indicates that a class or class member is accessible to everyone. In other words, it can be accessed from anywhere in any way. For example, a class or method declared as public can be used anywhere in the program.</li><li><strong>private:</strong> Private access modifier specifies that a class or a class member can only be accessed by other members within the same class, meaning it cannot be accessed by other classes. It is used to preserve the privacy of variables and methods inside the class.</li><li><strong>protected:</strong> The access specifier “protected” indicates that a class or class member can be accessed by other members within the same class, classes in the same package, or subclasses. This is used to allow subclasses of a class to access certain properties of the superclass.</li></ul><p>These access modifiers can be used for any member of the class. For example, the variables or methods of a class can be public, private, or protected.</p><p>Access modifiers are one of the fundamental principles of object-oriented programming in Java. This principle determines how classes and objects will interact with each other and which classes or objects can access which data. This increases the security, modularity, and readability of programs.</p><h4>2) Objects</h4><p><strong>The creation and usage of objects</strong></p><p>Objects are instances created by deriving from a class. These instances inherit the properties and behaviors defined in the class. The creation of objects is done using a constructor method, where the properties of a class are defined and the behaviors of objects are determined.</p><p>For example, let’s create a Car class with properties such as brand, model, color, and behaviors such as starting, stopping, accelerating, and slowing down.</p><pre>public class Car {<br>    String brand; // marka<br>    String model; // model<br>    String color; // renk<br><br>    public Car(String brand, String model, String color) {<br>        this.brand = brand;<br>        this.model = model;<br>        this.color = color;<br>    }<br><br>    public void start() { // calistir<br>        System.out.println(brand + &quot; &quot; + model + &quot; started.&quot;);<br>    }<br><br>    public void stop() { // durdur<br>        System.out.println(brand + &quot; &quot; + model + &quot; stopped.&quot;);<br>    }<br><br>    public void accelerate(int speed) { // hizlan<br>        System.out.println(brand + &quot; &quot; + model + &quot; accelerated to &quot; + speed + &quot; km/h.&quot;);<br>    }<br><br>    public void decelerate(int speed) { // yavasla<br>        System.out.println(brand + &quot; &quot; + model + &quot; decelerated to &quot; + speed + &quot; km/h.&quot;);<br>    }<br>}</pre><p>The above class creates a class called Car, with properties of brand, model, and color. Additionally, the constructor method of the class, i.e., the constructor method, takes parameters that will be used when creating an object named Car and fills the class’s properties with these parameters.</p><p>Then, methods that determine the behavior of the class are defined (start(), stop(), accelerate(), decelerate()). These methods become available when a Car object is created.</p><p>We can write the following code to create a Car object:</p><pre>Car car1 = new Car(&quot;Ford&quot;, &quot;Mustang&quot;, &quot;Black&quot;);</pre><p>The keyword “new” is used to determine the location of an object in memory when an instance of the object is created. When an object is created, an area in the heap is allocated, and the properties of the object are stored here based on the structure of the class.</p><p>The “new” keyword also provides a reference to the created object. This reference can be used to modify the object, or to call properties or methods within the class.</p><p>This code creates an object from the Car class and fills the properties of brand, model, and color with the values “Ford”, “Mustang”, and “Black”.</p><p>The created Car object can be managed using the behaviors of the class. For example:</p><pre>araba1.start();</pre><p>This code runs the object named car1 and outputs “Ford Mustang started.”</p><p>Similarly, we can create another object from the Car class:</p><pre>Car car2 = new Car(&quot;BMW&quot;, &quot;M3&quot;, &quot;Blue&quot;);</pre><p>This code creates a new object from the Car class and fills the properties of brand, model, and color with the values “BMW”, “M3”, and “Blue”.</p><p>This object can be managed using the behaviors of the class as well:</p><pre>car2.accelerate(50);</pre><p>This code increases the speed of the car2 object by 50 km/h and outputs “BMW M3 accelerated by 50 km/h.”</p><p>Objects are useful for filling the properties of a class with different values and using the behaviors of the class in different ways. In addition, using objects can increase the modularity of a program and make it easier to understand.</p><p><strong>Object references and their memory locations</strong></p><p>In the Java programming language, objects and references are stored in memory. Memory can be thought of as the area where a computer temporarily stores data.</p><p>Objects are stored in a memory area called the heap. Typically, addresses in memory are expressed as hexadecimal (base-16) numbers, such as “0x7fff5b6ba5c0”. The heap area dynamically grows and shrinks, which is important for the program’s memory usage.</p><p>Object references, on the other hand, are used to access objects. A reference points to the address of an object in memory. Therefore, references indicate the location of objects in memory.</p><p>References are stored in a memory area called the stack. The stack memory area is reserved for data such as temporary variables, method calls, and other local variables.</p><p>For example, in the following code:</p><pre>Car car1 = new Car(&quot;Ford&quot;, &quot;Mustang&quot;, &quot;Black&quot;);</pre><p>“car1” is an object reference and is stored in the stack memory. The “new” keyword creates a Car object in the memory and returns the starting address of this object in the heap memory. This address is then assigned to the “car1” reference variable. The visual below can help you understand this better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZWYpYmbnNviucTfY0eI3g.png" /></figure><p>So, the reference variable “car1” points to the starting address of the Car object in the memory. This object is stored in the heap memory.</p><p>Object references can change during the lifetime of objects in memory. For example, in this code:</p><pre>Car car2 = new Car(&quot;BMW&quot;, &quot;M3&quot;, &quot;Blue&quot;);<br>car1 = car2;</pre><p>The reference variable “car1” points to the object pointed to by the reference variable “car2”. Therefore, the reference variable “car1” now points to the starting address of the BMW M3 car object in the heap memory. This means that object references make the use of objects in memory more flexible.</p><h3>3-) Inheritance</h3><p>Inheritance is an OOP concept that allows a class to create a new class by using the properties (fields) and behaviors (methods) of an existing class. This increases code reusability and also improves code maintainability.</p><p>In Java, inheritance is implemented using the keyword “extends”. For a class to inherit from another class, the class being inherited from must have a “public” or “protected” access level.</p><p>For example, let’s assume we have a class named “Car” and we want to create a subclass named “SportsCar”. The “SportsCar” class will inherit the properties and behaviors of the “Car” class.</p><pre>public class Car {<br>    public String brand; // marka<br>    protected String model; // model<br>    private String color; // renk<br><br>    public Car(String brand, String model, String color) {<br>        this.brand = brand;<br>        this.model = model;<br>        this.color = color;<br>    }<br><br>    public void move() { // hareketEt<br>        System.out.println(&quot;Car is moving.&quot;);<br>    }<br>}</pre><pre>public class SportsCar extends Car {<br>    public SportsCar(String brand, String model, String color) {<br>        super(brand, model, color);<br>    }<br><br>    public void turbo() {<br>        System.out.println(&quot;Sports car has a turbo feature.&quot;);<br>    }<br>}</pre><p>In the example above, the SportsCar class inherits from the Car class. The SportsCar class can use the brand, model, and color properties as well as the move() behavior (method) of the Car class. Additionally, the SportsCar class defines the turbo() behavior (method).</p><p>The benefits of inheritance include code reusability, code readability, and more organized and maintainable code. Moreover, you can use the properties of the subclass along with the properties of the superclass.</p><p>However, when not used correctly, inheritance can also create disadvantages.</p><p>For example, improper use of inheritance can reduce code readability and increase update costs for future changes. It can also unnecessarily complicate subclasses and increase code duplication.</p><p>Another disadvantage is that it can increase the dependencies of subclasses. Modifying a class can affect all subclasses that inherit from it, making application maintenance more difficult and risky.</p><p>Inheritance can also prevent a program from working correctly in the case of an insufficient class design. For instance, if a class’s properties and behaviors are not properly designed, the subclasses that inherit from it may also carry the same issues.</p><p>In conclusion, inheritance can prevent code duplication, organize class hierarchies, and improve code readability when used correctly. However, it can create disadvantages when used improperly. Therefore, proper use and design of inheritance are crucial.</p><p><strong>Creating a class hierarchy</strong></p><p>Inheritance, which allows subclasses to use the properties of base classes, is also an important concept in the Java programming language. With this mechanism, it is possible to create classes with similar properties and prevent code duplication. Class hierarchy represents the structure of related classes, and this structure enables the relationships between classes to be clearly expressed.</p><p>In the class hierarchy, there are superclasses and subclasses. The superclass has a structure that includes the common properties of the subclasses, and the subclasses inherit these common properties. In this way, subclasses can add unique properties by using the properties of the superclass.</p><p>The inheritance structure allows the preservation of the properties of a superclass that have been passed down to the subclasses, and the addition of new properties. Thus, code duplication is prevented, and the programming process becomes more efficient. In addition, through class hierarchy, it is also possible to group classes with similar properties together.</p><p>When creating a class hierarchy, the access modifiers of the parent classes must be either protected or public for the child classes to be able to use the parent class’s properties. Additionally, child classes cannot directly access private properties of parent classes, but can access them through public or protected methods.</p><p><strong>Advantages of inheritance</strong></p><p>One advantage of inheritance is preventing code duplication. Creating a new class by using the properties of another class makes the code more concise and readable. Additionally, changes made to a parent class are reflected in all child classes that derive from it, making it easier and faster to implement program changes.</p><p>Inheritance also makes code maintenance easier. For example, a change made to a property in a class can affect other classes that inherit from it. In this case, instead of changing each individual class separately, the change made in the parent class can be applied to all child classes.</p><p>Inheritance also increases code reusability. Creating new classes using the properties of an existing class makes code reuse easier and speeds up the programming process.</p><h3>4-) Polymorphism</h3><p>Polymorphism is a concept that allows different methods with the same name to be implemented in different ways by different classes. Polymorphism reduces code repetition and increases the reusability of code in programming languages. It can also help reduce programming errors. For example, different classes that implement an interface can perform the same functionality in different ways. This makes the code more flexible and easier to change when requirements change.</p><p>Polymorphism can also be performed at runtime in Java. For example, it allows you to access a subclass object with a superclass reference and use the methods of the superclass. This way, when the same reference variable is assigned to both superclass and subclass objects, the method to be called is determined at runtime.</p><p>In Java, polymorphism is generally implemented in the following two ways:</p><ol><li><strong>Method Overloading</strong></li></ol><p>Method overloading allows for the definition of methods with the same name but different parameter lists. This allows for the use of the same-named methods with different functionalities.</p><p>For example, let’s consider a scenario where you are writing a math library and want to define a method that calculates the sum of two numbers. Instead of writing separate methods for different number types, you can use method overloading to define a method with the same name for all number types:</p><pre>public class Math {<br><br>    public int add(int x, int y) {<br>        return x + y;<br>    }<br><br>    public int add(int x, int y, int z) {<br>        return x + y + z;<br>    }<br><br>    public double add(double x, double y) {<br>        return x + y;<br>    }<br>    <br>    public float add(float x, float y) {<br>        return x + y;<br>    }<br><br>    // similarly, add methods can be defined for other number types<br>}</pre><p>Some points to keep in mind when overloading in Java are:</p><ul><li>The method name must be the same, but the number or type of parameters must be different. Defining two methods with the same name and parameters will result in an error.</li><li>Overloading cannot be used for methods that only differ in return type. Two methods with the same return type cannot be defined with the same parameters.</li><li>Care should be taken with the type and order of parameters during overloading. Using parameters of the same type in different orders can be confusing and can lead to errors in the code.</li><li>When overloading, using explicit types for the parameters helps to understand which version of the method is being called. For example, if a method accepts both int and double types, it can be difficult to know which version is being called.</li><li>When overloading, readability and maintainability of the code should be considered. Unnecessarily overloaded methods can reduce the readability of the code and make maintenance more difficult.</li></ul><p>2. <strong>Method Overriding</strong></p><p>Method overriding allows subclasses to write their own customized versions of methods by using the same names, parameters, and return types as those in their superclasses.</p><p>For example, let’s define a superclass and a subclass as shown below:</p><pre>public class Animal {<br><br>    public void makeSound() { // sesCikar<br>        System.out.println(&quot;Animal sound&quot;);<br>    }<br>}</pre><pre>public class Cat extends Animal {<br><br>    @Override<br>    public void makeSound() { // sesCikar<br>        System.out.println(&quot;Meow&quot;);<br>    }<br>}</pre><p>In this example, a soundMethod is defined in the Animal class, and the Cat class overrides this method by defining its own soundMethod. This allows the same block of code to produce multiple different results when working with different objects. This feature increases the reusability and flexibility of the code and also enables different classes to use the same method or property.</p><p>When overriding in Java, some points to keep in mind are:</p><ul><li>Private methods in the parent class are not subject to the override process. Otherwise, an error will occur.</li><li>We cannot reduce the access level of the overridden method, but we can increase it.</li><li>We cannot change the return type or parameters of a method inherited from the parent class.</li><li>We cannot override static and final methods.</li><li>The method names we want to override in the parent and child classes must be the same.</li><li>Constructor methods cannot be overridden.</li></ul><p><strong>Usage of object as a parameter</strong></p><p>The polymorphic features we obtain also appear when using objects as a parameter. In other words, we can send objects of different types as parameters to a method.</p><p>For example, let’s consider a Animal class and its derived Cat and Dog classes:</p><pre>public class Animal {<br>    public void feed() { // beslen<br>        System.out.println(&quot;The animal is being fed.&quot;);<br>    }<br>}<br><br>-----------------------------------------------------------------<br><br>public class Cat extends Animal {<br>    @Override<br>    public void feed() { // beslen<br>        System.out.println(&quot;The cat is eating cat food.&quot;);<br>    }<br>}<br><br>-----------------------------------------------------------------<br><br>public class Dog extends Animal {<br>    @Override<br>    public void feed() { // beslen<br>        System.out.println(&quot;The dog is chewing on a bone.&quot;);<br>    }<br>}</pre><p>Let’s create an instance of each of these classes and pass them as parameters to a method.</p><pre>public class Test {<br>    public static void main(String[] args) {<br>        Animal animal1 = new Animal(); // Hayvan<br>        Cat cat1 = new Cat(); // Kedi<br>        Dog dog1 = new Dog(); // Köpek<br><br>        feedingTime(animal1); // beslenmeZamani<br>        feedingTime(cat1);<br>        feedingTime(dog1);<br>    }<br><br>    public static void feedingTime(Animal animal) { // beslenmeZamani<br>        animal.feed();<br>    }<br>}</pre><p>The output will be as follows:</p><pre><br>An animal is being fed.<br>The cat is eating the cat food.<br>The dog is chewing on a bone.</pre><p>So, since the feed() method of the Animal class is overridden, it can be used in the Cat and Dog classes as well. And in the feedingTime() method, even though we receive a parameter of the Animal type, we can send objects of different types with this parameter. Thanks to the polymorphic features, our code becomes more flexible and extensible.</p><p>In short, subclasses that extend the Animal class (such as the Cat and Dog classes) can be used as objects of the Animal type.</p><h3>5-) Abstract Classes and Interfaces</h3><h4>Abstract Classes</h4><p>Abstract classes in Java are classes that represent unfinished classes and cannot be instantiated as objects. These classes have one or more abstract methods that only contain their signatures without any implementation. Subclasses must implement the abstract methods of the abstract class. In this way, subclasses can override the abstract methods of the abstract class and provide their own functionality.</p><p>When defining an abstract class, the keyword “abstract” is used alongside the “class” keyword. For example:</p><pre>public abstract class Shape {<br>   public abstract void draw(); // ciz<br>}</pre><p>In the above example, an abstract class named “Shape” is defined. The “Shape” class has an abstract method named “draw”. Three subclasses, “Triangle”, “Circle”, and “Rectangle”, inherit from the “Shape” class and implement the “draw” method. Each of these subclasses provides a different implementation of the “draw” method to draw its own shape.</p><pre>public class Triangle extends Shape {<br>   @Override<br>   public void draw() {<br>      System.out.println(&quot;Triangle drawn.&quot;);<br>   }<br>}<br>----------------------------------------------------------------------------<br>public class Circle extends Shape {<br>   @Override<br>   public void draw() {<br>      System.out.println(&quot;Circle drawn.&quot;);<br>   }<br>}<br>----------------------------------------------------------------------------<br>public class Rectangle extends Shape {<br>   @Override<br>   public void draw() {<br>      System.out.println(&quot;Rectangle drawn.&quot;);<br>   }<br>}</pre><p>Subclasses must implement abstract methods, otherwise, they are also defined as abstract classes. In the example above, the “Triangle”, “Circle”, and “Rectangle” classes must implement the “draw” method because they inherit from the “Shape” class.</p><p>In the main method, objects are created for three different shapes and the “draw” method is called.</p><pre>public static void main(String[] args) {<br>   Shape triangle = new Triangle(); // Sekil ucgen = new Ucgen();<br>   Shape circle = new Circle(); // Sekil daire = new Daire();<br>   Shape rectangle = new Rectangle(); // Sekil dikdortgen = new Dikdortgen();<br><br>   triangle.draw(); // ucgen.ciz(); outputs &quot;Triangle drawn.&quot;<br>   circle.draw(); // daire.ciz(); outputs &quot;Circle drawn.&quot;<br>   rectangle.draw(); // dikdortgen.ciz(); outputs &quot;Rectangle drawn.&quot;<br>}</pre><p>In this example, the objects “Triangle,” “Circle,” and “Rectangle” are derived from the “Shape” class and implement the “draw” method. This allows for the creation of objects from subclasses without creating objects from the parent class and provides access to the methods of the parent class through these objects.</p><p>Methods with bodies can also be defined, as shown in the following example:</p><pre>public abstract class Shape {<br>    public abstract double calculateArea(); // abstract method<br><br>    public double calculatePerimeter() {<br>        // concrete method<br>        // perimeter calculation operations can be done here<br>    }<br>}</pre><h4><strong>Interfaces</strong></h4><p>Interfaces are contracts that define a specific set of behaviors that a class can implement. An interface contains one or more method signatures, but their bodies are not defined. Interfaces are used to enforce a specific behavior on a class.</p><p>In Java, interfaces are used by a class with the “implements” keyword to implement an interface. A class can implement multiple interfaces.</p><p>The use of interfaces increases the readability and reusability of code. Interfaces reduce the dependencies in code and help in writing more scalable code.</p><p>Here’s an example:</p><pre>public interface CanMakeSound {<br>    public void makeSound();<br>}<br>----------------------------------------------------------------------<br>public class Cat implements CanMakeSound {<br>    @Override<br>    public void makeSound() {<br>        System.out.println(&quot;Meow&quot;);<br>    }<br>}<br>----------------------------------------------------------------------<br>public class Dog implements CanMakeSound {<br>    @Override<br>    public void makeSound() {<br>        System.out.println(&quot;Woof Woof&quot;);<br>    }<br>}</pre><p>In this example, an interface named “CanMakeSound” is defined, which contains a method named “makeSound”. Two classes named “Cat” and “Dog” implement the “CanMakeSound” interface. Both classes implement the “makeSound” method, but each in their own way.</p><p>The differences between abstract classes and interfaces are as follows:</p><ul><li>Abstract classes can only be used through inheritance, while interfaces can be implemented by any class.</li><li>Abstract classes can have both abstract and concrete properties and methods, while interfaces can only contain abstract methods.</li><li>Objects of abstract classes can be instantiated, while objects of interfaces cannot be instantiated.</li><li>Abstract classes are extended by a class through inheritance, while interfaces are implemented by a class and a class can implement multiple interfaces.</li><li>Abstract classes have additional features such as enabling code sharing between classes, while interfaces only allow a class to implement a specific behavior.</li><li>Abstract classes can hold variables and methods in their subclasses, while interfaces can only hold method signatures.</li></ul><p>Therefore, an abstract class can be used when you need to use common code in its subclasses or when you need to create an object. On the other hand, an interface is useful for different classes that require similar behavior.</p><h4>An Overview:</h4><p>Classes and objects are one of the fundamental building blocks when programming in the Java programming language. Java’s object-oriented programming paradigm allows for the creation, management, and interaction of objects. Classes can be thought of as templates used for creating objects. Each class has its own properties and functions, which are inherited by the objects.</p><p>By using classes and objects in Java, you can break down large and complex projects into smaller and more manageable parts. Objects can interact with each other and communicate with each other, along with their own properties and functions. This makes the code more readable and understandable when programming.</p><p>Classes and objects can be used in many different applications in Java. For example, classes and objects can be used in software development, web programming, mobile application development, and game programming, among many other areas.</p><p>Note:</p><p>AI tools have been used to translate this blog post, with the help of Chat-gpt 3 and Hashnode Rix.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e9098ffeb04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kodcular/classes-and-objects-in-java-detailed-9e9098ffeb04">Classes and Objects in Java (Detailed)</a> was originally published in <a href="https://medium.com/kodcular">Kodcular</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Markdown on Github]]></title>
            <link>https://adnanyagmur.medium.com/using-markdown-on-github-caa92fe5ef77?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/caa92fe5ef77</guid>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Fri, 05 May 2023 11:32:38 GMT</pubDate>
            <atom:updated>2023-05-05T11:32:38.800Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, today I’m going to talk about the usage of Github markdown. The Github Readme file is a document that contains information about a project or repository. This file is usually found on the project’s main page and provides users with the necessary information to get an idea about the project.</p><p>The Github Readme file is an important tool for a project for the following reasons:</p><p>Project Introduction: The Github Readme file provides an explanation about what the project does and why it is important. Potential users and developers who want to contribute to the project use this file to understand what the project is about. Installation and Usage Instructions: The Github Readme file provides information about how to install and use the project. These instructions help users to easily use the project. Contribution Instructions: The Github Readme file contains instructions for developers who want to contribute to the project. These instructions simplify the contribution process and help in the development of the project. License Information: The Github Readme file explains under which license the project is published. This helps users to understand what rules they need to follow while using the project. Project Status: The Github Readme file shows the current status of the project. This indicates whether there is still interest in the project, whether the project is being actively developed or has stopped.</p><p>For all these reasons, the Github Readme file is an important component of a project. A good Github Readme file helps to attract more users to the project and encourages more contributions.</p><p>Below are some examples and appearances:</p><p>Creating Headings, Bold Text, Italic Text, Strikethrough Text, Creating Lists, Creating Numbered Lists, Blocks, Code Blocks, Adding Images, Adding Links, Creating Tables.</p><pre><br># Heading 1<br>## Heading 2<br>### Heading 3<br>#### Heading 4<br>##### Heading 5<br>###### Heading 6<br><br>**This text is bold.**<br><br>__This text is bold.__<br><br>*This text is italicized.*<br><br>_This text is italicized._<br><br>***This text is both bold and italicized.***<br><br>___This text is both bold and italicized.___<br><br>~~This text is strikethrough.~~<br><br>- List item 1<br>- List item 2<br>- List item 3<br><br>* List item 1<br>* List item 2<br>* List item 3<br><br>1. List item 1<br>2. List item 2<br>3. List item 3<br><br>&gt; This text is a blockquote.<br><br>`This text is enclosed in single quotes.`<br><br>```<br>This text is a code block.<br>```<br><br>![The description of the picture should go in this section](https://www.hizliresim.com/nk51iuw)<br><br>[I will put my GitHub account link in this link](https://github.com/adnanyagmur)<br><br>|Column 1 Title | Column 2 Title|<br>|Cell 1, Column 1 | Cell 1, Column 2|<br>|Cell 2, Column 1 | Cell 2, Column 2|<br>|First Name | Last Name|<br>| --- | --- |<br>|Adam | Smith|<br>|John | Doe|<br>|Anne | Johnson|</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*-0obEPIqrEnFG0fRZeS_ZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*fr48vngqX0TzTRMfDlwjYg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caa92fe5ef77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub’da Markdown Kullanımı]]></title>
            <link>https://adnanyagmur.medium.com/githubda-markdown-kullan%C4%B1m%C4%B1-502135baef4d?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/502135baef4d</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[read]]></category>
            <category><![CDATA[markdown]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 07:07:09 GMT</pubDate>
            <atom:updated>2023-04-28T07:07:09.400Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba bu gün size github markdown kullanımından bahsedeceğim. Github Readme dosyası, bir proje veya depo ile ilgili bilgileri içeren bir dosyadır. Bu dosya genellikle projenin ana sayfasında bulunur ve kullanıcılara proje hakkında fikir edinmeleri için gerekli bilgileri sağlar.</p><p>Github Readme dosyası, bir proje için önemli bir araçtır. Aşağıdaki nedenlerden dolayı önemlidir:</p><ol><li>Projenin tanıtımı: Github Readme dosyası, projenin ne yaptığı ve neden önemli olduğu hakkında bir açıklama sunar. Potansiyel kullanıcılar ve katkıda bulunmak isteyen geliştiriciler, projenin ne olduğunu anlamak için bu dosyayı kullanır.</li><li>Kurulum ve kullanım talimatları: Github Readme dosyası, projenin nasıl kurulacağı ve kullanılacağı hakkında bilgi sağlar. Bu talimatlar, kullanıcıların projeyi kolayca kullanmalarına yardımcı olur.</li><li>Katkıda bulunma talimatları: Github Readme dosyası, projeye katkıda bulunmak isteyen geliştiriciler için talimatlar içerir. Bu talimatlar, projenin katkıda bulunma sürecini basitleştirir ve projenin geliştirilmesine yardımcı olur.</li><li>Lisans bilgisi: Github Readme dosyası, projenin hangi lisans altında yayınlandığını açıklar. Bu, kullanıcıların projeyi kullanırken hangi kurallara uymaları gerektiğini anlamalarına yardımcı olur.</li><li>Projenin son durumu: Github Readme dosyası, projenin son durumunu gösterir. Bu, projeye olan ilginin devam edip etmediğini, projenin aktif olarak geliştirilip geliştirilmediğini veya projenin durduğunu gösterir.</li></ol><p>Tüm bu nedenlerden dolayı, Github Readme dosyası, bir projenin önemli bir bileşenidir. İyi bir Github Readme dosyası, projenin daha fazla kullanıcının ilgisini çekmesine ve daha fazla katkıda bulunma sağlamasına yardımcı olur.</p><p>Aşağıda örnekleri ve görünümleri mevcuttur:</p><p>Başlık Oluşturma, Kalın Yazı, İtalik Yazı, İtalik Yazı, Çizgili Metin, Liste Oluşturma, Numaralı Liste Oluşturma, Bloklar, Kod Blokları, Resim Ekleme, Link Ekleme, Tablo Oluşturma</p><pre># Başlık 1<br>## Başlık 2<br>### Başlık 3<br>#### Başlık 4<br>##### Başlık 5<br>###### Başlık 6<br><br>**Bu metin kalındır.**<br><br>__Bu metin kalındır.__<br><br>*Bu metin italiktir.*<br><br>_Bu metin italiktir._<br><br>***Bu metin hem kalın hem de italiktir.***<br><br>___Bu metin hem kalın hem de italiktir.___<br><br>~~Bu metin çizgilidir.~~<br><br>- Liste elemanı 1<br>- Liste elemanı 2<br>- Liste elemanı 3<br><br>* Liste elemanı 1<br>* Liste elemanı 2<br>* Liste elemanı 3<br><br>1. Liste elemanı 1<br>2. Liste elemanı 2<br>3. Liste elemanı 3<br><br>&gt; Bu metin bloktur.<br><br>\`Bu metin tek tırnak içindedir.\`<br><br>\`\`\`<br>Bu metin kod bloğudur.<br>\`\`\`<br><br>![RESMİN METNİ](https://www.hizliresim.com/nk51iuw)<br><br>[Benim github hesabım](https://github.com/adnanyagmur)<br><br>| Sütun 1 Başlığı | Sütun 2 Başlığı |<br>| ------------- | ------------- |<br>| Hücre 1, Sütun 1 | Hücre 1, Sütun 2 |<br>| Hücre 2, Sütun 1 | Hücre 2, Sütun 2 |<br><br>| İsim | Soyisim |<br>| --- | --- |<br>| Ahmet | Yılmaz |<br>| Ayşe | Kaya |<br>| Mehmet | Şimşek |</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVy1wqpAqDULMZHTslR0jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*8fK5OZZtEmYyNwVhvTzWLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*Z1sCigMkO1r9rWQW_nxyLw.png" /></figure><p>Sırası ile yukardaki gibi gözükeceklerdir. Okuduğunuz için teşekkür ederim. Herkese başarılar dilerim.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=502135baef4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java’da Sınıflar ve Nesneler]]></title>
            <link>https://medium.com/t%C3%BCrkiye/javada-s%C4%B1n%C4%B1flar-ve-nesneler-cde712f1ab7e?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/cde712f1ab7e</guid>
            <category><![CDATA[türkçe]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[class]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Fri, 17 Mar 2023 12:51:51 GMT</pubDate>
            <atom:updated>2024-08-10T09:54:01.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*D6enwr_bwRPLPagO5A4OoA.png" /></figure><p>Java, günümüzde en popüler programlama dillerinden biridir. Nesne yönelimli bir programlama dilidir ve bu nedenle, programlama dünyasında oldukça popülerdir. Java’nın nesne yönelimli programlama konusunda sağladığı avantajlar, yazılım geliştiricileri tarafından sıklıkla tercih edilmesine neden olmuştur. Peki, nedir bu nesne yönelimli programlama? Bu konu hakkında bilgi sahibi olmak, Java’yı daha iyi anlamak için önemlidir.</p><p>Nesne yönelimli programlama (OOP), programlama dünyasında oldukça önemli bir kavramdır. OOP, programlama dünyasında, kodları nesnelere dayandırarak daha organize bir şekilde yazmanıza olanak tanır. Bu yaklaşım, karmaşık problemleri daha kolay bir şekilde çözmenize ve daha modüler bir kod tabanı oluşturmanıza yardımcı olur.</p><p>Java, nesne yönelimli programlama konusunda oldukça güçlü bir dil olarak öne çıkar. Java’da, her şey nesneler ve sınıflar aracılığıyla gerçekleştirilir. Sınıflar, benzer özelliklere sahip nesnelerin bir araya getirilmesine olanak tanır. Nesneler ise, sınıfların bir örneğidir. Java’da, her nesne, sınıfın bir örneği olmak zorundadır.</p><p>Örneğin, bir araba nesnesi oluşturmak istediğinizi varsayalım. Arabanın rengi, markası, modeli vb. gibi özellikleri olsun. Java’da, bu özellikleri tanımlamak için bir Araba sınıfı oluşturmanız gerekiyor. Bu sınıf, Araba nesnesinin özelliklerini ve davranışlarını (metodlar) içerir. Araba nesnesi ise, Araba sınıfının bir örneğidir ve gerçek dünyadaki arabaya karşılık gelir.</p><p>Java’nın nesne yönelimli yapısı, kodun daha anlaşılır ve daha az hata yapmanızı sağlar. Ayrıca, nesne yönelimli yaklaşım, programlama projelerinin daha büyük bir ekibin birlikte çalışmasını kolaylaştırır. Kodun daha modüler bir şekilde yazılması, farklı programcıların belirli bir sınıf veya nesne üzerinde çalışmasına olanak tanır.</p><h3>Yazının genel akışı şu şekildedir :</h3><ul><li>Sınıflar</li><li>Nesneler</li><li>Kalıtım (Inheritance)</li><li>Polimorfizm (Polymorphism)</li><li>Soyut Sınıflar ve Arabirimler (Abstract Classes and Interfaces)</li></ul><h3><strong>1-) Sınıflar</strong></h3><h4>Sınıflara Genel Bakış</h4><p>Sınıf, bir nesnenin tanımını belirleyen bir plan veya şablon olarak düşünülebilir. Sınıf, nesnenin özelliklerini (değişkenler) ve davranışlarını (metodlar) tanımlar. Örneğin, bir Araba sınıfı oluşturduğumuzu varsayalım. Bu sınıfın özellikleri, arabanın rengi, markası, modeli vb. olabilir. Metodlar ise, arabanın çalıştırılması, durdurulması, hızının artırılması vb. gibi davranışları tanımlayabilir.</p><p>Sınıflar, birbirleriyle ilişkili nesnelerin bir araya gelmesini sağlar. Bu nedenle, sınıfların özellikleri ve davranışları, bu sınıflardan türetilen nesneler için geçerlidir. Bir sınıftan türetilen nesne, o sınıfın bir örneği olarak düşünülebilir. Nesneler, sınıfın özelliklerine sahiptir ve sınıfın davranışlarını gerçekleştirebilirler.</p><p>Nesneler, gerçek dünyadaki varlıkların temsilleridir. Örneğin, bir Araba nesnesi, gerçek dünyadaki bir arabanın temsili olarak düşünülebilir. Nesnelerin birbirleriyle etkileşim içinde olduğu durumlar, genellikle birbirine bağımlı olan sınıflar tarafından yönetilir. Bu etkileşimler, farklı nesnelerin birbirleriyle iletişim kurması veya bir nesnenin diğer bir nesne üzerinde bir işlem yapması şeklinde gerçekleşebilir.</p><h4>Sınıfların Tanımlanması ve Kullanımı</h4><p>Sınıf tanımlamaları, aşağıdaki özellikleri içermesi gereken bir blok kodu kullanılarak gerçekleştirilir:</p><ol><li>Sınıfın adı: Sınıfların bir adı vardır ve bu isimler, genellikle isimlendirme kurallarına uygun şekilde belirlenir.</li><li>Değişkenler: Sınıfın değişkenleri, nesnelerin özelliklerini tanımlayan veri tipleridir. Örneğin, bir Araba sınıfında, renk, marka, model gibi değişkenler tanımlanabilir.</li><li>Metodlar: Sınıfın metodları, nesnenin davranışlarını tanımlayan bloklardır. Örneğin, bir Araba sınıfında, hareket etme, fren yapma, hızlandırma gibi metodlar tanımlanabilir.</li><li>Kurucu Metod: Sınıfın kurucu metodu, nesnelerin nasıl oluşturulacağını belirler. Bu metod, sınıfın adıyla aynı isme sahip bir metod olmalıdır.</li></ol><p>Sınıf Tanımlama Örneği:</p><p>Aşağıdaki örnek, bir Araba sınıfının nasıl tanımlandığını göstermektedir:</p><pre>public class Araba {<br>   // Değişkenler<br>   String renk;<br>   String marka;<br>   int model;<br><br>   // Kurucu metot<br>   public Araba(String renk, String marka, int model) {<br>      this.renk = renk;<br>      this.marka = marka;<br>      this.model = model;<br>   }<br><br>   // Metodlar<br>   public void hareketEt() {<br>      System.out.println(&quot;Araba hareket ediyor...&quot;);<br>   }<br><br>   public void frenYap() {<br>      System.out.println(&quot;Araba duruyor...&quot;);<br>   }<br><br>   public void hizlandir(int hiz) {<br>      System.out.println(&quot;Araba &quot; + hiz + &quot; km/s hızla hareket ediyor...&quot;);<br>   }<br>}</pre><p>Yukarıdaki kodda, Araba sınıfı tanımlanmıştır. Bu sınıfın özellikleri (değişkenleri) renk, marka ve modeldir. Kurucu metod, nesnelerin oluşturulmasını sağlar. Metodlar, Araba nesnelerinin davranışlarını tanımlar.</p><p>Sınıfların kullanımı, sınıflardan nesneler oluşturarak gerçekleştirilir. Bu nesneler, sınıfın özelliklerini ve davranışlarını taşır ve program içinde kullanılabilirler. Nesneler, sınıftan oluşturulduktan sonra, sınıfın metodlarını kullanarak işlem yapabilirler.</p><p>Nesne Oluşturma Örneği:</p><p>Aşağıdaki örnek, Araba sınıfından bir nesne oluşturmayı göstermektedir:</p><pre>public class ArabaUygulamasi {<br>   public static void main(String[] args) {<br>      // Araba nesnesi oluşturma<br>      Araba araba1 = new Araba(&quot;Kırmızı&quot;, &quot;BMW&quot;, 2021);<br><br>      // Araba özelliklerine erişim<br>      System.out.println(&quot;Renk: &quot; + araba1.renk);<br>      System.out.println(&quot;Marka: &quot; + araba1.marka);<br>      System.out.println(&quot;Model: &quot; + araba1.model);<br><br>      // Araba metodlarının kullanımı<br>      araba1.hareketEt();<br>      araba1.hizlandir(100);<br>      araba1.frenYap();<br>   }<br>}</pre><p>Yukarıdaki kodda, ArabaUygulamasi sınıfı içinde Araba sınıfından bir nesne oluşturulmuştur. Bu nesne, renk, marka ve model özelliklerine sahiptir. Ayrıca, hareketEt(), hizlandir() ve frenYap() metodları, Araba nesnesinin davranışlarını gerçekleştirir.</p><h4>Sınıf bileşenleri (alanlar, metotlar, kurucular)</h4><p>Sınıflar, nesnelerin özelliklerini ve işlevlerini tanımlayan yapılardır. Sınıfların içinde, sınıf bileşenleri olarak adlandırılan üç temel öğe yer alır: alanlar, metotlar ve kurucular.</p><p><strong>1. Alanlar (fields veya properties):</strong> Alanlar, sınıfın özelliklerini tanımlayan değişkenlerdir. Bir sınıfın alanları, sınıfın nesnelerinin özelliklerini taşır ve nesnelerin durumunu belirler. Alanlar, public, private veya protected gibi erişim belirleyicileri ile tanımlanabilirler. Alanlar, sınıfın içinde veya sınıf dışındaki bloklarda tanımlanabilirler. Aşağıdaki örnek, Araba sınıfında tanımlanan alanların bir örneğidir:</p><pre>public class Araba {<br>    public String marka;<br>    private int model;<br>    protected String renk;<br>}</pre><p>Yukarıdaki örnekte, Araba sınıfının marka, model ve renk adında üç farklı alanı olduğunu göstermektedir. marka alanı public olarak tanımlanmıştır, bu nedenle herkes tarafından erişilebilir ve değiştirilebilir. model alanı ise private olarak tanımlanmıştır, yani sadece Araba sınıfı içinde kullanılabilir. renk alanı ise protected olarak tanımlanmıştır, bu nedenle Araba sınıfının alt sınıfları tarafından erişilebilir ve değiştirilebilir.</p><p><strong>2. Metotlar (methods):</strong> Metotlar, sınıfın davranışlarını belirleyen işlevlerdir. Bir sınıfın metotları, nesnelerin işlemlerini gerçekleştirmelerine olanak tanır. Metotlar, sınıfın alanlarına erişebilir ve bunları kullanabilirler. Metotlar da alanlar gibi, public, private veya protected gibi erişim belirleyicileri ile tanımlanabilirler. Aşağıdaki örnek, Araba sınıfında tanımlanan iki farklı metodu göstermektedir:</p><pre>public class Araba {<br>    <br>    //Alanlar<br>    public String marka;<br>    private int model;<br>    protected String renk;<br><br>// Metodlar<br>   public void hareketEt() {<br>      System.out.println(&quot;Araba hareket ediyor...&quot;);<br>   }<br><br>   public void frenYap() {<br>      System.out.println(&quot;Araba duruyor...&quot;);<br>   }<br><br>}</pre><p>Yukarıdaki örnekte, Araba sınıfının hareketEt() ve frenYap() adında iki metodu vardır. hareketEt() metodu, nesneyi harekete geçirir, frenYap() metodu ise nesnenin yavaşlamasını yada durmasını sağlar.</p><p><strong>3. Kurucular (constructors):</strong> Kurucular, sınıfın nesnelerinin oluşturulması sırasında çağrılan özel metotlardır. Kurucular, nesnenin başlangıç durumunu belirlemek için kullanılır. Nesne oluşturulduğunda, kurucu otomatik olarak çalıştırılır ve nesnenin durumunu ayarlar. Kurucular, sınıfın adı ile aynı isimle tanımlanırlar ve geri dönüş değeri yoktur. Aşağıdaki örnek, Araba sınıfında tanımlanan kurucunun bir örneğidir:</p><pre>public class Araba {<br>   // Alanlar<br>   public String marka;<br>   private int model;<br>   protected String renk;<br><br>   // Kurucu metot<br>   public Araba(String renk, String marka, int model) {<br>      this.renk = renk;<br>      this.marka = marka;<br>      this.model = model;<br>   }<br>}</pre><p>Yukarıdaki örnekte, Araba sınıfının kurucusu, renk, marka ve model parametrelerini alır ve sınıfın marka ve model alanlarını başlatır. “this” kelimesi, sınıfın alanlarına erişmek için kullanılır.</p><h4>Erişim belirleyicileri (public, private, protected)</h4><p>Java’da erişim belirleyicileri, bir sınıfın veya sınıfın üyelerinin başka sınıflar tarafından ne ölçüde erişilebilir olduğunu belirlemek için kullanılır. Java’da üç ana erişim belirleyici bulunur: public, private ve protected.</p><ul><li><strong>public:</strong> public erişim belirleyici, bir sınıfın veya sınıf üyesinin herkes tarafından erişilebilir olduğunu belirtir. Yani, herhangi bir yerden herhangi bir şekilde erişilebilir. Örneğin, public olarak belirtilen bir sınıf veya metot, programın herhangi bir yerinde kullanılabilir.</li><li><strong>private:</strong> private erişim belirleyici, bir sınıfın veya sınıf üyesinin yalnızca aynı sınıfın içindeki diğer üyeler tarafından erişilebilir olduğunu belirtir. Yani, başka sınıflar tarafından erişilemez. Bu, sınıfın içindeki değişken ve metotların gizliliğini korumak için kullanılır.</li><li><strong>protected:</strong> protected erişim belirleyici, bir sınıfın veya sınıf üyesinin aynı sınıfın içindeki diğer üyeler, aynı paketteki sınıflar veya alt sınıflar tarafından erişilebilir olduğunu belirtir. Bu, sınıfın alt sınıflarının, üst sınıfın bazı özelliklerine erişmesine izin vermek için kullanılır.</li></ul><p>Bu erişim belirleyicileri, sınıfın herhangi bir üyesi için kullanılabilir. Örneğin, bir sınıfın değişkenleri veya metotları public, private veya protected olabilir.</p><p>Erişim belirleyicileri, Java’da nesne yönelimli programlamanın temel prensiplerinden biridir. Bu prensip, sınıfların ve nesnelerin birbirleriyle nasıl etkileşim kuracağını ve hangi sınıf veya nesnelerin hangi verilere erişebileceğini belirler. Bu sayede, programların güvenliği, modülerliği ve okunabilirliği artar.</p><h3>2-) Nesneler</h3><h4>Nesnelerin oluşturulması ve kullanımı</h4><p>Nesneler, bir sınıftan türetilerek oluşturulan örneklerdir. Bu örnekler, sınıfta tanımlanmış özellikleri ve davranışları miras alırlar. Nesnelerin oluşturulması, bir sınıfın özelliklerinin tanımlandığı ve nesnelerin davranışlarının belirlendiği bir yapıcı yöntemi (constructor method) kullanarak yapılır.</p><p>Örneğin, bir Araba sınıfı oluşturalım ve bu sınıfın özellikleri arasında marka, model, renk gibi özellikler olsun. Ayrıca bu arabaların çalıştırılması, durdurulması, hızlandırılması, yavaşlatılması gibi davranışları da olabilir.</p><pre>public class Araba {<br>String marka;<br>String model;<br>String renk;<br><br>public Araba(String marka, String model, String renk) {<br>    this.marka = marka;<br>    this.model = model;<br>    this.renk = renk;<br>}<br><br>public void calistir() {<br>    System.out.println(marka + &quot; &quot; + model + &quot; çalıştı.&quot;);<br>}<br><br>public void durdur() {<br>    System.out.println(marka + &quot; &quot; + model + &quot; durdu.&quot;);<br>}<br><br>public void hizlan(int hiz) {<br>    System.out.println(marka + &quot; &quot; + model + &quot; &quot; + hiz + &quot; km/s hızlandı.&quot;);<br>}<br><br>public void yavasla(int hiz) {<br>    System.out.println(marka + &quot; &quot; + model + &quot; &quot; + hiz + &quot; km/s yavaşladı.&quot;);<br>}<br>}</pre><p>Yukarıdaki sınıf, Araba adında bir sınıf oluşturur. Sınıfın özellikleri marka, model ve renk özellikleridir. Ayrıca sınıfın yapıcı yöntemi, yani constructor methodu Araba adında bir nesne oluştururken kullanılacak parametreleri alır ve sınıfın özelliklerini bu parametrelerle doldurur.</p><p>Ardından, sınıfın davranışlarını belirleyen yöntemler (calistir(), durdur(), hizlan(), yavasla()) tanımlanır. Bu yöntemler, Araba nesnesi oluşturulduğunda kullanılabilir hale gelirler.</p><p>Bir Araba nesnesi oluşturmak için şu şekilde bir kod yazabiliriz:</p><pre>Araba araba1 = new Araba(&quot;Ford&quot;, &quot;Mustang&quot;, &quot;Siyah&quot;);</pre><p>“new” anahtar kelimesi, nesnenin örneği oluşturulduğunda bellekteki yerini belirlemek için kullanılır. Nesne oluşturulduğunda, bellekteki bir alan (heap) ayrılır ve sınıfın yapısına göre nesnenin özellikleri burada saklanır.</p><p>“new” anahtar kelimesi, ayrıca oluşturulan nesneye bir referans sağlar. Bu referans, nesneyi değiştirmek, sınıf içindeki özellikleri veya yöntemleri çağırmak için kullanılabilir.</p><p>Bu kod, Araba sınıfından bir nesne oluşturur ve marka, model ve renk özelliklerini “Ford”, “Mustang” ve “Siyah” değerleri ile doldurur.</p><p>Oluşturulan Araba nesnesi, sınıfın davranışlarını kullanarak yönetilebilir. Örneğin:</p><pre>araba1.calistir();</pre><p>Bu kod, araba1 adlı nesneyi çalıştırır ve “Ford Mustang çalıştı.” çıktısını verir.</p><p>Benzer şekilde, Araba sınıfından başka bir nesne oluşturabiliriz:</p><pre>Araba araba2 = new Araba(&quot;BMW&quot;, &quot;M3&quot;, &quot;Mavi&quot;);</pre><p>Bu kod, Araba sınıfından yeni bir nesne oluşturur ve marka, model ve renk özelliklerini “BMW”, “M3” ve “Mavi” değerleriyle doldurur.</p><p>Bu nesne de sınıfın davranışlarını kullanarak yönetilebilir:</p><pre>araba2.hizlan(50);</pre><p>Bu kod, araba2 nesnesinin hızını 50 km/s artırır ve “BMW M3 50 km/s hızlandı.” çıktısını verir.</p><p>Nesneler, sınıfın özelliklerinin farklı değerlerle doldurulması ve sınıfın davranışlarının farklı şekillerde kullanılması için kullanışlıdır. Ayrıca, nesnelerin kullanımı, bir programın modülerliğini artırabilir ve daha kolay anlaşılmasını sağlayabilir.</p><h4>Nesne referansları ve bellekteki konumları</h4><p>Java programlama dilinde, nesneler ve referanslar bellekte tutulurlar. Bellek, bir bilgisayarın geçici olarak verileri sakladığı alan olarak düşünülebilir.</p><p>Nesneler, heap adı verilen bellek bölgesinde saklanır. Genellikle, bellekteki adresler hexadecimal (onaltılık) sayılar olarak ifade edilir. Örneğin, “0x7fff5b6ba5c0” gibi. Heap bölgesi, dinamik olarak büyür ve küçülür, bu da programın bellek kullanımı açısından önemlidir.</p><p>Nesne referansları ise, nesnelere erişmek için kullanılır. Bir referans, bellekteki bir nesnenin adresini gösterir. Yani, referanslar, nesnelerin bellekteki konumlarını işaret ederler.</p><p>Referanslar ise, stack adı verilen bellek bölgesinde saklanır. Stack bellek bölgesi, geçici veriler, metot çağrıları ve diğer yerel değişkenler gibi veriler için ayrılır.</p><p>Bir örnek vermek gerekirse, şu kodda:</p><pre>Araba araba1 = new Araba(&quot;Ford&quot;, &quot;Mustang&quot;, &quot;Siyah&quot;);</pre><p>“araba1”, bir nesne referansıdır ve stack bellekte saklanır. “new” anahtar kelimesi, bellekte bir Araba nesnesi oluşturur ve bu nesnenin başlangıç adresini heap bellekte geri döndürür. Bu adres daha sonra “araba1” referans değişkenine atanır. Aşağıdaki görsel kafanızda daha rahat oturmasını sağlayabilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pB5I437mLuOwx5zLyDeGCQ.png" /><figcaption>Nesne referansları ve bellekteki konumları</figcaption></figure><p>Yani, “araba1” referans değişkeni, bellekteki Araba nesnesinin başlangıç adresini işaret eder. Bu nesne ise heap bellekte saklanır.</p><p>Nesne referansları, bellekteki nesnelerin yaşam döngüsü boyunca değişebilir. Örneğin, şu kodda:</p><pre>Araba araba2 = new Araba(&quot;BMW&quot;, &quot;M3&quot;, &quot;Mavi&quot;);<br>araba1 = araba2;</pre><p>“araba1” referans değişkeni, “araba2” referans değişkeninin gösterdiği nesneyi işaret eder. Yani, artık “araba1”referans değişkeni, heap bellekteki BMW M3 Araba nesnesinin başlangıç adresini işaret eder. Bu, nesne referanslarının, bellekteki nesnelerin kullanımını esnek hale getirdiği anlamına gelir.</p><h3>3-) Kalıtım (Inheritance)</h3><p>Kalıtım (Inheritance), bir sınıfın, var olan bir sınıfın özelliklerini (alanları) ve davranışlarını (metotları) kullanarak yeni bir sınıf oluşturmasını sağlayan bir OOP kavramıdır. Bu, kodun yeniden kullanılabilirliğini arttırır ve aynı zamanda kodun sürdürülebilirliğini de arttırır.</p><p>Javada, kalıtım, anahtar kelime olarak “extends” kullanılarak gerçekleştirilir. Bir sınıfın bir diğer sınıftan kalıtım alabilmesi için, kalıtım alınacak sınıfın “public” veya “protected” erişim düzeyinde olması gerekmektedir.</p><p>Örnek olarak, “Araba” adında bir sınıfımız olduğunu ve “SporAraba” adında bir alt sınıf oluşturmak istediğimizi varsayalım. “SporAraba” sınıfı, “Araba” sınıfının özelliklerini ve davranışlarını miras alacak.</p><pre>public class Araba {<br>    public String marka;<br>    protected String model;<br>    private String renk;<br><br>    public Araba(String marka, String model, String renk) {<br>        this.marka = marka;<br>        this.model = model;<br>        this.renk = renk;<br>    }<br><br>    public void hareketEt() {<br>        System.out.println(&quot;Araba hareket ediyor.&quot;);<br>    }<br>}</pre><pre>public class SporAraba extends Araba {<br>    public SporAraba(String marka, String model, String renk) {<br>        super(marka, model, renk);<br>    }<br><br>    public void turbo() {<br>        System.out.println(&quot;Spor arabası turbo özelliğine sahiptir.&quot;);<br>    }<br>}</pre><p>Yukarıdaki örnekte, SporAraba sınıfı Araba sınıfından kalıtım almaktadır. SporAraba sınıfı, Araba sınıfının marka, model ve renközelliklerini ve hareketEt() davranışını (metodunu) kullanabilir. Ayrıca, SporAraba sınıfı turbo() davranışını da (metodunu) tanımlamaktadır.</p><p>Kalıtımın faydaları arasında, kodun yeniden kullanılabilirliği, kodun okunabilirliği, kodun daha düzenli ve daha sürdürülebilir olması yer almaktadır. Ayrıca, alt sınıfın özelliklerini, üst sınıfın özellikleri ile aynı zamanda kullanabilirsiniz.</p><p>Ancak, doğru kullanılmadığında, kalıtım dezavantajlar da yaratabilir.</p><p>Örneğin, kalıtımın yanlış kullanımı kodun okunaklılığını azaltabilir ve gelecekteki değişikliklerde güncelleme maliyetlerini artırabilir. Ayrıca, alt sınıfların gereksiz yere karmaşık hale gelmesine ve kod tekrarının artmasına da neden olabilir.</p><p>Başka bir dezavantaj ise, alt sınıfların bağımlılıklarının artmasıdır. Bir sınıfın değiştirilmesi, o sınıftan kalıtım alan tüm alt sınıfların da etkilenmesine neden olabilir. Bu, uygulamanın bakımını zorlaştırabilir ve riskli olabilir.</p><p>Kalıtım ayrıca, yetersiz bir sınıf tasarımı durumunda programın doğru çalışmasını engelleyebilir. Örneğin, bir sınıfın özellikleri ve davranışları doğru bir şekilde tasarlanmamışsa, bu sınıftan kalıtım alan alt sınıflar da aynı sorunları taşıyabilirler.</p><p>Sonuç olarak, kalıtım doğru kullanıldığında kod tekrarını önleyebilir, sınıf hiyerarşisini düzenleyebilir ve kodun okunaklığını artırabilir. Ancak, yanlış kullanıldığında dezavantajlar oluşturabilir. Bu nedenle, kalıtımın doğru bir şekilde kullanılması ve tasarlanması çok önemlidir.</p><h4>Sınıf hiyerarşisi oluşturma</h4><p>Taban sınıfların özelliklerini kalıtım alan alt sınıfların kullanabilmesini sağlayan kalıtım (inheritance), Java programlama dilinde de önemli bir konudur. Bu mekanizma sayesinde, benzer özelliklere sahip sınıfların oluşturulması ve kod tekrarının önlenmesi mümkün hale gelir. Sınıf hiyerarşisi ise, birbirine bağlı sınıfların yapısını ifade eder ve bu yapı sayesinde sınıfların birbirleriyle olan ilişkileri daha net bir şekilde ortaya konulabilir.</p><p>Sınıf hiyerarşisinde, üst sınıflar ve alt sınıflar bulunur. Üst sınıf, alt sınıfların ortak özelliklerini içeren bir yapıya sahiptir ve alt sınıflar bu ortak özellikleri miras alır. Bu sayede alt sınıflar, üst sınıfın özelliklerini kullanarak kendilerine özgü farklı özellikler de ekleyebilir.</p><p>Kalıtım yapısı, bir üst sınıfın alt sınıflara geçmiş özelliklerinin korunmasını ve yeni özelliklerin eklenmesini sağlar. Böylece, kod tekrarı önlenir ve programlama süreci daha verimli hale gelir. Ayrıca, sınıf hiyerarşisi sayesinde, benzer özelliklere sahip sınıfların bir arada toplanması da mümkün olur.</p><p>Sınıf hiyerarşisi oluştururken, alt sınıfların üst sınıfların özelliklerini kullanabilmesi için, üst sınıfların erişim belirleyicilerinin protected veya public olması gerekmektedir. Ayrıca, alt sınıflar, üst sınıfların private özelliklerine doğrudan erişemezler, ancak public veya protected aracılığıyla erişebilirler.</p><h4>Kalıtımın avantajları</h4><p>Kalıtımın avantajlarından biri, kod tekrarının önlenmesidir. Bir sınıfın özelliklerini kullanarak yeni bir sınıf oluşturmak, kodun daha sade ve okunaklı hale gelmesini sağlar. Ayrıca, bir sınıfta yapılan değişiklikler, bu sınıftan türetilen tüm alt sınıfları da etkiler. Bu sayede, programda yapılan değişikliklerin uygulanması daha kolay ve hızlı olur.</p><p>Kalıtım ayrıca, kodun bakımını da kolaylaştırır. Örneğin, bir sınıfın bir özelliğinde yapılan değişiklik, bu sınıftan türetilen diğer sınıfları da etkileyebilir. Bu durumda, her bir sınıfı ayrı ayrı değiştirmek yerine, üst sınıfta yapılan değişiklik tüm alt sınıflara uygulanabilir.</p><p>Kalıtım ayrıca, kodun yeniden kullanılabilirliğini de artırır. Bir sınıfın özellikleri kullanılarak yeni sınıflar oluşturmak, kodun yeniden kullanımını kolaylaştırır ve programlama sürecini hızlandırır.</p><h3>4-) Polimorfizm (Polymorphism)</h3><p>Polimorfizm, aynı isimdeki farklı metotların, farklı sınıflar tarafından farklı şekillerde uygulanabilmesine olanak tanıyan bir kavramdır. Polimorfizm, programlama dillerinde kod tekrarını azaltır ve kodun yeniden kullanılabilirliğini artırır. Ayrıca, programlama hatalarının azaltılmasına da yardımcı olabilir. Örneğin, bir arayüzü uygulayan farklı sınıfların aynı işlevselliği farklı şekillerde gerçekleştirmesi mümkündür. Bu, kodun daha esnek olmasını ve gereksinimlerin değiştiği durumlarda daha kolay değiştirilebilmesini sağlar.</p><p>Polimorfizm, Java’da runtime sırasında da gerçekleştirilebilir. Bu, örneğin, bir üst sınıf referansı ile alt sınıf nesnesine erişmenizi ve üst sınıfın yöntemlerini kullanmanızı sağlar. Bu şekilde, aynı referans değişkeni hem üst sınıf hem de alt sınıf nesnelerine atandığında, çalışma zamanında hangi yöntemin çağrılacağı belirlenir.</p><p>Java’da, polimorfizm genellikle aşağıdaki iki şekilde gerçekleştirilir:</p><ol><li><strong>Method Overloading (Metot Aşırı Yükleme)</strong></li></ol><p>Method overloading, aynı isimde farklı parametre listeleri olan metotların tanımlanmasına izin verir. Bu sayede, aynı isimli metotlar farklı işlevlerde kullanılabilirler.</p><p>Örnek olarak şöyle bir senaryo düşünelim: bir matematik kütüphanesi yazıyorsunuz ve iki sayının toplamını hesaplayan bir metot tanımlamak istiyorsunuz. Farklı sayı türleri için ayrı ayrı metotlar yazmak yerine, method overloading kullanarak tüm sayı türleri için aynı isimli bir metot tanımlayabilirsiniz:</p><pre>public class Matematik {<br><br>    public int topla(int x, int y) {<br>        return x + y;<br>    }<br><br>    public int topla(int x, int y, int z) {<br>        return x + y + z;<br>    }<br><br>    public double topla(double x, double y) {<br>        return x + y;<br>    }<br>    <br>    public float topla(float x, float y) {<br>        return x + y;<br>    }<br><br>    // diğer sayı türleri için de aynı şekilde topla metotları tanımlanabilir<br>}</pre><p>Java’da overloading yaparken dikkat edilmesi gereken bazı noktalar şunlardır:;</p><ul><li>Metodun adı aynı olmalıdır, fakat parametrelerin sayısı veya tipi farklı olmalıdır. İki aynı isimli metodun aynı parametrelerle tanımlanması hata verir.</li><li>Overloading sadece geri dönüş değeri farklı olan metotlar için kullanılamaz. Geri dönüş değeri aynı olan iki metot aynı parametrelerle tanımlanamaz.</li><li>Overloading sırasında farklı parametrelerin tipine ve sırasına dikkat edilmelidir. Aynı tipte parametrelerin farklı sıralarla kullanılması birbirleriyle karıştırılabilir ve kodun hataya neden olmasına neden olabilir.</li><li>Overloading yaparken, kullanılan parametrelerin tipinin açık olması, metotun hangi sürümünün çağrıldığının anlaşılmasını sağlar. Örneğin, bir metot hem int hem de double tipi kabul ederse, hangi sürümün çağrıldığını anlamak zor olabilir.</li><li>Overloading yaparken, kodun okunabilirliği ve sürdürülebilirliği göz önünde bulundurulmalıdır. Gereksiz yere fazla sayıda aşırı yüklemeli yöntemler kodun okunabilirliğini azaltabilir ve bakımını zorlaştırabilir.</li></ul><p>2. <strong>Method Overriding (Metot Ezme)</strong></p><p>Method overriding, alt sınıfların, üst sınıflarındaki metotların isimlerini, parametrelerini ve dönüş türlerini aynı şekilde kullanarak, kendi özelleştirilmiş sürümlerini yazmalarını sağlar.</p><p>Örnek olarak, aşağıdaki şekilde bir üst sınıf ve alt sınıf tanımlayalım:</p><pre>public class Hayvan {<br><br>    public void sesCikar() {<br>        System.out.println(&quot;Hayvan sesi&quot;);<br>    }<br>}</pre><pre>public class Kedi extends Hayvan {<br><br>    @Override<br>    public void sesCikar() {<br>        System.out.println(&quot;Miyav&quot;);<br>    }<br>}</pre><p>Bu örnekte, Hayvan sınıfında bir sesCikar metodu tanımlanmıştır ve Kedi sınıfı bu metodu ezerek kendi sesCikar metodunu tanımlamıştır. Bu sayede, aynı kod bloğu farklı nesnelerle çalışarak birden fazla farklı sonuç üretebilir. Bu özelliği sayesinde, kodun tekrar kullanılabilirliği ve esnekliği artar. Ayrıca, farklı sınıfların aynı yöntemi veya özelliği kullanabilmesine olanak tanır.</p><p>Java’da overriding yaparken dikkat edilmesi gereken bazı noktalar şunlardır:</p><ul><li>Üst sınıf içerisinde yer alan private metotlar override işlemine tabi tutulmaz. Aksi takdirde hata alınır.</li><li>Override ettiğimiz bir metodun erişim belirleyicisinin seviyesini düşüremeyiz fakat yükseltebiliriz.</li><li>Üst sınıftan miras aldığımız bir metodun dönüş tipini veya parametrelerini değiştiremeyiz.</li><li>Static ve Final olarak tanımlı metotları override edemeyiz.</li><li>Üst sınıfımızdaki ve alt sınıfımızda bulunan override edeceğimiz metot isimleri aynı olmalıdır.</li><li>Constructor (Yapıcı / Kurucu) metotlar override edilemez.</li></ul><h4>Parametre olarak nesne kullanımı</h4><p>Elde ettiğimiz polimorfik özellikler, parametre olarak nesne kullanımında da karşımıza çıkar. Yani, bir metoda farklı türlerden nesneleri parametre olarak gönderebiliriz.</p><p>Örneğin, Hayvan sınıfı ve bu sınıftan türetilmiş Kedi ve Köpek sınıflarımız olsun:</p><pre>public class Hayvan {<br>    public void beslen() {<br>        System.out.println(&quot;Hayvan besleniyor.&quot;);<br>    }<br>}</pre><pre>public class Kedi extends Hayvan {<br>    @Override<br>    public void beslen() {<br>        System.out.println(&quot;Kedi mamayı yiyor.&quot;);<br>    }<br>}</pre><pre>public class Köpek extends Hayvan {<br>    @Override<br>    public void beslen() {<br>        System.out.println(&quot;Köpek kemiği kemiriyor.&quot;);<br>    }<br>}</pre><p>Bu sınıflardan birer örnek oluşturalım ve bunları bir metoda parametre olarak gönderelim:</p><pre>public class Test {<br>    public static void main(String[] args) {<br>        Hayvan hayvan1 = new Hayvan();<br>        Kedi kedi1 = new Kedi();<br>        Köpek köpek1 = new Köpek();<br><br>        beslenmeZamani(hayvan1);<br>        beslenmeZamani(kedi1);<br>        beslenmeZamani(köpek1);<br>    }<br><br>    public static void beslenmeZamani(Hayvan hayvan) {<br>        hayvan.beslen();<br>    }<br>}</pre><p>Çıktı şu şekilde olacaktır:</p><pre>Hayvan besleniyor.<br>Kedi mamayı yiyor.<br>Köpek kemiği kemiriyor.</pre><p>Yani, Hayvan sınıfının beslen() metodu override edildiği için Kedi ve Köpek sınıflarında da bu metot kullanılabiliyor. Ve beslenmeZamani() metodunda, Hayvan türünden bir parametre aldığımız halde farklı türlerdeki nesneleri bu parametre ile gönderebiliyoruz. Bu sayede, polimorfik özellikler sayesinde kodumuz daha esnek ve genişletilebilir hale geliyor.</p><p>Yani kısaca Hayvan sınıfını extends eden alt sınıflar (örneğin Kedi ve Köpek sınıfları), Hayvan tipinde bir nesne olarak kullanılabilirler.</p><h3>5-) Soyut Sınıflar ve Arabirimler (Abstract Classes and Interfaces)</h3><h4>Soyut Sınıflar (Abstract Classes)</h4><p>Java’da soyut sınıflar, tamamlanmamış sınıfları temsil eden ve nesne olarak örneklendirilemeyen sınıflardır. Bu sınıfların bir veya daha fazla soyut metodu (method) bulunur. Soyut metodlar, sadece tanımlarını içerir ve gövdelerinde işlevsellik yoktur. Alt sınıflar, soyut sınıfın soyut metodlarını uygulamak zorundadır. Böylece alt sınıflar, soyut sınıfın soyut metotlarını geçersiz kılabilirler (override) ve kendi işlevselliğini sağlayabilirler.</p><p>Soyut sınıf tanımlanırken, class anahtar kelimesinin yanında abstract kelimesi kullanılır. Örneğin:</p><pre>public abstract class Sekil {<br>   public abstract void ciz();<br>}</pre><p>Yukarıdaki örnekte, “Sekil” adında soyut bir sınıf tanımlanıyor. “Sekil” sınıfı, “ciz” adında bir soyut metoda sahiptir. “Ucgen”, “Daire” ve “Dikdortgen” adında üç alt sınıf, “Sekil” sınıfından kalıtım alır ve “ciz” metodu uygulanır. Bu alt sınıfların her biri, “ciz” metodu ile kendi şekillerini çizdirmek için farklı bir uygulama sağlar.</p><pre>public class Ucgen extends Sekil {<br>   @Override<br>   public void ciz() {<br>      System.out.println(&quot;Üçgen çizildi.&quot;);<br>   }<br>}</pre><pre>public class Daire extends Sekil {<br>   @Override<br>   public void ciz() {<br>      System.out.println(&quot;Daire çizildi.&quot;);<br>   }<br>}</pre><pre>public class Dikdortgen extends Sekil {<br>   @Override<br>   public void ciz() {<br>      System.out.println(&quot;Dikdörtgen çizildi.&quot;);<br>   }<br>}</pre><p>Alt sınıflar, soyut metotları uygulamak zorundadır, yoksa kendileri de soyut sınıf olarak tanımlanır. Yukarıdaki örnekte, “Ucgen”, “Daire” ve “Dikdortgen” sınıfları, “Sekil” sınıfından kalıtım aldığı için “ciz” metodunu uygulamak zorundadır.</p><p>Ana metodda, üç farklı şekil için nesneler oluşturulur ve “ciz” metodu çağrılır:</p><pre>public static void main(String[] args) {<br>   Sekil ucgen = new Ucgen();<br>   Sekil daire = new Daire();<br>   Sekil dikdortgen = new Dikdortgen();<br><br>   ucgen.ciz();   // &quot;Üçgen çizildi.&quot; çıktısı verir<br>   daire.ciz();   // &quot;Daire çizildi.&quot; çıktısı verir<br>   dikdortgen.ciz();   // &quot;Dikdörtgen çizildi.&quot; çıktısı verir<br>}</pre><p>Bu örnekte, “Ucgen”, “Daire” ve “Dikdortgen” nesneleri, “Sekil” sınıfından türetilir ve “ciz” metodunu uygularlar. Bu sayede, ana sınıfın nesnesi oluşturulmadan, alt sınıfların nesneleri oluşturulabilir ve bu nesneler üzerinden ana sınıfın metotlarına erişim sağlanabilir.</p><p>Gövdesi olan metotlar da tanımlanabilir. Onları da şu örnekten görebilirsiniz:</p><pre>public abstract class Sekil {<br>    public abstract double alanHesapla(); //soyut metot<br><br>    public double cevreHesapla() {<br>        //gövdeli metot<br>        //burada cevre hesaplama işlemleri yapılabilir<br>    }<br>}</pre><h4>Arayüz (Interfaces)</h4><p>Arayüzler, bir sınıfın uygulayabileceği belirli bir davranış setini tanımlayan bir sözleşmedir. Bir arayüz, bir veya daha fazla metot tanımı içerir, ancak bu metotların gövdeleri yoktur. Arayüzler, bir sınıfın belirli bir davranışı uygulamasını zorunlu kılmak için kullanılır.</p><p>Java’da arayüzler, bir sınıfın “implements” anahtar sözcüğü ile bir arayüzü uygulayabileceği şekilde kullanılır. Bir sınıf, birden fazla arayüzü uygulayabilir.</p><p>Arayüzlerin kullanımı, kodun okunabilirliğini ve yeniden kullanılabilirliğini artırır. Arayüzler, kodun bağımlılığını azaltır ve daha ölçeklenebilir bir kod yazma sürecine yardımcı olur.</p><p>Aşağıda bir örnek verelim:</p><pre>public interface SesiCikarabilir {<br>    public void sesCikar();<br>}</pre><pre>public class Kedi implements SesiCikarabilir {<br>    @Override<br>    public void sesCikar() {<br>        System.out.println(&quot;Miyav&quot;);<br>    }<br>}</pre><pre>public class Kopek implements SesiCikarabilir {<br>    @Override<br>    public void sesCikar() {<br>        System.out.println(&quot;Hav Hav&quot;);<br>    }<br>}</pre><p>Bu örnekte, “SesiCikarabilir” adında bir arayüz tanımlanmıştır. Arayüz, “sesCikar” adında bir metot içerir. “Kedi” ve “Kopek” adında iki sınıf, “SesiCikarabilir” arayüzünü uygular. Her iki sınıf da “sesCikar” metotunu uygular, ancak her biri kendi şekillerinde uygular.</p><h4>Abstract class ve interface arasındaki farklar şunlardır:</h4><ol><li>Soyut sınıflar, sadece kalıtım yoluyla kullanılabilirken, arabirimler herhangi bir sınıf tarafından uygulanabilir.</li><li>Soyut sınıflar, özellikleri ve metotları hem soyut hem de gövdeli olabilirken, arabirimler sadece soyut metotları içerebilir.</li><li>Soyut sınıfların nesneleri oluşturulabilirken, arabirimlerin nesneleri oluşturulamaz.</li><li>Soyut sınıflar, bir sınıf tarafından kalıtım yoluyla genişletilirken, arabirimler bir sınıf tarafından uygulanabilir ve bir sınıf birden fazla arabirim uygulayabilir.</li><li>Soyut sınıfların, sınıflar arasında kod paylaşımını sağlama gibi ek özellikleri vardır, arabirimler ise sadece bir sınıfın belirli bir davranışı uygulamasını sağlar.</li><li>Soyut sınıflar, alt sınıflarında değişkenler ve metotlar tutabilirken, arabirimler yalnızca metot imzalarını tutabilir.</li></ol><p>Bu nedenle, bir soyut sınıf, alt sınıflarında ortak kodlar kullanmanız gerektiğinde veya bir nesne oluşturmanız gerektiğinde kullanılabilir. Diğer taraftan, bir arabirim, benzer davranışları gerektiren farklı sınıflar için kullanışlıdır.</p><h4>Genel bir bakış</h4><p>Java programlama dilinde sınıflar ve nesneler, programlama yaparken en temel yapı taşlarından biridir. Java’nın nesne yönelimli programlama paradigması, nesnelerin oluşturulmasına, yönetilmesine ve etkileşimine olanak sağlar. Sınıflar, nesnelerin oluşturulmasında kullanılan şablonlar olarak düşünülebilir. Her bir sınıfın kendi özellikleri ve işlevleri vardır ve nesneler bu sınıfların özelliklerini ve işlevlerini miras alır.</p><p>Java’da sınıflar ve nesneler kullanarak, büyük ve karmaşık projeleri daha küçük ve daha yönetilebilir parçalara ayırabilirsiniz. Nesneler, kendi özellikleri ve işlevleriyle birlikte, başka nesnelerle etkileşim kurabilir ve birbirleriyle iletişim halinde olabilirler. Bu, programlama yaparken kodun daha okunaklı ve daha anlaşılır hale gelmesine olanak sağlar.</p><p>Sınıflar ve nesneler, Java’da birçok farklı uygulama alanında kullanılabilir. Örneğin, yazılım geliştirme, web programlama, mobil uygulama geliştirme ve oyun programlama gibi birçok farklı alanda sınıflar ve nesneler kullanılabilir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cde712f1ab7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/t%C3%BCrkiye/javada-s%C4%B1n%C4%B1flar-ve-nesneler-cde712f1ab7e">Java’da Sınıflar ve Nesneler</a> was originally published in <a href="https://medium.com/t%C3%BCrkiye">Türkçe Yayın</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java’da Kullanıcıdan Veri Almak]]></title>
            <link>https://medium.com/kodcular/javada-kullan%C4%B1c%C4%B1dan-veri-almak-d83cb101631?source=rss-559f3ea5c268------2</link>
            <guid isPermaLink="false">https://medium.com/p/d83cb101631</guid>
            <category><![CDATA[kullanici-deneyimi]]></category>
            <category><![CDATA[veri-alma]]></category>
            <category><![CDATA[java-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[scanner]]></category>
            <dc:creator><![CDATA[Adnan Yağmur]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 06:18:08 GMT</pubDate>
            <atom:updated>2025-08-11T17:05:40.127Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Pb47wnmlN201inlk7FnT7A.jpeg" /></figure><p>Bu kısmında Scanner sınıfını import edeceğiz main sınıfımıza. Bu import şekli javada var olan bir hazır sınıfın mevcut kodumuza dahil edilmesi ve kullanılması için yapılır. 1. satırda gördüğünüz gibidir.</p><p>Kod bu kısma geldiğinde bizden değer bekler a = input.nextInt();</p><pre>import java.util.Scanner;</pre><pre>public class Main {</pre><pre>public static void main(String[] args) {</pre><pre>int a;</pre><pre>// kullanıcıdan bu yapı ile alıyoruz değeri<br>        Scanner input = new Scanner(System.in);<br>        System.out.print(&quot;Lütfen bir sayı giriniz: &quot;);<br>        // ve aldığımız değeri oluşturduğumuz değere atıyoruz.<br>        // aşağıda next kısmında bir çok yapı mevcut.<br>        //almak istediğimiz veri tipine göre next.... şekilde          //farktlı tipleri de verebilriz.<br>        a = input.nextInt();</pre><pre>System.out.println(a);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*y89JJ_P7XTmlJgHDhaq7dQ.png" /><figcaption>Console çıktısı.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d83cb101631" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kodcular/javada-kullan%C4%B1c%C4%B1dan-veri-almak-d83cb101631">Java’da Kullanıcıdan Veri Almak</a> was originally published in <a href="https://medium.com/kodcular">Kodcular</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>