<?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 Hatice Kumru on Medium]]></title>
        <description><![CDATA[Stories by Hatice Kumru on Medium]]></description>
        <link>https://medium.com/@hatice.kumru?source=rss-1d796ad124c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q44ESOCVhzA2fnDfONvHtQ.jpeg</url>
            <title>Stories by Hatice Kumru on Medium</title>
            <link>https://medium.com/@hatice.kumru?source=rss-1d796ad124c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:41:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hatice.kumru/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[What does ACID mean?]]></title>
            <link>https://medium.com/@hatice.kumru/what-does-acid-mean-7f575c6f66b7?source=rss-1d796ad124c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f575c6f66b7</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Hatice Kumru]]></dc:creator>
            <pubDate>Thu, 27 Oct 2022 23:23:29 GMT</pubDate>
            <atom:updated>2022-10-27T23:23:29.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*Jgiw9CD-7EiFhj5HMmKTWw.png" /></figure><p>ACID is an acronym for <strong>Atomicity</strong>, <strong>Consistency</strong>, <strong>Isolation</strong>, and <strong>Durability. </strong>These are properties for databases that can provide in different ways. Most of the databases provide these features, but that does not mean all the databases support them in the exactly same way.</p><p><strong>Atomicity</strong></p><p>Atomicity provides that all the changes made by the transaction should be aborted in case of an error.</p><p>Let&#39;s assume that your application started to process to make one transaction to the database, but suddenly because of a network issue transaction could not complete. What would you expect in the such situation from your application? It was in the middle of the transaction and some of the work was completed and some of it could not complete. If your database is in such a situation and the database undo what it does exactly as the previous version before the transaction happened it means this database provides <strong>atomicity</strong>.</p><p><strong>Consistency</strong></p><p>Databases have some rules for data correctness and <strong>consistency</strong> helps the database to keep in correct state according to these rules. The state of the data in the database before transaction should be preserved after the transaction as well according the rules.</p><p><strong>Isolation</strong></p><p><strong>Isolation</strong> helps to run your concurrent transactions like you are running them sequentially. In other words, one transaction does not affect the result of the other transaction and if you will run the same transactions at different times you will get the same result. This situation can create a problem especially if you try to write same entry at the same time with different transactions.</p><pre>User1          get current balance    add 5 </pre><pre>Database       balance = 20                     expected result = 35<br>joint account</pre><pre>User2          get current balance    add 10 </pre><p>In the above example, we have a joint bank account, and User1 and User2 try to put money into the same account at the same time. At the end of this operation, we expect the bank account balance is 35, but if the database does not support <strong>isolation</strong> property, it could end up with 25 or 30 which causes incorrect data.</p><p>So, how did this happen? User1 got the current balance and added money which resulted as 25. Afterwards, before 25 is written in the database, User2 got the current balance as 20 and overwrite 25 as with its result as 30. In conclusion, that caused isolation failure and wrong result in the bank account.</p><p>As I said in the beginning, every database does not have to implement the <strong>isolation</strong> or any other ACID property in the same way. Databases can choose one of the isolation levels to implement <strong>isolation</strong> property. So, there are different isolation levels like snapshot isolation, serialazable, read uncommitted and so on.</p><p><strong>Durability</strong></p><p>We want to use database to save our data after successful transaction. This is our main purpose of using the databases. Besides that our expectation after saving the data that we do not want to loose that data and do not want to deal with anything for this. <strong>Durability</strong> provides exactly this feature for databases. To provide durability databases replicate data to redundant nodes or backups.</p><p><strong><em>References</em></strong></p><ol><li>Designing Data-Intensive Applications by Martin Kleppmann</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f575c6f66b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Design Principles for Clean Architecture]]></title>
            <link>https://medium.com/@hatice.kumru/software-design-principles-for-clean-architecture-3aa80299e78c?source=rss-1d796ad124c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aa80299e78c</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Hatice Kumru]]></dc:creator>
            <pubDate>Sun, 09 Oct 2022 21:07:02 GMT</pubDate>
            <atom:updated>2022-10-09T21:08:29.769Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Component Cohesion</strong></p><p>Today, we will examine three design principles;</p><ul><li><strong>REP</strong>: Reuse/Release Equivalence Principle</li><li><strong>CCP</strong>: Common Closure Principle</li><li><strong>CRP</strong>: Common Reuse Principle</li></ul><p>These three principles are related to component cohesion. I will also explain <strong>component</strong> and <strong>cohesion</strong> here to understand the meaning of component cohesion.</p><p>We can think <strong>components</strong> are the smallest units deployable together. <strong>Cohesion</strong> is how much those components are related to each other.</p><p>In brief, these three design principles are about deciding which classes are put together in a component.</p><h4>Reuse/Release Equivalence Principle</h4><p>In this principle, we aim to make release/reuse software components that belong to the same release.</p><p>First, we need release numbers for each component to accomplish REP. Otherwise, we cannot understand whether the components are compatible with each other.</p><p>Secondly, components should consist of classes and modules that are releasable together.</p><p>Lastly, each release has its own documentation to inform users of that component.</p><h4>Common Closure Principle</h4><p>According to this principle, when we decide which classes to put together, we want to have classes has the same reason to change in the same component. This rephrases the SRP (Single Responsibility Principle) at the component level.</p><p>There should be only one reason to change one component that helps us to reduce our work. In this CCP principle, we will need to change only one component, deploy this component and test it. Otherwise, we need to make changes in different components and follow the whole lifecycle for each changed component. Consequently, if we will use the CCP principle, that will reduce the workload.</p><p>To sum up, there is a similarity between CCP and SRP principles. If we follow CCP in our component, that component has only one reason to change. Finally, we can understand the aim of SRP and CCP in this sentence.</p><blockquote>Gather together those things that change for the same reason, and separate those things that change for different reasons.</blockquote><blockquote><strong><em>— Robert C. Martin</em></strong></blockquote><h4>Common Reuse Principle</h4><p>Each component has many classes inside and the Common Reuse Principle (CRP) states that if some of the classes use each other a lot then you should put those classes in the same component.</p><p>Let`s assume that we have classes like showed in the below example</p><pre>Component A               Component B<br>- Class A                 - Class C<br>- Class B                 - Class D<br>Other classes..           - Class E<br>                          Other classes ..</pre><p>Class A uses methods in Class B a lot which means they are tightly coupled and should be in the same component. This reflects the correct structure for CCP.</p><p>However, if Class A uses Class C and does not have any usage for the rest of Component B, we have an issue here. Because we are dependent on classes we do not use in Component B like Class D and Class E. This is the opposite of want we want to achieve in this principle. CRP aims to create a component that has classes dependent on its own classes instead of unused and not needed classes from another component.</p><blockquote>Don`t force users of a component to depend on things they don`t need.</blockquote><blockquote><strong><em>— Robert C. Martin</em></strong></blockquote><p><strong><em>References</em></strong></p><ol><li>Clean Architecture by Robert C. Martin</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aa80299e78c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code]]></title>
            <link>https://medium.com/@hatice.kumru/clean-code-7201d8bfd2cb?source=rss-1d796ad124c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7201d8bfd2cb</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hatice Kumru]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 19:53:24 GMT</pubDate>
            <atom:updated>2022-09-26T19:53:24.724Z</atom:updated>
            <content:encoded><![CDATA[<p>Every developer would like to write code that works, but there is a more important thing than writing working code which is writing clean code.</p><blockquote>“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”</blockquote><blockquote>— Martin Fowler</blockquote><p><strong>Importance of naming</strong></p><p>We define functions, variables, and classes with names, do not differ whatever you named that should explain the meaning and intention of them.</p><p>Let`s assume that we give a name for a function, when another developer read the function name, that person should understand the intention of the function.</p><p>We should give more attention to naming when we are writing code. Let`s examine below example.</p><pre>public List&lt;int[]&gt; getThem(int[][] arr, List&lt;int[]&gt; theList) {<br>    List&lt;int[]&gt; res = new ArrayList&lt;&gt;();<br>    for (int[] x : theList) {<br>        int a = x[0];<br>        int b = x[1];<br>        if(a &lt; 0 || b &lt; 0 || a &gt;= arr.length || b &gt;= arr[0].length){<br>            continue;<br>        }<br>        if(arr[a][b] == 1) {<br>            res.add(new int[]{a, b});<br>        }<br>    }<br>    return res;<br>}</pre><p>When you read this code, could you imagine anything that the code is doing? If you know basic java, you could understand the code with that knowledge normally, but this is not easy with this version. Let`s improve the naming and try again.</p><pre>public List&lt;Point&gt; getFlaggedPoints(int[][] grid, List&lt;Point&gt; directions) {<br>   List&lt;Point&gt; flaggedCells = new ArrayList&lt;Point&gt;();<br>   for(Point point : directions) {<br>        if(point.x &lt; 0 || point.y &lt; 0 <br>           || point.x &gt;= rowLength || point.y &gt;= colLength){<br>            continue;<br>        }<br>        if(grid[point.x][point.y] == 1) {<br>            flaggedCells.add(new Point(point.x, point.y));<br>        }<br>    }<br>    return flaggedCells;<br>}</pre><p>Can you see the difference between the two examples? We can read the getFlaggedPoints method easily now. All the logic is same with getThem method, but we have better naming in the getFlaggedPoints for functions and variables.</p><p>Another important point when giving the name is that do not use repeated names in the same project which can cause confusion and hard to track when reading the code in the whole project.</p><p><strong>Comments</strong></p><p>If we want to use comment to explain the function what it does, it is also red flag to tell us that we did not name the function enough well to express the intention. Function names should explain themselves without comments.</p><p>It does not mean that we should not use comments at all, but general logic for the necessity of the comments is that they should not be necessary to explain the functions.</p><p>One example of redundant comments is</p><pre><em>/* findRoom methods which return Room when find suitable with id  */<br></em>public Room findRoom(int id) { ... }</pre><p><strong>Functions</strong></p><p>Functions always should do one thing. First of all, we need to question that is this function doing only one thing? Is it small enough?</p><pre>public String findAvailableRoom(Hotel hotel, Room room, int person, int budget) {<br>    Room selectedRoom;<br>    for (int i = 0; i &lt; hotel.getRooms().size(); ++i) {<br>        Room eachRoom = hotel.getRooms().get(i);<br>        if (eachRoom.numberOfPerson() &gt; person) {<br>            if(eachRoom.available) {<br>                for(Rate rate : eachRoom.getRates()) {<br>                    if(rate &lt; budget) {<br>                        selectedRoom = eachRoom;<br>                    }<br>                }<br>            }<br>        }<br>    }</pre><pre>    return selectedRoom.getName();<br>}</pre><p>findAvailableRoom function has five indent level which is too much for a function which means it has nested a lot. Besides that we should consider the level of abstraction in the function to understand whether function is doing one thing. For example, numberOfPerson() method has low level of abstraction, but getRooms() method has high level of abstraction. If we will use the single level of abstraction methods in the same function, like basic operations append() , that helps to reduce the complexity of the function.</p><p>for loops or if statements should do only function calls.</p><p><strong>The Law of Demeter</strong></p><p>The law of demeter is a design principle which suggests that a calling object should not have a knowledge about internals of the caller object. Law of demeter has four rules about which methods accessible from calling object. Let`s assume that we have an object called Person ;</p><ul><li>Any methods inside the Person class</li><li>An object passed as an argument to getAddressDescription</li><li>An object created by getOccupation function</li><li>An object instance variable in the Person class</li></ul><pre>class Person {</pre><pre>    private Language language;</pre><pre>public String getFullName() { <br>        return this.getSurname + this.getFirstName; //First rule<br>    }</pre><pre>private String getSurname() { … }<br>    private String getFirstName() { … }</pre><pre>    public String getAddressDescription(Address address) {<br>        return address.getDescription(); //Second rule<br>    }</pre><pre>private void getOccupation() {   <br>        Occupation occupation = new Occupation();<br>        occupation.description();  // Third rule</pre><pre>        language.getCount(); // Fourth rule<br>    }</pre><pre>}</pre><pre>class Occupation {<br>    public void description() { … }<br>}</pre><ul><li>We can call the getSurname and getFirstName functions inside getFullName which mean Person call any function belongs to Person class.</li><li>In the getAddressDescription function, we can call getDescription function because it is passed as argument with Address object which means we can call any function belongs to Address object.</li><li>In the getOccupation function, we can invoke the description function because it is initiated with Occupation object.</li><li>In the getOccupation function, we can call any function belongs to Language class, because it is instance variable of Person class.</li></ul><p><strong>Classes</strong></p><p>The same rule we learned in the functions chapter will apply in here also, classes should be small. To understand if a class is small enough, we can check the name of the class. If the class name describes all the responsibilities of that class and it has explanatory name, that is indication that we have a small enough class.</p><p>Single Responsibility Principle(SRP) states that</p><blockquote>A module should be responsible to one, and only one, actor.</blockquote><blockquote>— <strong>Robert C. Martin</strong></blockquote><p>If we will not follow this principle, we will continue to add responsibilities to our classes and after a while, we have fat, meaningless, and complex classes. Then we will have such side affects;</p><ul><li>It will be hard to find which method in which class</li><li>Increase maintenance time</li><li>There are no boundaries for classes anymore</li><li>It will decrease the readability of the code</li></ul><p><strong>Cohesion</strong></p><p>Cohesion means that every function, instance variables in the same class serve the same purpose and responsibility.</p><p>To make our code more clean and readable, we always aim to high cohesion.</p><p>Example of high cohesion with Room class</p><pre>class Room {<br>    private int roomId;<br>    private String roomName;<br>    public void setRoomName(String roomName, int roomId) { ... }<br>    public String getRoomName() { ... }<br>    public String getRoomRate(int roomId) { ... }<br>    public String getRoomCapacity(int roomId) { ... }<br>    public String getRoomAmenities(int roomId) { ... }<br>}</pre><p>Example of low cohesion with Room class</p><pre>class Room {<br>    private String employeeName;<br>    private String address;<br>    private int numberOfRooms;<br>    private String roomName;<br>   <br>    public int getRoomCount() { return numberOfRooms; }<br>    public String getAddress() { return address; }<br>    public void setEmployeeName(String employeeName) { ... }<br>    public void setRoomName(String roomName, int roomId) { ... }<br>    public String getRoomName() { ... }<br>    <br>}</pre><p>The usage of instance variables is a good indication of cohesion.</p><p>Low cohesion example with Hotel class</p><pre>class Hotel {<br><br>    private String employeeName;<br>    private int employeeId;<br>    private Double employeeSalary;<br>    private int numberOfRooms;<br>    private String roomStatus;<br>    public String getEmployeeName() { ... }<br>    public void prepareEmployeeShift(String employeeName, int employeeId) { ... }<br>    public Double setEmployeePayslip(String employeeName, int employeeId, Double employeeSalary) { ... }<br>    public int calculateAvailability(int numberOfRooms, String roomStatus) { ... }<br>    public int calculateMonthlyBudget(int numberOfRooms, String roomStatus) { ... }<br><br>}</pre><p>In Hotel class, we have five instance variables and three of them are used mostly used in three methods, and the rest of two variables are used in the two methods. This can show us, Hotel class has two different responsibilities and should be separated as two different classes like Staff and Room .</p><p><strong>Order of dependent functions</strong></p><p>Functions call other functions. To increase readability, we should put close to callee functions to caller functions based on the order of usage. Let’s examine vertical formatting with this example;</p><pre>class Order {<br>    <br>    public void makeOrder() {<br>        if(getPayment()) {<br>            prepareOrder();<br>        } else {<br>            informCustomer();<br>        }<br>    }<br>    <br>    public void getPayment() {}<br>    public void prepareOrder() {}<br>    public void informCustomer() {}<br>    <br>}</pre><p><strong>Boy scout rule</strong></p><p>There is a general term coming from Boy Scouts of America;</p><blockquote>Always leave the campground cleaner than you found it.</blockquote><p>We would like to apply this rule to our codebase. When you have a task in any project, do small changes to leave cleaner than before. It does not have to be big changes. You can do small things like renaming a variable or function, extracting one function into smaller pieces, and so on and that will create a big impact on the project in time.</p><p><strong><em>References</em></strong></p><ol><li>Clean Code by Robert C. Martin</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7201d8bfd2cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>