<?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 Sevcan Doğramacı on Medium]]></title>
        <description><![CDATA[Stories by Sevcan Doğramacı on Medium]]></description>
        <link>https://medium.com/@sevcan.dogramaci?source=rss-930aa5727a58------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tkHtFErUvKB-FU_wyL8oXw.jpeg</url>
            <title>Stories by Sevcan Doğramacı on Medium</title>
            <link>https://medium.com/@sevcan.dogramaci?source=rss-930aa5727a58------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:20:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sevcan.dogramaci/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[Kimin Gözlüğünü Takıyorsun?]]></title>
            <link>https://medium.com/@sevcan.dogramaci/kimin-g%C3%B6zl%C3%BC%C4%9F%C3%BCn%C3%BC-tak%C4%B1yorsun-3c2f5d4da00b?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c2f5d4da00b</guid>
            <category><![CDATA[öz-şefkat]]></category>
            <category><![CDATA[değersizlik]]></category>
            <category><![CDATA[özsaygı]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 09:07:04 GMT</pubDate>
            <atom:updated>2025-02-20T09:07:04.798Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5WV35Vy8YJnu9bvO" /><figcaption>Photo by <a href="https://unsplash.com/@nate_dumlao?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Nathan Dumlao</a> on <a href="https://unsplash.com/photos/person-holding-eyeglasses-OWV9RdZrYNE?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>O günlerden bir gün.</p><p>Lui, biriyle karşı karşıya geldi ve kafasındaki iç sesleri konuşmaya başladı.</p><ul><li>Yine yapamadın.</li><li>Yapamadığını düşünüyor.</li><li>Bu davranışı sana karşı yaptı, başkası olsa öyle davranmazdı.</li><li>Yüzü düşük gibi, sorumlusu sensin.</li><li>Sen bunu hak ediyorsun.</li></ul><p>Ve daha fazlası…</p><p>Bu seslerin döngüsüne girer bazen insan. Giderek kendini sorgular. Sorgulama noktası kötü bir nokta da değildir, hepimiz zaman zaman kendimizi sorgulayıp silkelenmez miyiz?</p><p>Ama ya döngüden çıkamazsa?</p><p>O gün öyle olmuştu.</p><p>Döngüde ısrar edip kendini bu düşüncelere maruz bıraktı Lui. Sonrasında, kendinden emin olamadığı ve varlığını değerlendiremediği bir düşünce oluşmaya başladı kafasında.</p><p>Bu tehlikeliydi işte. Çünkü beyni artık sonuç çıkarıp olayı bitiriyordu. Fakat kendi aleyhine.</p><p>Peki Lui’nin düşüncelerinin kaynağı neydi? Olayları nasıl anlamlandırıyor ve hangi duyguları üretiyordu? Bu duyguyu tanıyor muydu? Kimdi ki o?</p><p>Evet o duygu, değersizlik duygusuydu.</p><p>Kelimeye bakacak olursak; <strong>değer-siz-lik</strong>. Değersizliğin olması için değer kavramının olması gerekiyor. Peki onun değer kavramı neydi? Ya da gerçekten var mıydı?</p><p>Yukarıdaki iç sesleri örnek alırsak:</p><ul><li>Değeri, karşısındaki kişinin onun hakkında ne düşündüğüydü.</li><li>Değeri, karşısındaki kişinin onu takdir edip etmemesiydi.</li><li>Değeri, karşısındaki kişinin yüz ifadesinde saklıydı.</li></ul><p>Peki Lui, karşısındaki kişi onu yetersiz görse kendini yetersiz, başarılı görse başarılı mı görmeli öyleyse?</p><p>Onu takdir etmedi öyleyse o takdir edilmeye layık değil miydi?</p><p>O zaman, hayatında iletişim kurduğu insanların her birinde olan düşüncesi ve yeri sayısınca değeri mi var onun?</p><p>Peki hani o biricikti. Gerçek Lui nerede?</p><p>Aslında olan şuydu.</p><p>Lui, karşımdaki insan “beni şöyle görüyor” diyerek kabul ediyordu. Sonrasında ise bu kabul ettiği duruma inanarak kendini o hâlin içine sokuyordu.</p><p>Peki gerçek bu muydu?</p><p>Gerçek şu ki, karşısındakini kontrol edemezdi. Zihnine yerleşmiş iç sesleri vardı. Fakat, bu iç sesleri kabul etmek demek o gözlükle kendine bakmak demekti. Ve, o gözlüğü takıp hayat oyununa katılmak demekti.</p><p>Peki bu kadar gözlüğü taşımaktan yorulmamış mıydı Lui?</p><p>Lui, çok yorgun gözüküyordu.</p><p>O zaman başkalarının gözlükleri ile kendine bakma dostum. İç seslerini farket, onlar genellikle küçüklükte yaşadığımız olaylarla beynimizde çıkardığımız anlamlar.</p><p>Fakat, unutma ki çocukken birçok şeyin farkında değildik, veya anlayamıyorduk. Bu yüzden kendini çokça suçlamış olabilirsin. İç seslerindeki kökenleri farkettiğinde yetişkin bakış açınla gerçeklere bak. Sonra kendine tekrar bak.</p><p>Unutma ki, yanlış gözlük de gözü bozar.</p><p>Sağlıkla kalasın Lui 🤍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c2f5d4da00b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Elasticsearch by Practice Part 2]]></title>
            <link>https://medium.com/@sevcan.dogramaci/learn-elasticsearch-by-practice-part-2-1f7f0d81ce13?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f7f0d81ce13</guid>
            <category><![CDATA[analyzer]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[ingest-pipeline]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 09:04:52 GMT</pubDate>
            <atom:updated>2024-06-10T09:04:52.207Z</atom:updated>
            <content:encoded><![CDATA[<p>Data. We are all surrounded by it. In the software industry, an enormous amount of data is generated for running better businesses. To achieve this, data need to be stored and certain operations need to be performed like searching and analyzing.</p><p>This is where Elasticsearch comes to help us. In this post, we will dive into analyzers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVGdgOzkQhZmNgaDP8hSPA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@seffen99?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Sven Brandsma</a> on <a href="https://unsplash.com/photos/brown-wooden-blocks-with-numbers-C5SUkYZT7nU?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>In the <a href="https://medium.com/@sevcan.dogramaci/learn-elasticsearch-by-practice-part-1-3ac48a6686ff">previous part</a>, we have just met with the analyzers. By default, Elasticsearch uses the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-standard-analyzer.html">standard analyzer</a> if not defined. It tokenizes and converts tokens to lowercase when indexing and searching.</p><ol><li>Let’s remember how a text is analyzed by default. To prepare your environment, you can check queries <a href="https://github.com/SevcanDogramaci/elasticsearch-basics-by-practice">here</a>.</li></ol><pre>GET products/_analyze<br>{<br>  &quot;text&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>}</pre><p>The generated tokens are <strong>[description, of, a, beautiful, knit, sweater]</strong>. But, do we need to index or search “of” and “a”? These words are called <em>stop words</em> and they are often not intended to search. Therefore, it is possible to add custom analyzers in Elasticsearch according to our needs. You can check them <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html">here</a>.</p><p>2. Let’s create a new index with a custom analyzer that does not index English stop words and lowercase tokens.</p><pre>{<br>  &quot;settings&quot;: {<br>    &quot;analysis&quot;: {<br>      &quot;analyzer&quot;: {<br>        &quot;custom_analyzer&quot;: {<br>          &quot;type&quot;: &quot;custom&quot;,<br>          &quot;tokenizer&quot;: &quot;standard&quot;,<br>          &quot;filter&quot;: [&quot;lowercase&quot;, &quot;english_stopwords&quot;]<br>        }<br>      },<br>      &quot;filter&quot;: {<br>        &quot;english_stopwords&quot;: {<br>          &quot;type&quot;: &quot;stop&quot;,<br>          &quot;stopwords&quot;: &quot;_english_&quot; <br>        }<br>      }<br>    }<br>  },<br>  &quot;mappings&quot;: {<br>    &quot;properties&quot;: {<br>      &quot;id&quot;: {<br>          &quot;type&quot;: &quot;long&quot;<br>      },<br>      &quot;description&quot;: {<br>        &quot;type&quot;: &quot;text&quot;,<br>        &quot;analyzer&quot;: &quot;custom_analyzer&quot;<br>      },<br>      &quot;title&quot;: {<br>        &quot;type&quot;: &quot;text&quot;,<br>        &quot;fields&quot;: {<br>          &quot;keyword&quot;: {<br>            &quot;type&quot;: &quot;keyword&quot;,<br>            &quot;ignore_above&quot;: 256<br>          }<br>        }<br>      },<br>      &quot;sellerPhoneNumber&quot;: {<br>        &quot;type&quot;: &quot;text&quot;,<br>        &quot;fields&quot;: {<br>          &quot;keyword&quot;: {<br>            &quot;type&quot;: &quot;keyword&quot;,<br>            &quot;ignore_above&quot;: 256<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Now, analyze again and check the difference. The generated tokens are <strong>[description, beautiful, knit, sweater]</strong>. Thanks to this, we can reduce the indexed data size. Since an analyzer is also used in search, when we search for a text, it will be analyzed and searched in the index.</p><pre>GET products-with-custom-analyzer/_analyze<br>{<br>  &quot;analyzer&quot;: &quot;custom_analyzer&quot;,<br>  &quot;text&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>}</pre><p>If we do not want to process the text in searching then ingest pipelines come. They only work while indexing the document which can be utilized for various purposes like removal of sensitive data.</p><p>Let’s create new products with sellerPhoneNumber field which may contain a piece of sensitive information.</p><pre>POST products-with-custom-analyzer/_doc<br>{<br>   &quot;id&quot;: 1, <br>   &quot;title&quot;: &quot;Knit Sweater&quot;,<br>   &quot;description&quot;: &quot;Description of a beautiful knit sweater.&quot;,<br>   &quot;sellerPhoneNumber&quot;: &quot;123123&quot;<br>}</pre><p>When we search the data, it is searchable. Let’s create the pipeline.</p><pre>PUT /_ingest/pipeline/sensitive-data-remover<br>{<br>  &quot;processors&quot;: [<br>    {<br>      &quot;remove&quot;: {<br>        &quot;field&quot;: &quot;sellerPhoneNumber&quot;,<br>        &quot;ignore_failure&quot;: true<br>      }<br>    }<br>  ]<br>}</pre><p>When we search, it hits to search results again. Why? It is because we have already indexed the document. The new pipeline feature will not work for the old data unless we reindex them. That is one of the reasons why Elasticsearch has a reindex feature with which we can index our data again.</p><p>In addition to this, the index’s <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#index-default-pipeline">default_pipeline</a> can be updated from the settings and new documents will be manipulated.</p><pre>POST _reindex<br>{<br>  &quot;source&quot;: {<br>    &quot;index&quot;: &quot;products-with-custom-analyzer&quot;<br>  },<br>  &quot;dest&quot;: {<br>    &quot;index&quot;: &quot;products-with-custom-analyzer-reindexed&quot;,<br>    &quot;pipeline&quot;: &quot;sensitive-data-remover&quot;<br>  }<br>}</pre><p>Check the new index and search again. Now, sellerPhoneNumber field is removed from the document.</p><p>To sum up, we covered analyzers, ingest pipelines, and reindexing in Elasticsearch. That was all for this post, see u in the next episodes 🧐 🚗</p><h3>References:</h3><ul><li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index-modules.html#index-modules-settings">https://www.elastic.co/guide/en/elasticsearch/reference</a></li><li><a href="https://github.com/SevcanDogramaci/elasticsearch-basics-by-practice">https://github.com/SevcanDogramaci/elasticsearch-basics-by-practice</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f7f0d81ce13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Divide & Rule: Sharding the Data]]></title>
            <link>https://medium.com/@sevcan.dogramaci/divide-rule-sharding-the-data-94cc9932d9e9?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/94cc9932d9e9</guid>
            <category><![CDATA[sharding]]></category>
            <category><![CDATA[partitioning]]></category>
            <category><![CDATA[shard]]></category>
            <category><![CDATA[partition]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Mon, 25 Dec 2023 09:32:57 GMT</pubDate>
            <atom:updated>2023-12-25T09:32:57.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eFsYqvcGaRDh1VIN7A2fYw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@claybanks?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Clay Banks</a> on <a href="https://unsplash.com/photos/people-walking-on-pedestrian-lane-in-between-high-rise-buildings-To-bi71M5Jc?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>The number of internet users has been increasing by <a href="https://datareportal.com/global-digital-overview#:~:text=There%20are%205.30%20billion%20internet,higher%20in%20many%20developing%20economies.">5.30 billion</a> today. By 2025, global data creation will reach more than <a href="https://www.statista.com/statistics/871513/worldwide-data-created/">180 zettabytes</a> according to forecasts. Along with these, as users, we expect to get services in less time to complete our tasks faster.</p><p>Then how this can be achieved? Assume we store all user data in one database on a server and there are too many search operations. Since there is one machine and it holds the whole data, all the operations will be routed there. Therefore, the machine will be overloaded 🔥 and cannot handle the search efficiently ⛔️.</p><p>Then how can the big data be served in a way that scales?</p><p>The answer is simple. Divide and rule. You heard of the <a href="https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm#:~:text=The%20divide%2Dand%2Dconquer%20paradigm,to%20solve%20the%20given%20problem.">divide-and-conquer strategy in computer science</a> to solve complex problems. In the data management context, this approach is called <strong>sharding</strong>, partitioning data so that the system can scale and load can be balanced.</p><p>The data is split into multiple parts, each called a shard in Elasticsearch, or vbucket in Couchbase, and distributed to different machines(nodes). Let’s continue with the shard in this article.</p><h3>Sharding Strategies</h3><h4>By Range of Key:</h4><p>This is the technique exactly applied in encyclopedias. The data is partitioned by selecting a key in the data. For example, the data is split by the first letter of words in the encyclopedia. While the information about the words starting with A to M is in the first encyclopedia, the rest will be in the second.</p><p>The downside of this approach is that it should adapt the boundaries. When the amount of data increases in the A-M range, the first encyclopedia will be used more and overloaded. Therefore, the range of the first encyclopedia should be updated in the next editions.</p><h4>By Hash of Key:</h4><p>This technique overcomes the non-uniform distribution of the data over time. The hash of the key is used instead of using the key after selecting it directly.</p><p>A hash function is applied to distribute a key in a shard. Likewise, when there is a search operation, the searched key is hashed first, and then the data is fetched by the hash from the shard.</p><p>All these help when we need to search by using only one key, which is called a primary key. What happens if we need to search by other keys in the data too, which are called secondary indices?</p><h4>Local Secondary Index:</h4><p>A shard already keeps the data partitioned by the primary key. This technique also indices the data in the shard by secondary indices separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xkd7qa7BMdpYah0XCAQ_Sg.png" /><figcaption>All students are indexed by their classes in their shards.</figcaption></figure><p>When there is a search operation to get second-class students, the request should be sent to all shards. Then, all results are combined and returned to the client.</p><h4><strong>Global Secondary Index:</strong></h4><p>A shard already keeps the data partitioned by the primary key. This technique partitions data to the shards by secondary indices, like a separate shard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuR79ggPdUSRZ9dkKP1BHw.png" /><figcaption>While third-class students are stored in shard 2, second-class students are in shard 1.</figcaption></figure><p>When there is a search operation to get second-class students, the request should be sent to only one shard, resulting in faster reads. However, writes are slower since the data is partitioned by a secondary index completely separately.</p><p>Okay. The data is distributed. But how will a search request be handled then? How can the request be routed to the correct destination?</p><h3>Request Routing</h3><p>To do so, we need to know which shards are located in which nodes(machines). This problem is known as the <a href="https://www.baeldung.com/cs/service-discovery-microservices">service discovery problem</a>. There are three main approaches:</p><p><strong>1. Request to Random Node: </strong>Send the request to a random node. If it has the data it returns, otherwise it forwards the request to the proper node.</p><p><strong>2. Request to Routing Tier: </strong>Send the request to the load balancer which knows which data is located on which node.</p><p><strong>3. Request to Exact Node:</strong> You know which shard is located on which node and directly send the request to that node.</p><p>To sum up,</p><p>To effectively scale the big data, it is partitioned into multiple parts called shards. The shards are distributed to various machines(nodes). In that distributed environment, certain sharding techniques are followed and requests are routed to the correct nodes.</p><p>That was all for this post, see u in the next episodes 🧐 🚗</p><h4>References:</h4><ul><li><a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/">Designing Data-Intensive Applications</a> / Chapter 6: Partitioning</li><li><a href="https://learn.microsoft.com/en-us/azure/architecture/best-practices/data-partitioning#horizontal-partitioning-sharding">https://learn.microsoft.com/en-us/azure/architecture/best-practices/data-partitioning#horizontal-partitioning-sharding</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94cc9932d9e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Elasticsearch by Practice Part 1]]></title>
            <link>https://medium.com/@sevcan.dogramaci/learn-elasticsearch-by-practice-part-1-3ac48a6686ff?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ac48a6686ff</guid>
            <category><![CDATA[inverted-index]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Sat, 23 Sep 2023 12:58:57 GMT</pubDate>
            <atom:updated>2023-09-23T12:58:57.798Z</atom:updated>
            <content:encoded><![CDATA[<p>Data. We are all surrounded by it. In the software industry, an enormous amount of data is generated for running better businesses. To achieve this, data need to be stored and certain operations need to be performed like searching and analyzing.</p><p>This is where Elasticsearch comes to help us. In this post, we will dive into how data is stored in Elasticsearch, mapping, and settings for an index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bY3G6bpsQmoBPFEkyvd1MQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Winkler</a> on <a href="https://unsplash.com/photos/cV9-hOgoaok?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>What is Elasticsearch?</h3><p>It is a distributed, search and analytics engine that centrally stores our data so we can search, index, and analyze the data. It is a document-based database where each document is represented in JSON format.</p><h4>How data is stored?</h4><p>Data is stored in a data structure called an <a href="https://www.educative.io/answers/what-is-an-inverted-index">inverted index</a> in Elasticsearch. This data structure basically tokenizes inputs and maps the token to where it exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agD-X-omgGxNJI_y61A2Bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2V5iGjQx-y6ct_EHga0IaQ.png" /></figure><p>Each field in a document is indexed separately. For example, there is product data with id, title, and description fields. The documents’ description fields are tokenized and then indexed.</p><h4>What is mapping?</h4><p>I have just stated that each field is indexed separately. A field value can be a boolean, integer, float, string, etc. In Elasticsearch, we define the settings for how to index a field in mappings. We can either use <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html">dynamic mapping</a> or <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/explicit-mapping.html">explicit mapping</a>.</p><p>Let’s start with dynamic mapping, and we’ll define mappings explicitly in the following series.</p><ol><li>Run docker-compose up.</li><li>Go to <a href="http://localhost:5601/app/dev_tools#/console">http://localhost:5601/app/dev_tools#/console</a>.</li><li>Create <em>products</em> index by inserting documents.</li></ol><pre>POST products/_doc<br>{<br>   &quot;id&quot;: 1, <br>   &quot;title&quot;: &quot;Knit Sweater&quot;,<br>   &quot;description&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>}<br><br>POST products/_doc<br>{<br>   &quot;id&quot;: 2, <br>   &quot;title&quot;: &quot;Cotton Sweater&quot;,<br>   &quot;description&quot;: &quot;Description of a beautiful cotton sweater.&quot;<br>}</pre><p>4. Run GET products to get info about the index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*ipEGsMiUxqex3szppvfgFg.png" /></figure><p>Elasticsearch mapped the description and title fields as text, and the id field as long. Good job 😎 But wait! Also it indexed the description and title as keyword. Why?</p><p>The main difference between text and keyword mapping is that text fields are used for partial matching whereas keyword fields are used for full matching. This is because text fields are analyzed (tokenized and applied analyzer functions if defined via <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html">analyzer</a>) before indexing.</p><p>5. See how a text is analyzed.</p><pre>GET products/_analyze<br>{<br>  &quot;text&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>}</pre><p>6. Run the following match query.</p><pre>GET products/_search<br>{<br>  &quot;query&quot;: {<br>    &quot;match&quot;: {<br>      &quot;description&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>    }<br>  }<br>}</pre><p>Since the description field is indexed as text and analyzed, it returns all the products we have inserted.</p><p>However, for the keyword fields, this analysis step is not applied. They are indexed as is. Thanks to this, we are able to use them for exact match searches.</p><p>7. Run the following match query again using the description keyword.</p><pre>GET products/_search<br>{<br>  &quot;query&quot;: {<br>    &quot;match&quot;: {<br>      &quot;description.keyword&quot;: &quot;Description of a beautiful knit sweater.&quot;<br>    }<br>  }<br>}</pre><p>Now, it is just returning one document using exact matching.</p><h4>What is setting?</h4><p>This part contains settings for the index. The setting can be either static (set only at index creation) or dynamic (can be modified later).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*2v3P8ufY-rqlzDWymclZAQ.png" /></figure><p>Elasticsearch created our products index using default settings. It is configured to store data in content data nodes using one primary shard and one replica shard. These settings and more can be used to optimally and securely keep the data in the cluster.</p><p>To sum up, we covered what is inverted index Elasticsearch uses, mapping, and setting for an index. That was all for this post, see u in the next episodes 🧐 🚗</p><h4><strong>References:</strong></h4><ul><li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index-modules.html#index-modules-settings">https://www.elastic.co/guide/en/elasticsearch/reference</a></li><li><a href="https://github.com/SevcanDogramaci/elasticsearch-basics-by-practice">https://github.com/SevcanDogramaci/elasticsearch-basics-by-practice</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ac48a6686ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Highlights from the Clean Coder Part 3: Saying Yes]]></title>
            <link>https://medium.com/@sevcan.dogramaci/highlights-from-the-clean-coder-part-3-saying-yes-5c7511f3710b?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c7511f3710b</guid>
            <category><![CDATA[professional-software]]></category>
            <category><![CDATA[clean-coder]]></category>
            <category><![CDATA[professionalism]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Mon, 20 Mar 2023 10:36:09 GMT</pubDate>
            <atom:updated>2023-03-20T10:36:09.945Z</atom:updated>
            <content:encoded><![CDATA[<p>The work environment is different. We are there as a colleague of others and have responsibilities towards our work. Throughout this journey, all of us come across technical and social difficulties in that environment, and learning by experience is challenging. This is where Uncle Bob’s <strong>the Clean Coder</strong> book comes to benefit us in improving ourselves on how to deal with these challenges and become <strong><em>software professionals</em></strong>.</p><p>We discussed Saying No from the Clean Coder in the <a href="https://medium.com/@sevcan.dogramaci/highlights-from-the-clean-coder-part-2-saying-no-a8b9ffe01df9">previous post</a>. Today I will mention the parts that I highlight and apply in Saying Yes chapter of the book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rY7jDGhwLk8aQE6s03D24g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/de/@floschmaezz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Florian Schmetz</a> on <a href="https://unsplash.com/photos/LPckxbrqE5w?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Saying yes is just as valuable to software professionals as saying no. They are aware that saying yes is taking responsibility and a sign of commitment. Thus, they pay attention to how to make these commitments.</p><p>Let’s take a look at what a commitment looks like.</p><p>We said that a commitment was taking responsibility. While taking this responsibility we should be concise. What does it mean exactly? Let’s investigate it with an example.</p><blockquote><strong>I will finish this by Tuesday.</strong></blockquote><p>✅ It clearly states the fact that <strong>YOU </strong>will do with a <strong>clear end time</strong>. You are stating the action you <strong>will take</strong>. Neither possibly nor might.</p><p>But is this always possible, meaning that can we ensure it all the time when making a commitment?</p><p>Not actually.</p><h3><strong>You can only commit to things that you have full control of.</strong></h3><p>Of course, getting a task done independently of other factors is not always possible. For example, the task may depend on another team’s task. In this case, making a commitment without considering the dependency can cause a wrong estimation.</p><p><strong>🔴 It wouldn’t work because I rely on person X to get this done.</strong></p><p>If the end goal depends on someone else, software professionals commit to specific actions that bring them closer to the end goal. They meet other teammates, create abstract interfaces and build integration tests.</p><p><strong>🔴 It wouldn’t work because I don’t really know if it can be done.</strong></p><p>Sometimes the actions to achieve a task can be fuzzy and we don’t know if it is achievable at all. In these circumstances, the professionals can still commit to actions that will bring them closer to the target. For example, finding out if it can be done can be one of the actions to commit to! We can benefit from debugging or working with QAs etc.</p><p><strong>🔴 It wouldn’t work because sometimes I just won’t make it.</strong></p><p>From time to time, just we may not able to solve a problem. At this time, software professionals raise a red flag as soon as possible to reflect on the problem and not hesitate to get help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8ePB7sQoccHpf9-pnwWb9g.gif" /></figure><p>In brief,</p><p>Software professionals pay attention to what they are committing. They clearly state the fact and take responsibility for their statements. If they notice any obstacles or dependency, they explicitly make others notice them too and they only commit to the actions they have full control of.</p><p>That was all for this post, see you in the next post 🧐 🚗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c7511f3710b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Highlights from the Clean Coder Part 2: Saying No]]></title>
            <link>https://medium.com/@sevcan.dogramaci/highlights-from-the-clean-coder-part-2-saying-no-a8b9ffe01df9?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8b9ffe01df9</guid>
            <category><![CDATA[clean-coder]]></category>
            <category><![CDATA[professionalism]]></category>
            <category><![CDATA[professional-software]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 09:44:26 GMT</pubDate>
            <atom:updated>2023-01-31T09:44:26.095Z</atom:updated>
            <content:encoded><![CDATA[<p>The work environment is different. We are there as a colleague of others and have responsibilities towards our work. Throughout this journey, all of us come across technical and social difficulties in that environment, and learning by experience is challenging. This is where Uncle Bob’s <strong>the Clean Coder</strong> book comes to benefit us in improving ourselves on how to deal with these challenges and become <strong><em>software professionals</em></strong>.</p><p>In the previous post, we talked about <em>Professionalism</em> from the Clean Coder. Today I am going to mention the parts that I highlight and apply in Saying No chapter of the book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5L7oeA_SfCcpxDu7bILMMw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/de/@floschmaezz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Florian Schmetz</a> on <a href="https://unsplash.com/photos/LPckxbrqE5w?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Can you think of a professional hesitating to speak the truth?</p><p>No, of course.</p><p>Let’s ponder a scenario. You are the developer having an approximately ten-days task and you have just started developing. Your project manager comes to you and asks if you can complete the task within three days. What should you say?</p><p>👍 You say <strong>“Ok, I will try.”</strong>. Then, you will find yourself rushing in order to finish the task for the deadline. However, you are sure that the task is not a three-days task. Then, how? You will work overtime, but it is not enough. Then, what is more? You will start searching for workarounds to develop as fast as you can which may cause leaving your development principles. In the end, you might have a fragile feature in your hands that only saves the day but definitely needs testing and refactoring (not completed actually), or even worse nothing.</p><p>👎 You say <strong>“No.”</strong>. You explain why it is not possible to complete it with all qualities supplied and adhere to reality. Then, you make your development without abandoning your principles and finish with your heart.</p><p>Software professionals do not hesitate to state the reality. There is no trying! Trying here means “to apply extra effort”.</p><p>There is a simple logic behind this. If you say you will try something, it means that you have the time and resources to make this happen. Also, the one spoken to will accept it as “<strong>Yes</strong>.”.</p><p>Without having a reservoir of resources for the task, then how will you try? If we do not have, then we are actually lying by saying “I will try.”. Moreover, based on your statement, your project manager may take certain actions which can cause more trouble and pressure on you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*pEpZN97ZDw0Eb301wBHyqA.gif" /></figure><p>To sum up,</p><p>if there is a requirement, you can either do it or not. You can either do the requirement in X time or you cannot. By saying I will try, you are putting the other party in expectation. In these circumstances, software professionals have the courage to express the truth and say <strong>“No”</strong>.</p><p>That was all for this post, see you in the next post 🧐 🚗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8b9ffe01df9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Highlights from the Clean Coder Part 1: Professionalism]]></title>
            <link>https://medium.com/@sevcan.dogramaci/highlights-from-the-clean-coder-part-1-professionalism-52a8a4ce3adb?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/52a8a4ce3adb</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[professional-software]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[professionalism]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Tue, 24 Jan 2023 09:06:39 GMT</pubDate>
            <atom:updated>2023-01-24T09:06:39.949Z</atom:updated>
            <content:encoded><![CDATA[<p>The work environment is different. We are there as a colleague of others and have responsibilities towards our work. Throughout this journey, all of us come across technical and social difficulties in that environment, and learning by experience is challenging. This is where Uncle Bob’s <strong>the Clean Coder</strong> book comes to benefit us in improving ourselves on how to deal with these challenges and become <strong><em>software professionals</em></strong>.</p><p>In this post, I will mention the parts that I highlight and apply in Professionalism chapter of the book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*WmN0sFvkilEr6i3C" /><figcaption>Photo by <a href="https://unsplash.com/fr/@amyhirschi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Amy Hirschi</a> on <a href="https://unsplash.com/photos/szrJ3wjzOMg?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>First, what is professionalism?</p><p>Imagine yourself while learning a new musical instrument. You start as an amateur. As you work hard, you become a professional. In the end, you have a profession in a field which is music in this example. At that time, we expect people to look at us with respect and hold up as an example.</p><p>No pain no gain. To acquire this deference, firstly we need to take responsibility. Without putting anything in, how do we expect to get? So, professionals take responsibility. In addition to taking responsibility, professionals are aware that when they cause a problem, they are the ones to fix it.</p><p>Well, can we also do something to avoid causing trouble? Yes, we can. While developing software, software professionals follow certain principles so as to reduce problems and bugs.</p><p>💎 <strong>Do not harm to function</strong>: Software professionals do not damage the already working functionality of the system they are developing.</p><p>💎 <strong>QA should find nothing: </strong>Software professionals make development in a way that when they deliver it to QAs and they expect no bugs will be found.</p><p>💎 <strong>You must know it works:</strong> Software professionals test the parts they are developing and ensure that it serves as desired.</p><p>💎 <strong>Do not harm to structure: </strong>Software professionals do not deteriorate the software structure. They make their development in a way that it maintainable and clean.</p><p>Career. Software professionals know that their career is their responsibility. They spend their time improving themselves in their field. So, they know their field. Uncle Bob gives a minimal list of the things that every software professional should be conversant with:</p><p>📌 Design patterns</p><p>📌 Design principles (SOLID)</p><p>📌 Methods (XP, Scrum, Lean…)</p><p>📌 Disciplines (TDD, OOP, CI, Pair Programming)</p><p>📌 Artifacts (UML, Decision Tables…)</p><p>Career is a journey in which places and surroundings change constantly. Therefore, it needs continuous learning. Software professionals learn new things by exceeding their comfort zones. Additionally, they strengthen lifelong learning with hands-on practice.</p><p>Being a software professional is not just related to the technical side. We are developing software for serving a business to our customers. Software professionals know the value they are creating for the customer. They know their domain. Thanks to this knowledge, they can understand the flow and identify problems within easier, contributing more to produce more value.</p><p>To sum up,</p><p>professionalism comes with responsibility. Software professionals adhere to certain principles to discharge the responsibility as well as they can. They reinforce their career by lifelong learning, practicing, and understanding their business.</p><p>That was all for this post, see you in the next post 🧐 🚗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52a8a4ce3adb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to denormalize data by merging a table as an object into a document in couchbase]]></title>
            <link>https://medium.com/modanisa-engineering/how-to-denormalize-data-by-merging-a-table-as-an-object-into-a-document-in-couchbase-b9deb006eb33?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9deb006eb33</guid>
            <category><![CDATA[couchbase]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[n1ql]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Mon, 16 May 2022 09:29:54 GMT</pubDate>
            <atom:updated>2022-05-17T12:25:06.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3bJF69_mO2LiuSaxW--2A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jandira_sonnendeck?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jandira Sonnendeck</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Imagine you have data in RDBMS, and at some point, you have decided to move your structure to Couchbase. You investigated the data and decided that you will denormalize a table into a document in migration. In this post, we will see how to embed data in a table with relation to couchbase documents.</p><h3>Data in RDBMS</h3><p>Let’s say you have two tables in relation:</p><ol><li>delivery_option table where you keep delivery options info.</li><li>delivery_option_translation table where you keep translations of delivery options.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfejchBzleS8Gc9KV4sGVA.png" /><figcaption>delivery_option and delivery_option_translation tables</figcaption></figure><h3>Data Design in Couchbase</h3><p>Now, instead of creating two tables, you want to create one table for storing delivery options. You will eliminate delivery_option_translation table. But what happens to data there then?</p><p>The answer is simple. We will merge each delivery option’s translations into its document in Couchbase. So, a delivery option will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7R1CADTJ83LxZnkX2rFeow.png" /><figcaption>Sample delivery_option document in Couchbase</figcaption></figure><h3>Migration</h3><p>We can use couchbase:community-7.1.0 docker image to use couchbase in local.</p><h4>Prepare couchbase</h4><p><strong>1. Run</strong></p><pre>docker run -p 8091-8096:8091-8096 couchbase:community-7.1.0</pre><p><strong>2. Setup couchbase cluster</strong></p><ul><li>Go to <a href="http://localhost:8091/">localhost:8091</a></li><li>Configure cluster name, admin username, and password settings</li><li>Create a bucket called sample</li><li>Create a collection called delivery_option in sample bucket _default scope</li><li>Create additional scope called migration</li><li>Create a collection called delivery_option in sample bucket migration scope</li><li>Create a collection called delivery_option_translation in sample bucket migration scope</li></ul><p><strong>3. Import </strong><strong>delivery_option and </strong><strong>delivery_option_translation data</strong></p><ul><li>Download sample data <a href="https://github.com/SevcanDogramaci/denormalization-couchbase-example">here</a>.</li><li>Import <em>delivery_option.json</em> as JSON list into sample.migration.delivery_option keyspace using UUID.</li><li>Import <em>delivery_option_translation.json</em> as JSON list into sample.migration.delivery_option_translation keyspace using UUID.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_WShD9f3Wlopooig9yD8VQ.jpeg" /><figcaption>Import data screen</figcaption></figure><p><strong>4. Create indexes</strong></p><p>We need several primary and secondary indexes before running the merge query. Run queries to create these indexes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edda573d2f63386fadfcd06ee4b9060b/href">https://medium.com/media/edda573d2f63386fadfcd06ee4b9060b/href</a></iframe><p><strong>5. Merge translations into delivery options and insert</strong></p><p>Run the merge query to insert delivery options into delivery_option collection in _default scope.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e931efa71c4fcedd3d40f738e8c959fc/href">https://medium.com/media/e931efa71c4fcedd3d40f738e8c959fc/href</a></iframe><p>If we take a look at the query deeper, we create an object v.`language`: v.translation with all translations of a delivery option by looping over.</p><ul><li>We use SELECT RAW OBJECT and [0] for eliminating the field attribute.</li><li>We use LEFT NEST for getting all translations even if there is no translation. (So that object will be empty.)</li><li>We use MERGE INTO ..... WHEN MATCHED ... query to insert or update new delivery options into a bucket.</li></ul><h3>Result</h3><p>Voila 🥳 Here are the delivery options data migrated!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5L-3Q7WmejBKpHFI5jTKpA.jpeg" /><figcaption>New delivery options with translations</figcaption></figure><p>To sum up, we achieved to merge data as an object to couchbase documents. That was it for this post, see u in the next episodes 🧐 🚗</p><p>References:</p><ul><li><a href="https://github.com/SevcanDogramaci/denormalization-couchbase-example">https://github.com/SevcanDogramaci/denormalization-couchbase-example</a></li><li><a href="https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/">https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/</a></li><li><a href="https://blog.couchbase.com/denormalize-imported-documents-rdbms-to-couchbase-using-n1ql/">https://blog.couchbase.com/denormalize-imported-documents-rdbms-to-couchbase-using-n1ql/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9deb006eb33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/modanisa-engineering/how-to-denormalize-data-by-merging-a-table-as-an-object-into-a-document-in-couchbase-b9deb006eb33">How to denormalize data by merging a table as an object into a document in couchbase</a> was originally published in <a href="https://medium.com/modanisa-engineering">Modanisa Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a custom matcher for testing with gomock]]></title>
            <link>https://medium.com/modanisa-engineering/writing-a-custom-matcher-for-testing-with-gomock-d3ef5f13db82?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3ef5f13db82</guid>
            <category><![CDATA[gomock]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Sun, 02 Jan 2022 18:04:38 GMT</pubDate>
            <atom:updated>2022-01-03T15:08:11.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*sReyu_w8I6GJFqbjs4MOyg.png" /></figure><p>Everyday we write tests for our applications. While writing a test, we usually mock integrated parts. Doing so, we aim to hide the implementation details of the integrated parts. Thanks to mocking, we do not need to modify our tests whenever there is a change in the implementation of mocked parts.</p><p><a href="https://github.com/golang/mock">gomock</a> is a package for mocking in go. It matches given expected values with actual ones. Sometimes, we need to customize the way it works. In this post, we will investigate such a case.</p><p>Let’s say, we have /product endpoint for inserting new products into our repository. We use a POST method handler for this.</p><p>Our handler receives requests and interacts with the service to add a new product into the repository. Below is a service test for the happy path scenario:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6339fcca7d48ac928460b99ab813431d/href">https://medium.com/media/6339fcca7d48ac928460b99ab813431d/href</a></iframe><p>If you look at our test, you can see that we mock the repository and expect to call the repository’s Insert function with expectedProduct. When we run the test we face an issue:</p><pre>Got: {Product - ID:000001 Description:some-description Quantity:5 CreatedAt:2022-01-02 19:58:24.594343 +0300 +03 m=+0.001580715} (*product.Product)</pre><pre>Want: is equal to {Product - ID:000001 Description:some-description Quantity:5 CreatedAt:2022-01-02 19:58:24.594045 +0300 +03 m=+0.001282804} (*product.Product)</pre><p>The issue is that the expected and actual values given to Insert function are different. Why? 🤔 After we make a deep dive, we see that the problematic part is createdAt field. There has been a subtle difference due to time.Now().</p><p>Under the hood, gomock uses some predefined matchers to work. In its official doc Matcher is defined like:</p><blockquote>A Matcher is a representation of a class of values. It is used to represent the valid or expected arguments to a mocked method.</blockquote><p>You can check them further <a href="https://pkg.go.dev/github.com/golang/mock/gomock#Matcher">here</a>. By default, gomock matches expected values with actual ones using eqMatcher. This is where our problem on createdAt field starts.</p><p>In order to overcome this issue, we need to implement a custom matching mechanism for our Product model. gomock provides an interface for this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48ff6733749aa15224f9de8035188857/href">https://medium.com/media/48ff6733749aa15224f9de8035188857/href</a></iframe><p>If you look above, you can see that we can achieve this by implementing Matches and String methods. Here is our implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e763e2057dc958221eddd8c81437b20/href">https://medium.com/media/0e763e2057dc958221eddd8c81437b20/href</a></iframe><p>In Matches function, we check if all fields are equal except for CreatedAt. Also, we implement String method to describe the fields that the matcher needs for matching.</p><p>Voila ! Now, the test is passing 🥳</p><p>To sum up, we covered how we could write a custom matcher with gomock to use a different matching strategy. That was all for this post, see u in the next episodes 🧐 🚗</p><p>References:</p><ul><li><a href="https://pkg.go.dev/github.com/golang/mock/gomock#Matcher">https://pkg.go.dev/github.com/golang/mock/gomock#Matcher</a></li><li><a href="https://github.com/golang/mock/blob/master/gomock/call.go">https://github.com/golang/mock/blob/master/gomock/call.go</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3ef5f13db82" width="1" height="1" alt=""><hr><p><a href="https://medium.com/modanisa-engineering/writing-a-custom-matcher-for-testing-with-gomock-d3ef5f13db82">Writing a custom matcher for testing with gomock</a> was originally published in <a href="https://medium.com/modanisa-engineering">Modanisa Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How do compilers work?]]></title>
            <link>https://medium.com/skydome-academy/how-do-compilers-work-8a1ffddf0667?source=rss-930aa5727a58------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a1ffddf0667</guid>
            <category><![CDATA[compilers]]></category>
            <dc:creator><![CDATA[Sevcan Doğramacı]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 18:28:01 GMT</pubDate>
            <atom:updated>2021-12-23T18:29:09.014Z</atom:updated>
            <content:encoded><![CDATA[<p>Computers. As we interact with them every day mostly using dozens of software, we sometimes forget that they are working with hardware indeed. So, the thing that they just understand is whether electric is on/off, or 1/0.</p><p>But wait? How do they understand our program then? Let’s look 👀</p><p>In this post, we will talk about how computers understand our program written in a compiled programming language. Let’s say, we develop an application using a programming language which might be C, Go, Haskell, or others which we can understand easily (sometimes not that much easy though 😀). And let’s see how we start talking to computers mainly. The compiler takes this application code and converts it to assembly code. Finally, the assembler converts this assembly code to machine code so that the computers can execute them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuxUUUByopCUrOf40DW_vQ.png" /><figcaption>A high-level view of application code to machine code</figcaption></figure><p>If we learn application to machine code journey in a broad perspective, then be ready to dive more into what the compiler does to convert the application code to assembly code 🚀.</p><p>Here is the outline of compiler stages :</p><ol><li>Lexical Analysis (Tokenization)</li><li>Syntax Analysis (Parsing)</li><li>Semantic Analysis</li><li>Intermediate Code Generation</li><li>Code Optimization</li><li>Code Generation</li></ol><h4>1. Lexical Analysis (Tokenization)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*A2QabbqXfo4leZSQ4WYFJQ.png" /><figcaption>Example of tokens</figcaption></figure><p>The first step of compilation is lexical analysis or so-called tokenization. In this step, the lexical analyzer which is a part of the compiler scans the application code character by character and converts sequences of characters into tokens. A token is a classification of groups of characters. To convert the sequences of characters into tokens, each programming language has rules on which tokens are defined.</p><p>Let’s say, there are 3 rules in our programming language.</p><ul><li>We want to use a if keyword for creating if conditions.</li><li>We want to use a ; symbol for ending a line.</li><li>We want to define variables only using small letters and underscore.</li></ul><pre>&quot;if&quot; { return IF; }<br>&quot;;&quot; { return END_OF_LINE; }<br>[a-z_]+ { return IDENTIFIER; }</pre><p>Lexical analyzer starts to read characters in code. If the sequences of characters read by the lexical analyzer match with one of the token rules defined, then it understands that it finds that token 🥳 and sends the token to the 2nd step. If the lexical analyzer cannot match the sequences with any rule 😡 then it generates an error.</p><h4>2. Syntax Analysis (Parsing)</h4><p>Each programming language has its own syntax. This syntax is defined by some rules which are called<strong> context-free grammar </strong><a href="https://www.tutorialspoint.com/compiler_design/compiler_design_syntax_analysis.htm"><strong>(CFG)</strong></a>. These rules are defined using tokens in the lexical analysis step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*uI4uX-fr3Hq_QBjPwHszGQ.png" /><figcaption>Example of CFG for variable definition</figcaption></figure><p>Lexical analyzer sends tokens to parsing as it finds a token. In this step, the parser tries to match tokens to a rule defined. To achieve this, it continuously checks if the tokens kept from the lexical analyzer conform to any rule.</p><p>If the tokens match with one of the rules, then it constructs a parse tree using these tokens. Else the tokens cannot form a valid syntax meaning that conforms with no rule 😡, then it throws a syntax error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*BwtWJSm3uuHmDtNqHNqWng.png" /><figcaption>Parse tree visualization of x =&gt; INT;</figcaption></figure><h4>3. Semantic Analysis</h4><p>After constructing a parse tree of the code, semantic analysis is done. In this step, the compiler</p><ul><li>checks for type mismatches,</li><li>checks for incompatible operands,</li><li>checks if a function called with improper arguments,</li><li>checks for an undeclared variable, etc. for ensuring that the application is semantically correct.</li></ul><h4>4. Intermediate Code Generation</h4><p>After the semantic analysis is done, an intermediate code is generated. This is for making the conversion of the code to the machine-level code (assembly code) easier. Rather than directly transforming the code into machine-level code, the compiler generates an intermediate-level code. Typically, these intermediate codes have two important features which make them preferable:</p><ul><li>they are easier to optimize than machine-level code,</li><li>they are easy to convert to machine-level code.</li></ul><h4>5. Code Optimization</h4><p>The intermediate code just generated previously is used in this step for optimization. For code optimization, there are a couple of tasks done so that the code performance might be increased in terms of execution speed and resource usage. For example, in this step,</p><ul><li>unnecessary code lines are removed,</li><li>unreachable code is removed,</li><li>unused variables are removed,</li><li>the sequence of statements is rearranged.</li></ul><h4>6. Code Generation</h4><p>Finally, the intermediate code that is just optimized in the previous step is converted into the machine-level code which is an assembly code.</p><p>After this step, the compiler finishes its work and now, it is the assembler’s responsibility to convert the assembly code into machine code which consists of only 1s and 0s.</p><p>This was the end of our journey in how a compiler works, see u in the next episodes 🧐 🚗</p><h3>References</h3><ul><li><a href="https://www.baeldung.com/cs/how-compilers-work">https://www.baeldung.com/cs/how-compilers-work</a></li><li><a href="https://github.com/SevcanDogramaci/fun-language-parser">https://github.com/SevcanDogramaci/fun-language-parser</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a1ffddf0667" width="1" height="1" alt=""><hr><p><a href="https://medium.com/skydome-academy/how-do-compilers-work-8a1ffddf0667">How do compilers work?</a> was originally published in <a href="https://medium.com/skydome-academy">Skydome Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>