<?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 Jitendra Vishwakarma on Medium]]></title>
        <description><![CDATA[Stories by Jitendra Vishwakarma on Medium]]></description>
        <link>https://medium.com/@jitendra.kv8250?source=rss-1e30a1e47197------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MfPXlhIASCO-tsLx.jpg</url>
            <title>Stories by Jitendra Vishwakarma on Medium</title>
            <link>https://medium.com/@jitendra.kv8250?source=rss-1e30a1e47197------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:14:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jitendra.kv8250/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[Implementing Behavioral Design Patterns: Strategy Pattern with Java Enums]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Imagine you&#x2019;re implementing a discount processing system with multiple discounts that have different calculation methods. Your first&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@jitendra.kv8250/implementing-behavioral-design-patterns-strategy-pattern-with-java-enums-adb04d9bae20?source=rss-1e30a1e47197------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@jitendra.kv8250/implementing-behavioral-design-patterns-strategy-pattern-with-java-enums-adb04d9bae20?source=rss-1e30a1e47197------2</link>
            <guid isPermaLink="false">https://medium.com/p/adb04d9bae20</guid>
            <category><![CDATA[clean-code-java]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[java-enum]]></category>
            <category><![CDATA[strategy-pattern]]></category>
            <dc:creator><![CDATA[Jitendra Vishwakarma]]></dc:creator>
            <pubDate>Mon, 14 Jul 2025 06:13:13 GMT</pubDate>
            <atom:updated>2025-07-14T06:13:13.404Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Refactoring with Fluent APIs for Cleaner, readable Syntax]]></title>
            <link>https://medium.com/@jitendra.kv8250/refactoring-with-fluent-apis-for-cleaner-readable-syntax-b83ac47ef258?source=rss-1e30a1e47197------2</link>
            <guid isPermaLink="false">https://medium.com/p/b83ac47ef258</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Jitendra Vishwakarma]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 18:47:05 GMT</pubDate>
            <atom:updated>2024-11-02T17:35:22.690Z</atom:updated>
            <content:encoded><![CDATA[<p>I have just completed the review of a junior Engineer’s PR and I couldn’t help but notice a rather sizeable class that houses a method with an excessive number of parameters. This method is utilized to modify the request received by the application, such as adding headers, removing existing headers, and adding or removing request parameters.</p><p>Let’s start by exploring how the class was structured.</p><pre>public class RequestModifier {<br>    <br>    public void performOperation(Request request,Operation1 operationParam1, Operation2 operationParam2) {<br>        this.performOperation(request,operationParam1,operationParam2,null,null,null,null,null,null);<br>    }<br><br>    public void performOperation(Request request, Operation3 operationParam3, Operation4 operationParam4) {<br>        this.performOperation(request,null,null,operationParam3,operationParam4,null,null,null,null);<br>    }<br>    public void performOperation(Request request,Operation1 operationParam1, Operation2 operationParam2, Operation3 operationParam3, Operation4 operationParam4, Operation5 operationParam5, Operation6 operationParam6,Operation7 operationParam7,Operation8 operationParam8){<br><br>        if(operationParam1!=null){<br>            //Do some operation on request based on operationParam1<br>        }<br>        if(operationParam2!=null){<br>            //Do some operation on request based on operationParam2<br>        }<br>        if(operationParam3!=null){<br>            //Do some operation on request based on operationParam3<br>        }<br>        if(operationParam4!=null){<br>            //Do some operation on request based on operationParam4<br>        }<br>        if(operationParam5!=null){<br>            //Do some operation on request based on operationParam5<br>        }<br>        if(operationParam6!=null){<br>            //Do some operation on request based on operationParam6<br>        }<br>        if(operationParam7!=null){<br>            //Do some operation on request based on operationParam7<br>        }<br>        if(operationParam8!=null){<br>            //Do some operation on request based on operationParam8<br>        }<br>    }<br><br>}</pre><p>Now, what is wrong with the above method? Here are a few issues that need to be addressed -</p><ul><li>The method has too many parameters, which can make it difficult to manage and understand.</li><li>Adding any new operation will require changes to be made in all three methods, which can be time-consuming and error-prone.</li><li>If we accidentally change the values of any parameters, it can cause the app to break.</li></ul><p>How can we enhance and revamp this method? Fear not, for the Fluent API design is here to save the day.</p><h3>What is a Fluent-API?</h3><p>It’s an API that uses method chaining to make the code more readable.Fluent APIs are implemented using method chaining where each method call returns the current object,allowing the next method to be called on it. This style is common in libraries like Java stream, SQL builder and various builder patterns. The term “fluent interface” was actually coined by Eric Evans and Martin Fowler back in 2005. Check out this link for more details: <a href="https://en.wikipedia.org/wiki/Software_engineering">https://en.wikipedia.org/wiki/Software_engineering</a>).</p><p><strong>Characteristics of Fluent APIs</strong></p><p>1. <strong>Method Chaining</strong>: Methods return the current object (this), allowing multiple method calls to be chained together in a single statement.</p><p>2. <strong>Readability</strong>: The API is crafted to be read like everyday language, making the code more intuitive.</p><p>3. <strong>Optional Parameters : </strong>Fluent APIs are clever enough to dodge complicated parameter lists in single methods. Instead, they let you set optional parameters with extra chained calls.</p><h3><strong>Example -</strong></h3><p><strong>Java Streams API </strong>provides a Fluent API for working with collections and performing operations like filtering, mapping, and reducing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NeFEkvEg_Ln22Obu8rtuFQ.png" /></figure><h3>Refactoring the RequestModifier class-</h3><pre>public class RequestModifier {<br>    private Request request;<br>    private RequestModifier() {<br>    }<br>    public static RequestModifier of() {<br>        return new RequestModifier();<br>    }<br>    public RequestModifier onRequest(Request request) {<br>        this.request = request;<br>        return this;<br>    }<br>    public RequestModifier performOperation1(Operation1 operationParam1) {<br>        //Do operation on request based operationParam1<br>        this.request.getHeaders().add(operationParam1);<br>        return this;<br>    }<br><br>    public RequestModifier performOperation2(Operation2 operationParam2) {<br>        //Do operation on request based operationParam2<br>        this.request.getHeaders().remove(operationParam1);<br>        return this;<br>    }<br><br>    public RequestModifier performOperation3(Operation3 operationParam3) {<br>        //Do operation on request based operationParam3<br>        return this;<br>    }<br><br>    public RequestModifier performOperation4(Operation4 operationParam4) {<br>        //Do operation on request based operationParam4<br>        return this;<br>    }<br><br>    public RequestModifier performOperation5(Operation5 operationParam5) {<br>        //Do operation on request based operationParam5<br>        return this;<br>    }<br><br>    public RequestModifier performOperation6(Operation6 operationParam6) {<br>        //Do operation on request based operationParam6<br>        return this;<br>    }<br><br>}<br><br> public static void main (String[] args) {<br>        Request request1 = new Request(new ArrayList&lt;&gt;());<br>        RequestModifier.of().onRequest(request1).performOperation1(new Operation1())<br>                .performOperation2(new Operation2())<br>                .performOperation3(new Operation3());<br><br>        Request request2 = new Request(new ArrayList&lt;&gt;());<br>        RequestModifier.of().onRequest(request2).performOperation1(new Operation1())<br>                .performOperation5(new Operation5())<br>                .performOperation6(new Operation6());<br>    }</pre><p>Isn’t it amazing how effortlessly we can maintain a fluent method? Plus, adding any new operation is as simple as adding a new fluent method. It’s like a piece of cake! 😄</p><p>That’s all for today’s content sharing. I’ll be sure to keep you updated on my future journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b83ac47ef258" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I actually became a Senior Engineer- part 1]]></title>
            <link>https://medium.com/@jitendra.kv8250/how-i-actually-became-a-senior-engineer-part-1-947f7c19b2db?source=rss-1e30a1e47197------2</link>
            <guid isPermaLink="false">https://medium.com/p/947f7c19b2db</guid>
            <category><![CDATA[career-growth-tips]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Jitendra Vishwakarma]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 23:59:21 GMT</pubDate>
            <atom:updated>2024-09-29T23:59:21.076Z</atom:updated>
            <content:encoded><![CDATA[<p>As an engineer, I used to focus on writing code extensively during my early days in software engineering. The more code I wrote, the more accomplished I felt. Initially, my main objective was to build and deliver quickly without conducting unit tests or integration tests. I would only test the code locally and if it met the requirements, I would ship it. However, this approach hindered my growth as a software engineer and made me question my skills. It was effective for smaller projects with smaller codebases, but for larger projects, code changes became risky. Consequently, I found myself spending more time debugging and manually verifying rather than actually developing features.</p><p>This is when I realized the importance of Unit Testing and Integration Testing as they became my saviors.</p><h4>My First Encounter with Unit Test</h4><p>My first encounter with unit test was when as sprint backlog we were asked to do a 80% code coverage for existing service. This backlog was something which i want to avoid as possible as I can. With no clue on how to write unit test , I took one night udemy course on Junit and mockito and with half understanding ,I did complete this story somehow but didn’t understand the bigger picture yet.</p><h4>Embracing the Unit Testing</h4><p>The major turning point came when I joined a big organization where 80% code coverage is must and we had to write Unit Test and Integration Test for any feature which we develop. I started getting comfortable in writing unit testing and integration testing, read more about unit testing , helped junior team member to fix their unit tests.</p><h4>Just Writing unit Test is not enough</h4><p>Anything you do , if you are not following the best practices ,at later point of time it will do the work but will also slow you down. Same thing happened in our codebase.</p><blockquote>Unit test started taking a lot of time to run resulting in increase build time.</blockquote><p>Whenever we perform a complete build of the project, we have to wait for 10 minutes for the build to be completed. Although the unit test is not solely to blame, it does contribute to the delay.</p><h4>Learning to See the Bigger Picture</h4><p>As I gained more experience , I realized that being a good engineer is not just about writing code that works- its about writing code that is scalable , efficient and maintainable. I started to care about things like -</p><ul><li>Proper unit tests</li><li>best practices in writing code as well as test.</li><li>project build time and application boot up time.</li><li>memory consume by application</li><li>docker image size for application.</li></ul><h4>Becoming a Testing Advocate</h4><p>At this point in my career, I have become a strong advocate for unit testing. I have been actively exploring ways to reduce build time and discussing it with my colleagues and superiors. I have been reading blogs on unit testing, taking courses, and gaining a deeper understanding of the problem. During my observations, I have identified several issues with our tests:</p><ul><li>Tests were not written properly.</li><li>Stubbing was used instead of mocking in many places.</li><li>Tests were not completely isolated.</li><li>Any code refactoring without behavioral changes could potentially break the tests.</li><li>Tests were not designed to run in parallel.</li><li>We were not fully utilizing the potential of the testing framework.</li></ul><p>During this exploration , I came across a really good blog and got better understanding of writing unit test case. I suggest everyone to go through it onces - <a href="https://www.artima.com/weblogs/viewpost.jsp?thread=126923">https://www.artima.com/weblogs/viewpost.jsp?thread=126923</a></p><p>As Michael Feathers says -</p><p><em>A test is not a unit test if:</em></p><ul><li>It talks to the database</li><li>It communicates across the network</li><li>It touches the file system</li><li>It can’t run at the same time as any of your other unit tests</li><li><em>You have to do special things to your environment (such as editing config files) to run it.</em></li></ul><p><em>Tests that do these things aren’t bad. Often they are worth writing, and they can be written in a unit test harness. However, it is important to be able to separate them from true unit tests so that we can keep a set of tests that we can run fast whenever we make our changes.</em></p><p>That’s all for today’s content sharing. I’ll be sure to keep you updated on my future journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=947f7c19b2db" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>