<?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 Nilesh Jarad on Medium]]></title>
        <description><![CDATA[Stories by Nilesh Jarad on Medium]]></description>
        <link>https://medium.com/@nileshjarad?source=rss-a143b16b46d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0j3upLtJJUEXOcXpEkArIw.jpeg</url>
            <title>Stories by Nilesh Jarad on Medium</title>
            <link>https://medium.com/@nileshjarad?source=rss-a143b16b46d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 13:57:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nileshjarad/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[Clean architecture in Android and some thoughts]]></title>
            <link>https://medium.com/@nileshjarad/clean-architecture-in-android-and-some-thoughts-1a9707e3761d?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a9707e3761d</guid>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 14:59:56 GMT</pubDate>
            <atom:updated>2023-07-30T16:12:08.100Z</atom:updated>
            <content:encoded><![CDATA[<p>After so long, I am here again 🙃.</p><p><strong>Clean architecture</strong> is becoming increasingly popular in the Android world. There are tons of articles out there that are helping people get hands-on experience with Clean architecture.</p><p>During a recent conversation with one of my friends, I found out that he was struggling to figure out how to properly implement all the layers in the architecture.</p><p>I’d like to discuss my perspective on Clean Architecture. Before we proceed, I’d like to acknowledge the original source of origin of Clean Architecture, which you can find through the link below.</p><p><a href="https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html">Clean Coder Blog</a></p><p>However, for the purpose of our conversation, I’ll provide a brief overview of the concept before delving into my insights.</p><h4><strong>Presentation</strong>/UI</h4><ul><li>This layer deal with handling the UI part</li><li>It contains Activity, Fragment, ViewModel, and imports with the Android package</li><li>This is a pure Android library or application module in the multi-module application</li></ul><h4><strong>Domain</strong></h4><ul><li>This layer deal with the Business logic part</li><li>It contains Usecase, a Repository interface</li><li>This is a pure Java/Kotlin module in the multi-module application</li></ul><h4>Data</h4><ul><li>This layer deal with all Data related part like fetch, store etch</li><li>It Contains Repository Implementation from the case</li><li>This can be a pure Java/ Kotlin module based on the library you used in the multi-module application</li></ul><p>Here is the link to one of my older samples of clean architecture</p><p><a href="https://github.com/NileshJarad/SearchImage">GitHub - NileshJarad/SearchImage</a></p><h3>My points on the clean architecture layers</h3><p><strong>Inner layer should not depend on out layer</strong></p><ul><li>This implies that the repository should have no dependency on the use case, and similarly, the use case should not depend on the presentation layer ( <strong>ViewModel</strong>).</li></ul><p><strong>UI/Presentation</strong></p><ul><li>This purely deals with UI and views the system of Android and its state handling</li></ul><p><strong>Domain Layer</strong></p><ul><li>The Domain must remain independent of all other layers.</li><li>On the other hand, a use case can have another use case as its dependency, allowing the delegation of responsibilities to the dependent use case. but this can lead to circular dependency in large projects which we need to keep watch on.</li><li>Do not hold any state</li><li>It calls a method of the repository to fetch data without caring how and from where it comes.</li><li>No threading details on the Domain layer.</li><li>I prefer to have a single method in use cases like <strong>invoke(..).</strong> Many are adding multiple methods to use case.</li></ul><pre> * Search image use case declaration<br> */<br>interface SearchImageUseCase {<br>    suspend operator fun invoke(searchQuery: String, pageCount: Int): ApiResponse&lt;List&lt;SearchImageResponse&gt;&gt;<br>}<br><br>/**<br> * Search use case implementation<br> *<br> * It will take search repository object , calls search image method on repository and return result to calling co-routine<br> */<br>class SearchImageUseCaseImpl @Inject constructor(<br>    private val searchImageRepository: SearchImageRepository<br>) : SearchImageUseCase {<br>    override suspend operator fun invoke(<br>        searchQuery: String,<br>        pageCount: Int<br>    ): ApiResponse&lt;List&lt;SearchImageResponse&gt;&gt; {<br>        return searchImageRepository.searchImage(searchQuery, pageCount)<br>    }<br>}</pre><p><strong>Data Layer</strong></p><ul><li>To ensure flexibility in replacing the data layer library, such as Retrofit, with another library without affecting the domain and UI layers, the data layer should solely consist of the API and a data source for memory.</li><li>It should only depend on api , datasource memory if the data layer depends on anything else it&#39;s a red flag</li></ul><p>I would greatly appreciate hearing your thoughts on this matter.</p><h4>If you like this post, Please tap little (👏), it means a lot to me.</h4><h4>For further updates please follow me on Medium.</h4><h3>Lets connect on <a href="http://stackoverflow.com/users/4626831/n-j">Stackoverflow</a> , <a href="https://www.linkedin.com/in/nileshjarad">LinkedIn</a> , <a href="https://www.facebook.com/nilesh.jarad.50">Facebook</a> &amp; <a href="https://twitter.com/?lang=en">Twitter</a> .</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a9707e3761d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reasons that fails the team]]></title>
            <link>https://medium.com/mobility/reasons-that-fails-the-team-549e51db9c22?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/549e51db9c22</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[process]]></category>
            <category><![CDATA[teamwork]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Tue, 20 Dec 2016 06:41:09 GMT</pubDate>
            <atom:updated>2016-12-20T06:41:19.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VxBV6Q0yC-owbF98qn0wBw.jpeg" /><figcaption><a href="https://davidsummertonconsulting.files.wordpress.com/2015/03/failing-team.jpg?w=1024">https://davidsummertonconsulting.files.wordpress.com/2015/03/failing-team.jpg?w=1024</a></figcaption></figure><h4>1. Lack of vision and planning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*FwrAekktWabJg5v30D8TYg.png" /><figcaption><a href="http://www.ciwm-journal.co.uk/wordpress/wp-content/uploads/2013/09/blindfold.png">http://www.ciwm-journal.co.uk/wordpress/wp-content/uploads/2013/09/blindfold.png</a></figcaption></figure><p>Many people in team don’t have vision about what they are doing, why they are doing &amp; for whom they are doing. Is this really going to solve the problem?<br>How the various modules are connected each other.<strong><br></strong>Everyone in team should walk in with same understating of what is this module or project.<br>Before execution of any task or module , everyone should have clear vision of what he/she has to do to accomplish the job. Lack of vision reduces the commitment from team member.</p><h4>2. Lack of leadership or good leadership</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*awOm1Z_lUPwy8sMqG2sdPg.jpeg" /><figcaption><strong>Bad leadership</strong> (<a href="http://www.k12hrsolutions.com/wp-content/uploads/2012/08/bad-leadership.jpg">http://www.k12hrsolutions.com/wp-content/uploads/2012/08/bad-leadership.jpg</a>)</figcaption></figure><p>Most of the team fails only because of this reason. Great leader knows strength and weakness of team. Great leader outlines the path and strategy to reach the goal. If leader are not good, Members refuse to recognise their interdependence and act as if they were independent. This will lead to the failure of the team</p><h4>3. Improper communication and Co-ordination.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*E_ZYquIuDh_qSMoaXytBnw.jpeg" /><figcaption><strong>After fail(</strong><a href="https://speckycdn-sdm.netdna-ssl.com/wp-content/uploads/2014/10/mvp_fail_06.jpg">https://speckycdn-sdm.netdna-ssl.com/wp-content/uploads/2014/10/mvp_fail_06.jpg</a><strong>)</strong></figcaption></figure><p>People don’t know how to communicate with teammates. Members are unwilling to understand each other . There is severe personality conflicts in team. Communication are one way top to down through the leader. Due to this one way communication negligible points are debated &amp; productivity or great solution are remains hidden. People only complains but don’t suggest ways to overcome.</p><h4><strong>4. Lack Processes</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*MwaiH2SnJCKR_GIVlmX7sg.png" /><figcaption><a href="https://sarahlhaase.files.wordpress.com/2014/07/escapingthelandofconfusion-02.png">https://sarahlhaase.files.wordpress.com/2014/07/escapingthelandofconfusion-02.png</a></figcaption></figure><p>Lack of process always makes critical point. Decision making by single person (being dominant) always lead to poor team commitment. <br>Meetings are unproductive with issues unresolved that implies the improper planning. No proper process is defined for team to work.</p><p>Above all points are from my experience &amp; observation. If there is something that I missed or something wrong with my observation. Do comments.</p><h3>What are other factor that fails the team ?</h3><h4>If you like this post, Please tap little heart(❤️) below, it means a lot to me.</h4><h4>For further update please follow me on Medium.</h4><h3>Lets connect on <a href="http://stackoverflow.com/users/4626831/n-j">Stackoverflow</a> , <a href="https://www.linkedin.com/in/nileshjarad">LinkedIn</a> , <a href="https://www.facebook.com/nilesh.jarad.50">Facebook</a> &amp; <a href="https://twitter.com/?lang=en">Twitter</a> .</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=549e51db9c22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/reasons-that-fails-the-team-549e51db9c22">Reasons that fails the team</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile First : What Does It Mean And Why ?]]></title>
            <link>https://medium.com/mobility/mobile-first-what-does-it-mean-and-why-92cc9a172a3c?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/92cc9a172a3c</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-first]]></category>
            <category><![CDATA[responsive-design]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Wed, 19 Oct 2016 07:24:42 GMT</pubDate>
            <atom:updated>2016-10-20T12:26:23.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UUsbGQ9SdSmhW2eBi78Wtw.png" /><figcaption><a href="http://blog.usabilla.com/wp-content/uploads/mobile-first.png">http://blog.usabilla.com/wp-content/uploads/mobile-first.png</a></figcaption></figure><p>Mobile first design was introduced by google in <strong>2010</strong>,<strong> </strong>hence forth it has become most popular trend in UX design &amp; development communities.</p><h4>What does it mean ?</h4><p>Think in terms of mobile before designing anything.</p><ol><li><em>Mobile website :- </em>Design website specially for mobile devices instead of reusing desktop version of website on mobile using some adjustment.</li><li><em>Digital content :-</em> Pull or send only necessary data required to be displayed on mobile device(Avoid data overhead). Optimize images, video and files on server for mobile instead of optimizing or processing on content at mobile. Text should be easily readable. User must have easy access to images, videos, maps etc. on mobile.</li><li><em>Processing :-</em> Try to avoid intense processing on mobile.</li><li><em>Content View :- </em>Design view keeping mobile in mind. All the content must displayed properly on mobile.</li></ol><h4>Why mobile first ?</h4><p>In past, users used to focus on desktop design, mobile design was never the priority. But now a days mobile devices are primary source by which users access their content 0r web site.</p><p>Today people prefer to access their online content, application, social networking on handy devices.</p><p>Everybody want thing on single click, that can be possible with mobile only.</p><blockquote>“Mobile first in everything. Mobile first in terms of applications. Most first in terms of the way people use things. And it means … that we have a role now to inform, to educate through all these devices.” -<strong>Google chief executive Eric Schmidt</strong></blockquote><p><a href="http://www.pcmag.com/article2/0,2817,2359752,00.asp">Google&#39;s New Rule: Mobile First</a></p><h4>If you like this post, Please tap little heart(❤️) below, it means a lot to me.</h4><h4>For further update please follow me on Medium.</h4><h3>Lets connect on <a href="http://stackoverflow.com/users/4626831/n-j">Stackoverflow</a> , <a href="https://www.linkedin.com/in/nileshjarad">LinkedIn</a> , <a href="https://www.facebook.com/nilesh.jarad.50">Facebook</a> &amp; <a href="https://twitter.com/?lang=en">Twitter</a> .</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92cc9a172a3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/mobile-first-what-does-it-mean-and-why-92cc9a172a3c">Mobile First : What Does It Mean And Why ?</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think Twice Code Once!]]></title>
            <link>https://medium.com/mobility/think-twice-code-once-fbc693bf4261?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbc693bf4261</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[requirement-analysis]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Fri, 09 Sep 2016 17:29:15 GMT</pubDate>
            <atom:updated>2017-04-15T14:39:41.526Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*3ET_B23xHpqS0btBS5SoBQ.png" /><figcaption>Think twice , code once! Image credit : — (<a href="http://hd.wallpaperswide.com/thumbs/think_twice_code_once-t2.jpg">http://hd.wallpaperswide.com/thumbs/think_twice_code_once-t2.jpg</a>)</figcaption></figure><h4><strong>Problems :-</strong></h4><p>We start implementation without thinking of abstraction or reusability . We even don’t bother to understand the clear requirement or system that we are implementing.</p><p>Working with system, designed by well abstraction is like rewarding.</p><p>Well design abstraction save massive work later.</p><p>If we work faster without thinking or told us to work faster then after some our implementation &amp; we are in adversity.</p><h4><strong><em>Then we ask below questions to ourselves/colleague :-</em></strong></h4><ol><li>why ? we missed opportunity of code reuse.</li><li>why ? because analysis is done by fools.</li><li>why this happen ? because computer do, whatever told to do.</li><li>Why ? we haven’t thought about this situation.</li><li>why ? we haven’t followed rules/architecture.</li><li>Why? we have not thought about abstraction etc.</li></ol><p>So before code, <strong><em>the million dollar rule is, think twice code once</em></strong> and you will go far further from all above situations/questions.</p><h4>We are programmer , yeah✌️ we are professional thinkers.</h4><p>We are unable to sustain attention on one task more than 20 min, that makes us feel like drowsy. You can read below link</p><p><a href="https://en.wikipedia.org/wiki/Attention_span">Attention span</a></p><h4><strong>Solutions :-</strong></h4><ol><li>Choose good architecture and follow rules</li><li>think about abstraction</li><li>Think about code re-usability</li><li>Use TDD refer series of post <a href="https://medium.com/mobility/how-to-do-tdd-in-android-90f013d91d7f#.ibcvexa3z"><strong>TDD in Android</strong></a></li><li>Analyse the requirement before starting implementation</li><li>Write pseudo code / algorithm so you will get better problem solving skill , improve efficiency &amp; clarity.</li><li>To concentrate on single task do below when you feel drowsy <br>i) Listen to favourite songs<br>ii) Discuss with workmate<br>iii) Read other stuff that excites you<br>iv) Drink water take break.<br>v) GO outside and have walk</li></ol><p><strong>Don’t blame computer or program they are most loyal to you they only obey what is told to do them.</strong></p><p><strong>I want you to ask questions 🤔</strong></p><ol><li>What do you do, when you feel drowsy after long concentration ?’</li><li>How you start your development ?</li><li>Do you think your program has emotions 😉?</li></ol><h4>If you found this post is helpful, recommend it to others .</h4><h3>Please tap ,that below empty heart ❤ to make it filled ❤️ with your support . For further interesting stuffs, please follow me &amp; Mobility (Publication).</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbc693bf4261" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/think-twice-code-once-fbc693bf4261">Think Twice Code Once!</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do TDD in Android ? Part 4 — UI testing using Espresso.]]></title>
            <link>https://medium.com/mobility/how-to-do-tdd-in-android-part-4-ui-testing-using-espresso-b381ebede191?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b381ebede191</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-testing]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Wed, 24 Aug 2016 17:57:05 GMT</pubDate>
            <atom:updated>2016-08-26T08:15:02.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMec9KPXMtY_Xdr0It97ZA.png" /></figure><p>In this post we will cover what is Espresso, What api espresso provided, How to write UI test.</p><p>So far in the journey, in <a href="https://medium.com/@nileshjarad/why-developers-scared-to-refactor-code-47efd1b854e7#.8rxkxou48"><strong>Why developers are scared to refactor code</strong></a> , <a href="https://medium.com/@nileshjarad/how-to-do-tdd-in-android-90f013d91d7f#.71b3gyo7w"><strong>Part 1</strong></a><strong> , </strong><a href="https://medium.com/@nileshjarad/how-to-do-tdd-in-android-part-2-project-architecture-setup-unit-testing-77cdd1d6aa3a#.uk11ux2s5"><strong>Part 2</strong></a><strong> &amp; </strong><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-3-mocking-integration-testing-60b057840db6#.y9hnd7749"><strong>part 3</strong></a> of this series, we gained why TDD is supreme, types of testing in android, where to place tests, how to write, run tests , what is mocking, how to verify is method is called etc.</p><p><strong><em>What is Espresso ?</em></strong></p><p>Espresso is testing framework by google for UI testing. It provides API’s for UI testing in single application. UI test ensures that user don’t have poor interaction or encounter unexpected behaviour.</p><pre><strong>I know you are now  used to write test for your code(at-least that is my expectation from you😉).</strong></pre><p><strong>Espresso mainly 3 collection</strong></p><ol><li><strong>ViewMatcher: </strong>is used to locate the view on UI using <strong>onView()</strong></li><li><strong>ViewActions: </strong>is user to preform action on UI element using <strong>ViewInteraction.perform()</strong></li><li><strong>ViewAssertion: </strong>is used to assert view using <strong>ViewInteraction.check()</strong></li></ol><pre>onView(withId(R.id.my_view))<strong>// withId(R.id.my_view) is a ViewMatcher</strong><br>    .perform(click())       <strong>// click() is a ViewAction</strong><br>    .check(matches(isDisplayed())); <strong>// matches(isDisplayed()) is a ViewAssertion</strong></pre><p><strong>You can find Espresso cheat sheet on official site</strong></p><p><a href="https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/index.html">Espresso cheat sheet</a></p><pre><br>press <strong>SHIFT+CTRL+T</strong> on <strong>LoginActivity</strong> and create test class for UI testing in <strong>androidTest </strong>folder.</pre><p>After creating <strong><em>@RunWith(AndroidJUnit4.class)</em> </strong>on class name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nSDNz81yNzMoZv9ATHni6Q.png" /></figure><p>Now we write test <strong>checkUserNameEditTextIsDisplayed()</strong> with <strong><em>@Test </em></strong>annotation<em>. </em>We also<em> </em>need <a href="https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html"><strong>ActivityTestRule</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXmipgWmUgbRjSKIua5qSA.png" /></figure><p>In <strong>checkUserNameEditTextIsDisplayed() </strong>we are checking is user name EditText is displayed on UI.</p><blockquote><em>Espresso methods are self explanatory.</em></blockquote><p><em>Run the test it will pass</em><strong><em>(For running test we need emulator or actual device as this is UI test )</em></strong><em>.</em></p><p>Now try making <strong>visibility</strong> of user edit text to <strong>gone </strong>and again run the test it fails.</p><p>Now we test click on login button for empty fields and check if error message is displayed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dimJrtNfxgNzRWqqY6dHmg.png" /></figure><p>Run test it is passing .</p><p>Next we are going to write test for login success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7utZHMwuzuac8WaoDLr0jA.png" /></figure><p>Run the test it is passing.</p><p><strong>Cheers!!!🍺🍺🍺</strong>. We have completed basic of testing. There is lot more to explore in testing.</p><p>Would like to hear your suggestion, inputs on this series or post<br>If you like the series about TDD please recommend it to other as well.<br>For more update please follow me on Medium.</p><h3>Thanks to all reader.</h3><p><strong>Thanks to people who helped or encouraged me while writing this post</strong></p><p><a href="https://medium.com/u/28a3b7b48506">Nikhil Narkhedkar</a> (Reviewer), <a href="https://medium.com/u/19138f1f218c">Shrikant Ekde</a>(Reviewer), <a href="https://medium.com/u/cb98fb324947">Maheshwar Ligade</a>, <a href="https://medium.com/u/89ab7829327d">Varsha Nehatrao</a>, <a href="https://medium.com/u/b335f6ec0c79">Chaitanya Deshpande</a> &amp; <a href="https://medium.com/u/31962d78e758">Amol Bombe</a>.</p><p><strong>People who added value to series</strong></p><p><a href="https://medium.com/u/8863736420e">Keith Ensign</a> , <a href="https://medium.com/u/ff876df7f398">Marlon López</a> , <a href="https://medium.com/u/9306d25bb73f">Alexander Pletnev</a>.</p><p><strong>Links form where I took references</strong></p><ol><li><a href="https://en.wikipedia.org/wiki/Test-driven_development">https://en.wikipedia.org/wiki/Test-driven_development</a></li><li><a href="http://agiledata.org/essays/tdd.html">http://agiledata.org/essays/tdd.html</a></li><li><a href="http://martinfowler.com/bliki/TestPyramid.html">http://martinfowler.com/bliki/TestPyramid.html</a></li><li><a href="http://antonioleiva.com/mvp-android/">http://antonioleiva.com/mvp-android/</a></li><li><a href="http://mockito.org/">http://mockito.org/</a></li><li><a href="https://developer.android.com/training/testing/ui-testing/espresso-testing.html">https://developer.android.com/training/testing/ui-testing/espresso-testing.html</a></li></ol><p>You can reach me at <strong><em>nlshjarad7@gmail.com</em></strong></p><p><strong>You can find complete code for this series</strong></p><p><a href="https://github.com/NileshJarad/TDD_Demo">NileshJarad/TDD_Demo</a></p><h3>Gently Press the ♡(empty) and make it ❤️(filled).</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b381ebede191" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-4-ui-testing-using-espresso-b381ebede191">How to do TDD in Android ? Part 4 — UI testing using Espresso.</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do TDD in Android ? Part 3 — Mocking & Integration testing.]]></title>
            <link>https://medium.com/mobility/how-to-do-tdd-in-android-part-3-mocking-integration-testing-60b057840db6?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/60b057840db6</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-testing]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Wed, 17 Aug 2016 07:49:00 GMT</pubDate>
            <atom:updated>2016-08-24T18:00:19.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pO5vhPzoIRzosTnL4zwz2w.jpeg" /></figure><p>After long time, this is third tutorial in series . I hope you all are doing good 😊 , enjoying tutorial series(Reading,Coding and improvement).</p><p>So far in the journey, in <a href="https://medium.com/@nileshjarad/why-developers-scared-to-refactor-code-47efd1b854e7#.8rxkxou48"><strong>Why developers are scared to refactor code</strong></a> , <a href="https://medium.com/@nileshjarad/how-to-do-tdd-in-android-90f013d91d7f#.71b3gyo7w"><strong>Part 1</strong></a><strong> &amp; </strong><a href="https://medium.com/@nileshjarad/how-to-do-tdd-in-android-part-2-project-architecture-setup-unit-testing-77cdd1d6aa3a#.uk11ux2s5"><strong>Part 2</strong></a><strong> </strong>of this series, we gained why TDD is supreme, types of testing in android, where to place tests, how to write &amp; run tests etc.</p><p>We covered <strong>Unit</strong> tests till now, next we will move towards integration testing to verify that presenter cope up with UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFyDEdZTg8DFVbsIml9OIQ.jpeg" /></figure><p>Lets create UI for login as shown in diagram (I know you will make better UI than this 😉).</p><p>Checkout below commit as for UI.</p><pre>git checkout c1988a44127c5e08196f459b50902a1a794d98ef</pre><p>So we will write some code related to UI. We have contract between our View and Presenter i.e <strong>LoginView</strong> as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*zlqvuVohRqCIV2c-5HeVLA.png" /></figure><p>Now we implement LoginView to our Activity as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skbdE-GZsnnpCj-1msPJug.png" /></figure><p>Our presenter implementation is like as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8u3cyg546FopzR2Yc5CbQ.png" /></figure><p>Checkout commit till now</p><pre>git checkout 6ef35a482c72c6266ccd10319728b44668a621ce</pre><p>You will get error in <strong>LoginPresenterTest</strong> as we have constructor for presenter which takes <strong>LoginView’s</strong> object .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCKwoXItQiLJzYc9_z3qjQ.png" /></figure><p>To get rid of this error we have to pass LoginView’s object to presenter while creating presenter object. So we have to <strong><em>mock</em></strong> LoginView.Here comes Mocking 😍.</p><h4><strong><em>What is mocking ?</em></strong></h4><p>You have an object whose method you want to test, and those method are depend on some other object. You create a mock of dependency object rather than creating actual instance of that dependency . Mock object are used for <strong>Unit Testing</strong> .</p><p>For mocking we are going to use <a href="http://mockito.org/"><strong>Mockito</strong></a><strong>.<br></strong>Add below <strong>testCompile </strong>dependency<strong> </strong>to app’s <strong>build.gradle</strong></p><pre>testCompile &#39;org.mockito:mockito-core:1.10.19&#39;</pre><p>Now we mock our <strong>LoginView</strong> as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*CqN7YriY3D7NVkkXV2TZ-g.png" /></figure><p>Ooho😳, 😎 we have our mocked (magical) login object that can passed to presenter. So our implementation becomes like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JO-0qh-ZMd8XONeOBtYZmg.png" /></figure><p>Run test shows green signal to go ahead.</p><h4><strong><em>Integration testing (Between Presenter &amp; View)</em></strong></h4><p>To verify that after presenter is calling correct method of view we use <strong>verify().</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5FxqfH3kFGp9qVtq3U_2g.png" /></figure><p>In above code diagram verify method ensures that <strong>showLoginSuccessMessage() </strong>is called on view object, which ensure that our presenter is correctly integrated with view.</p><p>Other test are as follow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xwuV6prCaZ2kImWZzdLpg.png" /></figure><p>Checkout code till now</p><pre>git checkout 97f0eff1d0eef26494dcec6872355458a6340cf7</pre><p><strong>Checkout next post</strong></p><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-4-ui-testing-using-espresso-b381ebede191">How to do TDD in Android ? Part 4 — UI testing using Espresso.</a></p><p>Till then, write your suggestions &amp; inputs on this in comments.</p><p>Cheers 🍻 !!!</p><h3>If you liked this post, please press ♥️ below.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60b057840db6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-3-mocking-integration-testing-60b057840db6">How to do TDD in Android ? Part 3 — Mocking &amp; Integration testing.</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do TDD in Android ? Part 2 — Project architecture , Setup & Unit Testing]]></title>
            <link>https://medium.com/mobility/how-to-do-tdd-in-android-part-2-project-architecture-setup-unit-testing-77cdd1d6aa3a?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/77cdd1d6aa3a</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-automation-testing]]></category>
            <category><![CDATA[android-testing]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Thu, 04 Aug 2016 07:24:57 GMT</pubDate>
            <atom:updated>2016-09-09T17:34:57.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XLqPqdiLkUiGKnUXuBbBcA.jpeg" /></figure><p>This tutorial will go through project architecture, setup from scratch and finally we will write some Unit tests.</p><p>In <a href="https://medium.com/@nileshjarad/why-developers-scared-to-refactor-code-47efd1b854e7#.8rxkxou48"><strong>Why developers are scared to refactor code</strong></a> and <a href="https://medium.com/@nileshjarad/how-to-do-tdd-in-android-90f013d91d7f#.71b3gyo7w"><strong>Part 1 of this series</strong></a> we covered what is importance of automation test, what is testing pyramid, what are type of test, what tools can be use to do TDD in android and where the testing folders are located.</p><h3><strong>Project architecture</strong></h3><p>In accordance to automation testing we have to follow some kind of architecture pattern that will help us to test &amp; structure our app in clean, testable manner.</p><p>There are many architecture pattern that easily support TDD <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter">Model–View–Presenter(MVP)</a> , <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel">Model–View–Viewmodel(MVVM)</a>.</p><p><strong>We are choosing MVP for our tutorial series.</strong></p><ol><li><strong>Model </strong>is typically POJO’s that are used by Presenter and View to convey information or to act upon.</li><li><strong>View </strong>(Activity or Fragment) is passive interface that displays data.This is place where we set data &amp; make UI related changes like hiding , moving view.</li><li><strong>Presenter </strong>decides presentation logic , our business logic resides here. It talks to repository gets data, format it to display in view. It decides what should be displayed on View.Try avoiding use of Android specific code in presenter as much as possible (I know sometimes it’s harder 😉).</li></ol><h3>Project setup</h3><p>In this post we will be creating simple android app from scratch . The app we will be creating is simple app that logins and take student attendance.</p><ol><li>Open Android Studio select <strong>“Start a new Android Project”</strong></li><li>Enter Application Name is <strong>“StudentAttendance”</strong>, Company Domain <strong>“nilesh.tdd.com”</strong> . Click Next</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpnE8qzqmPToc7-nwYTQXA.png" /></figure><p><strong>3</strong>. Select Android version you want support and Click <strong>“Next”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAM95sofW0ggruqfKFteJA.png" /></figure><p>4. Select <strong>“Empty Activity”</strong> and click <strong>“Next”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_BIm70j5TYd5dpNWvvSgQ.png" /></figure><p>5. Enter Activity Name and click <strong>“Finish”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxVoXI3ojq6iyLgSZI2nvg.png" /></figure><p>6. Final project structure would look like below image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*-ZwGaMG5y0tnv7-qC-NFIA.png" /></figure><h3><strong>Unit Testing</strong></h3><p>After some refactoring of package structure, checkout commit (<strong>81d1668667bcb5eacf4cf94a8dffe738ad206d67</strong>)</p><p><strong>Use below commands</strong></p><pre>git clone  <a href="https://github.com/NileshJarad/TDD_Demo.git">https://github.com/NileshJarad/TDD_Demo.git</a><br>git checkout 81d1668667bcb5eacf4cf94a8dffe738ad206d67</pre><p><strong>If someone getting below error after checkout</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lfKyDU02BXRo1B-7Ul7BnQ.png" /></figure><p>Then change <strong>build.gradle </strong>version to <strong>2.1.2</strong> in project build.gradle</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kja_Shq18OXShIX2xPkBXw.png" /></figure><p><strong>So finally we are here to get hands dirty on coding 😇.</strong></p><p>Now we will write our first test case to check “<strong>If user tries to login after three attempt we will show him/her error message</strong>”</p><pre>Go to <strong>com.tdd.nilesh.studentattendance.login.LoginPresenter</strong> class. Cursor over class name and press <strong>SHIFT+CTRL+T</strong> (for mac <strong>SHIFT+CMD+T</strong>) this will pop up window with Create New Test option.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMhQkMxos0hS06TBYGw7Xg.png" /></figure><pre>It will auto pick the class name for for Test and append Test at end of class name in our case <strong>LoginPresenterTest</strong>.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRhJiRo7wye4X0Ojj2qixw.png" /></figure><pre>Click OK . It will again pop on window for which Test Folder. As we are writing JUnit select <strong>../app/src/test/…</strong> it will create test class with same package structure.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*j5pa8aebCAGyLKWLpxbwdg.png" /></figure><p><strong><em>I am posting snapshot of code as I want you to write a code. </em>😊 <em><br>Now we will write Test as in below screen shot.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wz1hC51x6wRkqA7OJAcTA.png" /></figure><pre><strong>@Test</strong> annotation indicates it&#39;s test. As <strong>incrementLoginAttempt</strong> &amp; <strong>isLoginAttemptExceeded</strong> are indicating in red colour. We must create method in <strong>LoginPresenter</strong>. Press <strong>ALT+ENTER</strong> that will create methods in presenter class as show below.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*3sOPDcwW7eXa6yv2RDFDMw.png" /></figure><p>We have written failing test. Gradually we will write its implementation for it. To run a test, press small green play image left of test name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VlQnTHDvgvRdt3wFl2LeWg.png" /></figure><p>As we written failing test output of test should be as below.<br>We are expecting <strong>1</strong> as output but we are getting <strong>0.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugRLt-KJZu9NogmwYGgGNQ.png" /></figure><p>Now we will write passing test implementation for test. Below is implementation for passing test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*yq0xP22HkiBto1ZK4edQCw.png" /></figure><p>Again run test it should be passing 😍.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCriHjd_c72e7I3Xv54Y4A.png" /></figure><p><strong><em>Use below checkout command for Repo till now.</em></strong></p><pre>git checkout 302962ea6f63aa3afba003efa043ebacbaf02345</pre><p>Now you must write your <strong>checkIfLoginAttemptIsNotExceeded </strong>test and check if your implementation is correct. If you not, don’t worry it will be in next commit.</p><p>Now We want to check “<strong>User name &amp; password is correct</strong>”</p><p>So we will write test and below is how it looks like (<strong>Failing test 😉</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaeEY0mdhu4ytUzi9_nD-Q.png" /></figure><p>Again repeat process for <strong>ALT+ENTER </strong>&amp; run test. As it is failing test it will show red alert for failing.</p><p>Now we will write its implementation as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xAkaUJiXA_At67-R0092Xg.png" /></figure><p>Run test again it will be passing now.</p><p>Now give your try for <strong>checkUsernameAndPasswordIsInCorrect </strong>test case .</p><p><strong><em>Use below checkout command for Repo till now.</em></strong></p><pre>git checkout 4771fbfb8c6cbda98d9f01ac5e035ea02f0f5da6</pre><p>Meanwhile , would like to hear suggestions &amp; inputs on this.</p><p>Cheers 🍻 !!!.</p><h3>Gently hit ♥️ below.</h3><h4>Checkout Next post :</h4><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-3-mocking-integration-testing-60b057840db6">How to do TDD in Android ? Part 3 — Mocking &amp; Integration testing.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77cdd1d6aa3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-2-project-architecture-setup-unit-testing-77cdd1d6aa3a">How to do TDD in Android ? Part 2 — Project architecture , Setup &amp; Unit Testing</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do TDD in Android ? Part 1 — Overview]]></title>
            <link>https://medium.com/mobility/how-to-do-tdd-in-android-90f013d91d7f?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/90f013d91d7f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-automation-testing]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Sat, 23 Jul 2016 14:34:39 GMT</pubDate>
            <atom:updated>2016-08-23T11:09:44.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3eOzdO5B_ej7VXpHk_3Zg.png" /><figcaption>Tutorial series for android automation testing . Using JUnit &amp; Espresso .</figcaption></figure><p>Automation tests are important as it ensures quality while developing application.TDD enforces writing tests before writing implementation.</p><p>Refer this <a href="https://medium.com/@nileshjarad/why-developers-scared-to-refactor-code-47efd1b854e7#.m4ot7zaaq">previous tutorial</a> for more information about <strong>TDD</strong>.</p><p><strong>Testing pyramid :</strong></p><p>As we can see Pyramid below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LV9happxsb-UqmmnDk-Qw.png" /></figure><p><strong><em>Unit tests</em> </strong>cover large section of pyramid making solid base. Unit tests are easy to write.</p><p><strong><em>Integration Testing </em></strong>ensures integration of modules is correct and cover second large piece of Pyramid.</p><p><strong><em>Functional testing </em></strong>usually describes <em>what</em> the system does and occupies smallest amongst the three part.</p><p>There are many testing tools and frameworks that can be used while developing application. Some of them are provided &amp; supported by Google and some of them are third party .</p><p><strong><em>Types of testing in Android :</em></strong></p><p><strong>Unit Test</strong></p><p>Unit tests mainly target smallest functionality (like method, class , component or small module) with isolation from other component.</p><p><em>Tools used for Unit Test</em></p><ul><li><a href="http://junit.org/junit4/">JUnit</a> is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.</li><li><a href="http://robolectric.org/">Robolectric</a> is popular Android unit test framework that allows faster test execution by running tests on the JVM (no device or emulator needed😊).</li></ul><p><strong>Instrumentation Test</strong></p><p>Instrumentation Test (UI) are tests that mock User Interaction like clicking button , Typing text in EditText. Android Instrumentation is a set of “hooks” into the Android system that allows you to control the lifecycle of Android components (i.e. drive the activity lifecycle yourself instead of having these driven by the system). These tests require an actual device or emulator to run .</p><p><em>Tools used for Instrumentation Test</em></p><ul><li><a href="https://github.com/codepath/android_guides/wiki/UI-Testing-with-Espresso">Espresso</a> — Android UI Test Framework provided by Google that handles test synchronization very well.</li><li><a href="https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html">UIAutomator</a> — Android UI Test Framework provided by Google for testing across multiple apps at the same time.</li><li><a href="https://github.com/codepath/android_guides/wiki/UI-Testing-with-Robotium">Robotium</a> — Third party Android UI Test Framework (<a href="http://stackoverflow.com/a/20487527/5154829">Robotium vs Espresso</a>)</li><li><a href="http://selendroid.io/">Selendroid</a> — Selenium for Android</li></ul><p><strong>Package Structure for Testing :-</strong></p><p>In our project, two folders host our tests which are <strong><em>test</em></strong> and <strong><em>androidTest.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*64ZYn-MpgqAMAwXaWNHdFA.png" /></figure><p><strong>Test :</strong>Unit tests are hosted in this folder. These tests run on JVM and do not requires <em>Android device or emulator</em>. This type of test have no access to any android framework specific component like <em>Context</em>.</p><p><strong>androidTest</strong>:- All Instrumentation (<em>Espresso</em>) tests are hosted in this folder.These tests need physical Android device or emulator in order to run.</p><p>In next post, we will dive deep into what architecture to follow &amp; implementation for unit testing .</p><p>Meanwhile , would like to hear suggestions &amp; inputs on this.</p><p>Cheers 🍻 !!!.</p><h3>Hit that little ♥️ below .</h3><h4><strong>Checkout Next post :</strong></h4><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-part-2-project-architecture-setup-unit-testing-77cdd1d6aa3a">How to do TDD in Android ? Part 2 — Project architecture , Setup &amp; Unit Testing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90f013d91d7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/how-to-do-tdd-in-android-90f013d91d7f">How to do TDD in Android ? Part 1 — Overview</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why developers are scared to refactor code ?]]></title>
            <link>https://medium.com/mobility/why-developers-scared-to-refactor-code-47efd1b854e7?source=rss-a143b16b46d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/47efd1b854e7</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nilesh Jarad]]></dc:creator>
            <pubDate>Thu, 21 Jul 2016 14:22:35 GMT</pubDate>
            <atom:updated>2016-08-17T16:04:36.383Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*Z4NTvY3umivs1tKrtUVB3Q.png" /></figure><p>How do I do it . I’m afraid to refactor the code ……</p><p>I have seen many programmers being afraid while changing or refactoring code. Even I was afraid five months ago to change the code but now I am confident enough while changing the code .</p><p>And I am sure I am not alone . There are millions of coders around world who are afraid to change or refactor their code.</p><p><strong><em>Why programmers are afraid of changing code ?</em></strong></p><ol><li><strong>Lack of Confidence ! </strong>.They are not confident about their changes (is it going to work or will it break other dependent code).</li><li>If it doesn’t work, what amount of existing code will it hamper ?</li><li>They are not sure about <a href="https://en.wikipedia.org/wiki/Regression_testing"><strong>Regression testing.</strong></a></li></ol><p>Now since we have established why programmer are anxious about refactoring . Let me tell you why it isn’t grueling process as it is imagined to be .</p><p>Here comes in picture <a href="https://en.wikipedia.org/wiki/Test-driven_development"><strong>TDD(Test Driven Development)</strong></a></p><p><strong><em>What is TDD?</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*wMfZbyyF0fPXjW36YGHLsA.png" /><figcaption><strong><em>TDD mantra “Red-Greeen-Refactor”</em></strong></figcaption></figure><p><strong><em>Following is sequence for TDD:</em></strong></p><ol><li><strong>Failing Test :</strong> Write a failing test.</li><li><strong>Passing Test : </strong>Write a passing test that defines function .</li><li><strong>Write Code : </strong>The next step is to write some code that makes the test to pass. At this stage code is not perfect but it is acceptable as code will be improved in 5th stage.</li><li><strong>Run test : </strong>If all tests pass programmer is confident about code.</li><li><strong>Refactor code :</strong> Eliminate redundancy .By continually re-running the test cases throughout each refactoring phase, the developer can be confident that process is not altering any existing functionality.</li></ol><blockquote><em>Test-driven development is a way of managing fear during programming . Fear makes you tentative. Fear makes you want to communicate less. Fear makes you shy away from feedback. Fear makes you grumpy. —</em> TDD By Example</blockquote><p><strong><em>What are advantages of TDD:</em></strong></p><ol><li>You feel confident about your code and logic.</li><li>Your code is cleaner .</li><li>Code quality &amp; maintainability increases .</li><li>TDD can lead to more modularized, flexible and extensible code</li><li>Regression testing is much more easier as automated test cases find bugs early (so you are confident while changing code or delivering code to production).</li></ol><p><strong>Problem with less acceptance of TDD:</strong></p><p>The problem with TDD is that it does not show it’s impact in initial stage.You will see it’s true value when you will have to refactor the code after two-three months down the line.</p><p>Hope this piece of information provides you relief in some manner.</p><p>Would like to hear your inputs on this article.</p><h3>Hit little ❤️ below. Cheers !</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47efd1b854e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobility/why-developers-scared-to-refactor-code-47efd1b854e7">Why developers are scared to refactor code ?</a> was originally published in <a href="https://medium.com/mobility">Mobility</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>