<?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 HarshaVardhanReddy Bommareddy on Medium]]></title>
        <description><![CDATA[Stories by HarshaVardhanReddy Bommareddy on Medium]]></description>
        <link>https://medium.com/@harshavardhan-reddy?source=rss-6e0f46783c68------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o8qZLUREAGrIWwAvj5f6cg.jpeg</url>
            <title>Stories by HarshaVardhanReddy Bommareddy on Medium</title>
            <link>https://medium.com/@harshavardhan-reddy?source=rss-6e0f46783c68------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:52:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshavardhan-reddy/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[Design Patterns — What, Why and Types]]></title>
            <link>https://harshavardhan-reddy.medium.com/design-patterns-what-why-and-types-121dfa8c7c10?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/121dfa8c7c10</guid>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Mon, 28 Aug 2023 05:31:07 GMT</pubDate>
            <atom:updated>2023-08-28T05:31:07.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*iGnDP3sJBudLXohCNuhXlA.png" /></figure><h3>Design Patterns — What, Why and Types</h3><p>Design Patterns are the reusable solution for commonly occurring issues in any project architecture where object oriented programming approach is used.</p><h3>Why</h3><p>Design Patterns provides a set of solutions to the developers to make the architecture understandable. Each design pattern is a generic and reusable solution to most commonly occurring issues. Patterns are flexible for customisation.</p><blockquote><strong>Are design patterns specific to any programming language?</strong></blockquote><p>No, design patterns can be used in any programming language which used object oriented approach</p><h3>Types of Design Patterns</h3><ul><li>Creational Patterns</li><li>Structural Patterns</li><li>Behavioural Patterns</li></ul><h4>Creational Patterns</h4><ul><li>Creational Patterns describes the instantiation process</li><li>These deal with object creations</li><li>Creating objects in basic format could result in design problems by adding complexity to the design</li></ul><h4>Structural Patterns</h4><ul><li>Structural Patterns focuses on how classes and objects can be composed to form large structures</li><li>Follows inheritance prince to compose interfaces or implementations</li><li>Used to design by identifying a simple way to realise the relationships between entities</li></ul><h4>Behavioural Patterns</h4><ul><li>Explains how objects interact with each other</li><li>Describes how different objects and classes sends messages to each other</li><li>And how the steps of a task are divided among objects</li></ul><figure><img alt="Types of Design Patterns" src="https://cdn-images-1.medium.com/max/1024/1*yTexQ4BRxf8yboYu7p7wUA.jpeg" /><figcaption>Types of Design Patterns</figcaption></figure><h3>Conclusion</h3><p>Creational Patterns describes a moment of object, Structural Patterns are a more or less static structure and Behavioural Patterns are a process of flow. We also have Class and Object Patterns which I would love to share in my next article.</p><p>Thank you for reading!<br>Happy Coding 👨‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=121dfa8c7c10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java 8 Interface]]></title>
            <link>https://harshavardhan-reddy.medium.com/java-8-interface-bd59f88dfdc1?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd59f88dfdc1</guid>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[interfaces]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Thu, 31 Dec 2020 13:10:00 GMT</pubDate>
            <atom:updated>2023-08-28T05:20:57.729Z</atom:updated>
            <content:encoded><![CDATA[<h3>Java 8 Interface : What’s new?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VY7ilIP2iBUygp52" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=medium&amp;utm_medium=referral">Caspar Camille Rubin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s get started with our obvious questions What and Why?</p><h4>What?</h4><ul><li>Prior to Java 8, we could have only abstract methods.</li><li>Now we can also have Default and Static methods in an Interface</li></ul><h4>Why?</h4><ul><li>As Interface grows old, it would be troublesome changing all the required classes as we have to keep adding the new methods of Interface</li><li>In other words adding new methods to existing interfaces will help developers in a such a way that they are backward compatible</li><li>Static methods are same as Default methods but only we cannot override static methods in the classes that implements those interfaces</li></ul><pre>interface MyInterface{  <br> <br>    default void newDefaultMethod(){  <br>        System.out.println(&quot;Default method&quot;);  <br>    }  <br>    void existingAbstractMethod(String str);  <br>}</pre><p>From the above code it’s not mandatory to implement the <strong><em>newDefaultMethod()</em> </strong>in any class that implements <strong><em>MyInteface</em></strong><em>.</em></p><pre>interface MyInterface{  <br> <br>    static void newStaticMethod(){  <br>        System.out.println(&quot;static method&quot;);  <br>    }  <br>    void existingAbstractMethod(String str);  <br>}</pre><p>Since the <strong><em>newStaticMethod()</em></strong> is static method we cannot override them in implementation classes. Simply we can add them in the existing interfaces without changing the code in implementation classes.</p><p>By this we will not be able to achieve full abstraction even by using Interfaces and there would be no difference between Abstract Class and Interface. That’s not true, even in Java 8 we cannot have constructor for Interface whereas for abstract class we can.</p><p>And Interfaces providing full abstraction is still true even if we have default methods. Adding default methods is to simply add new features to interfaces without effecting existing classes.</p><h3>Conclusion</h3><ul><li>Default methods has brought down the differences between Interface and Abstract Classes</li><li>Default methods will help in removing base implementation classes</li><li>Static methods are useful for providing utility methods</li><li>Static methods provide security by not allowing implementation classes to override them</li></ul><p>Drop your comments and suggestions.</p><p>Thanks for reading!<br>Keep Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd59f88dfdc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TDD :  Test Driven Development]]></title>
            <link>https://harshavardhan-reddy.medium.com/tdd-test-driven-development-a592f492bb0b?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/a592f492bb0b</guid>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[red-green-refactor]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 08:08:40 GMT</pubDate>
            <atom:updated>2020-08-28T08:08:40.411Z</atom:updated>
            <content:encoded><![CDATA[<h3>TDD : Test Driven Development</h3><p>Hello!<br>Hope everyone is well and staying safe.</p><p>I would like to share about few points about Test Driven Development (TDD).</p><p>Test Driven Development is a software development process where testing is used to develop in small cycles.</p><p>First write test cases and then the production code. This seems a little difficult initially but following this process increases the quality of production code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*ffQ-5RvwrBs5Rj3Cjb4KPg.png" /><figcaption><strong>The TDD Cycle</strong></figcaption></figure><ul><li>Write a test and make it fail</li><li>Write enough code to make the test pass</li><li>Refactor the code. If there is nothing to refactor skip this step, but when we write complex code we do have to write enough tests to pass while maintaining the code readability and making sure all the test cases are passed.</li></ul><h4>Why TDD?</h4><ul><li>TDD improves the quality of code and reduces a lot of issues raised during the testing phase.</li><li>Writing tests first makes sure more bugs are fixed before production.</li><li>TDD leads to <a href="https://www.researchgate.net/publication/3249271_Guest_Editors&#39;_Introduction_TDD--The_Art_of_Fearless_Programming">40%-80% fewer bugs</a> in production.</li><li>TDD eliminates fear of merging the code.</li></ul><h4>Conclusion</h4><p>TDD is always a way to write better code and reduces bug before production. It feels like we are spending a lot of time in writing tests which is extra time but if we don’t we will be doing the same for debugging and fixing the bugs.</p><p>Hope this will be helpful.<br>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a592f492bb0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mockito + PowerMock : Using ArgumentMatchers]]></title>
            <link>https://harshavardhan-reddy.medium.com/mockito-powermock-using-argumentmatchers-7b38f0d3deff?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b38f0d3deff</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[powermock]]></category>
            <category><![CDATA[mockito]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 11:00:07 GMT</pubDate>
            <atom:updated>2020-08-28T08:09:54.247Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mockito + PowerMock : Using ArgumentMatchers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cDgj-RFcK1pECqeq" /></figure><p>Hello Everyone!</p><p>For “Developers” it’s mandate to have unit test cases for each line of the code to make it better. In fact following <a href="https://medium.com/@harshavardhan_reddy/tdd-test-driven-development-a592f492bb0b?sk=186141c9f71471be989f58eafadbed62">TDD</a>(Test Driven Development) would be great.</p><p>Anyways that’s not gonna be our topic.</p><p>The goal of this article is to provide understanding on ArgumentMatchers for those who use Mockito and PowerMock.</p><p><em>Matchers</em> was the child class of <em>ArgumentMatchers</em> and now it is deprecated from the version 3.2.0 of <strong>mockito-core </strong>in order to avoid a name clash with Hamcrest <strong><em>org.hamcrest.Matchers</em></strong> class.</p><h4><strong><em>What is ArgumentMatchers for ?</em></strong></h4><p>ArgumentMatchers allows us to mock the method behavior for any argument.</p><p>Let’s look at few methods of the ArgumentMatchers.</p><ul><li>any() → Matches anything (null values)</li><li>anyString() → Matches non-null Strings</li><li>anyBoolean() → Matches any boolean or non-null Boolean</li><li>anyInt() → Matches any int or non-null Integer</li><li>anyFloat() → Matches any float or non-null Float</li><li>anyLong() → Matches any long or non-null Long</li><li>anyList() → Matches any non-null List</li><li>anyMap() → Matches any non-null Map</li></ul><p>These are few methods which are frequently used for matching the arguments of stubbed methods.</p><h4>How to use ArgumentMatchers ?</h4><p>The below snippets are examples for how to user ArgumentMatchers</p><pre>//stubbing using anyInt()<br>Powemockito.when(mockObj.get(anyInt())).thenReturn(returnValue);</pre><pre>//stubbing using anyBoolean()<br>Powemockito.when(mockObj.run(anyBoolean())).thenReturn(returnValue);</pre><pre>//stubbing using anyString()<br>Powemockito.when(mockObj.run(anyString())).thenReturn(returnValue);</pre><p>Yes, it looks simple and you are right. But, myself faced few hurdles. Some of them are:</p><ul><li>Passing <strong>null</strong> as parameter</li></ul><pre>//stubbing using isNull()<br>Powemockito.when(mockObj.run(isNull())).thenReturn(returnValue);</pre><pre>mockObj.run(null);</pre><ul><li>Stubbing an overloaded method</li></ul><p>This happens when you are using Singleton class to get instance for a Class and it might also extend a different class having the same method. This might happen rarely but it happens.</p><pre>Powemockito.when(mockObj.run(any(Example.class))).thenReturn(returnValue);</pre><h4>Conclusion</h4><ul><li>Matchers class was used to stub methods for with arguments</li><li>Matchers is deprecated from mockito-core version 3.2.0 to avoid name clash with Hamcrest <em>org.hamcrest.Matchers</em></li><li>ArgumentMatchers is parent class of Matchers, Mockito</li><li>Mockito extends ArgumentMatchers so to get access to all matchers just import Mockito class statically.</li></ul><h4>References</h4><ul><li><a href="https://javadoc.io/static/org.mockito/mockito-core/3.2.0/org/mockito/ArgumentMatchers.html">ArgumentMatchers (Mockito 3.2.0 API)</a></li><li><a href="https://github.com/powermock/powermock/wiki/mockito#how-to-use-argument-matchers">powermock/powermock</a></li></ul><p>Help me grow by dropping suggestions. Thanks for reading and hope this article helps!</p><p><em>Happy Coding! Happy Testing!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b38f0d3deff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java 13 Enhanced Switch]]></title>
            <link>https://harshavardhan-reddy.medium.com/java-13-enhanced-switch-3d22b001ee0d?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d22b001ee0d</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-13]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Wed, 06 Nov 2019 11:38:17 GMT</pubDate>
            <atom:updated>2019-12-04T13:28:05.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3UbObXpwpMyvt7nG" /></figure><p><strong>Traditional Switch</strong></p><p>Switch statement is available in Java from the beginning. Let’s look at a normal old switch case.</p><pre>int day = 4;<br>switch (day) {<br>  case 1:<br>    System.out.println(&quot;Monday&quot;);<br>    break;<br>  case 2:<br>    System.out.println(&quot;Tuesday&quot;);<br>    break;<br>  case 3:<br>    System.out.println(&quot;Wednesday&quot;);<br>    break;<br>  case 4:<br>    System.out.println(&quot;Thursday&quot;);<br>    break;<br>  case 5:<br>    System.out.println(&quot;Friday&quot;);<br>    break;<br>  case 6:<br>    System.out.println(&quot;Saturday&quot;);<br>    break;<br>  case 7:<br>    System.out.println(&quot;Sunday&quot;);<br>    break;<br>}<br>// Outputs &quot;Thursday&quot; (day 4)</pre><p>Let’s look at how it works, when a <strong>case </strong>matched and executed, the switch automatically moves to next case until and unless we provide a <strong>break</strong>. We saw an example with break and let’s look at another example without a break for one of the cases and see what would be the output.</p><pre>int day = 4;<br>switch (day) {<br>  case 1:<br>    System.out.println(&quot;Monday&quot;);<br>    break;<br>  case 2:<br>    System.out.println(&quot;Tuesday&quot;);<br>    break;<br>  case 3:<br>    System.out.println(&quot;Wednesday&quot;);<br>    break;<br>  case 4:<br>    System.out.println(&quot;Thursday&quot;);<br>  case 5:<br>    System.out.println(&quot;Friday&quot;);<br>    break;<br>  case 6:<br>    System.out.println(&quot;Saturday&quot;);<br>    break;<br>  case 7:<br>    System.out.println(&quot;Sunday&quot;);<br>    break;<br>}<br>//outputs Thursday and Friday</pre><p>The input we are giving is 4 and when it reaches case 4, the code block of that case gets executed and as there is no break it would go for the next case and executes the code in the case 5 and it breaks the execution there as we can see there is a break statement for case 5.</p><p><strong>Single Values in a Case</strong></p><pre>switch (day) {<br>    case 1:<br>    case 2:<br>    case 3:<br>        System.out.println(&quot;This is a weekday&quot;);<br>        break;<br>}</pre><p>The above switch can be written simply in a single line as</p><pre>switch (day) {<br>    case 1, 2, 3 :System.out.println(&quot;This is a weekday&quot;);<br>        break;<br>}</pre><p>But unfortunately this is not supported in the traditional switch case.</p><p><strong>Multiple Values in a Case</strong></p><p>Now, we have enhanced switch and multiple values in a case is supported.</p><pre>switch (day) {<br>    case 1, 2, 3 :System.out.println(&quot;This is a weekday&quot;);<br>        break;<br>}</pre><p><strong>Switch Expression</strong></p><p>The traditional switch that we know is a conditional statement and the new enhanced switch can also be expression just like a ternary operator which can return a value.</p><pre>x = condition ? 1 : 2;</pre><p>If the condition is true value of x is 1 else 2. The similar way now we can write our switch as an expression.</p><pre>String msg = switch (statusCode) {<br>    case 404:<br>        yield &quot;Not found!&quot;;<br>    case 500:<br>        yield &quot;Internal server error!&quot;;<br>    default:<br>        throw new IllegalArgumentException(&quot;Unexpected value: &quot; + statusCode);<br>};</pre><p>The above code always return a message as there is default, if we don’t have default and if no case is matched it would throw an error stating the switch expression doesn’t cover all possible input values. And it would look like the below code.</p><pre>String message = switch (statusCode) {<br>    case 404:<br>        yield &quot;Not found!&quot;;<br>    case 500:<br>        yield &quot;Internal server error!&quot;;<br>    <em>// default:</em><br>    <em>//    throw new IllegalArgumentException(&quot;Unexpected value: &quot; + statusCode);</em><br>};</pre><p><strong>Note: </strong>Switch statement uses break and never uses yield and Switch Expression the vice-versa.</p><p><strong>Switch with Arrows</strong></p><p>As we have seen in the above code samples, even we have multiple values in case we still have to add a break to end the statement which is not necessary if we go with arrows.</p><pre>switch (statusCode) {<br>      case 404 -&gt; System.out.<strong>println</strong>(&quot;Not found!&quot;);<br>      case 500 -&gt; System.out.<strong>println</strong>(&quot;Internal server error!&quot;);<br>}</pre><p><strong>Note: </strong>Remember you can mix both arrows and traditional switch cases. (case: and case →).</p><h3><strong>Conclusion</strong></h3><ul><li>In Java 13 switch needs to be enabled explicitly</li><li>To return a value from a switch expression you can use<br>break in Java 12<br>yield in Java 13</li><li>You cannot combine <strong>case:</strong> and <strong>case →</strong> in one switch</li><li>Switch expression must cover all the possible inputs</li><li>You can use either “<strong>:”</strong> or “<strong>→”</strong> in both switch statement and switch expression</li></ul><p>Help me grow by dropping some suggestions. Thanks for reading and hope this article helps! Happy Coding! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d22b001ee0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Publish Chrome Extension]]></title>
            <link>https://harshavardhan-reddy.medium.com/how-to-publish-chrome-extension-4f3c781b5233?source=rss-6e0f46783c68------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f3c781b5233</guid>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[publishing]]></category>
            <dc:creator><![CDATA[HarshaVardhanReddy Bommareddy]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 13:11:49 GMT</pubDate>
            <atom:updated>2019-04-17T13:17:06.773Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0LZ1DJ5FL5MgbEeI" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>With the basic knowledge on HTML, CSS and Javascript Chrome Extensions are easy to create. A chrome extension can have different components but should serve a single purpose.</p><h3>Testing Chrome Extension</h3><ul><li>Open <a href="/service/chrome://extensions"><strong>chrome://extensions/</strong></a> in your chrome browser.</li><li>Enable developer mode.</li><li>Click on Load Unpacked.</li><li>Select the chrome extension folder and Open.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*StaPXq9oVUBpi0YW0At95g.png" /></figure><h3>Publishing Chrome Extension</h3><p>Once your extension looks good and tested well, it’s time for publishing to chrome store.</p><ul><li>Open developer dashboard of the chrome web store <a href="https://chrome.google.com/webstore/developer/dashboard">Developer Dashboard</a></li><li>Sign in to your google account if you are not already logged in.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WmE2bQe58xVs00WzSP1pzg.png" /><figcaption>Fig: Developer Dashboard Home Page</figcaption></figure><ul><li>Click on the <strong>Add new item </strong>button.</li><li>Accept the terms and conditions. Then compress your chrome extension folder and upload that ZIP file.</li><li>Once it is uploaded, you will see a form where you need to add some information about your extension. You can add an icon (logo), description, add some screenshots of your extension.</li><li>Click on the <strong>Preview Changes</strong> button to preview your extension as to how it looks in the chrome web store.</li><li>Then you can publish your extension by clicking on <strong>Publish Changes </strong>button. It may take a while to get published to the chrome web store. (Max One hour). It will be reviewed and then published.</li><li>Once it is published you can search for the title of your extension, you can install and use it.</li></ul><p><strong>Note:</strong> As you can see in the above figure, you have to pay the US $5.00 to verify your account and publish items.</p><h3>Conclusion</h3><p>If you are web developer, it is easy to create a chrome extension with the basic knowledge on HTML, CSS, and Javascript. For more information check out the <a href="https://developer.chrome.com/extensions">documentation</a> here.</p><p>This is my first article and if it is helping give a clap and I am open to suggestions. Please comment if you got any questions.</p><p>Thanks for reading! Hope the article is helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f3c781b5233" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>