<?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 Sapan Parikh on Medium]]></title>
        <description><![CDATA[Stories by Sapan Parikh on Medium]]></description>
        <link>https://medium.com/@sapanparikh18?source=rss-7f8685c85b30------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c1hosFZN8StEFk3J6pG5rg@2x.jpeg</url>
            <title>Stories by Sapan Parikh on Medium</title>
            <link>https://medium.com/@sapanparikh18?source=rss-7f8685c85b30------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:06:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sapanparikh18/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[Dead code]]></title>
            <link>https://medium.com/@sapanparikh18/dead-code-384235a2bd06?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/384235a2bd06</guid>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Thu, 16 Jul 2020 10:51:48 GMT</pubDate>
            <atom:updated>2020-07-16T10:59:54.895Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Delete It</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGBhNqe8svJGmwMlUhAhDQ@2x.jpeg" /></figure><p>While developers look at their(yes only theirs) code as a prized possession, I have learned to look at code as a liability and I think it should be discussed why</p><p>more code = more liability</p><p>and why dead code from any system should be deleted.</p><h4>Security issues</h4><p>Security issues in dead code are still security issues. This means, a SQL or command injection in dead code may still be exploited to retrieve unauthorized data, or worst, to delete data! There are only two ways to prevent such security threats, either delete the dead code or fix the security vulnerabilities in your dead code.</p><h4>Impact on coupling</h4><p>Dead methods, even though not referred from anywhere may still be coupled with other classes that increase the coupling for the entire class.</p><h4>Impact on refactoring</h4><p>As lined out above, dead code doesn’t care about it being dead. It has a full impact on coupling and cohesiveness of the system. This means if we have a plan to refactor the code or transition them to more modern architecture, say Microservices, then this dead code can become a hindrance in achieving your goals, or worst, you will achieve your goals by creating a microservice of dead code!</p><h4>Impact on Unit/Integration testing</h4><p>Having dead code can inversely impact testing in two ways.</p><ol><li>If a system already has many test cases then automated test cases are testing dead code. This means developers not only maintain the dead code but also maintain these useless test cases. Plus everyone gets a false sense of confidence when all the test cases pass!</li><li>If the system does not have test cases and developers have just started writing unit/integration tests then they may end up testing dead code. If nothing else deleting dead code will increase the test code coverage automatically, assuming dead code was not covered earlier.</li></ol><h4>Static Code Analysis</h4><p>A pattern seems to be emerging by now! If your CI/CD pipeline has static code analysis tools integrated then not only the scan time will increase but once again, a team may start fixing issues that are in dead code!</p><h4>Code Understandability</h4><p>There is no arguing that dead code can make your code less readable and less maintainable by just being there. Code under unused feature flags or code for moduels not being used increases the cognitive complexity of the code. This may mean you will be slower when you have to edit this code next time or want to add more features to the same code.</p><h4>Size</h4><p>Finally, dead code increases the size of your code. This means, bit by bit, dead code makes your tests slower, your builds slower, security and static analysis scans slower, download of artifacts slower.</p><p>If you are still not convinced about deleting dead code then, once again, let me remind you, it has an impact on security :-).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=384235a2bd06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[After 15 Years, Remote Overnight]]></title>
            <link>https://medium.com/@sapanparikh18/after-15-years-remote-overnight-70dfe0f4487b?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/70dfe0f4487b</guid>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 04:13:18 GMT</pubDate>
            <atom:updated>2020-03-29T04:13:18.355Z</atom:updated>
            <content:encoded><![CDATA[<h3>After 15 Years, Remote Over a Weekend</h3><p>It’s been a week we have been working remotely, and we got a notice of one weekend to change the way of work and the way of life. I think everyone will have to agree with one thing. The concern is not that people won’t work hard enough but rather people will work extra hard when working remotely. And that turned out to be one of the very first observations made by Jason Fried, and David Heinemeier Hansson, in their book Remote. In this post, I am going to summarize a few things from the book that I think are relevant in current times. Books like Remote, Extreme Ownership, Turn the Ship Around all seem to be agreeing that the rituals of the current way of working come from older times of industrial revolution where most people were working in industries operating heavy machines. That’s where the hardware and software should fundamentally differ. It was the hardware that required people to go where it was placed! While in the software world the software can go where the teams are! Here are a few takeaways from Remote about managing remote workers.</p><h4>Stop managing the chairs</h4><p>Managers should stop managing hours and start managing projects and work. Managers should stop worrying about 9 to 6 and start worrying about dividing and assigning work to the right people, understand delays, and understand priorities. This can be tough for traditional companies where people punch in punch out and log their hours in lieu of actual work.</p><h4>Meetups and Sprint</h4><p>An important point in the book, but pointless when you are working from home because of a pandemic.</p><p>Teams should meetup on every once in a while for presentations, sharing progress, educational events or sprint through a project so that people don’t forget others. Though this isn’t advised right now I would at least use video chatting generously instead of emails.</p><h4>Learn from Open Source Software</h4><p>At the time of hiring try to find people who have contributed to Open Source Softwares. Essentially, find people who do coding for the love of it, not the people who are in it to follow instructions. People who are motivated will need minimal supervision. Another way of identifying motivated people is to know whether they have worked on personal projects, or have kitchen sink projects, etc. My favorite question in an interview is “What books have you read recently?” This reveals more than you can think about a person.</p><h4>Keep Everything Open</h4><p>Level the playing field by applying all the policies and processes to all the employees, across the offices, countries, and continents. Also, make most of your work data visible to everyone.</p><p>It will be great if your top management also worked remotely once in a while.</p><h4>One on One</h4><p>Make sure that every manager talks to every direct reportees in his or her team. Keep these conversations casual, consistent and open. One of the tools I just came to know about from the book was <a href="https://knowyourteam.com/">https://knowyourteam.com/.</a> It seems like a promising tool.</p><h4>Remove the Road Blocks</h4><p>Empower teams to achieve higher-level goals and processes and policies should help in doing so. Removing dependencies and access barriers are important.</p><h4>Overwork not Underwork</h4><p>People who work from the office get to pack the bags and go home. People who work from home have no such delineation of work and home. This may be good in the beginning but it causes burnout later. Managers should spot burnouts. In the long term, coming up with programs like hobby sponsoring and holiday gifts will go a long way. You want people to put consistent hours. “Abundance and value are opposite of each other.” The conference calls and meetings in offices have a lot of value in the beginning but when they start happening in abundance and start taking 60 minutes of 13 people to communicate something which can be sent on a chat message they start losing value. Access to people is a good thing but too much of it can be qualified as interruptions. Once the number of face to face calls or meetings decreases the value automatically increases.</p><h4>Building Routine</h4><p>While working from home; a day does not have clear boundaries! You are not rushing to get ready, you don’t hurriedly eat your sandwich before you hop in your car, and you are not looking for the best parking spot. When your office is 10 steps away from the dining table your problems can be different, you may end up eating your sandwich while reading your emails, you may put off showering till evening or totally skip it! This is why it is important to bring structure to your day. My day felt very different after following some of the advice from the book, for example, putting on work clothes while working, it’s not a suit luckily but also not a short or a sweatshirt. Plus, being adequately dressed means, being ready for video calls anytime, which I have found to be very important while working remotely. The structure should also not be limited to what you wear but also when you work and where you work. One must separate work hours and personal hours, also some corner in your home should represent the workplace. In short “demarcate the work and play.” Bringing structure will help you get the most out of your WFH stint.</p><h4>Working Alone in a Crowd</h4><p>Though can’t be applied while you are observing #SocialDistancing things like working from a cafe, a park or library may help you change the scenery as well as bring structure to life.</p><h4>Staying motivated</h4><p>While working remotely managers will have to be engaged enough to keep all the team members motivated. Rewards and threats rarely work, people will only be motivated if they will be working on what they love. Work should be challenging, interesting, interactive, engaging and fulfilling. Work should be well defined and shouldn’t feel pointless.</p><h4>Making sure you are not ignored</h4><p>While working remotely one may worry about being ignored or not getting enough facetime. There are only two ways one can not be ignored.</p><ol><li>Make noise</li><li>Do exceptional work</li></ol><p>Doing exceptional work is the only way you will not be ignored, if you make progress you won’t be ignored. Remember while working remotely your work speaks the loudest.</p><h4>Old Habits Die Hard</h4><p>To sum it up in the authors’ words, “The more entrenched you are with the old ways of working the harder it will be to overcome them.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70dfe0f4487b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Notes from clean code]]></title>
            <link>https://medium.com/@sapanparikh18/notes-from-clean-code-2bfbfd45f9a8?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bfbfd45f9a8</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Sat, 06 Apr 2019 09:10:17 GMT</pubDate>
            <atom:updated>2019-04-08T04:48:05.219Z</atom:updated>
            <content:encoded><![CDATA[<h3>Notes from clean code (Uncle Bob)</h3><h4>Meaningful names</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eWYm3Dm7s0t8lLWYRW4pow.jpeg" /></figure><h4>Use Intention-Revealing Names:</h4><p>instead of int d; it should be int elapsedTimeInDays;</p><p>This also means Sonar’s `<em>magic number should not be used` </em>rule<em> </em>is your good friend here.</p><h4>Avoid Disinformation</h4><p>Do not use well-known abbreviation as variable names like ls or mkdir which may mean something else.</p><p>Also, do not name variables like accountList unless it’s really a List data structure.</p><p>Do not name variables which are different in very small ways. For example UserController in one place and UsersController in the other.</p><h4>Make Meaningful Distinctions</h4><p>Avoid non-informative names. For example; substring(int <strong>i1</strong>,int <strong>i2</strong>) can be rewritten as substring(int <strong>beginIndex</strong>, int <strong>endIndex</strong>)</p><p>Also, avoid noise words. For example; classes named User<strong>Info</strong> , Userand User<strong>Detail</strong> may be named differently but they don’t convey distinct information</p><p>One of the biggest antipatterns I have seen is developers creating tables named tbl_user, tbl_account etc. Why should the word table appear in a table name and word var appear in a variable name!</p><h4>Use Pronounceable Names</h4><p>A variable named dateFormat would be much better than one namedmmddyyyy.</p><h4>Use Searchable Names</h4><p>Problem with very short variable names is that they are hardly searchable. For example, if you were to search for all the variables named i then it would be virtually impossible to do so. On the other hand, MAX_ACCOUNT_VALUE can easily be searched across the whole project.</p><h4>Hungarian Notation</h4><p>When using a strongly typed language one may not need to encode data type in the name of the variable. For example; String sqlString can be re-written as String sql it also has an added advantage that when one changes the data type from String to StringBuilder the variable name does not have to change</p><h4>Member Prefixes</h4><p>With the newer IDEs which highlights all the occurrences of variables you may not need to prefix all names with m_ for denoting member variables.</p><h4>Interface and Implementations</h4><p>If you are working with one implementation and an interface then prefer to suffix Impl in class name as opposed to prefix I in interface name. Though, this is a matter of preference.</p><h4>Avoid Mental Mapping</h4><p>Avoid situations where readers will have to remember what a variable means. A variable namedlcu means lowercase URL is a good example of such brain overload.</p><h4>Class Names</h4><p>Class names should be nouns like `Patient`, `User`, or `Account`. Avoid using words like Info, Details, etc, they increase disinformation.</p><h4>Method Names</h4><p>Method names should be verbs or verb phrases like add or deleteUser</p><h4>Don’t be Cute</h4><p>Don’t use names like nukeIt() people won’t know what this method would do. Will it delete a user or will it drop the entire table.</p><h4>Pick One Word per Concept</h4><p>Decide what convention everyone will use for names which perform similar actions. For instance UserManager or UserController? Stick with one convention either controller or manager one codebase with both may increase confusion.</p><h4>Don’t Pun</h4><p>Be careful while using words like add and append</p><h4>Use Solution Domain Names</h4><p>Use computer science names like JobQueue or EventListener you won’t have to explain their responsibilities to other programmers.</p><h4>Add Meaningful Context</h4><p>When you see a variable named state you won’t know, unless some context is provided, whether it is a state in an address or state of an object. If it is a state in an address then the solution may be to create a class name Address and put the variable in it. So that it reads Address.state making the use of the variable clearer.</p><h4>Don’t Add Gratuitous Context</h4><p>Let’s say If you are working on an application named CocoWeb. Prefixing all your classes with CW may work against you. Just imagine yourself typing the character C in your modern IDE and the autocomplete showing names of all the classes because all of them start with a C and a W!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bfbfd45f9a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technical debt]]></title>
            <link>https://medium.com/@sapanparikh18/technical-debt-4f75fc832afd?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f75fc832afd</guid>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Fri, 15 Feb 2019 09:15:20 GMT</pubDate>
            <atom:updated>2019-02-15T09:15:20.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkTjDdq259aqF0azbIpXzw.jpeg" /></figure><p>As per Wikipedia technical debt is defined as follows</p><blockquote>Technical debt is a concept in software development that reflects the implied cost of additional rework caused by choosing an easy solution now instead of using a better approach that would take longer.</blockquote><p>I would like to add one more dimension to this definition. A debt is called debt because you have to pay it later, most probably with interest, but would you call something a debt if you never had to pay it back? Similarly, if someone chose an easy solution(Short-cut) instead of better approach but he had to never get back to that code to edit or read it would you call it technical debt?</p><p>Popular code scanning tools may give you analysis like the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*JhEQmGovOSPh8dd4dgPfag.png" /></figure><p>It’s 8100 days worth of technical debt(“days” not working days!!) How can we go about fixing this?</p><p>Developers must separate the code that matters from the code that doesn’t. In terms of reading, editing or fixing.</p><p>That is why when automated tools treat all code equally and raise technical debt in hours or dollars there is a fundamental issue! A risk that a specific commit would introduce a defect is directly proportional to how many developers have worked on the modified code earlier. This means lesser the people lesser the risk and vice versa[TBPD15].</p><blockquote>In summary <strong>more people on a piece of code (file) = more risk</strong></blockquote><p>The collective intelligence of an organization is not just in the code but also in the version control system. Every time a file changes it records who, when and why it was changed. In a nutshell, each commit on a file increases its importance. Change frequency of a file is a good indication of fault prediction and quality issues[BOW11].</p><blockquote>In summary</blockquote><blockquote><strong>More change = higher the importance of a file</strong></blockquote><blockquote><strong>More change = more risk</strong></blockquote><blockquote><strong>More change = more time required to maintain</strong></blockquote><p>One more dimension to identify possible quality issues is code complexity. The simplest measure of complexity is the number of lines of code in a file.[OW10]</p><p>Code with high-interest rate can be identified as following</p><ol><li>Files with high change frequency</li><li>Files with high LoC</li><li>And files with deeper indentation[HGH08].</li></ol><p>All three measures lined out so far are language neutral.</p><p>Now, equipped with the above knowledge, we can follow the following steps to find hotspots in a large code base</p><ol><li>Decide a time frame to find change frequency</li><li>Calculate change frequency of files</li><li>Calculate loc in each file to narrow down candidate files</li><li>Fetch historic revisions of files identified</li><li>Get diff on every subsequent revision</li><li>Match diff results to identify most changed functions</li><li>Start refactoring these functions!!</li></ol><p>Above steps should give you FOCUS to scientifically choose the lines of code which you should really start refactoring.</p><h3>References</h3><p>Adam Tornhill. Software Design X-Rays(<a href="https://amzn.to/2EbJF6D">Amazon.in</a>, <a href="https://amzn.to/2X2qrrs">Amazon.com</a>)</p><p>[TBDP15]: <a href="https://onlinelibrary.wiley.com/doi/full/10.1002/smr.1797">Michele Tufano Gabriele Bavota Denys Poshyvanyk Massimiliano Di Penta Rocco Oliveto Andrea De Lucia. An empirical study on developer‐related factors characterizing fix‐inducing commits</a></p><p>[BOW11]: <a href="https://www.semanticscholar.org/paper/Does-measuring-code-change-improve-fault-prediction-Bell-Ostrand/05fb32f30c4fbb403486f0ce8ae70d522d84139e">Robert M. Bell, Thomas J. Ostrand, Elaine J. Weyuker. Does measuring code change improve fault prediction?</a></p><p>[OW10]: Andy Oram, Greg Wilson. Making Software: What Really Works, and Why We Believe It (<a href="https://amzn.to/2SCjnDy">Amazon.in</a>, <a href="https://amzn.to/2GKop9Z">Amazon.com</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f75fc832afd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding squid S00107: Method has “x” parameters which are greater than “y”]]></title>
            <link>https://medium.com/@sapanparikh18/understanding-squid-s00107-method-has-x-parameters-which-are-greater-than-y-655f60ef2f5c?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/655f60ef2f5c</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 07:13:30 GMT</pubDate>
            <atom:updated>2019-01-10T07:17:06.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUOknyEHrQ6wGqynmp__Eg.jpeg" /></figure><p>Ever seen a java method that looked like this?</p><pre>public static String CalculateAgeForPediatrics(String dob, String strEncDate, String strYearLetter, String strMonLetter, String strWeekLetter, String strDayLetter, String strHourLetter, String strMinLetter)</pre><p>Apart from the obvious red flags like the incorrect case in the method name, or unclear parameter name like <em>strMonLetter </em>one of the issues that SonarQube reports is ‘<em>method has 8 parameters which are greater than 7 authorized.’</em></p><p>SonarQube categorizes this error as brain overload, which really makes sense, having one more parameter than 7 does overload the brain (cough sarcasm). Jokes aside, having too many parameters is usually a sign that your method depends far too much on other modules/classes/objects.</p><p>In the above method, of course, we do not depend on too many things rather it depends on just two, dates and format. If you look at it closely this method depend on two dates and others are just formatting postfixes. If you can’t believe it just trust me, I have seen the code ;-)</p><p>So, in this case, each of the parameters is definitely needed but how can avoid having so many parameters!</p><p>There are two solutions to this, one is stinky and the other, how it should be!</p><p><strong>Stinky one first</strong></p><p>You could use a hashmap to group all the formatting related parameters. For example, the method can look like the following</p><pre>public static String CalculateAgeForPediatrics(String dob, String strEncDate, Map formattingPostFixes)</pre><p>You say what’s wrong with this? I say read ahead!</p><p>A Map is a dynamic (run-time) data structure you lose all the compile time protection you get. Just imagine what would happen if someone populates the Map with all upper case keys while the program expected them in lower? Or what would happen if someone entirely forgot to add one or two keys! No compile errors would occur, no red curvy underlines would show up!</p><p>Also, unless you write descriptive comments or you expect your API users to read your code they will not be able to know what is expected by this function.</p><p>I love Maps myself but replacing them to group parameters sounds like a wrong use case.</p><p><strong>How it should be — Introduce Parameter Object:</strong></p><p>I learnt about this refactoring technique in <a href="https://amzn.to/2SFJwNE">Martin Fowler’s Refactoring: Improving the Design of Existing Code (Addison-wesley Signature Series (Fowler))</a></p><p>Instead of using a Map one should use a class to group similar parameters. Not only it makes the method signature more readable but gives you more control over each parameter as well.</p><p>For example:</p><pre>public static String CalculateAgeForPediatrics(String dob, String strEncDate, FormattingPostfixes postFixes);<br>//While calling this method this is what you would do<br>FormattingPostFixes postFixes = new FormattingPostFixes(&quot;Yr&quot;,&quot;Month(s)&quot;, &quot;Week(s)&quot;,&quot;Hr&quot;, &quot;Min&quot;);</pre><p>How is it useful? Well first of, it makes your method more readable. And if you group your primitives in a class in a long run they will help you in avoiding code duplication.</p><p>And how is it better than the Map? Well, it simply gives you a compile-time check which means one cannot “forget” one of the postfixes. Also, you can have your validation in your new class, for example, check for nulls or empty strings and take appropriate actions.</p><p><strong>Conclusion</strong>:</p><p>When you have too many parameters group related parameters in a class and pass objects around.</p><p><strong>Reference:</strong></p><p><a href="https://www.amazon.in/gp/product/0134757599/ref=as_li_tl?ie=UTF8&amp;camp=3638&amp;creative=24630&amp;creativeASIN=0134757599&amp;linkCode=as2&amp;tag=sp1809-21&amp;linkId=46246b115afa0ee98d4ac375a7320264">Refactoring: Improving the Design of Existing Code (Addison-wesley Signature Series (Fowler))</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=655f60ef2f5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who owns your career?]]></title>
            <link>https://medium.com/@sapanparikh18/who-owns-your-career-7d6451c55312?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d6451c55312</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-craftsmanship]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Tue, 01 Jan 2019 14:02:14 GMT</pubDate>
            <atom:updated>2019-01-01T14:02:14.372Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hLqBcoEJhLkEjBVH1vfplA.jpeg" /></figure><p>As I read <a href="https://amzn.to/2SBg0J7"><em>The Software Craftsman: Professionalism, Pragmatism, Pride</em></a><em> </em>there are a few thoughts influenced me to a great extent. I think these thoughts are worth spreading!</p><p>For far too long software developers have acted, treated and behaved like assembly workers. While it is easy to blame others(cough, project managers) for getting ourselves into this situation I read a wonderful anecdote by the author.</p><p>As it goes. Once upon a time, the author happened to meet a long time working employee of a company, let’s call the company StarTech and the employee John.</p><p>John was extremely unhappy about his tenure at StarTech. The reasons for unhappiness may sound quite familiar to all software developers.</p><p>StarTech had never spent any money, efforts or time behind educating its technical team. John felt that in past years his knowledge never got updated. He never grew technically, the company never upgraded its tech-stack to the latest and the greatest, forget about everything, StarTech didn’t even gift him a book!</p><p>While I really feel for John and I believe companies should invest in their employees the Author’s reply was apt. He asked: “Who is in charge of your career?” He also goes on explaining why a company should pay an employee a salary and then also take responsibility for educating them. This was common when employees were heavy machinery operators and each time a machine would change they will have to be retrained. But are we heavy machinery operators? Or are we professionals, like doctors and lawyers?</p><p>I am sure everyone would like to be treated like a professional but have we acted like one? Do professionals ask their customers for a book? How would you feel if your doctor asked you for a book while treating you? Or do we expect them to possess all the knowledge all the time? And that my friends were the thought number one which got stuck with me.</p><p>It is developers who have to take responsibility to constantly educate themselves like doctors and lawyers and they are the in charge of their own careers, no one else.</p><p>What is the best way to stay updated you may ask? Well, I will say first good step is to read the book!</p><p><a href="https://amzn.to/2SBg0J7"><em>The Software Craftsman: Professionalism, Pragmatism, Pride</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d6451c55312" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TDD with Java and Spock]]></title>
            <link>https://medium.com/@sapanparikh18/tdd-with-java-and-spock-ccd2d9115cf1?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccd2d9115cf1</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[spock]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Mon, 22 Oct 2018 14:37:27 GMT</pubDate>
            <atom:updated>2018-10-24T08:05:31.492Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mrdUKOySJBc7ebN1vzgsFQ.jpeg" /><figcaption>Why TDD?</figcaption></figure><h3>Test Driven Development with Java and Spock</h3><p><a href="https://www.youtube.com/watch?v=qkblc5WRn-U&amp;t=1176s">Watching Uncle Bob talking about TDD</a> has inspired me to write this post for the impatient. If you can’t watch 1+ hour of video, hopefully, reading this post will be faster. At least, medium tells me it’s a 4-minute read.</p><h3>What is TDD</h3><p>While a lot of people considers TDD as a software development process, Robert C Martin nicely underlines the fact that it’s rather a discipline. Think of how surgeons wash their hands, seemingly simple thing like washing hand has 10 steps and a blog post explaining how to do it here</p><p><a href="https://www.infectioncontroltoday.com/hand-hygiene/how-perform-surgical-hand-scrubs">https://www.infectioncontroltoday.com/hand-hygiene/how-perform-surgical-hand-scrubs</a></p><p>Surgeons do follow it, they have developed a discipline because of underlying reasons for health and safety. They may have found it stupid in the mid-1800s because they did not know the impact of not washing hands. There is a parallel here too, developers tend to avoid writing unit testing because just like the doctors in 1800s developers right now have not discovered the importance of doing so.</p><h4>Three rules of TDD</h4><p>Following are the three rules of TDD which work in a cycle, as soon as you are done with number three, you resume to number one.</p><ol><li>You are not allowed to write any production code unless it is to make a failing unit test pass</li><li>You are not allowed to write any more of unit test then it is sufficient to fail, and compilation failures are failures</li><li>You are not allowed to write any more production code then it is sufficient to pass the one failing unit test</li></ol><p>This way developers are working in a one-minute cycle all the time. Developers are constantly writing tests which fail and then immediately they start writing production code which makes the unit test pass and then immediately they expand the unit test to cover new functionality which makes the tests fail again and so for and so forth!</p><p>If all the developers in an organization followed this discipline then you know that the test which broke just now while you were editing the code got broken in this one-minute cycle. Essentially, this means that you have to hit undo enough time to make the failing test case pass again.</p><p><strong>Why not write unit tests after the coding is done?</strong><br>Well, just because we are already aware that the functionality works thus there is no motivation left to write any unit test cases. Now you will think it’s a huge waste of time.<br>And if you get yourself to write a few unit tests because you had to check some boxes in your organization’s handbook you will definitely encounter a block of code which is not testable! <br>Finally, at that moment, you will drop the idea of writing more unit tests. And you leave your test suite with many such holes.<br>As a result of this human behavior following happens at most development shops.</p><ul><li>When unit tests fail, it tells you that something is broken</li><li>But when a whole test suit passes it tells you nothing. (because your test suit is filled with holes)</li></ul><h4><strong>Benefits of TDD</strong></h4><p>Now let’s discuss what would happen if we start following TDD all the time.</p><ol><li>We are constantly writing test cases that means that for every feature that we have written there will be some example code in our own code base. Which is very important looking at the fact that developers will do anything to avoid documentation and skip directly to working examples.</li><li>It’s fun to do TDD because you are always solving a problem at hand which developers love because it is like a challenge.</li><li>Because you wrote the tests from the beginning it can never happen that a chunk of production code exists which is not testable. Thinking of it one step further, your code being testable means that it is decoupled. This in itself is a huge advantage from the perspective of system design.</li><li>If you follow TDD then the underlying assumption is that you have a test case for every scenario and all the code. This means that when you test cases pass you are confident that you are ready to go live (of course if all the features are completed.)</li><li>One of the biggest advantages is that now you can be confident while refactoring and cleaning your code. If you removed unused variables or moved some block of code to another class and the test cases failed then you can just hit undo enough time. Similarly, if all the test cases ran successfully then you know that you have not broken anything.</li></ol><p><strong>As a closing note, in an environment where test cases are not written or are full of holes, developers avoid refactoring because if they cleaned up some code and if it broke then “It becomes theirs”. Because of this reason, without TDD you are writing code to preserve your own safety and to avoid responsibility for anything being broken.</strong></p><p>I have initiated the whole project with Spock, Java and Gradle at the following bitbucket project.</p><p><a href="https://bitbucket.org/anonymousme/tdd/commits/all">anonymousme / TDD / Commits - Bitbucket</a></p><p>Here is the walk through the first 15 commits to see how a project would progress if you follow TDD.</p><ol><li>Setup build.gradle</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/669d9cc954ab3e50fd4935471e51adfe/href">https://medium.com/media/669d9cc954ab3e50fd4935471e51adfe/href</a></iframe><p>2. Write a “nothing test” This will validate if the project is set up correctly with Java, Groovy and Spock</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a84bd3ff0a2854dd420ef796f8c1029/href">https://medium.com/media/6a84bd3ff0a2854dd420ef796f8c1029/href</a></iframe><p>3. Add the first <strong>failing</strong> test case for a function which will return all the prime factors of a given integer</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a5d15cf96da362a8dbd43a909b3db70/href">https://medium.com/media/5a5d15cf96da362a8dbd43a909b3db70/href</a></iframe><p>4. The above code will fail because no method named factorsOf() exists. This we added that function to make the test case <strong>pass</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d06b04ba98e7462e90a005949556eb0/href">https://medium.com/media/2d06b04ba98e7462e90a005949556eb0/href</a></iframe><p>5. Now the above code works correctly but just for input = 1. We will add one more scenario where factorsOf 2 is 2 itself. But the test case will <strong>fail again</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bab46f854809afffb82b19d4b67cd392/href">https://medium.com/media/bab46f854809afffb82b19d4b67cd392/href</a></iframe><p>6. The function factorsOf changed again to make the test case <strong>pass</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94543298090abeba443f43a888004503/href">https://medium.com/media/94543298090abeba443f43a888004503/href</a></iframe><p>Observe the pattern here of test cases passing-failing-passing-failing…. following the same pattern 15 times the final result looks like the following</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1657035276935ec61a3958dbb8fde747/href">https://medium.com/media/1657035276935ec61a3958dbb8fde747/href</a></iframe><p>In conclusion, we were able to develop the algorithm to find prime factors of given number with 100% behavioral test cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccd2d9115cf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lean Mean Test Cases]]></title>
            <link>https://medium.com/@sapanparikh18/lean-mean-test-cases-52a4fa634b65?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/52a4fa634b65</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Thu, 30 Aug 2018 11:28:00 GMT</pubDate>
            <atom:updated>2018-08-30T12:36:58.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writing Lean Mean Test Cases</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZhtCFidrT5-pQHw7Bzvdw.jpeg" /></figure><h4>Objective</h4><p>We will be discussing preconditions and attributes to write lean, understandable test cases in English which has no fluff.</p><h4>Components of Test Cases</h4><p>Assuming the people who will be reading test cases may be new to the company or the role and thus each test case should have enough details to be comprehensible. For which all test cases should at least have the following details</p><p>- Id<br>- Attributes<br>- Component<br>- Capability<br>- Scenario<br>- Pre Condition<br>- Steps<br>- Expected Results<br>- Test Data<br>- Frequency<br>- ImpactDetails</p><p><strong>ID:</strong> Every test script should be uniquely identified by an ID. Though a very minor requirement, this has a huge impact on maintaining your test scripts. Not only ID makes it easier to refer to your test cases, they are important in tracking changes as well.</p><p><strong>Attributes:</strong> Attributes are the adjectives of a product. For example, Amazon.com is fast, easy and secure. In the healthcare industry, it usually is HIPPA compliant, safe, secure etc. The best source for getting all your attributes are from your sales or marketing team.</p><p><strong>Components:</strong> Components are different features where operations can be performed. Using the previous example of Amazon; product page, shopping cart, billing page etc are the components.</p><p><strong>Capabilities:</strong> Capabilities are the “verbs” of any system. For example, Amazon lets you see an image of a product, or it lets you add products to cart.</p><p><strong>Scenario:</strong> Scenario is a short description of what is being tested. For example, <em>“Test sign in page with valid credentials”</em> Or <em>“Test visibility of captcha after 3 unsuccessful attempts”</em></p><p><strong>Pre-Conditions:</strong> Any prerequisites for a test case to run successfully should be defined here. For example, in order to remove an item from the shopping cart, it is assumed that you are on the checkout page and already some products are added to the cart. Such details must be documented.</p><p><strong>Steps:</strong> These are the actual steps which should be performed in order to test a feature/components in detail.</p><p><strong>Expected Results:</strong> Any behavior that should be expected as a result of executing the steps described. For example,</p><p>“Your account is locked” message should display after 5 unsuccessful sign-in attempts.</p><p>Sometimes the result has to be accurately documented. For example, in an e-commerce website, one may have to document that if the product price is $15 and $10 gift card is applied then the expected total should be exactly $5. No less no more!</p><p><strong>Test Data:</strong> Any data that is required in order to run test cases successfully should be noted. For example, to successfully test sign-in functionality, one must note that the system should already have one valid user created.</p><p>It’s hard to determine in which details test data should be documented. But one rule of thumb can be where data matters it should be documented.</p><p>For example, if there was a form where arithmetic is done to calculate tax, discount etc in that case important data element should be documented. In a test case of invoice printing, it may not hurt to mention the exact price of the product, quantity, discount etc.</p><p><strong>The Frequency of Usage &amp; Impact:</strong> Every developed feature of the product may not get the same importance at the time of testing. Just to understand the risk score of test cases one should include Frequency and impact of each scenario.</p><p>Frequency can have one of the following value.</p><ul><li><strong>Rarely:</strong> This keyword should be used when it would be hard to imagine a failure.</li><li>Example: A scenario where you want to check if marketing images are loading properly on the sign-up page may have a low frequency of failure unless changed. And there are recovery mechanism where if the images don’t load from the web service then use another endpoint etc.</li><li><strong>Seldom:</strong> For some scenarios failure can occur but because of low usage or complexity you know that such occurrences will be rare.</li><li>Example: In Admin screen of a product, some of the features may be simple and rarely used, for example, creating a new facility. The complexity may be low plus the usage is not frequent which will make failure rare.</li><li><strong>Occasionally:</strong> Failure circumstances are readily imaginable, somewhat complex, and the capability is one we expect to be popular.</li><li>Example: Chrome’s sync history. Chrome syncs bookmarks apps etc on multiple devices, the syncing algorithm are inherently complex and may behave in such a way so that some behavior may look like bugs to user.</li><li><strong>Often:</strong> The capability is part of a high-use, high-complexity feature that may experience failure on regular basis. — Example: Digital faxing functionality, here one can imagine scenarios where outgoing faxes may fail because of several external reasons, like the line being busy and integration with third-party web services.</li></ul><p>One of the following value should be used for indicating the impact of a feature.</p><ul><li><strong>Minimal:</strong> Use may not even notice a failure. — Example: Minor UI or Alignment issue has no impact on functionality.</li><li><strong>Some:</strong> A failure that might annoy the user, if noticed, retry or recovery mechanisms are straightforward.</li><li>Example: A screen showing list of items may fail to refresh on a regular interval. A user can overcome this issue by refreshing the screen via browser refresh</li><li><strong>Considerable:</strong> A failure would block usage scenario — Example: Not being able to navigate to a reporting module will block users from viewing any reports.</li><li><strong>Maximal:</strong> A failure would permanently damage the reputation of the product and cause users to stop using it. Purpose of EHR software is to create, store and use health records to provide care. If any scenario stops users from being able to provide care then it will have the maximal impact.</li><li>Example: If doctors can not order medication or labs or can’t create patients then it will have a negative impact not only on the product but also the image of the company.</li></ul><p>Details on how to document testing steps: <em>Behavior-driven development (BDD)</em> is one of the upcoming software development philosophy which has an impact on how a software is tested as well. For the scope of this document, we will see how test cases are written in BDD BDD switches the attention from writing tests to defining behavior. For example, rather than writing a test case that reads “test validity of email” one should define behavior, “Given a text box when I enter email in it and click on submit button then email address should be tested for validity” Though a little verbose it accelerates collaboration between business stakeholders, analysts, QA, and development team. The BDD test cases are formally written in the following format.</p><pre>Feature: Sign-up<br>As a User<br>I want to sign-up for the product<br>So that I can start using the software<br><br>Scenario: User should be able to sign-up using the valid email address<br>Given I am on the sign-up screen<br>When I sign-up with a valid email<br>Then I should see &quot;You have successfully signed up&quot; message<br><br>Scenario: User should not be able to sign-up using an invalid email address<br>Given I am on the sign-up screen<br>When I sign-up with an invalid email<br>Then I should see &quot;Yo! It doesn&#39;t look like an email&quot; message</pre><p>These test cases can become a permanent component of your software requirement documentation and each behavior can be noted in your user stories. This means that in BDD test cases are not an afterthought but they are rather expected at the beginning of the software development process and each scenario becomes your user acceptance test (UAT)</p><h4>Conclusion</h4><p>If we capture all the information lined out in this post it will be lot easier for other teams to make use of them.</p><p><strong>References</strong></p><ul><li><a href="https://semaphoreci.com/community/tutorials/introduction-to-writing-acceptance-tests-with-cucumber">Introduction to Writing Acceptance Tests with Cucumber</a></li><li><a href="https://docs.cucumber.io/guides/overview/">Introduction : Cucumber</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52a4fa634b65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REPLACE TYPE CODE WITH SUBCLASSES]]></title>
            <link>https://medium.com/@sapanparikh18/replace-type-code-with-subclasses-192e85d5d534?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/192e85d5d534</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Mon, 20 Aug 2018 13:19:20 GMT</pubDate>
            <atom:updated>2018-08-20T13:19:20.911Z</atom:updated>
            <content:encoded><![CDATA[<p>Read my latest post on refactoring at the following link. This post explains how classes having type codes can use inheritance in favor of writing robust and clean code.</p><p><a href="https://sapanparikh18.github.io/Refactoring-Part-2/">Refactoring Part 2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=192e85d5d534" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Link to my “refactoring” github page.]]></title>
            <link>https://medium.com/@sapanparikh18/link-to-my-refactoring-github-page-18315ab15a68?source=rss-7f8685c85b30------2</link>
            <guid isPermaLink="false">https://medium.com/p/18315ab15a68</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Sapan Parikh]]></dc:creator>
            <pubDate>Sat, 04 Aug 2018 13:35:19 GMT</pubDate>
            <atom:updated>2018-08-07T07:32:22.961Z</atom:updated>
            <content:encoded><![CDATA[<p>Though a great platform, I find Medium to be quite limiting for a tech blog and started writing my notes directly in Intellij IDEA. Did you know it works great as a markdown editor? Just like iA editor but even better!</p><p>Regardless, here is a link to my new blog entry about refactoring at githubpages</p><p><a href="https://sapanparikh18.github.io/Refactoring/">Refactoring Part-1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18315ab15a68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>