<?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 Aslı Öztürk on Medium]]></title>
        <description><![CDATA[Stories by Aslı Öztürk on Medium]]></description>
        <link>https://medium.com/@ozturkaslii?source=rss-850d9be76685------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VIrDVh6tp3BpbMQZf_R56w.jpeg</url>
            <title>Stories by Aslı Öztürk on Medium</title>
            <link>https://medium.com/@ozturkaslii?source=rss-850d9be76685------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 03:23:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ozturkaslii/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[Mirrors, Machines and Memory: What Sufism Taught Me About the AI Race]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ozturkaslii/mirrors-machines-and-memory-what-sufism-taught-me-about-the-ai-race-33a24ff9f059?source=rss-850d9be76685------2"><img src="https://cdn-images-1.medium.com/max/1400/0*LJDlA5x8OTlwES0d.jpeg" width="1400"></a></p><p class="medium-feed-snippet">Through Sufi philosophy&#x2019;s mirror metaphor: what gets lost when imperfect humans create AI? On the race to build something smarter than us.</p><p class="medium-feed-link"><a href="https://medium.com/@ozturkaslii/mirrors-machines-and-memory-what-sufism-taught-me-about-the-ai-race-33a24ff9f059?source=rss-850d9be76685------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ozturkaslii/mirrors-machines-and-memory-what-sufism-taught-me-about-the-ai-race-33a24ff9f059?source=rss-850d9be76685------2</link>
            <guid isPermaLink="false">https://medium.com/p/33a24ff9f059</guid>
            <category><![CDATA[sufism]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-ethics]]></category>
            <category><![CDATA[critical-thinking]]></category>
            <category><![CDATA[amsterdam]]></category>
            <dc:creator><![CDATA[Aslı Öztürk]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 15:14:53 GMT</pubDate>
            <atom:updated>2025-12-01T15:14:53.012Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Finite State Machine and Its Implementation with State Pattern from Scratch]]></title>
            <link>https://levelup.gitconnected.com/finite-state-machine-and-its-implementation-with-state-pattern-from-scratch-9732787a1277?source=rss-850d9be76685------2</link>
            <guid isPermaLink="false">https://medium.com/p/9732787a1277</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[finite-state-machine]]></category>
            <category><![CDATA[state-machine]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[state-pattern]]></category>
            <dc:creator><![CDATA[Aslı Öztürk]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 21:00:04 GMT</pubDate>
            <atom:updated>2020-06-26T22:24:58.977Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ogh1fUyExFYtXx4NMh7GiA.jpeg" /><figcaption>image from <a href="https://www.pexels.com/">pexels.com</a></figcaption></figure><p>Let’s start with a sample case: Suppose you have some business requirements on state changes for an e-commerce website. In this website, there are three types of users: sellers, admins and customers. When a seller adds its product to the website, it should be approved by an admin so that it can be visible on the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*FHiLg0C8d97e6TqxbOTfEw.png" /><figcaption>Figure 1: Site State</figcaption></figure><p>In Figure 1, circles represent the states and arrows are the actions that can make state transitions. There are two types of states of a product: Site State and Product State. Site State can be in Draft, Approved and Archived States. On the other hand, Product State can be in either Active State or Passive State. For visibility of a product, it should be in Approved Site State and Active Product State.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*NspVId501LPRsnPr8rD20g.png" /><figcaption>Figure 2: Product State</figcaption></figure><p>When a seller adds a product to the website, initial conditions are set to Draft Site State and Passive Product State. If admin rejects (maybe it’s because product’s photo quality is bad?), Site State changes from Draft to Archived State. If product is sold, Site State changes from Approved to Archived and Product State changes from Active to Passive so that product can’t be sold again and seller get paid.</p><p>Overwhelmed, already? In some software projects, you may encounter 10x more complex business requirements than this. You need to design a system that meets all the requirements and the code should be clean. You may already noticed that you can’t manage this complexity (and it can be more complicated over time) with if/else or switch case. This is where finite state machine comes into play.</p><h4>Finite State Machine</h4><blockquote>Finite State Machine (Automaton) is an abstract machine that can only be in one of a finite number of states at any given time.</blockquote><p>By the definition, an object should be in one state at a time. So, our product should be in either Draft or Approved States, not both. You may think that “Dude, you said that a product can only be visible if Site State is Approved AND Product State is Active. How can we meet these conditions if we only have one state?”. Yes, i did and yes, we can do by designing two separate State Machines :)</p><p>Let’s look at some concepts in finite state machine:</p><ul><li><strong>Context: </strong>It is a class that maintains an instance of a concrete state as the current state.</li><li><strong>State: </strong>An interface which encapsulates behaviors (or actions) common to all concrete states.</li><li><strong>Concrete State:</strong> Subclass that implements behavior associated with a particular state of the context.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*gcFu2wGr-aaQUofW18FGXw.png" /><figcaption>Figure 3: Sample structure of a state machine (source: <a href="https://howtodoinjava.com/design-patterns/behavioral/state-design-pattern/">state design pattern</a>)</figcaption></figure><p>You may see that finite state machine or state pattern is used interchangeable in some places. They are closely related, but not the same. Finite state machine is one of the very old concepts in computer science and state pattern is one and very common way to implement it in object oriented way.</p><h4>The Coding Part</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mB7PFE8aS5Mkwa_KN-zUIg.jpeg" /><figcaption>image from <a href="https://www.pexels.com/">pexels.com</a></figcaption></figure><p>Let’s define our state interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32a52ef8782fae9bd2c92d423c3112e9/href">https://medium.com/media/32a52ef8782fae9bd2c92d423c3112e9/href</a></iframe><p>This interface holds the necessary actions to make transitions in Site State.</p><p>Now we need to define concrete classes based on our states. In Site State, there were Draft, Approved and Archived States.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0540c48224276ca92b3708ebe618ef4/href">https://medium.com/media/c0540c48224276ca92b3708ebe618ef4/href</a></iframe><p>In DraftState.cs, we implement ISiteState interface and we have our actions to make state transitions. If admin rejects a product which is in Draft Site State, it is going to be in Archived Site State. But a product can’t be sold if it is in Draft Site State, so we need to throw an exception.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7d3f4f03c851bfa38d587d0c2e3dc2d/href">https://medium.com/media/a7d3f4f03c851bfa38d587d0c2e3dc2d/href</a></iframe><p>As you can see in ApprovedState.cs, a product can’t be approved more than once. Other state transitions are like in the Figure 1.</p><p>When product is in the Archived State, no state transitions can be allowed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31d88585fdaa81ffe6a7962cc97a8988/href">https://medium.com/media/31d88585fdaa81ffe6a7962cc97a8988/href</a></iframe><p>As you can see, we managed all the behaviors of Site State with concrete classes.</p><p>In the context class, we define our Current State and manage all the state transitions. State objects can be manipulated via context class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e7a47cd561e145cc236954a389b4015/href">https://medium.com/media/2e7a47cd561e145cc236954a389b4015/href</a></iframe><p>Site State Machine is completed with the implementation of finite state machine elements such as Context, State, and Concrete State. Product State Machine has also similar implementation. However, as the business requirements dictate that Product State can only be Active if Site State is Approved. So, Product State Machine needs to know about Site State Machine’s situation so that it can be altered. Technically, different state machines can be combined but it is NOT a nice thing to do because when you do this, you create an interdependence and it can have negative impact on code maintainability.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2b5d818d0532a80bab40902ae4c96dd/href">https://medium.com/media/d2b5d818d0532a80bab40902ae4c96dd/href</a></iframe><p>As shown in the code, before we change Product State from Passive to Active, we check if Site State is in Approved State.</p><p>Let’s modify our program.cs file to see a success case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a280061fa4c73518105497306f1dae5e/href">https://medium.com/media/a280061fa4c73518105497306f1dae5e/href</a></iframe><p>As a result, we see that the state transitions made properly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*B02LSEbKt4otKI136tmpJA.png" /><figcaption>Figure 4: Success Case</figcaption></figure><p>The product is started with Default Site State, and then, let’s say, admin approved the product so that it transitioned to Approved Site State. Since Site State is Approved, Product State with Approve() action is also changed from Passive to Active State and Voila! Now, the product is visible to customers!</p><p>Suppose we have an approved product, then we sold it. If we want to approve a product which is already sold, we have to get an exception.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f01604fcbb804162dbda5ed55222633/href">https://medium.com/media/0f01604fcbb804162dbda5ed55222633/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*A9WpErCO6FDRdF-h6tCh-w.png" /><figcaption>Figure 5: Failure Case</figcaption></figure><p>As shown in Figure 5, we see all the transitions about approval and sold out actions. When a product is sold, it can’t be approved again and exception is thrown.</p><p>Thanks for reading! Please see the complete source code from the link below:</p><p><em>Source Code: </em><a href="https://github.com/ozturkaslii/StateMachine"><em>https://github.com/ozturkaslii/StateMachine</em></a></p><h4>References</h4><ul><li><a href="https://en.wikipedia.org/wiki/Finite-state_machine">https://en.wikipedia.org/wiki/Finite-state_machine</a></li><li><a href="https://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional-ebook/dp/B000SEIBB8">Design Patterns : Elements of Reusable Object-Oriented Software</a></li><li><a href="https://www.amazon.com/Head-First-Design-Patterns-Brain-Friendly/dp/0596007124">Head First Design Patterns: A Brain-Friendly Guide</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9732787a1277" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/finite-state-machine-and-its-implementation-with-state-pattern-from-scratch-9732787a1277">Finite State Machine and Its Implementation with State Pattern from Scratch</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>