<?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 Hatef Palizgar on Medium]]></title>
        <description><![CDATA[Stories by Hatef Palizgar on Medium]]></description>
        <link>https://medium.com/@palizgar?source=rss-a560d92dc99d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*txQfuc2L8vv5qNjssGyMMA.png</url>
            <title>Stories by Hatef Palizgar on Medium</title>
            <link>https://medium.com/@palizgar?source=rss-a560d92dc99d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 12:31:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@palizgar/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 on earth is a Protocol?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://palizgar.medium.com/what-on-earth-is-a-protocol-67ebf051c510?source=rss-a560d92dc99d------2"><img src="https://cdn-images-1.medium.com/max/2600/0*zpw4jWBuXVvRoDGn" width="7952"></a></p><p class="medium-feed-snippet">A clear explanation of digital communication protocols, comparing them to a common language that facilitates seamless interaction between&#x2026;</p><p class="medium-feed-link"><a href="https://palizgar.medium.com/what-on-earth-is-a-protocol-67ebf051c510?source=rss-a560d92dc99d------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://palizgar.medium.com/what-on-earth-is-a-protocol-67ebf051c510?source=rss-a560d92dc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/67ebf051c510</guid>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[protocol]]></category>
            <dc:creator><![CDATA[Hatef Palizgar]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 14:43:29 GMT</pubDate>
            <atom:updated>2024-12-20T14:43:29.674Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Projections vs. DTOs: Choosing the Right Tool for the Job–A Personal Experience]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/projections-vs-dtos-choosing-the-right-tool-for-the-job-a-personal-experience-63c5953c7ed4?source=rss-a560d92dc99d------2"><img src="https://cdn-images-1.medium.com/max/2600/0*-zcK4Pp0OYmh68LA" width="3024"></a></p><p class="medium-feed-snippet">TL;DR: Projections in Spring fetch only the data you need, making queries faster and cleaner, while DTOs provide flexibility for complex&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/projections-vs-dtos-choosing-the-right-tool-for-the-job-a-personal-experience-63c5953c7ed4?source=rss-a560d92dc99d------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/projections-vs-dtos-choosing-the-right-tool-for-the-job-a-personal-experience-63c5953c7ed4?source=rss-a560d92dc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/63c5953c7ed4</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[dto]]></category>
            <category><![CDATA[jpa]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[projection]]></category>
            <dc:creator><![CDATA[Hatef Palizgar]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 19:31:43 GMT</pubDate>
            <atom:updated>2024-11-29T19:33:36.157Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Code Smarter, Not Harder: Why Every Software Engineer Needs to Take Notes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/code-smarter-not-harder-why-every-software-engineer-needs-to-take-notes-e74a3127f7fb?source=rss-a560d92dc99d------2"><img src="https://cdn-images-1.medium.com/max/2600/0*ofS4VnbCKICpREJy" width="4000"></a></p><p class="medium-feed-snippet">I promise to keep it short&#x200A;&#x2014;&#x200A;no fuss.</p><p class="medium-feed-link"><a href="https://medium.com/swlh/code-smarter-not-harder-why-every-software-engineer-needs-to-take-notes-e74a3127f7fb?source=rss-a560d92dc99d------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/code-smarter-not-harder-why-every-software-engineer-needs-to-take-notes-e74a3127f7fb?source=rss-a560d92dc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e74a3127f7fb</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[notetaking]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[pkm]]></category>
            <dc:creator><![CDATA[Hatef Palizgar]]></dc:creator>
            <pubDate>Sat, 23 Nov 2024 22:29:20 GMT</pubDate>
            <atom:updated>2024-11-30T13:46:13.218Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Abstraction in Object-Oriented Programming: Benefits and Examples]]></title>
            <link>https://medium.com/swlh/abstraction-in-object-oriented-programming-benefits-and-examples-b0befcdcf7d0?source=rss-a560d92dc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0befcdcf7d0</guid>
            <category><![CDATA[object-oriented-program]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[interfaces]]></category>
            <category><![CDATA[abstraction]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Hatef Palizgar]]></dc:creator>
            <pubDate>Sun, 18 Dec 2022 01:12:36 GMT</pubDate>
            <atom:updated>2023-12-05T18:28:40.047Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Object-oriented programming (OOP) is a popular programming paradigm that allows developers to write organized and efficient code. Abstraction is an important concept when it comes to OOP, as it allows for the simplification of complex coding tasks. In this post, we will explore the concept of abstraction in OOP, how it helps us, and the benefits of using it in our code. We will also discuss what can happen if we don’t use abstraction when coding.</p><h3>What is an abstraction in OOP?</h3><p>Abstraction is a powerful concept in OOP that allows developers to hide details and complexity in their code. This means that when writing code, we don’t need to think about small details such as the implementation of the code. Instead, we can focus on the bigger picture of the programme and think about the desired behaviour. In OOP, abstraction is typically achieved through abstract classes and interfaces.</p><h3>Ok, but can you explain abstraction to me in simple terms?</h3><p>Absolutely. I can start with a simple mini-story to make more sense to you. Below is that mini-story called “<strong>The Different Kind of Love</strong>”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r-fj8q_Ig7-s5BPo" /><figcaption>Photo by <a href="https://unsplash.com/@shairad?utm_source=medium&amp;utm_medium=referral">Shaira Dela Peña</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Hatef loved his girlfriend and his dog, each in their own unique ways. When it came to his girlfriend, he gave her lots of presents and flowers, trying his absolute best to express his undying love for her. His days and nights were filled with thoughts of her, and he tried his best to make her happy.<br>Hatef’s love for his dog showed a different side to his affection. He often took his dog outside to play with the other animals, and he made sure to bathe and groom him regularly. He could be seen throwing the ball around in the park or running around, trying to get the dog to chase him. <br>But when it came to deeper things, Hatef knew his love for his girlfriend was special, and it was something his dog didn’t quite understand. He often found himself having conversations with his girlfriend late into the night, talking about their hopes and dreams and future plans. <br>Hatef was never afraid to express his feelings to his girlfriend, and he was never afraid to admit when he was wrong. He knew he was well taken care of by his girlfriend and that she was the one constant in his life that would never go away. <br>However, the same couldn’t be said about his dog. Even though Hatef loved him and spent time with him every day, he knew that one day his dog would pass away, and he would have to say goodbye. This was something that was hard for Hatef to come to terms with, and it was something he often struggled with.</em></p><p>Love can be expressed in many different ways. In the mini-story, Hatef expressed his love for his girlfriend in a different way than he did for his dog. For his girlfriend, Hatef gave presents and flowers, and he spent time talking with her about their hopes and dreams. For his dog, Hatef took him outside to play, bathed and groomed him, and ran around trying to get him to chase him.</p><p>Both his girlfriend and his dog were important to him, but the way he showed his love for each was different. He knew that his relationship with his girlfriend was something special and would last, while his relationship with his dog was more fleeting and he would one day have to say goodbye.</p><p>Now, let’s turn this story into a simple piece of Java code:</p><h3>Girlfriend and Dog</h3><p>Below is the code for the classes Girlfriend and Dog .</p><p><em>Note: I’ve written code logic as comments to avoid messing with the example. Take it as a pseudocode.</em></p><pre>public class Girlfriend {<br><br>  public void loveMe() {<br>    // Give presents and flowers<br>    // Spend time talking about hopes and dreams<br>  }<br>}<br><br><br>public class Dog {<br><br>  public void loveWoofWoof() {<br>    // Take dog outside to play<br>    // Bathe and groom the dog<br>    // Run around trying to get the dog to chase<br>  }<br>}</pre><p>Each class has a love method (loveMe and loveWoofWoof) defined, which corresponds to the information in the short narrative. TheGirlfriend class implements expressions of love with presents and flowers and spends time talking about hopes and dreams. TheDog class implements expressions of love by taking the dog outside to play, bathing and grooming the dog, and running around trying to get the dog to chase.</p><p>Now, let’s say Hatef is a Java class that has two methods, each for showing love to both his girlfriend and his dog:</p><pre>public class Hatef {<br><br> public void showLoveToGirlFriend(GirlFriend gf){<br>  gf.loveMe();<br> }<br><br> public void showLoveToDog(Dog dog){<br>  dog.loveWoofWoof(); <br> }<br><br>}</pre><p>So far, so good. Look back at Hatef class. Can you spot a problem? The horrible fact about the above code is that for everything that Hatef loves in his life, we need to create a separate method. A method similar to showLoveToDog() that does nothing but call the love method of another object. This is called <strong>duplication</strong> in our logic. Additionally, ourHatef class should be aware of which methods of GirlFriend or Dog object to call. In other terms, Hatef needs to be concerned about how the love feature of each object is implemented (i.e. whether to call loveMe() or loveWoofWoof()).</p><p>Let’s fix this with the help of abstraction.</p><ol><li>We all agree that the only thing his girlfriend and dog have in common is the need for being loved. To make Hatef life easier so that he no longer cares about <strong>HOW</strong> he should show love to each, we create an interface called Loveble below:</li></ol><pre>public interface Lovable {<br>  void love();<br>}</pre><p>2. We change GirlFriend and Dog class to implement Lovable because both <strong>agree</strong> on the <strong>common</strong> need for being loved (remember <strong>interface</strong> is a form of <strong>contract</strong>):</p><pre>public class Girlfriend implements Lovable {<br><br>  @Override<br>  public void love() {<br>    // Give presents and flowers<br>    // Spend time talking about hopes and dreams<br>  }<br>}<br><br><br>public class Dog implements Lovable {<br><br> @Override<br>  public void love() {<br>    // Take dog outside to play<br>    // Bathe and groom the dog<br>    // Run around trying to get the dog to chase<br>  }<br>}</pre><p>3. Now we can change Hatef to love any object that is also lovable:</p><pre>public class Hatef {<br><br> public void showLove(Lovable lovely){<br>  lovely.love();<br> }<br>}</pre><p>Yeeeeesss!!! We achieved it!</p><p>Hatefno longer needs to worry about the number of different lovely things he loves (no more duplication). He has a single method that can take any lovable object and show love to them without being concerned about their love method implementation. He <strong>ONLY</strong> needs to call their love() method.</p><h3>Benefits of Abstraction</h3><p>The benefits of abstraction in OOP are numerous. Firstly, it helps us write organised code that is easier to read and understand. This also means that our code is more efficient and less prone to errors. Additionally, abstraction helps us save time since we don’t have to worry about low-level details and can instead focus on the bigger picture. Finally, abstraction also makes our code more reusable, meaning that it can be easily adapted for other applications.</p><h3>What if We Don’t Use Abstraction?</h3><p>If we don’t use abstraction when coding, our code can become extremely inefficient and difficult to read. This is because there is no way to hide the details and complexity of the code, resulting in a large amount of code that is difficult to understand and debug. Additionally, without abstraction, our code may not be reusable and will be difficult to adapt to new applications.</p><h3>Conclusion</h3><p>In conclusion, abstraction is an important concept in object-oriented programming that allows us to write organized and efficient code. Abstraction helps us save time and makes our code more reusable, which is essential when writing code. However, if we don’t use abstraction when coding, our code can become difficult to read and inefficient. Through the code examples in this post, we can see how abstraction is used to hide the details and complexity of a programme, allowing us to focus on the desired behaviour.</p><p>Before you go, here’s an inelegant poem on abstraction:</p><blockquote>Coding with abstraction, creating a great life,<br>Java is the language that is so full of strife, <br>For the complex tasks and complex minds, <br>Abstraction makes life of all kinds.</blockquote><blockquote>Strings and loops and numbers, too, <br>Objects made with abstraction through and through, <br>Classes floating on the wings of the night, <br>Producing the power to do what is right.</blockquote><p>Please don’t forget to follow me if you enjoy my approach to translating difficult terms into easier language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0befcdcf7d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/abstraction-in-object-oriented-programming-benefits-and-examples-b0befcdcf7d0">Abstraction in Object-Oriented Programming: Benefits and Examples</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why and when to use polymorphism?]]></title>
            <link>https://medium.com/swlh/why-and-when-to-use-polymorphism-ffcbf3709509?source=rss-a560d92dc99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffcbf3709509</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[polymorphism]]></category>
            <dc:creator><![CDATA[Hatef Palizgar]]></dc:creator>
            <pubDate>Thu, 12 Dec 2019 23:50:18 GMT</pubDate>
            <atom:updated>2019-12-13T21:23:08.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QcwwhrPl5CLEKR2V3FCjA.png" /><figcaption>Photo by <a href="https://unsplash.com/@amseaman?utm_source=medium&amp;utm_medium=referral">Andrew Seaman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>A SIMPLIFIED STATEMENT ON POLYMORPHISM</h4><h4>Object-Oriented Programming or shortly, OOP, is a constitutional part of modern application architecture. OOP comprises four fundamental concepts: <strong>A PIE:</strong> Abstraction, Polymorphism, Inheritance, and Encapsulation.</h4><p>Polymorphism is made of two parts: <strong>poly (multiple) </strong>and <strong>morph(form). </strong>According to <a href="https://en.wikipedia.org/wiki/Polymorphism_(computer_science)">Wikipedia.com</a>, polymorphism is described as follows:</p><blockquote>In programming languages and type theory, <strong>polymorphism</strong> is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types.</blockquote><p>To make it simpler:</p><p>In the world of OOP and objects, every single object that has more than one shape or can be assigned to more than one class is called a polymorphic object.</p><p>As a Java trainer, I continually come across various questions like <em>“what is polymorphism exactly?”</em> or <em>“why do we need such thing at all?”</em>.</p><p>Since understanding polymorphism is essential to grasp the idea behind object-oriented programming, I decided to write this article. Indeed, what made me write on this topic was a question that one of my students asked me one day:</p><blockquote>Hey Hatef !! Why we need polymorphism? What is the point in it?</blockquote><p>The rest of this article is the lines I wrote to describe why and when to use polymorphism.</p><p>The main idea for the polymorphism is to bring flexibility. How? I’ll describe it with <em>Car Service Shop</em> example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sQT3_L-o6_KYAfg4" /><figcaption>Photo by <a href="https://unsplash.com/@davidsthephotographer?utm_source=medium&amp;utm_medium=referral">Davids Kokainis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s imagine you are an experienced car technician at a service shop that can repair any B-class car. If you put this concept in OOP format, you have to create a class called <strong><em>Technician</em></strong> as below:</p><pre><strong>class Technician{<br> private String name;<br> private Car car<br> <br> public Technician(String name){<br>  this.name = name;<br> }</strong><br>  <em>/*<br>  ... getters and setters<br>  */</em><br>  <br> <strong> public void repair(Car theCar){</strong><br>    <em>// ... the body of repair method</em><br>  <strong>}<br>}</strong></pre><p>So far, so good. We have created out <em>Technician</em> class with one method repair() that accepts any object of type Car.</p><p><strong>The point is here:</strong></p><p><em>The shop manager knows that you can repair any B-class car. Thus, if any customer with car models below comes to the shop and asks for a repair job, the manager is confident that you can repair them successfully.</em></p><p>In OOP terms, the manager can call you (<em>instantiate a </em><em>Technician object</em>) and ask you to repair a car (<em>call you </em><em>repair() method</em> ). But wait, which type of car the manager is going to pass as you <em>theCar argument</em>?</p><p>As a technician you are not worried about that. Because you can repair any sort of B-class car. As a result the codes below are all true and make sense:</p><pre><strong>Technician hatef = new Technician(&quot;Hatef&quot;);</strong></pre><pre><em>// create several Car instances</em></pre><pre><strong>Car yaris = new Toyota();<br>Car focus = new Ford();<br>Car azera = new Hyundai();<br>Renault megane = new Renault();</strong></pre><pre><em>// create manager object</em></pre><pre><strong>Manager manager = new Manager();</strong></pre><pre><em>// now manager calls the technician to start repairing</em></pre><pre><strong>hatef.repair(yaris);</strong> // <em>hatef is able to repair any Car instances</em><br><strong>hatef.repair(focus);</strong> // <strong>focus</strong><em> is a Car instance</em><br><strong>hatef.repair(azera);</strong> // <strong>azera</strong><em> is a Car instance</em></pre><pre><em>// now, watch below code, it is wrong because of polymorphism violation. </em><strong>megane</strong><em> is not an object of Car class.</em></pre><pre><strong>hatef.repair(megane);</strong></pre><p>But wait, why it is like so? why the code on last line is not right?</p><h3><em>Answer:</em></h3><p><em>Due to polymorphism objects like </em><em>yaris, </em><em>focus, </em><em>azera are all reference variables of type </em><em>Car that point to an object of different type. </em><em>yaris points to a </em><em>Toyota. </em><em>focus points to a </em><em>Ford and </em><em>azera points to a </em><em>Hyundai.</em></p><p><strong>BUT</strong><em>: </em><em>megane is a reference variable of type </em><em>Renault that points to a </em><em>Renault object, so it is wrong to say: </em><em>megane is a </em><em>car !!!!</em></p><p>So, the point here is that if you have noticed, we were able to process several objects of a different type into a single Car reference variable. This way, it made coding the repair() method very easy for us. We just needed to say public void repair(Car theCar){....}.</p><blockquote>Consider we had no polymorphism. How you could write the repair method in its simplest form ??</blockquote><p>With no polymorphism, you have to re-write the Technician repair() method as below:</p><pre>public void repair(Toyota theCar){....}</pre><pre><em>// an overloaded repair</em><br>public void repair(Ford anotherCar){...}</pre><pre><em>//another overloaded repair</em><br>public void repair(Hyundai anotherCar){...}</pre><p>Did you notice? Instead of a simple line of code, I have to write a bunch of overloaded methods.</p><blockquote>This is the magic of <strong>POLYMORPHISM</strong></blockquote><p>Now, let me put some other concepts here:</p><p>Just think about the situation that you have finished writing your code and built your app. It is now the day you have to release the product to the customer. Suddenly, the customer comes to you and says:</p><blockquote>Hey Hatef! Did you know that we have just launched our new service department? We are now giving service to heavy vehicles like bus and tractors :D</blockquote><p>OOPS!! I can’t believe it. I have not considered this change in customer requirements. My code is only able to repair Ford, Toyota, and Hyundai.</p><h3>So, try to hug Polymorphism. Try to love it and use it in your daily coding tasks. Otherwise, you have to re-invent the wheel each time.</h3><p><em>For more information, take a look at this great post by </em><a href="https://medium.com/u/b945176c6e31"><em>Shanika Ediriweera</em></a><em>:</em></p><p><a href="https://medium.com/@shanikae/polymorphism-explained-simply-7294c8deeef7">Polymorphism explained simply!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffcbf3709509" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/why-and-when-to-use-polymorphism-ffcbf3709509">Why and when to use polymorphism?</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>