<?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 Merve Arslan on Medium]]></title>
        <description><![CDATA[Stories by Merve Arslan on Medium]]></description>
        <link>https://medium.com/@merve_arslan?source=rss-90e3dbad94d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Merve Arslan on Medium</title>
            <link>https://medium.com/@merve_arslan?source=rss-90e3dbad94d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:07:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@merve_arslan/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[Head First Design Patterns Series / 6 (Encapsulating Invocation: The Command Pattern)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-6-encapsulating-invocation-the-command-pattern-4226dd4dbd2?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4226dd4dbd2</guid>
            <category><![CDATA[design-principles]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <category><![CDATA[the-command]]></category>
            <category><![CDATA[command-pattern]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 05:20:46 GMT</pubDate>
            <atom:updated>2023-03-23T05:20:46.076Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><blockquote><strong>The Command</strong> <strong>Pattern</strong> is a behavioral design pattern that turns a request into a stand-alone object that contains all information about the request. This transformation lets you pass requests as a method arguments, delay or queue a request’s execution, and support undoable operations.</blockquote><p>In this chapter, the authors this pattern is explained through the example of the “<strong> Order Slip </strong>”.</p><p>First, let’s look at how the system works in a restaurant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*TwHhyXx6_A_hG5Gc" /></figure><p>The customer comes and calls the waiter to order after examining the menu. The waiter adds the order received from the customer to the order slip and returns to the kitchen and forwards the order slip to the relevant persons. Relevant persons can only prepare the order via the order slip without any dialogue with the customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*WJ7Iq5NaKRdawRpL.png" /></figure><p>Think of the Order Slip as an object that functions as a meal prep request. Like any object, it’s like an object that can pass from the Waiter to the order counter or the next waiter who takes over his shift. It has an interface that consists of a single method called orderUp() that summarizes the actions required to prepare the meal. It also has a reference to the object that needs to instantiate it. The waiter doesn’t have to know what’s on the order or even who is preparing the food; just pass the receipt through the order window and say “Order!”<br>The waiter’s job is to get the order slips and call the orderUp() method on them. The waiter parameterizes the TakeOrder() method with different order receipts from different customers throughout the day and knows that all order receipts support the orderUp() method and can call orderUp() whenever he needs to prepare any food.<br>The cook has the necessary knowledge to prepare the food. It is the object that really knows how to prepare food. When the waiter calls the orderUp() method; the cook inherits and implements all the methods needed to create a meal. Note that the waiter and the cook are completely separated from each other: the waiter has order slips outlining the details of the dish; it just calls a method on each order to prepare it. Likewise, the cook takes his instructions from the order slip; never need to communicate directly with the waiter.</p><p>In this chapter we’ve added a pattern that allows us to encapsulate methods into Command objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*CWHQQ3oH18YJrglv.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4226dd4dbd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-6-encapsulating-invocation-the-command-pattern-4226dd4dbd2">Head First Design Patterns Series / 6 (Encapsulating Invocation: The Command Pattern)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Head First Design Patterns Series / 5 (One of a Kind Objects: The Singleton Pattern)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-5-one-of-a-kind-objects-the-singleton-pattern-b4629162f9cd?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4629162f9cd</guid>
            <category><![CDATA[singleton-pattern]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[design-principles]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 05:48:22 GMT</pubDate>
            <atom:updated>2023-03-16T05:48:22.930Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><p>The singleton design patterns allow only one instance of the class to be taken. In this way, creating and copying a new one from the object is prevented and it makes the related object global. Also, when that object is needed, the previous instance of the object is called. In general, a singular structure is used when it is desired to control how many objects are produced from a class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*OVu7H1srk0swyKX3E8JLKg.png" /></figure><blockquote>The government is an excellent example of the Singleton pattern. A country can have only one official government. Regardless of the personal identities of the individuals who form governments, the title, “The Government of X”, is a global point of access that identifies the group of people in charge.</blockquote><p>If your class is self-contained and not dependent on complex initialization, creating a class where all methods and variables are defined as static would be the same as a singleton.However, because of the way static initializations are handled in Java, this can get very messy, especially if multiple classes are involved. Often this scenario can result in subtle, hard-to-find bugs involving order of initialization. Unless there is a compelling need to implement your “singleton” this way, it’s far better to stay in the object world.</p><p>In Java, global variables are basically static references to objects. There are a couple of disadvantages to using global variables in this manner. We need to keep in mind the intent of the pattern: to ensure only one instance of a class exists and to provide global access. A global variable can provide the latter, but not the former. Global variables also tend to encourage developers to pollute the namespace with lots of global references to small objects. Singletons don’t encourage this in the same way, but can be abused nonetheless.</p><p>We can also use singleton pattern using enum. Like that ↴</p><pre>public enum Singleton {<br>    UNIQUE_INSTANCE;<br>    // more useful fields here<br>}<br>public class SingletonClient {<br>       public static void main(String[] args) {<br>              Singleton singleton = Singleton.UNIQUE_INSTANCE;<br>              // use the singleton here<br>       }<br>}</pre><blockquote>You’ve now added another pattern to your toolbox. Singleton gives you another method of creating objects — in this case, unique objects.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*w_NV_OVW6my2XKjz.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4629162f9cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-5-one-of-a-kind-objects-the-singleton-pattern-b4629162f9cd">Head First Design Patterns Series / 5 (One of a Kind Objects: The Singleton Pattern)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Head First Design Patterns Series / 4 (The Factory Pattern: Baking with OO Goodness)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-4-the-factory-pattern-baking-with-oo-goodness-34cac1edfa6e?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/34cac1edfa6e</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <category><![CDATA[factory-pattern]]></category>
            <category><![CDATA[design-principles]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 06:01:17 GMT</pubDate>
            <atom:updated>2023-01-30T06:01:17.590Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><blockquote><strong>The Factory Pattern </strong>defines an interface for creating an object, but lets subclasses decide which class to instantiate.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2_yBq_inQEefynnqNPgug.png" /></figure><p><strong>Encapsulating object creation</strong></p><p>In this chapter, the authors explain through a pizza shop sample. As a result of the need for more than one type of pizza, they first start by separating the things that varying and the things that don’t. Then they resort to the encapsulation method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*Fx9WayZAQUzp9_yb.jpg" /></figure><p>The orderPizza() method has a well-honed order system. The things that change are the styles demanded by region. So we will collect all these variations under the createPizza() method and hold it responsible for creating the right type of pizza.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xu_UGdE0SSlTHEmE6uVEzA.png" /></figure><p>After defining the creator classes, let’s define the products and take a look at the final classes we tried to make with the factory pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRk6kQ5yGY3JYOmJhQTRgg.png" /></figure><p><strong>The Dependency Inversion Principle</strong></p><p>In previous chapters, the authors mentioned that reducing dependencies on concrete classes makes code better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1EYAzAWnNIQrA4LjYwLsg.png" /></figure><p>This design principle is that our high-level components do not depend on our lower-level components; instead, it suggests that both should depend on abstractions.</p><p>When we adapt this design principle to the PizzaStore example and examine it on the diagram, the change is as follows.</p><p><strong><em>Before :</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*Xt1JVGtkdZnHWe0SYkx95Q.png" /></figure><p><strong><em>After Applying the Principle:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*VHmi1f4Vdswg1eNE8O7iog.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34cac1edfa6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-4-the-factory-pattern-baking-with-oo-goodness-34cac1edfa6e">Head First Design Patterns Series / 4 (The Factory Pattern: Baking with OO Goodness)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Head First Design Patterns Series / 3 (Decorating Objects: The Decorator Pattern)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-3-decorating-objects-the-decorator-pattern-7eda5485033f?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7eda5485033f</guid>
            <category><![CDATA[decorator-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <category><![CDATA[design-principles]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 06:01:00 GMT</pubDate>
            <atom:updated>2023-01-30T06:01:00.533Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><blockquote><strong>The decorator pattern </strong>is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*1_BnNeDD0ou6LvrH" /></figure><p>In this chapter, the authors explained the decorator pattern through the example of a corporate coffee chain.</p><p>In addition to the regular system, a variety of condiments such as steamed milk, soy and mocha (also known as chocolate) can be requested into the coffee, all of which can be topped with whipped milk. These changes need to be placed in ordering systems, as additional charges are required for all these changes.</p><p>Here’s their first attempt 🙃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*gjPU7Lqin2iC9Gdj.png" /></figure><p>Instead, you can start with a beverage and “decorate” it with seasonings at runtime. For example, if the client wants Dark Roast with Mocha and Whip:</p><p><strong>1.) First, let’s consider the DarkRoast object</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*BJL4Y2GnUj1SDBnw.png" /></figure><p><strong>2.) The client wants Mocha, so we create a Mocha object that we wrap around the DarkRoast.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/0*Gl-xPX9UgFWIKXfe.png" /></figure><p><strong>3.) Then we do the process in step 2 for Whip and Mocha.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*sqxv1SFYxKulz6ol.png" /></figure><p><strong>4.) Now it’s time to calculate the cost for the customer. We do this by calling cost() in the outermost decorator, Whip and Whip will delegate the cost calculation to the objects it decorates. Mocha and Mocha will delegate the cost calculation to the objects they decorate. Let’s see how this works:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NdG4hvfbz5mgRZbW.png" /></figure><p>Now let’s see what we’ve learned looks like in the big picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/0*npAXfMQyg1Duo4Mw.png" /></figure><p>Isn’t it much more tidy and understandable than picture 1?</p><p><a href="https://refactoring.guru/design-patterns/decorator"><strong><em>Real-World Analogy</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*PUZw0V9N4oDw9Y3F" /></figure><p>Wearing clothes is an example of using decorators. When you’re cold, you wrap yourself in a sweater. If you’re still cold with a sweater, you can wear a jacket on top. If it’s raining, you can put on a raincoat. All of these garments “extend” your basic behavior but aren’t part of you, and you can easily take off any piece of clothing whenever you don’t need it..</p><p>I want to end this article with the design principle in this chapter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*6J-b9V9ybcKkXenr.png" /></figure><blockquote><strong>Our goal is to allow classes to be easily extended to incorporate new behavior without modifying existing code. What do we get if we accomplish this? Designs that are resilient to change and flexible enough to take on new functionality to meet changing requirements.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7eda5485033f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-3-decorating-objects-the-decorator-pattern-7eda5485033f">Head First Design Patterns Series / 3 (Decorating Objects: The Decorator Pattern)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Head First Design Patterns Series / 2 (Keeping your Objects in the Know: The Observer Pattern)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-2-keeping-your-objects-in-the-know-the-observer-pattern-31d21a31e10f?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/31d21a31e10f</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[design-principles]]></category>
            <category><![CDATA[observer-pattern]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 05:47:16 GMT</pubDate>
            <atom:updated>2023-01-20T05:47:16.223Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*J2rgNV6Sl37jUA0U.jpg" /></figure><p>A pattern that keeps your objects in the know when something they care<em> </em>about happens. It’s the <strong>Observer Pattern</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/0*2i9u2LUGeMwqDQZC.png" /></figure><p><strong>The Observer Pattern</strong> defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*mw4cAXfuNzWvF5ga.png" /></figure><p>The subject and observers define the one-to-many relationship. We have one subject, who notifies many observers when something in the subject changes. The observers are dependent on the subject — when the subject’s state changes, the observers are notified.</p><p>When two objects are loosely coupled, they can interact, but they typically have very little knowledge of each other. As we’re going to see, loosely coupled designs often give us a lot of flexibility. And, as it turns out, the Observer Pattern is a great example of loose coupling. Let’s walk through all the ways the pattern achieves loose coupling:</p><ul><li><strong><em>First, the only thing the subject knows about an observer is that it implements a certain interface (the Observer interface).</em></strong> It doesn’t need to know the concrete class of the observer, what it does, or anything else about it.</li><li><strong><em>We can add new observers at any time.</em></strong> Because the only thing the subject depends on is a list of objects that implement the Observer interface, we can add new observers whenever we want. In fact, we can replace any observer at runtime with another observer and the subject will keep purring along. Likewise, we can remove observers at any time.</li><li><strong><em>We never need to modify the subject to add new types of observers.</em></strong> Let’s say we have a new concrete class come along that needs to be an observer. We don’t need to make any changes to the subject to accommodate the new class type; all we have to do is implement the Observer interface in the new class and register as an observer. The subject doesn’t care; it will deliver notifications to any object that implements the Observer interface.</li><li><strong><em>We can reuse subjects or observers independently of each other.</em></strong> If we have another use for a subject or an observer, we can easily reuse them because the two aren’t tightly coupled.</li><li><strong><em>Changes to either the subject or an observer will not affect the other.</em></strong> Because the two are loosely coupled, we are free to make changes to either, as long as the objects still meet their obligations to implement the Subject or Observer interfaces.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*LDwdVHs5S8_k--XE.png" /></figure><blockquote><strong><em>Loosely coupled designs allow us to build flexible OO systems that can handle change because they minimize the interdependency between objects.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31d21a31e10f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-2-keeping-your-objects-in-the-know-the-observer-pattern-31d21a31e10f">Head First Design Patterns Series / 2 (Keeping your Objects in the Know: The Observer Pattern)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Head First Design Patterns Series / 1 (Welcome to Design Patterns)]]></title>
            <link>https://medium.com/odeal-tech/head-first-design-patterns-series-1-welcome-to-design-patterns-be8848f66b7b?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/be8848f66b7b</guid>
            <category><![CDATA[design-principles]]></category>
            <category><![CDATA[head-first-design-pattern]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[observer-pattern]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Thu, 12 Jan 2023 05:58:54 GMT</pubDate>
            <atom:updated>2023-01-12T05:58:54.126Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Extensible &amp; Maintainable Object Oriented Software</h4><p>In this series, you will accompany my notes as a summary from the book Design Patterns written by Eric Freeman &amp; Elisabeth Robson and Kathy Sierra &amp; Bert Bates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r_rP4aKiSYTbE3P7.jpg" /></figure><p>Just before the first chapter, the authors gave us important notes about metacognition: thinking about thinking or activating the brain. I followed footsteps of the authors and started by taking notes about them first. <em>Here are some of them :</em></p><ol><li><em>Slow down. The more you understand, the less you have to memorize.</em></li><li><em>Do the exercises. Write your own notes.</em></li><li><em>Make this the last thing you read before bed. Or at least the last challenging thing.</em></li><li><em>Drink water. Lots of it.</em></li><li><em>Talk about it. Out loud.</em></li><li><em>Listen to your brain.</em></li><li><em>Feel something.</em></li><li><em>Design something.</em></li></ol><p>Yes, if you’re ready let’s get it started 🤙🏻</p><blockquote>The best way to use patterns is to <em>load your brain</em> with them and then <em>recognize places</em> in your designs and existing applications where you can <em>apply them</em>. Instead of <em>code</em> reuse, with patterns you get <em>experience</em> reuse.</blockquote><p>The first chapter begins when Joe, a software developer working for a company developing a duck pond simulation game, is asked to add a new feature (fly &amp; quack) to ducks. The initial designers of the system used standard OO techniques and created one Duck superclass from which all other duck types inherit. And Joe thinked “I just need to add a fly() method in the Duck class and then all the ducks will inherit it.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*XrCfdbWELLcWOp76MzNzJw.png" /></figure><p><strong>What happened?</strong></p><p>Joe failed to notice that not <em>all</em> subclasses of Duck should <em>fly</em>. When Joe added new behavior to the Duck superclass, he was also adding behavior that was <em>not</em> appropriate for some Duck subclasses.</p><p><em>A localized update to the code caused a nonlocal side effect !</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*z54-oLQ4BR82eCFf7Ya1-A.png" /></figure><p><strong>Okay, what’s the one thing you can always count on in software development?</strong></p><p>No matter where you work, what you’re building, or what language you are programming in, what’s the one true constant that will be with you always?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/0*Qw-CP_nY_qJyDBAR.jpg" /><figcaption>CHANGE</figcaption></figure><p>(use a mirror to see the answer)</p><p><strong><em>No matter how well you design an application, over time an application must grow and change or it will die.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*egp9VBzWQlyxN7xOcf8Smw.png" /></figure><p><strong><em>Take what varies and “encapsulate” it so it won’t affect the rest of your code.</em></strong></p><p>Here’s another way to think about this principle: <strong><em>take the parts that vary and encapsulate them, so that later you can alter or extend the parts that vary without affecting those that don’t.</em></strong></p><blockquote><strong>Separating what changes from what stays the same</strong></blockquote><blockquote>Where do we start? As far as we can tell, other than the problems with fly() and quack(), the Duck class is working well and there are no other parts of it that appear to vary or change frequently. So, other than a few slight changes, we’re going to pretty much leave the Duck class alone.</blockquote><blockquote>Now, to separate the “parts that change from those that stay the same,” we are going to create two <em>sets</em> of classes (totally apart from Duck), one for <em>fly</em> and one for <em>quack</em>. Each set of classes will hold all the implementations of the respective behavior. For instance, we might have <em>one</em> class that implements <em>quacking</em>, <em>another</em> that implements <em>squeaking</em>, and <em>another</em> that implements <em>silence</em>.</blockquote><blockquote><strong>We know that fly() and quack() are the parts of the Duck class that vary across ducks.</strong></blockquote><blockquote><strong>To separate these behaviors from the Duck class, we’ll pull both methods out of the Duck class and create a new set of classes to represent each behavior.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*ItYZdr0amzuaRECWOjTyCQ.png" /></figure><p>Then we will proceed with the second design principle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*Qba-SJ2G5bACOVabsIgiIA.png" /></figure><p>So this time it won’t be the Duck classes that will implement the flying and quacking interfaces. Instead, we’ll make a set of classes whose entire reason for living is to represent a behavior (for example, “squeaking”), and it’s the behavior class, rather than the Duck class, that will implement the behavior interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*hY7rpQ6HZDr7LozRpSUEXw.png" /></figure><p><strong>Implementing the Duck Behaviors</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*HcnckP8Sx0wmGLcDzRf6HQ.png" /></figure><p><strong>HAS-A can be better than IS-A</strong></p><p>The HAS-A relationship is an interesting one: each duck has a FlyBehavior and a QuackBehavior to which it delegates flying and quacking.</p><p>When you put two classes together like this you’re using <strong>composition</strong>. Instead of <em>inheriting</em> their behavior, the ducks get their behavior by being <em>composed</em> with the right behavior object.</p><p>This is an important technique; in fact, it is the basis of our third design principle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*iWslwcunWwyeJvVDBcW-hA.png" /></figure><blockquote>Design patterns don’t go directly into your code, they first go into your BRAIN. Once you’ve loaded your brain with a good working knowledge of patterns, you can then start to apply them to your new designs, and rework your old code when you find it’s degrading into an inflexible mess.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*smLlIBReO-5wLJGIr3zdLA.png" /></figure><p>For now, I end the first chapter of the series with this question that the authors leave the answer to our neurons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*IgIgf_OBZMx7L4wqpzSZgw.png" /></figure><p><em>Stay tuned for other chapters of the series.. ;)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be8848f66b7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/head-first-design-patterns-series-1-welcome-to-design-patterns-be8848f66b7b">Head First Design Patterns Series / 1 (Welcome to Design Patterns)</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Karate Framework ile Api Test & Raporlama]]></title>
            <link>https://medium.com/odeal-tech/karate-framework-ile-api-test-raporlama-fc3b733741af?source=rss-90e3dbad94d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc3b733741af</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[karate]]></category>
            <category><![CDATA[bdd-testing]]></category>
            <category><![CDATA[karate-framework]]></category>
            <dc:creator><![CDATA[Merve Arslan]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 06:34:03 GMT</pubDate>
            <atom:updated>2022-11-25T06:34:03.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba,</p><p>Bu yazıda Karate ile api test yazma ve rapor alma konusunu inceleyeceğiz.</p><p>Karate Peter Thomas tarafından geliştirilen açık kaynak kodlu api test otomasyon aracıdır. Karate, <a href="https://github.com/karatelabs/karate/tree/master/karate-netty">API test otomasyonu</a>, <a href="https://github.com/karatelabs/karate/tree/master/karate-gatling">performans testi</a> ve hatta <a href="https://github.com/karatelabs/karate/tree/master/karate-core">UI otomasyonunu</a> tek bir birleşik çerçevede birleştiren açık kaynaklı bir araçtır. Cucumber tarafından popüler hale getirilen BDD sözdizimi ile dilden bağımsızdır ve programcı olmayanlar için de kolay anlaşılabilirdir. Assertionlar ve HTML raporları yerleşiktir ve hız için testleri paralel olarak çalıştırabilirsiniz.</p><blockquote>PUT, POST, DELETE, GET gibi birkaç API istek yöntemi vardır. Başka bir dilde veya çerçevede, o yöntemleri bir kütüphane ile bildirmeniz veya yöntemleri geliştirmeniz gerekirken, karate’de istekte bulunmak için “Method” anahtar sözcüğünden sonra ihtiyacınız olan istek türünü yazmanız yeterlidir.</blockquote><blockquote>Ayrıca, diğer BDD framework’lerinin (Cucumber, JBehave, Specflow) aksine, step definition’larını (Kullanılan BDD cümleciklerinin kodla içinin doldurulması) da yazmanız gerekmez çünkü, Karate, API testine başlamanız için gereken bütün step definition’ları sizin için oluşturmuş durumda bünyesinde tutar.</blockquote><p><strong><em>Gereksinimler</em></strong></p><ul><li><em>IntelliJ</em></li><li><em>Java jdk 1.8 ve üzeri</em></li><li><em>Maven</em></li><li><em>Cucumber Plugins</em></li></ul><p><strong>1. Geliştirme Ortamını Ayarlama</strong></p><p>IntelliJ Ide’sini açtıktan sonra<strong><em> New Project</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*ftw8kda7eBzQ1ZThpMslTg.png" /></figure><p>ya da sol üstteki toolbar üzerinden <strong><em>File &gt; New &gt; Project</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*mlTN-Meu4NNPXcNiwFjP4Q.png" /></figure><p>yolunu takip ederek proje adı, build system, jdk sürüm bilgilerini girdikten sonra create butonuna tıkladığımızda ilk adımı tamamlamış oluyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*t7yTlWJKr7AnsWx1LvMKVA.png" /></figure><p><strong>2. Karate Kurulumu</strong></p><pre>&lt;dependencies&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;net.masterthought&lt;/groupId&gt;<br>            &lt;artifactId&gt;cucumber-reporting&lt;/artifactId&gt;<br>            &lt;version&gt;4.11.2&lt;/version&gt;<br>        &lt;/dependency&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;com.intuit.karate&lt;/groupId&gt;<br>            &lt;artifactId&gt;karate-junit4&lt;/artifactId&gt;<br>            &lt;version&gt;0.6.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.testng&lt;/groupId&gt;<br>            &lt;artifactId&gt;testng&lt;/artifactId&gt;<br>            &lt;version&gt;7.1.0&lt;/version&gt;<br>            &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;junit&lt;/groupId&gt;<br>            &lt;artifactId&gt;junit&lt;/artifactId&gt;<br>            &lt;version&gt;4.13.1&lt;/version&gt;<br>            &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br>    &lt;/dependencies&gt;</pre><p>Pom.xml dosyasına gerekli dependency’leri girdikten sonra</p><p><strong>Cucumber for java</strong> ve <strong>Gherkin</strong> pluginlerini de <strong><em>File &gt; Settings &gt; Plugins</em></strong> yolunu izleyerek ekleyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uF8PDXcZp-fOMRXiq9YPkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LTmrao1sfj6wnW8sYHRYXg.png" /></figure><p><strong>3. Proje Dizini Oluşturma</strong></p><p>Öncelikle aynı toolbar üzerinden <strong><em>java &gt; New &gt; Package </em></strong>yolu ile içerisine kullanacağımız feature dosyası ve test runner classını koyacağımız bir package oluşturalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*YEbOeHnb2w0mR2xoOHexPw.png" /></figure><p>Package’e sağ tıklayarak projeyi çalıştıracağımız TestRunner adlı java classını oluşturalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*nPeYN9XaBae6aITVuE9hSw.png" /></figure><p>Sonrasında package’a sağ tıklayarak <strong><em>New &gt; File</em></strong> yolu üzerinden feature dosyasını oluşturalım. Uzantısını “.feature” olarak verdiğinizde cucumber ikonunun otomatik geldiğini göreceksiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*VXDHKx6MS9HEVTYPxPbM_A.png" /></figure><p>Sonrasında feature dosyasında kullanmak üzere config dosyasını oluşturalım. Feature dosyasında olduğu gibi <strong><em>src &gt; test &gt;java</em></strong> altında .js uzantılı (karate-config.js) file şeklinde oluşturalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*fL0t6JTW55g6rYvIEbHBDA.png" /></figure><p>Bu adımları tamamladıktan sonra geliştirmeye başlayabiliriz.</p><p><strong>4. Geliştirmeye Başlama</strong></p><p>Background olarak genel bir url tanımladığımız için her senaryonun başında buraya gelecek ve yine her senaryo için bu url’i kullanacak. Background içerisinde tanımladığımız url’e path olarak ayrı ayrı tanımlama yapacaksak bunu scenario’lar içerisinde verebiliriz.</p><p>Ben <a href="https://reqres.in/">https://reqres.in/</a> sitesi üzerinden testlerimi gerçekleştireceğim.</p><p><strong>GET REQUEST</strong></p><p><strong>Get </strong>methodunu kullanıp status code’un 200 döndüğünü kontrol ettikten sonra <strong>print</strong> yöntemi ile response’u yazdırabilir, assertion için de <strong>assert</strong> ya da <strong>match</strong> yöntemlerini kullanabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*J-_U-47eHp-53o82S9v5Og.png" /></figure><p>Ben 2 numaralı kullanıcının bilgilerini getirecek pathi girdikten sonra <strong>get </strong>methodunu uygulayıp başarılı status code (200) kontrolü yaptım. Response’u yazdırdım, raporda gördüm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJal_iPGIke_CVr55HD5rw.png" /></figure><p>Sonrasında da <strong>assert </strong>ile response id’nin 2 olduğunu doğruladım.</p><p><strong>POST REQUEST</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*P7U3JcdNySn5DjGQ-gfKjQ.png" /></figure><p><strong>Post </strong>methodunda kullanıcıların içerisine yeni bir kullanıcı eklemek için <strong>/users</strong> pathini girdikten sonra create etmek istediğim bilgileri içeren body’i json formatta tanımladım. Body’i gönderip <strong>post </strong>methodunu uygulayarak başarılı status code (201) kontrolü yaptım. Response’u yazdırdım, oluşturduğum yeni kullanıcı bilgilerini ve atanan id’yi hem console’da hem de raporda gördüm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qua93i8-a5UCQesSnQ2cGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpWgezM4B88ARtg2leUXTQ.png" /></figure><p>Sonrasında da <strong>match </strong>ile first_name değerinin “Mars” olduğunu ve “null olmayan” bir id’nin oluşturulabildiğini doğruladım.</p><p><strong>PUT REQUEST</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*zHJy5qLf9g8oFrxtN41I4A.png" /></figure><p><strong>Put</strong> methodunda 3 numaralı kullanıcının bilgilerini güncellemek için <strong>/users/3</strong> pathini girdikten sonra update etmek istediğim bilgileri içeren body’i json formatta tanımladım. Body’i gönderip <strong>put </strong>methodunu uygulayarak başarılı status code (201) kontrolü yaptım. Response’u yazdırdım, oluşturduğum yeni kullanıcı bilgilerini ve atanan id’yi hem console’da hem de raporda gördüm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*USy3D6tscFcv995IeuBXYw.png" /></figure><p><strong>DELETE REQUEST</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*S3NXIyxDGkMxf1eg_v7Wxg.png" /></figure><p>Url gibi tanımlamaları karate-config.js dosyasında yapıp çalıştıracağımız senaryoda kullanabiliriz. Ben bunu (göstermek amacıyla) delete methodunda kullanmayı tercih ettim.</p><p><strong>Delete</strong> methodunda 2 numaralı kullanıcının bilgilerini silmek için <strong>.js </strong>uzantılı dosyaya url’i tanımladım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*uRmGOOEpfn_TF9ls16vjug.png" /></figure><p>Tanımladığım isimle scenario üzerinden çağırdım. Bu arada dosyadaki background kısmındaki url’i comment line yaptım. <strong>Delete </strong>methodunu uygulayarak başarılı status code (204) kontrolü yaptım. Response’u yazdırdım, response’un boş döndüğünü raporda gördüm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A0rki7XMwEisMiJuCA03gw.png" /></figure><p><strong>5. Raporlama</strong></p><ul><li><strong>HTML Rapor Alma</strong></li></ul><p>Karate default olarak yapısında html rapor barındıran bir framework’e sahiptir.</p><p>Herhangi bir senaryoyu run ettikten sonra<strong><em> target &gt; surefire-reports &gt; karate-summary.html</em></strong> yolunu takip ederek raporları görebilir, sağ click<strong><em> Open In &gt; Browser</em></strong> yolu ile de raporu dilediğimiz browser içinde açabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0A-5MAR9h5zc1NViGhStQ.png" /></figure><p>Ya da pom.xml’e ekleyeceğimiz</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.intuit.karate&lt;/groupId&gt;<br>    &lt;artifactId&gt;karate-core&lt;/artifactId&gt;<br>    &lt;version&gt;1.0.1&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>sayesinde scenario run edildiğinde otomatik oluşturulan <strong><em>target &gt; karate-reports</em></strong> klasörü içinden html raporlara gidebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*5msrFxmcuNPrtmQDJpdK9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvMz3cem6fIoNE9iJDQoEw.png" /></figure><ul><li><strong>Cucumber Rapor Alma</strong></li></ul><p>Sağ üst köşeden features, tags, steps ya da failures seçeneklerine tıklayarak hangisinin detaylarına gitmek istiyorsak gidebiliriz.</p><p>İstatistiklere feature bazında bakmak istersek <strong>“features”</strong> kısmına gelmeliyiz.</p><p>Features raporunda, hangi feature dosyasını çalıştırdıysak ayrıntılı bir şekilde geçen, fail olan, atlanan bekleyen ya da tanımlanmayan step oranlarını, toplam geçen ya da fail olan senaryo miktarını ve feature koşum süresini ve statülerini görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wVw5d17zKDXCJwPkzhbXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6le20cFuV1zea7bBygMgPQ.png" /></figure><p>İstatistiklere tag bazında bakmak istersek <strong>“tags”</strong> kısmına gelmeliyiz. Burada tag bazında gösterilen oranlar ile farklı feature’lardaki farklı senaryoları bir arada koştuğumuzda, geçen, fail olan, atlanan bekleyen ya da tanımlanmayan step oranlarını, tag bazında toplam geçen ya da fail olan senaryo miktarını ve her bir feature dosyasının ayrı ayrı koşum süresini ve statülerini görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NmCoRWPLJ87HDmT6KZpqw.png" /></figure><p>İstatistiklere step bazında bakmak istersek <strong>“steps”</strong> kısmına gelmeliyiz.</p><p>Burada step bazında sırasıyla toplam step sayısını, ortalama test koşum süresini, max süreyi, toplam süreyi ve toplam statü oranını görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BAkxvb4xp1or_w5hLue3hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pg9JSGkTdzLIjTpTINy5jA.png" /></figure><p>İstatistiklere failure bazında bakmak istersek <strong>“failures”</strong> kısmına gelmeliyiz.</p><p>Son olarak burada da fail olan senaryo bazında bir istatistik ile birlikte failure olma sebebini ayrıntılı görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2yYD6_HxPCuY_D7mnZCqA.png" /></figure><p>Bu yazı ile sizlere karate framework ile temel api testleri yapmayı ve iki çeşit rapor almayı göstermeye çalıştım.</p><p><em>Projenin linkini bırakıyorum.</em></p><p><a href="https://github.com/odealmrv/KarateApiTesting"><em>https://github.com/odealmrv/KarateApiTesting</em></a></p><p>Geliş(tir)meli nice günlere.. 💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc3b733741af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/odeal-tech/karate-framework-ile-api-test-raporlama-fc3b733741af">Karate Framework ile Api Test &amp; Raporlama</a> was originally published in <a href="https://medium.com/odeal-tech">Odeal-Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>