<?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 Zeliha İnan on Medium]]></title>
        <description><![CDATA[Stories by Zeliha İnan on Medium]]></description>
        <link>https://medium.com/@zelihainann?source=rss-51fd3b80593------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T5J_5k5cCSdGluxHRN7eIA.jpeg</url>
            <title>Stories by Zeliha İnan on Medium</title>
            <link>https://medium.com/@zelihainann?source=rss-51fd3b80593------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 21:47:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zelihainann/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[Beyond Points and Badges: Designing Gamification Around Meaningful Progress]]></title>
            <link>https://medium.com/@zelihainann/beyond-points-and-badges-designing-gamification-around-meaningful-progress-30057b810b7b?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/30057b810b7b</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[gamification]]></category>
            <category><![CDATA[points]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 13:24:07 GMT</pubDate>
            <atom:updated>2026-07-10T13:24:07.819Z</atom:updated>
            <content:encoded><![CDATA[<p>When people hear the word gamification, they usually think of points, badges, levels, and daily streaks. These can definitely be part of gamification, but I do not think they explain the whole idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1XhlXaayfKGYKyEbWCl6lg.png" /></figure><p><strong>Good gamification does not simply reward the user. </strong>It turns a small action into something visible, meaningful, and worth continuing.</p><p>Completing a task in an app is a small action on its own. But when that action keeps a streak alive, grows a character, expands a collection, or makes the user’s past effort visible, it becomes a much stronger experience.</p><p>My interest in this topic started especially through the idea of a habit tracker. In habit tracking apps, the biggest challenge is usually not adding habits. The real challenge is <strong>continuing</strong>.</p><p>On the first day, anyone can feel motivated. You set a few goals, choose colorful icons, and open the app with excitement. But after a few days, notifications start to feel ordinary, checking off a list becomes less satisfying, and the app slowly turns from “something that motivates me” into “just another task.”</p><p>This is where gamification can help. But only if it is used well.</p><h4>Gamification Is Not Just About Giving Points</h4><p>Giving users points after every action is easy. Adding a few badges is also easy. Even building a level system may not be technically difficult.But the real question is: <em>Does this mechanic actually give the user a sense of progress?</em></p><p>If points are only numbers on a screen, they can lose their meaning after a while. If badges are given for every tiny action, badges may start to feel less valuable. If losing a streak makes the user feel bad, the system may start creating pressure instead of motivation. That is why I think this distinction matters: Bringing the user back is one thing. Pressuring the user is another.</p><p>A good system does not shout, “You must continue.”<br>It feels more like: <strong><em>“</em></strong><em>You can continue from where you left off.”</em></p><h4>Duolingo: A Strong System That Needs Balance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4-CePrTRdXQ38nDmsbUqg.jpeg" /></figure><p>Duolingo is one of the most well-known examples of gamification. Users complete lessons, earn XP, protect their streak, move through leagues, and try to complete daily goals.</p><p>The strong part here is that Duolingo connects a small action, such as completing a daily lesson, to a larger sense of continuity. The user does not only think, “<em>I studied today.</em>” They also feel that they protected their streak, earned XP, and are still making progress.</p><p>But there is another important detail in Duolingo: <strong>Streak Freeze</strong>.</p><p>When a user misses a day, their streak may not be lost immediately. This small detail says a lot about gamification. <strong>Because real life is not perfect every day.</strong> People can be busy, sick, forgetful, or simply need rest. That is why good gamification should not only bring users back; it should also leave room for the days when they cannot come back.</p><blockquote>Gamification should motivate users, not make them feel guilty.</blockquote><h3>Why Do Users Form a Bond?</h3><p>Examples like <strong>Tamagotchi</strong>, <strong>Pou</strong> or <strong>My Talking Tom</strong> are memorable not only because they were fun. They were memorable because they gave users the feeling of caring for something.</p><p>When a character grows, changes, or evolves, the user’s actions become connected to something more emotional. The user does not just press a button. <em>They affect something.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*qmJtkQKgOVruXvkTRplbPA.jpeg" /></figure><p>I think this is where one of the strongest sides of gamification begins.</p><ul><li>In an education app, a map can unlock as the user learns.</li><li>In a finance app, a visual goal can be completed as the user saves money.</li><li>In a fitness app, a virtual space can develop as the user moves.</li><li>In a habit tracker, a small creature can grow as the user completes habits.</li></ul><p>The last example is the one that interests me the most. In habit trackers, a completed habit does not have to end as a simple checkmark. It can become part of something visible, something that grows with the user’s effort.</p><h3>Habit Tracker Example: Growing a Creature</h3><p>In a habit tracker app, the simplest feedback is a checkmark. The user completes a task, a mark appears next to it, and the day ends. Functionally, this is enough. But emotionally, it is not very strong.</p><p>Instead, imagine a system like this:</p><ul><li>The user completes a habit.</li><li>A small creature earns XP.</li><li>As XP increases, the creature grows.</li><li>At certain levels, it evolves into a new form.</li><li>When it becomes an adult, it joins a collection.</li><li>The user starts growing a new creature.</li></ul><p>In this system, the user does not only complete a task. They also witness the development of something.</p><p><strong>Checking off a list gives instant satisfaction.</strong><br><strong>Watching a character grow creates a sense of continuity.</strong></p><p>When the user comes back to the app, they do not only see their unfinished tasks. They also see a small world they are still taking care of. For a habit tracker, which is built around repetition, I think this makes a meaningful difference.</p><h4>What Could a Small XP System Look Like?</h4><p>A simple system could look like this:</p><pre>Each completed habit: +10 XP<br>Daily maximum: 40 XP<br>3-day streak bonus: +5 XP<br>7-day streak bonus: +10 XP<br>Missed day: main progress stays, streak bonus resets<br><br>100 XP: Baby → Young<br>300 XP: Young → Adult<br>Adult creature: added to the collection</pre><p>The goal here is not to design a perfect game economy. The important part is to think about what the system encourages.</p><p>For example, the daily maximum XP prevents users from speeding through the system by adding too many habits. The streak bonus rewards consistency but does not become more important than the main progress. When the user misses a day, all their effort is not erased. I think this tone is especially important in habit-building apps.</p><h4>When Do Badges and Collections Become Meaningful?</h4><p>Badges are used often in gamification, but giving a badge for every action can reduce their impact.</p><p>A badge should carry meaning.</p><p>For example:</p><ul><li>Completing the first habit</li><li>Continuing for 7 days</li><li>Growing the first creature into an adult</li><li>Reaching 5 creatures in the collection</li><li>Returning regularly for a month</li></ul><p>These can be meaningful milestones in the user’s journey.</p><p>Collections, on the other hand, can feel more emotional than badges. Each creature in the collection can represent a period of effort from the user. Rather than looking at a generic achievement badge, the user sees something they helped grow over time. That makes past effort feel more personal, visible, and memorable.</p><h3>What Does This Become on the iOS Side?</h3><p>So far, I have mostly talked about the product and experience side. But when this idea becomes a real iOS app, the emotional experience starts depending on technical consistency.</p><p>If the user is growing a creature, that progress needs to feel reliable. XP should persist between app launches, collected creatures should remain in the collection, and the creature’s stage should always be calculated consistently. Even if a streak is broken, the main progress should not disappear. Otherwise, the emotional layer of the experience can break very quickly.</p><p>This is where SwiftUI and SwiftData become part of the design. SwiftData can store the important parts of the user’s progress locally on the device, while SwiftUI can reflect those changes on the screen. When XP increases, the creature can evolve, the interface can update, and small animations can make that progress feel alive.</p><p>The technical principle behind this is simple: <strong>store the core data, and derive the rest from it.</strong> For example, instead of saving the creature’s stage as a separate value, the app can calculate it from total XP. This keeps the system more consistent and reduces the chance of strange situations, like a creature having enough XP to be an adult but still appearing as a younger form.</p><p>Good gamification is not only about cute illustrations, badges, or animations. If users are going to form a bond with something inside the app, the system behind it has to be reliable enough to protect that bond.</p><h4>Small Actions Should Turn Into Something</h4><p>For me, the essence of gamification is turning small user actions into meaningful progress.</p><p>Completing a lesson, checking off a habit, adding a small amount to a savings goal, or reaching a daily step target may seem like small actions on their own. But when these actions become part of a streak, a collection, a growing character, or a visible journey, they start to feel much more valuable.</p><p>Points, streaks, badges, and levels are not enough on their own. They only become meaningful when they support the experience instead of replacing it.</p><p>That is why I think this question matters when designing gamification: Am I only giving the user a reward, or am I creating a reason for them to come back?</p><p>For me, growing a creature inside a habit tracker is a small but powerful answer to this question. Because sometimes, the thing that brings users back is not a bigger reward, but a small bond they do not want to lose.</p><blockquote>Stay tuned for my other articles, and don’t hesitate to ask any questions you have! <em>☆</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30057b810b7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The most disturbing thing about AI was written in 1965]]></title>
            <link>https://blog.stackademic.com/the-most-disturbing-thing-about-ai-was-written-in-1965-7f4a4304a380?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f4a4304a380</guid>
            <category><![CDATA[thinking]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dune]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 17:52:55 GMT</pubDate>
            <atom:updated>2026-04-21T09:58:22.380Z</atom:updated>
            <content:encoded><![CDATA[<p>Frank Herbert wrote it as fiction. But reading it today, it feels less like a novel and more like an early observation about the world we are living in.</p><p>Some sentences grab you faster than an entire book ever could. A quote I came across from <em>Dune</em> had exactly that effect on me. There was something strangely familiar about it; as if it were not a science fiction line written in 1965, but a comment from someone watching the age of artificial intelligence from the outside.</p><blockquote>“Once men turned their thinking over to machines in the hope that this would set them free. But that only permitted other men with machines to enslave them.”</blockquote><p>What struck me was not the power of the machines themselves. What struck me was the idea of people slowly handing over the burden of thinking and decision-making to other systems in the hope of becoming freer. Maybe that is exactly why <em>Dune</em> still feels so alive today.</p><p>This is not a <em>Dune</em> analysis. But I do want to follow the two questions opened up by Herbert’s sentence: Who gets to shape the power of artificial intelligence? And why is blind trust in charismatic leaders always dangerous? Because these are no longer just science fiction questions.</p><h3>The first danger: handing over the burden of thinking</h3><p>In the <em>Dune</em> universe, there is a turning point known as the “<em>Butlerian Jihad”</em>. Humanity creates thinking machines, a small minority gains enormous power by owning them, and after a two-hundred-year war, artificial intelligence is completely banned. What remains is a single commandment:</p><blockquote>“Thou shalt not make a machine in the likeness of a human mind.”</blockquote><p>For something written in 1965, this feels disturbingly familiar today. We created thinking machines. Once again, a small minority holds that power. The rest of society can access these tools, but does not own them. At first glance, the difference between access and ownership may seem small. But that is exactly where the real issue begins.</p><p>As a developer, I use these tools every day. While coding, researching, and making decisions. And the more I use them, the more I notice something: I have quietly moved some parts of my thinking outside myself. There are moments when I accept an output without questioning it enough. There are moments when I ask the model before I try to solve something on my own. Is that really freedom? Or is it a softer, more comfortable, and therefore less visible version of the surrender Herbert was talking about?</p><p>The real issue is not how good the machines are. The real issue is this: Who trains these tools, on what data, and according to which values? And where exactly do we, the users, stand within those decisions?</p><h3>Why did Geoffrey Hinton leave Google?</h3><p>One of the pioneers of artificial intelligence, Geoffrey Hinton, left his position at Google in 2023. His reason was clear: he wanted to be able to speak more freely about the dangers of this technology. Today, many people remember him not only for his technical contributions, but also for those warnings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vq-_LSOpoBId4fqmWOtyQ.jpeg" /><figcaption>“The Godfather of AI” Geoffrey Hinton, has quit Google to warn people of AI risks.</figcaption></figure><p>Hinton keeps emphasizing a few points. AI may deepen inequality. It may make the rich richer and the vulnerable even more fragile. If society is not prepared for the speed of this transformation, the result could be much darker than many people expect. What Hinton is drawing attention to is not only the power of the technology itself, but how that power grows, who controls it, and how fast it is being scaled.</p><p>Those warnings overlap almost perfectly with the fear Herbert pointed to in 1965. Sixty years apart, one expresses it through fiction, the other from inside AI labs. And yet they arrive at almost the same conclusion.</p><p>And these concerns do not belong to just one person. There are different camps in the AI debate. On one side are those who emphasize pluralism, transparency, and control. On the other are those driven mainly by speed, competition, and commercial growth. At that point, the core question stops being purely technical and becomes political: Will this power remain concentrated in the hands of a few companies and a few centers of influence, or will it be distributed more broadly?</p><h3>Is AI thinking, or just imitating?</h3><p>This leads to another debate. Some <em>transhumanist</em> views suggest that artificial intelligence may one day develop consciousness, surpass the human mind, or even become its next vessel. From that perspective, today’s large language models are only the beginning.</p><p>But there is an important distinction here. Consciousness cannot simply be reduced to reasoning. Consciousness involves will, feeling, experience, and action. It is a more complex structure in which all of those elements shape one another. Large language models, no matter how powerful they are, still fundamentally operate by processing patterns and generating the next most likely output.</p><p>That does not make them insignificant. Quite the opposite. For the first time, we are facing tools that challenge us in domains that resemble reasoning itself. Maybe that is what makes this moment so unsettling. For the first time, we are no longer comparing ourselves to machines only in terms of physical strength or computational speed, but in areas that seem close to thought.</p><p>And yet we still come back to the same question: What data are these tools built on, what values shape them, and whose purposes do they serve? Because the thing that still determines their direction is human intention. That is why this is not just a debate about how intelligent AI is. It is also a debate about whose will AI carries.</p><h3>The second danger: charismatic leaders and absolute power</h3><p>There is another idea at the center of Herbert’s <em>Dune</em> series: the idea that charismatic leaders can be dangerous for humanity.</p><p>This is one of the smartest things <em>Dune</em> does. Paul Atreides begins the story on the right side. He appears morally strong, intelligent, charismatic, and just. He becomes the voice of an oppressed people. Naturally, the reader trusts him and stands behind him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWyuewg6vnZe-XaAtp5XrA.jpeg" /></figure><p>But that is exactly what Herbert wants to show. The problem is not only when bad people gain power. The problem is that even someone who seems good, seems right, and may even truly have good intentions can still corrupt the system once they gain absolute power. Over time, Paul turns the people around him into followers who are dependent on him, even if he does not fully intend to. Leadership that begins with good intentions becomes something corrosive once it merges with absolute power.</p><p>At that point, the issue is not simply the leader’s personality, but the structure of power itself. Unconditional obedience corrupts the system, even when it begins in the name of something good. That is why Herbert’s warning still feels so current. In difficult times, it is easy to be drawn toward figures who speak with certainty and promise to solve everything. But those are exactly the moments when caution matters most.</p><blockquote>“Power tends to corrupt, and absolute power corrupts absolutely.”</blockquote><h3>What happens when the two dangers come together</h3><p>This is where the most unsettling question appears. Artificial intelligence on its own may look like a manageable problem. Authoritarianism is also a danger history has made us familiar with. But when the two come together, the picture becomes much darker.</p><p>Imagine extremely powerful AI tools merged with extremely concentrated political power: surveillance, propaganda, decision-making, resource distribution, classification, and behavioral steering. Such a combination would not merely deepen inequality; it could make those inequalities permanent. This is no longer only a science fiction scenario. It is already beginning to take shape.</p><p>One of the things Herbert was pointing to long ago was this: the question is not whether we should simply admire technology or fear it. The question is whether we can build a conscious relationship with it. Whether we know which technologies we are using, why we are using them, who controls them, and where limits need to be drawn.</p><p>The answer is not to reject technology entirely. But neither is it to embrace every new tool simply because it is possible or because it looks impressive. The real issue is conscious choice. Which tool, for what purpose, under whose control, and within which limits?</p><h3>Matrix let AI win. Dune let humanity win.</h3><p>One is a universe where AI comes to dominate. The other is a universe where AI has been banned: <em>The Matrix</em> and <em>Dune</em>. Both tell stories shaped by the tension between humans and machines. But they do not end the same way. In <em>The Matrix</em>, the machines win. In <em>Dune</em>, humanity does.</p><p>As a developer, I work with these tools every day. Rejecting them is neither realistic nor reasonable. But one thing I do know is this: we cannot stop asking who stands behind these tools, what they want, and where they are trying to lead us. Because when I read Herbert’s sentence again, I see that “other men with machines” is not an abstract threat. They are real people.</p><p>And they are moving very fast.</p><blockquote>If this piece made you think, I’d genuinely like to hear your perspective in the comments. And if you’d like to read more essays like this one, feel free to follow along ☆</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f4a4304a380" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/the-most-disturbing-thing-about-ai-was-written-in-1965-7f4a4304a380">The most disturbing thing about AI was written in 1965</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dependency Injection Made Simple with SwiftUI’s Environment]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/dependency-injection-made-simple-with-swiftuis-environment-d2f50951ad9c?source=rss-51fd3b80593------2"><img src="https://cdn-images-1.medium.com/max/1200/1*BnJh2Jjmre9U8SWSfglZkw.png" width="1200"></a></p><p class="medium-feed-snippet">Software engineering emphasizes principles such as modularity, testability, and maintainability. One design principle that strongly&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/dependency-injection-made-simple-with-swiftuis-environment-d2f50951ad9c?source=rss-51fd3b80593------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/dependency-injection-made-simple-with-swiftuis-environment-d2f50951ad9c?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2f50951ad9c</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[id]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 16:22:14 GMT</pubDate>
            <atom:updated>2025-11-30T13:20:55.962Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[SwiftUI Property Wrappers Explained: The Only Decision Tree You’ll Ever Need]]></title>
            <link>https://medium.com/@zelihainann/swiftui-property-wrappers-explained-the-only-decision-tree-youll-ever-need-37af53875f83?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/37af53875f83</guid>
            <category><![CDATA[property-wrapper]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 19:27:05 GMT</pubDate>
            <atom:updated>2025-08-31T19:27:05.143Z</atom:updated>
            <content:encoded><![CDATA[<p>SwiftUI views are structs. They are lightweight, declarative, and <em>recreated frequently</em>. This means you can’t just keep mutable state inside a view like in UIKit. Instead, SwiftUI provides a set of <strong>property wrappers</strong> to manage state, environment values, and data persistence. But here’s the tricky part: which one should you use, and when?</p><p>The key question is always: <strong>Where does the data come from?</strong><em><br>(From a parent? From the environment? Created by the view? Stored on disk?)</em></p><p>Using this decision tree, let’s go step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vYW9P4xUKH2bE6tzOHbaZA.png" /></figure><h3>1. When data comes as a parameter</h3><h4>Immutable → Regular Property</h4><p>If the child just needs to display it, no wrapper required:</p><pre>struct TitleRow: View {<br>    let title: String<br>    var body: some View { Text(title) }<br>}</pre><h4>Mutable in child → @Binding</h4><p>If the child should also update it, use a two-way binding:</p><pre>struct ParentView: View {<br>    @State private var isOn = false<br><br>    var body: some View {<br>        ToggleRow(isOn: $isOn)<br>    }<br>}<br><br>struct ToggleRow: View {<br>    @Binding var isOn: Bool<br>    var body: some View {<br>        Toggle(&quot;Enable&quot;, isOn: $isOn)<br>    }<br>}</pre><p><strong><em>Note: </em></strong>A common mistake is to declare a @Binding without a source. Remember: every @Binding must point back to a real source like @State or a property in @StateObject.</p><h4>Observable model → @ObservedObject</h4><p>When a model is created outside and passed down:</p><pre>final class UserVM: ObservableObject {<br>    @Published var name = &quot;Alice&quot;<br>}<br><br>struct ProfileView: View {<br>    @ObservedObject var vm: UserVM<br>    var body: some View {<br>        Text(vm.name)<br>    }<br>}</pre><p><strong><em>Note:</em></strong> Don’t create the model inside with @ObservedObject var vm = UserVM(). That will recreate it on every render. If the view owns the model, use @StateObject.</p><h3>2. When data comes from the environment</h3><h4>System values → @Environment</h4><p>Use this for framework-provided values like colorScheme or dismiss:</p><pre>struct ThemedView: View {<br>    @Environment(\.colorScheme) var scheme<br>    var body: some View {<br>        Text(scheme == .dark ? &quot;Dark&quot; : &quot;Light&quot;)<br>    }<br>}</pre><h4>App-wide models → @EnvironmentObject</h4><p>For shared state across the app:</p><pre>final class Settings: ObservableObject {<br>    @Published var darkMode = false<br>}<br><br>@main<br>struct MyApp: App {<br>    @StateObject private var settings = Settings()<br>    var body: some Scene {<br>        WindowGroup {<br>            RootView().environmentObject(settings)<br>        }<br>    }<br>}<br><br>struct RootView: View {<br>    @EnvironmentObject var settings: Settings<br>    var body: some View {<br>        Toggle(&quot;Dark Mode&quot;, isOn: $settings.darkMode)<br>    }<br>}</pre><p><strong><em>Note:</em></strong> Forgetting .environmentObject(settings) causes a runtime crash.</p><h3>3. When the view itself creates the data</h3><h4>Local state → @State</h4><p>Perfect for small, simple, view-owned values:</p><pre>struct Counter: View {<br>    @State private var count = 0<br>    var body: some View {<br>        Button(&quot;Increment&quot;) { count += 1 }<br>        Text(&quot;Count: \(count)&quot;)<br>    }<br>}</pre><p>Use @State for flags, form input, tab selections. Avoid storing heavy models here.</p><h4>Owned model → @StateObject</h4><p>When the view creates and owns a view model:</p><pre>final class TodosVM: ObservableObject {<br>    @Published var items: [String] = []<br>}<br><br>struct TodosView: View {<br>    @StateObject private var vm = TodosVM()<br>    var body: some View {<br>        List(vm.items, id: \.self, rowContent: Text.init)<br>    }<br>}</pre><p><strong>Rule of thumb:</strong></p><ul><li>If you <strong>create it</strong> → @StateObject.</li><li>If you <strong>receive it</strong> → @ObservedObject.</li></ul><h3>4. When the data lives on disk</h3><h4>UserDefaults → @AppStorage</h4><p>For simple persistent settings:</p><pre>struct SettingsView: View {<br>    @AppStorage(&quot;darkMode&quot;) private var darkMode = false<br>    var body: some View {<br>        Toggle(&quot;Dark Mode&quot;, isOn: $darkMode)<br>    }<br>}</pre><h4>Scene-specific persistence → @SceneStorage</h4><p>Keeps values tied to each window/scene:</p><pre>struct NoteEditor: View {<br>    @SceneStorage(&quot;draft&quot;) private var draft = &quot;&quot;<br>    var body: some View {<br>        TextEditor(text: $draft)<br>    }<br>}</pre><h4>Core Data / SwiftData → @FetchRequest or @Query</h4><pre>struct ArticlesView: View {<br>    @FetchRequest(<br>        sortDescriptors: [NSSortDescriptor(keyPath: \Article.date, ascending: false)]<br>    ) private var articles: FetchedResults&lt;Article&gt;<br><br>    var body: some View {<br>        List(articles) { Text($0.title ?? &quot;&quot;) }<br>    }<br>}</pre><p>In SwiftData (iOS 17+):</p><pre>struct ArticlesView: View {<br>    @Query(sort: \Article.date, order: .reverse) var articles: [Article]<br>    var body: some View { /* ... */ }<br>}</pre><h3>Supporting Wrappers</h3><ul><li><strong>@Published</strong>: Inside ObservableObject to publish changes.</li><li><strong>@FocusState</strong>: Manage keyboard focus.</li><li><strong>@GestureState</strong>: Temporary state during a gesture.</li><li><strong>@Namespace</strong>: For matched geometry animations.</li><li><strong>@ScaledMetric</strong>: Auto-scale measurements for Dynamic Type.</li></ul><blockquote>In day-to-day app development, the most frequently used wrappers are not only essential in practice but are also common topics in technical interviews.</blockquote><blockquote>By internalizing this decision-making framework, you will be able to build SwiftUI projects that are more consistent, maintainable, and scalable, while also demonstrating solid technical expertise in professional settings.</blockquote><blockquote><em>☆</em>Stay tuned for my other articles, and don’t hesitate to ask any questions you have!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37af53875f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing Between Structs and Classes in Swift: How to Make the Right Decision]]></title>
            <link>https://medium.com/womenintechnology/choosing-between-structs-and-classes-in-swift-how-to-make-the-right-decision-6425b4514cf8?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/6425b4514cf8</guid>
            <category><![CDATA[women-in-technology]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[pass-by-reference]]></category>
            <category><![CDATA[pass-by-value]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 14:52:25 GMT</pubDate>
            <atom:updated>2025-09-02T16:23:03.391Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most fundamental questions when learning Swift is: “Should I define this as a struct or as a class?”</p><p>At first glance, both look similar. They can hold properties, define methods, conform to protocols, and even be extended with extensions. But when we look closer, they behave very differently.</p><p>Apple’s official documentation clearly explains these differences and when to choose one over the other. Let’s dive into the key points with examples.</p><h4>Memory Model: Value vs Reference</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WLNQSSTZXRA_3YuFOJrQw.gif" /><figcaption>© 2025</figcaption></figure><p>The left side represents a Class (reference type) where both variables point to the same object, while the right side represents a Struct (value type) where each variable holds its own independent copy.</p><ul><li><strong>Structs</strong> are <em>value types</em>. Typically allocated on the <strong>stack</strong>, they are copied whenever assigned to a new variable or passed into a function. Swift optimizes this with <strong>Copy-on-Write (CoW)</strong>, meaning the actual copy only happens when one instance mutates.</li><li><strong>Classes</strong> are <em>reference types</em>. They live on the <strong>heap</strong>, and multiple variables can point to the same instance. Memory is managed with <strong>Automatic Reference Counting (ARC)</strong>, which keeps track of how many references exist and deallocates the object when none remain.</li></ul><h3>Struct: The Default Choice</h3><p>Apple recommends that you default to using struct. The main reason is that structs are <strong>value types</strong>.<br> This means that when a struct is assigned to another variable or passed into a function, <strong>it gets copied</strong>. Each copy is completely independent from the original.</p><p>This eliminates shared-state problems and makes reasoning about your code easier. In fact, Swift’s core library types like String, Array, and Dictionary are all implemented as structs.</p><p>Example:</p><pre>struct Point {<br>    var x: Int<br>    var y: Int<br>}<br><br>var p1 = Point(x: 5, y: 10)<br>var p2 = p1   // copied<br>p2.x = 100<br><br>print(p1.x) // 5<br>print(p2.x) // 100</pre><p>Here, p1 and p2 are completely independent. This independence keeps data integrity intact in your program.</p><h3>Class: When Is It Necessary?</h3><p>Most of the time, structs will do the job. But there are certain cases where <strong>classes are necessary</strong>. Apple highlights four main scenarios:</p><h4>1. Inheritance</h4><p>If you need one type to inherit from another, you must use a class. Structs cannot inherit.</p><pre>class Animal {<br>    func makeSound() {<br>        print(&quot;Some generic sound&quot;)<br>    }<br>}<br><br>class Dog: Animal {<br>    override func makeSound() {<br>        print(&quot;Woof!&quot;)<br>    }<br>}<br><br>let dog = Dog()<br>dog.makeSound() // &quot;Woof!&quot;</pre><p>Here, Dog inherits from Animal and customizes behavior. A struct cannot do this.</p><h4>2. Type Casting</h4><p>Classes allow runtime type checking (is) and type casting (as). Structs do not.</p><pre>class Vehicle { }<br>class Car: Vehicle { }<br><br>let myVehicle: Vehicle = Car()<br><br>if myVehicle is Car {<br>    print(&quot;This is a car!&quot;)<br>}</pre><p>In this example, myVehicle is stored as a Vehicle but is actually a Car. This flexibility is only possible with classes.</p><h4>3. Identity</h4><p>Structs don’t have identity — copies are always independent. Classes, being reference types, do. You can check whether two references point to the exact same object using the === operator.</p><pre>class Person {<br>    var name: String<br>    init(name: String) { self.name = name }<br>}<br><br>let p1 = Person(name: &quot;Zeliha&quot;)<br>let p2 = p1<br>let p3 = Person(name: &quot;Zeliha&quot;)<br><br>print(p1 === p2) // true (same object)<br>print(p1 === p3) // false (different objects)</pre><h4>4. Deinitializer (deinit)</h4><p>Classes have a deinit method that runs just before the object is deallocated. Structs don’t have this feature.</p><pre>class FileHandler {<br>    init() {<br>        print(&quot;File opened.&quot;)<br>    }<br>    <br>    deinit {<br>        print(&quot;File closed.&quot;)<br>    }<br>}<br><br>var handler: FileHandler? = FileHandler()<br>handler = nil<br>// Output: &quot;File opened.&quot; then &quot;File closed.&quot;</pre><p>This makes it possible to perform cleanup operations such as closing files or terminating connections.</p><h4>Performance Considerations</h4><p>Structs are often faster for small, <strong>immutable</strong> models because they avoid reference counting overhead.</p><p>Classes may be better for large, complex models where copying would be expensive.</p><p>Swift’s <strong>Copy-on-Write</strong> mechanism optimizes performance for collections like Array or Dictionary, avoiding unnecessary duplication until mutation occurs.</p><h4>Protocol-Oriented Design with Structs</h4><p>Swift encourages <strong>Protocol-Oriented Programming (POP)</strong>, which works especially well with structs. Instead of relying on class inheritance, you compose behavior with protocols and extensions:</p><pre>protocol Flyable {<br>    func fly()<br>}<br><br>struct Drone: Flyable {<br>    func fly() { print(&quot;Drone is flying!&quot;) }<br>}<br><br>struct Bird: Flyable {<br>    func fly() { print(&quot;Bird is flying!&quot;) }<br>}</pre><p>This approach avoids the rigidity of inheritance and makes your codebase more flexible and modular.</p><h4>Common Ground: What Structs and Classes Share</h4><p>Despite their differences, structs and classes share many capabilities:</p><ul><li>Both can define properties.</li><li>Both can define methods.</li><li>Both can have initializers.</li><li>Both can conform to protocols.</li><li>Both can be extended with extensions.</li></ul><p>So in terms of functionality, they overlap quite a bit. The differences show up in inheritance, memory management, and reference behavior.</p><h3>When to Choose Struct vs Class</h3><p>Here’s the rule of thumb:</p><ul><li><strong>Use structs</strong> for small, simple, independent models where copying is safe (coordinates, colors, user settings, etc.).</li><li><strong>Use classes</strong> for complex models that require inheritance, shared state, or lifecycle management (deinit).</li></ul><p>Apple’s advice is very clear: <em>Think </em><em>struct first. Only use </em><em>class if you need what only a class can provide.</em></p><h4>Conclusion</h4><p>One of Swift’s greatest strengths is how it treats structs as first-class citizens. In many languages, classes dominate, but in Swift, structs are the default solution. This results in safer, faster, and more predictable code.</p><p>Still, classes have their place. When you need inheritance, identity, or deinitializers, a class is the right choice. The key is analyzing your needs and making the right decision for your model.</p><p><strong>Reference: </strong><a href="https://developer.apple.com/documentation/swift/choosing-between-structures-and-classes">Apple Developer Documentation</a></p><blockquote>☆ If you liked my article, don’t forget to follow and add your questions! You can also find more of my software-related writings on my profile!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6425b4514cf8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/womenintechnology/choosing-between-structs-and-classes-in-swift-how-to-make-the-right-decision-6425b4514cf8">Choosing Between Structs and Classes in Swift: How to Make the Right Decision</a> was originally published in <a href="https://medium.com/womenintechnology">Women in Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Swift 6 and iOS 18: Fundamentals, Variables, and Type Safety]]></title>
            <link>https://medium.com/@zelihainann/getting-started-with-swift-6-and-ios-18-fundamentals-variables-and-type-safety-2c24881de588?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c24881de588</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-developer]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Thu, 07 Aug 2025 12:53:17 GMT</pubDate>
            <atom:updated>2025-08-09T12:29:15.214Z</atom:updated>
            <content:encoded><![CDATA[<p>For years, Apple supported Objective-C as the primary language for app development. While powerful, Objective-C came with a complex syntax and limited safeguards against errors — making it harder for developers to write safe and maintainable code, especially in the fast-paced world of mobile development. In 2014, Apple introduced <strong>Swift</strong>, a modern language designed from the ground up to solve these very problems. Since then, Swift has become the <strong>official, recommended, and dominant language</strong> for building applications across Apple’s platforms.</p><p>Swift wasn’t just a new syntax — it was a shift in mindset. Its design encourages developers to write safer, more predictable, and highly performant code. With the release of <strong>Swift 6</strong>, the language continues to mature, introducing improvements in <strong>concurrency, performance, and safety</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coGQRI8Zbao2ucBaRiFppw.png" /></figure><p>In this series, we’ll explore the core foundations of Swift — not just how to write code, but why Swift is structured the way it is. Understanding the language’s design philosophy is essential if you want to build scalable and reliable applications.</p><p>This first article focuses on the basics: how to set up your environment, understand <strong>variables and constants</strong>, get familiar with <strong>type inference</strong>, and explore <strong>Swift’s unique approach to optionals</strong>. Throughout this series, we’ll align our content with Swift’s official documentation, but rewrite it in a way that is clearer and more digestible for beginners.</p><h3>Setting Up Swift</h3><p>Swift is a type-safe, expressive, and intuitive language. It was created to replace Objective-C with something more modern and maintainable. You can use Swift to build apps for iOS, macOS, watchOS, and tvOS.</p><p>To start writing Swift code, you’ll need <strong>Xcode</strong>, Apple’s official development environment. And if you’re just learning, <strong>Xcode Playgrounds</strong> is an excellent place to begin. It lets you experiment with Swift code in real time without having to create a full-blown app project.</p><p>Here’s what a new Playground file typically looks like:</p><pre>import UIKit<br><br>var greeting = &quot;Hello, playground&quot;</pre><p>From the very first lines, Swift begins to show its character.</p><h3>Variables, Constants, and Type Inference</h3><p>Swift uses var to declare variables and let for constants. This distinction is not just a style guideline—it&#39;s enforced by the compiler. If you declare a value with let, you cannot change it later. This design choice helps prevent accidental state changes.</p><pre>let pi = 3.14<br>pi = 3.1415 // Error: Cannot assign to &#39;let&#39; constant</pre><p>Using var allows for changes:</p><pre>var name = &quot;Zeliha&quot;<br>name = &quot;Ayşe&quot;</pre><p>What makes Swift unique here is its strong type system combined with <strong>type inference</strong>. If you don’t explicitly define the type, Swift infers it from the assigned value:</p><pre>var age = 22 // Swift infers Int<br>var height = 1.58 // Infers Double</pre><p>However, you can still declare types explicitly when you want:</p><pre>let birthYear: Int = 2002</pre><p>Swift’s approach ensures that many bugs can be caught at compile time rather than during runtime. It’s stricter, yes — but in a helpful way.</p><h3>Type Safety and Optionals</h3><p>One of Swift’s most defining features is its treatment of <strong>optionals</strong>. Unlike many languages where a variable can silently become null, Swift requires you to explicitly state when a value can be absent.</p><pre>var petName: String?<br>petName = &quot;Leo&quot;<br>petName = nil</pre><p>Here, petName is an optional String. It can contain either a String or nil. To use the value safely, you need to unwrap it—often with an if let statement:</p><pre>if let name = petName {<br>    print(&quot;Pet name: \(name)&quot;)<br>} else {<br>    print(&quot;No name provided.&quot;)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jDQqfRLhHnv3dOGRAdmgA.png" /></figure><p>This mechanism helps avoid the infamous “null reference” errors that plague many other languages. Swift forces you to consider the presence or absence of data and write your code accordingly.</p><h4>Why Swift Is Different</h4><p>Swift’s structure may feel strict at first — especially if you come from languages like Python or JavaScript. But that structure helps you write better, safer code. Rather than debugging unpredictable behavior at runtime, Swift makes you think about types, immutability, and nil values up front.</p><p>This might seem like a small difference, but it changes the entire development experience. You’ll spend more time designing your data and less time chasing bugs.</p><blockquote>In this article, we covered Swift’s core principles: variables, constants, type inference, optionals, and type safety. These aren’t just syntax rules — they reflect Swift’s core philosophy of <strong>safe and thoughtful code</strong>.</blockquote><blockquote>In the next part, we’ll dive into <strong>functions</strong>, <strong>collections</strong>, and <strong>control flow structures</strong> that form the logic of most Swift programs.</blockquote><blockquote><em>☆ </em>If you liked my article, don’t forget to follow and add your questions! You can also find more of my software-related writings on my profile!</blockquote><p><strong>Reference</strong>:<em><br></em><a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/"><em> Swift.org — The Basics<br></em></a><em> </em><a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/#Optionals"><em>Swift.org — Optionals</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c24881de588" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Framework: The Indispensable of the Java World]]></title>
            <link>https://medium.com/@zelihainann/spring-framework-the-indispensable-of-the-java-world-e19205cda41f?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/e19205cda41f</guid>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[id]]></category>
            <category><![CDATA[ioc]]></category>
            <category><![CDATA[spring]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Thu, 20 Mar 2025 16:12:00 GMT</pubDate>
            <atom:updated>2025-03-20T16:12:00.926Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a technology that everyone who develops software with Java encounters at some point: Spring Framework. So, what exactly is Spring, and why is it so popular? More importantly, why is it so critical for Java developers?<br>In this article, I will explore the Spring Framework in detail, explaining the problems it solves and why it is preferred in a way that everyone can understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*clBeqAat_oQ09nbUubog3g.jpeg" /></figure><h4><strong>What is Spring Framework?</strong></h4><blockquote><strong>Spring</strong> is an open-source framework used to develop enterprise-level Java applications.</blockquote><p>Its main goal is to make Java projects more flexible, manageable, and scalable. One of the greatest conveniences that Spring offers is greatly simplifying complex configurations and dependency management.</p><p><strong>The Story Behind the Birth of Spring Framework</strong><br>The story of the Spring Framework begins with an effort to find a solution to the complexity of Java’s traditional J2EE (Java 2 Platform Enterprise Edition) model. Developed by Rod Johnson in 2003, Spring was gradually embraced by a large community and revolutionized the Java world.</p><p>In the past, developing large-scale Java applications was tedious and exhausting. Issues like dependency management, database operations, and security management were a significant burden for developers. Spring’s innovative approach made these processes much more manageable.</p><p>One of the biggest differentiators of Spring is its modular and flexible structure. You can use only the components you need and build lighter and faster applications without including unnecessary modules.</p><h4><strong>Spring Modules</strong></h4><blockquote>Spring is not just a single tool; it is an <strong><em>ecosystem.</em></strong></blockquote><p>You can use different modules based on your needs to make your developed application more efficient. Here are some of the most commonly used modules of Spring:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*PCAW_S1PIxoIiKTW47HWPg.png" /><figcaption>Spring Modules</figcaption></figure><p><strong>1) Core Container</strong></p><p>This module manages the basic components and dependencies.</p><ul><li><strong>Beans</strong>: Manages and defines the core components of the application.</li><li><strong>Core</strong>: Contains the essential structural components that support the Spring Framework.</li><li><strong>Context</strong>: Helps manage the application components in the container.</li><li><strong>SpEL (Spring Expression Language)</strong>: Provides a flexible language for object management.</li></ul><p><strong>2) Data Access/Integration</strong><br>Spring offers various modules for database operations and integration with external systems:</p><ul><li><strong>JDBC (Java Database Connectivity)</strong>: Simplifies database operations.</li><li><strong>ORM (Object-Relational Mapping)</strong>: Provides integration with ORM technologies like Hibernate and JPA.</li><li><strong>OXM (Object-XML Mapping)</strong>: Facilitates working with XML elements.</li><li><strong>JMS (Java Message Service)</strong>: Supports messaging protocols.</li><li><strong>Transactions</strong>: Ensures consistency and security in database transactions.</li></ul><p><strong>3) Web Modules</strong><br> Spring offers several modules for developing web-based applications:</p><ul><li><strong>Web</strong>: Includes components that form the foundation of the Spring MVC framework.</li><li><strong>WebSocket</strong>: Provides real-time two-way communication.</li><li><strong>Servlet</strong>: Ensures compatibility with Java Servlet technology.</li><li><strong>Portlet</strong>: Supports Java portlet API.</li></ul><p><strong>4) AOP (Aspect-Oriented Programming)</strong><br>Spring AOP provides modular cross-cutting functionalities (like logging and security) that are independent of the application logic.</p><p><strong>5) Instrumentation</strong><br>Provides performance monitoring and profiling tools for Java applications.</p><p><strong>6) Messaging</strong><br>Facilitates integration with message-based systems, often used in microservices architectures.</p><p><strong>7) Test Module</strong><br>The Spring Framework simplifies unit and integration testing by integrating with testing libraries like JUnit and TestNG.</p><h4><strong>Core Components of Spring Framework</strong></h4><p>✧ <strong>Spring Core</strong>: Provides dependency management (Dependency Injection — DI) and object management (Inversion of Control — IoC).</p><p>✧ <strong>Spring MVC (Model-View-Controller)</strong>: Used for developing web applications.</p><p>✧ <strong>Spring Boot</strong>: Allows you to start applications quickly and easily by minimizing configuration requirements.</p><p>✧ <strong>Spring Data</strong>: Simplifies database operations.</p><p>✧ <strong>Spring Security</strong>: Manages authorization and authentication.</p><p>✧ <strong>Spring Cloud</strong>: Facilitates working with <em>microservice architectures</em>.</p><p><strong>Spring Core and Dependency Management (IoC and DI)</strong><br> The Spring Framework offers great conveniences to developers in terms of object management and dependency management. Two key concepts stand out in this context: IoC (Inversion of Control) and DI (Dependency Injection).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UQHil8kXF7lKe4yBdAiI9A.png" /><figcaption>The images belong to me. They are copyrighted.</figcaption></figure><p><strong>IoC (Inversion of Control)</strong><br> IoC refers to the process where the responsibility of creating and managing objects is handled by Spring’s IoC container instead of the developer. This minimizes dependencies between the application’s components.<br><strong>Advantages</strong>:</p><ul><li><strong>Loose Coupling</strong>: Reduces the dependency between objects, making the code more flexible and testable.</li><li><strong>More Modular Code</strong>: Since object management is handled by Spring, the code becomes more modular.</li></ul><p><strong>DI (Dependency Injection)</strong><br> DI is a design pattern that allows dependencies of an object to be injected from the outside. Spring automatically manages the dependencies between objects using DI.</p><p><strong>Types of Dependency Injection</strong><br> DI in Spring can be done in two primary ways:</p><p><strong>Constructor Injection</strong>: Dependencies are injected via the constructor when the object is created.<br><strong>Example</strong>:</p><pre>@Component  <br>public class MyService {  <br>    private final MyRepository myRepository;  <br>    @Autowired  <br>    public MyService(MyRepository myRepository) {  <br>        this.myRepository = myRepository;  <br>    }  <br>}</pre><p><strong>Setter Injection</strong>: Dependencies are injected through the setter methods of a class.<br><strong>Example</strong>:</p><pre>@Component  <br>public class MyService {  <br>    private MyRepository myRepository;  <br>    @Autowired  <br>    public void setMyRepository(MyRepository myRepository) {  <br>        this.myRepository = myRepository;  <br>    }  <br>}</pre><p><strong>Spring IoC Container and Bean Management</strong><br>The IoC Container (Inversion of Control Container) is a vital structure at the heart of the Spring Framework. IoC allows the creation and management of objects through an external container. This way, the application developer can leave the responsibility of creating objects and determining their relationships to Spring.<br> The goal of the Spring IoC container is to create objects called <strong>Beans</strong> — manageable units — and manage their lifecycle. Beans are objects controlled by Spring. The IoC container creates, configures, and provides dependencies for each Bean.</p><p>To manage the IoC container, Spring uses two main classes:</p><ul><li><strong>ApplicationContext</strong>: The primary IoC container that manages the application’s overall functionality and configuration. It is the container used in most Spring applications.</li><li><strong>BeanFactory</strong>: A lighter version of the IoC container that uses fewer resources to manage Beans. However, ApplicationContext is generally preferred as it offers more features.</li></ul><p><strong>What is a Bean?</strong><br> In Spring, a bean is an object managed by the Spring container. It is an instance of a class whose dependencies are injected by the Spring container. To make a class manageable by the Spring container, annotations like @Component, @Service, @Repository, or @Controller are typically used. These annotations allow Spring to consider the class a Bean. For example:</p><p>@Component: Used for general classes.</p><p>@Service: Used for service classes (business logic).</p><p>@Repository: Used for data access layers.</p><p>@Controller: Used for web layer (controller) classes.</p><p><strong>For more information:</strong></p><p><a href="https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/overview.html"><strong>Spring Framework Documentation</strong></a></p><blockquote>☆ In this article, we covered the basics of the Spring Framework. But to dive deeper and develop a truly meaningful application with Spring, in my next article, we will take a step into a Spring Boot project! In this project, I will show you how to use these concepts you’ve learned in a real-world application.</blockquote><blockquote>☆ If you liked my article, don’t forget to follow and add your questions! You can also find more of my software-related writings on my profile!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e19205cda41f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical Applications and Solutions with Window Functions in Advanced SQL]]></title>
            <link>https://medium.com/@zelihainann/practical-applications-and-solutions-with-window-functions-in-advanced-sql-79419ff93331?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/79419ff93331</guid>
            <category><![CDATA[query]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[practise]]></category>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[window-functions]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 11:15:05 GMT</pubDate>
            <atom:updated>2025-03-01T11:15:44.297Z</atom:updated>
            <content:encoded><![CDATA[<p>I have reached the end of my <strong>SQL Training</strong> series. Together, we embarked on a <strong>9-part journey</strong> from scratch. You can check out my previous articles <a href="https://medium.com/@zelihainann">on my profile</a>. <strong><em>Your comments and feedback are valuable to me!</em></strong></p><p>Of course, ensuring the retention of this knowledge is up to you through plenty of practice.</p><p>To help you get started, let’s solve<strong> </strong>three practical examples!</p><p><strong><em>Note:</em></strong> Below, I am sharing the <strong>ER diagram</strong> of the <strong>Northwind dataset</strong>, which I will use to solve the examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1Ce6hrvutws9C49mYMDrg.png" /></figure><p><strong>Question 1: </strong>Retrieve customers’ most recent orders and the shipping cost paid for those orders.</p><p><strong>Answer:</strong></p><p>Solution <em>without using a Window Function</em>:</p><pre>with t1 as (<br>select<br>    customer_id,<br>    max(order_id) as last_order<br>from orders<br>group by customer_id<br>)<br>select<br>    t1.customer_id,<br>    freight<br>from t1<br>left join orders o on t1.customer_id = o.customer_id and t1.last_order = o.order_id<br>order by 1;</pre><p>In this solution, we accessed the <strong>Orders</strong> table twice. Accessing the same table twice usually adds overhead in terms of time and cost. Generally, this is something we are expected to avoid.</p><p><em>Solution using a Window Function:</em></p><pre>with t1 as (<br>    select<br>        customer_id,<br>        order_id,<br>        freight,<br>        row_number() over (partition by customer_id order by order_id desc) as r_number<br>        --Rank orders per customer, latest order gets rank 1    <br>from orders<br>    order by 1,2<br>)<br>select<br>    customer_id,<br>    freight<br>from t1<br>where r_number = 1 --Select only the latest order per customer<br>order by 1;</pre><p><strong>Question 2: </strong>Find the monthly cumulative freight amount.</p><p><strong>Answer:</strong></p><pre>select<br>    to_char(shipped_date, &#39;YYYY-MM&#39;) as date,<br>    --Convert shipped_date to &#39;YYYY-MM&#39; format (Year-Month)<br>    sum(freight) as sum_freight,<br>    --Calculate total freight for each month<br>    sum(sum(freight)) over (order by to_char(shipped_date, &#39;YYYY-MM&#39;)) as cum_freight<br>    --Calculate cumulative sum of freight over time<br>from orders<br>where shipped_date is not null<br>group by 1<br>order by 1;</pre><p><strong>Question 3: </strong>Calculate the ratio of monthly sales to the annual total sales.</p><p><strong>Answer:</strong></p><pre>select<br>    extract(year from order_date) as year,<br>    extract(month from order_date) as month,<br><br>    sum(unit_price * quantity * (1-discount)) as total_monthly_revenue,<br>    sum(sum(unit_price * quantity * (1-discount))) over (partition by extract(year from order_date)) as total_yearly_revenue,<br><br>    100 * sum(unit_price * quantity * (1-discount)) <br>/ sum(sum(unit_price * quantity * (1-discount))) over (partition by extract(year from order_date)) <br>as percentage_of_annual_sales<br><br>from order_details od<br>left join northwind.orders o on o.order_id = od.order_id<br>group by 1,2<br>order by 1,2</pre><blockquote>☆If you enjoy my articles, you can follow me to stay updated and read them instantly!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79419ff93331" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing Data with Advanced Window Functions in SQL]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/womenintechnology/analyzing-data-with-advanced-window-functions-in-sql-56deced9da91?source=rss-51fd3b80593------2"><img src="https://cdn-images-1.medium.com/max/980/1*txDOpYdUdp2Ms8jYd7ADdw.png" width="980"></a></p><p class="medium-feed-snippet">Chapter 7: Learn to use Window Functions in SQL</p><p class="medium-feed-link"><a href="https://medium.com/womenintechnology/analyzing-data-with-advanced-window-functions-in-sql-56deced9da91?source=rss-51fd3b80593------2">Continue reading on Women in Technology »</a></p></div>]]></description>
            <link>https://medium.com/womenintechnology/analyzing-data-with-advanced-window-functions-in-sql-56deced9da91?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/56deced9da91</guid>
            <category><![CDATA[analyzing]]></category>
            <category><![CDATA[query]]></category>
            <category><![CDATA[window-functions]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 18:30:11 GMT</pubDate>
            <atom:updated>2025-08-27T01:23:45.069Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Learn Date & Time Functions in SQL and Write Powerful Queries]]></title>
            <link>https://medium.com/@zelihainann/learn-date-time-functions-in-sql-and-write-powerful-queries-3a85d9a7236f?source=rss-51fd3b80593------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a85d9a7236f</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[time]]></category>
            <category><![CDATA[function]]></category>
            <category><![CDATA[date]]></category>
            <dc:creator><![CDATA[Zeliha İnan]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 17:52:51 GMT</pubDate>
            <atom:updated>2025-02-27T17:52:51.918Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Chapter 6: Date-Time Functions in SQL</strong></p><p>Date and time operations are frequently used in databases. PostgreSQL provides powerful functions for handling date and time operations. In this article, we will explore commonly used <strong>SQL date/time functions</strong> along with example usages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*icKU8c252xvM3GWjNkTRhw.png" /></figure><h4>✧Getting the current date and time</h4><p>You can use the following commands to retrieve the current date and time:</p><pre>SELECT CURRENT_DATE; --Returns the current date.<br>SELECT CURRENT_TIME; --Returns the current time.<br>SELECT CURRENT_TIMESTAMP; --Returns the current date and time.<br>SELECT now(); --Returns the current timestamp value.</pre><h4>✧date_trunc Function</h4><p>The <strong>date_trunc</strong> function rounds a date or time value to a specified time unit. For example, it can be used to extract only the year, month, or day.</p><pre>SELECT <br>    bookingdate,  --The original booking date.<br>    DATE_TRUNC(&#39;month&#39;, bookingdate), --Returns the date truncated to the beginning of the month, setting day and time to zero.<br>    DATE_TRUNC(&#39;day&#39;, bookingdate), --Returns the date truncated to the beginning of the day, setting the time to zero.<br>    DATE_TRUNC(&#39;year&#39;, bookingdate), --Returns the date truncated to the beginning of the year, setting month, day, and time to zero.<br>    DATE_TRUNC(&#39;year&#39;, bookingdate)::DATE --Extracts only the year by converting it to a date format.<br>FROM bookings;</pre><h4>✧extract Function</h4><p>The <strong>extract</strong> function is used to retrieve a specific part of a timestamp.</p><p><strong>Examples:</strong></p><pre>SELECT EXTRACT(YEAR FROM &#39;2024-06-01 12:30:15&#39;::TIMESTAMP); <br>--Returns only the year (2024).<br><br>SELECT EXTRACT(DAY FROM &#39;2024-06-01 12:30:15&#39;::TIMESTAMP); <br>--Returns only the day (1).<br><br>SELECT bookingdate, <br>    EXTRACT(MONTH FROM bookingdate) <br>FROM bookings;<br>--Retrieves only the month from the booking date.</pre><h4>✧<strong>age Function</strong></h4><p>The <strong>age</strong> function returns the difference between two dates as an<strong> <em>interval </em>data type</strong>.</p><p><strong>Examples:</strong></p><pre>SELECT <br>    AGE(&#39;2022-06-03 11:30:15&#39;::TIMESTAMP, &#39;2022-06-01 12:40:15&#39;::TIMESTAMP);  <br>    --Returns the difference between two timestamps as an interval.<br><br>SELECT <br>    &#39;2022-06-03 11:30:15&#39;::TIMESTAMP - &#39;2022-06-01 12:40:15&#39;::TIMESTAMP;  <br>    --The same operation can be done using subtraction, which also returns an interval.<br><br>SELECT <br>    EXTRACT(DAY FROM &#39;2022-06-03 11:30:15&#39;::TIMESTAMP - &#39;2022-06-01 12:40:15&#39;::TIMESTAMP);  <br>    --Extracts only the number of days from the difference between two timestamps.</pre><p><strong>Question:</strong> How many days have passed since the customer’s last booking?</p><p><strong>Answer:</strong></p><pre>--Subtracting directly returns the difference in days. Example: 1901 days.<br>SELECT <br>    CURRENT_DATE - bookingdate <br>FROM bookings;<br><br>--Using the AGE function removes this issue by providing a more detailed interval.<br>SELECT <br>    AGE(CURRENT_DATE, bookingdate) <br>FROM bookings;<br><br>--Extracts only the number of days that have passed.<br>SELECT <br>    EXTRACT(DAY FROM CURRENT_DATE - bookingdate) <br>FROM bookings;</pre><h4>✧date_part Function</h4><p>The <strong>date_part</strong> function extracts a specific part of a date/time value, similar to the extract function.</p><pre>SELECT DATE_PART(&#39;month&#39;, &#39;2022-06-01 12:30:20&#39;::TIMESTAMP);  <br>--Returns the month part from the given timestamp (6).<br><br>SELECT EXTRACT(MONTH FROM &#39;2022-06-01 12:30:20&#39;::TIMESTAMP);  <br>--Returns the same output as the above query (6).</pre><h4>✧<strong>Date Calculation with </strong><strong>interval</strong></h4><p>In PostgreSQL, we can use interval to move dates forward or backward.</p><pre>SELECT (&#39;2022-06-01&#39;::DATE - INTERVAL &#39;1 month&#39;)::DATE;  <br>--Subtracts 1 month from the given date, returning &#39;2022-05-01&#39;.<br><br>SELECT (&#39;2022-06-01&#39;::DATE + INTERVAL &#39;1 month&#39;)::DATE;  <br>--Adds 1 month to the given date, returning &#39;2022-07-01&#39;.</pre><p><strong>Question: </strong>Let’s take the date as <strong>2021-06-02</strong> and retrieve reservations made in the last week.</p><p><strong>Answer:</strong></p><pre>select id,<br>       bookingdate,<br>       contactid<br>from bookings<br>where bookingdate &gt;= &#39;2021-06-01 00:00:00&#39;::timestamp - interval &#39;1 week&#39;;</pre><p><strong>Question: </strong>Let’s group reservations by month and count them:</p><p><strong>Answer:</strong></p><pre>select<br>    to_char(bookingdate, &#39;YYYY-MM&#39;) as booking_month,<br>    count(*)<br>from bookings<br>group by 1;</pre><blockquote>In this article, we covered date and time functions in SQL. Functions like date_trunc, extract, age, date_part, and interval are highly useful for performing date-based analyses. With the powerful functions SQL offers, you can easily manage date and time operations in your database.</blockquote><blockquote>Stay tuned for my upcoming articles! Our next topic is <strong>Analyzing Data with Advanced Window Functions in SQL</strong>.</blockquote><blockquote>If you have any questions, feel free to ask!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a85d9a7236f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>