<?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 Kailash Dabhi on Medium]]></title>
        <description><![CDATA[Stories by Kailash Dabhi on Medium]]></description>
        <link>https://medium.com/@kailash09dabhi?source=rss-2148b0c14807------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MBYjv4g-CvWDCR62.jpg</url>
            <title>Stories by Kailash Dabhi on Medium</title>
            <link>https://medium.com/@kailash09dabhi?source=rss-2148b0c14807------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 21:18:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kailash09dabhi/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[KT-Xtension (Extension for Kotlin)]]></title>
            <link>https://medium.com/@kailash09dabhi/kt-xtension-extension-for-kotlin-d0b234ccafe8?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0b234ccafe8</guid>
            <category><![CDATA[higher-order-function]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Fri, 13 Oct 2017 10:49:05 GMT</pubDate>
            <atom:updated>2017-10-14T11:55:24.761Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I opensourced few kotlin extensions which i made during few kotlin projects.:)</p><p><a href="https://github.com/kailash09dabhi/KT-Xtension">kailash09dabhi/KT-Xtension</a></p><p>Kotlin is very expressive language and It is fun to write code in kotlin. There are several features which is interesting but my favourite one is extension functions and higher order functions. Its great tool to remove boilerplate.</p><h3>Cursor Extension</h3><p>With the helps of cursor extension it is so easy to to fetch the data from sqlite and access!</p><h4>I was doing before <strong>without cursor extension</strong> like this:-</h4><pre><strong>class </strong>Order(<strong>val id</strong>: Long, <strong>val date</strong>: Long,<br>            <strong>val text</strong>: String) {<br><br>  <strong>constructor</strong>(cursor: Cursor) : <strong>this</strong>(<br>      <strong><em>cursor.getLong</em></strong>(<strong><em>cursor.getColumnIndexOrThrow</em></strong>(&quot;ID&quot;)),<br>      <strong><em>cursor.getLong</em></strong>(<strong><em>cursor.getColumnIndexOrThrow</em></strong>(&quot;DATE&quot;)),<br>      <strong><em>cursor.getString</em></strong>(<strong><em>cursor.getColumnIndexOrThrow</em></strong>(&quot;TEXT&quot;))<br>  )<br>}</pre><pre><em>//Fetch all orders from orders table</em></pre><pre><strong>fun</strong> all(): List&lt;Order&gt;{<br>  val cursor = sqliteDatabase<strong><em><br>              </em></strong><em>.rawQuery(</em><strong><em>&quot;select * from Orders&quot;</em></strong><em>, </em>null<em>)</em> <br>  <strong>val </strong>list = <em>arrayListOf</em>&lt;Order&gt;()<br>  <strong>if </strong>(cursor.<em>count() </em>&gt; 0) {<br>    <strong>try </strong>{<br>      cursor.moveToFirst()<br>      <strong>do </strong>{<br>        list.add(Order(cursor))<br>      } <strong>while </strong>(cursor.moveToNext())<br>    } <strong>catch </strong>(e: Exception) {<br>    }<br>  }<br>  curosr.close()<br>  <strong>return </strong>list<br>}</pre><pre><em>//</em>find Order from Orders table </pre><pre><strong><em>fun</em></strong> with(id: Int): Order {<br>  val cursor = sqliteDatabase<br>     .rawQuery(&quot;select * from Orders where id = &#39;&quot; + id + &quot;&#39;&quot;, null)<br>  <strong>var </strong>object = EmptyOrder()<br>  <strong>if </strong>(cursor.<em>count </em>&gt; 0) {<br>    <strong>try </strong>{<br>      cursor.moveToFirst()<br>      <strong>do </strong>{<br>        object = Order(cursor)<br>      } <strong>while </strong>(cursor.moveToNext())<br>    } <strong>catch </strong>(e: Exception) {<br>    }<br>  }<br>  cursor.close()<br>  <strong>return </strong>object<br>}</pre><h4>but now <strong>with the help of cursor extension </strong>I do like this:<strong><em>-</em></strong></h4><pre><strong><em>class </em></strong><em>Order(</em><strong><em>val id</em></strong><em>: Long, </em><strong><em>val date</em></strong><em>: Long,<br>            </em><strong><em>val text</em></strong><em>: String) {<br><br>  </em><strong>constructor</strong><em>(cursor: Cursor) : </em>this<em>(<br>      </em><strong><em>cursor</em></strong><em>.</em><strong><em>long</em></strong><em>(&quot;ID</em><strong><em>&quot;</em></strong><em>),//extension to read long from column &quot;ID&quot;<br>      </em><strong><em>cursor</em></strong><em>.</em><strong><em>long</em></strong><em>(&quot;DATE</em><strong><em>&quot;</em></strong><em>),<br>      </em><strong><em>cursor</em></strong><em>.</em><strong><em>string</em></strong><em>(&quot;TEXT</em><strong><em>&quot;</em></strong><em>)//to read String from column &quot;TEXT&quot;<br>  )<br>}</em></pre><pre><strong>// Cursor.<em>eachRow</em> Extension</strong><br><em>// Use it when you want list from cursor</em></pre><pre><strong>fun<em> </em></strong><em>all(): </em><strong><em>List&lt;Order&gt;</em></strong><em> {<br>  </em><strong><em>return </em></strong>sqliteDatabase<strong><em><br>      </em></strong><em>.rawQuery(</em><strong><em>&quot;select * from Orders&quot;</em></strong><em>, </em>null<em>)<br>      .</em><strong><em>eachRow</em></strong><em> </em><strong><em>{ <br>        Order(it)</em></strong><em><br>      </em><strong><em>}<br></em></strong><em>}</em></pre><pre><strong>// Cursor.toObject Extension</strong><br><em>// Use it when you want to find one raw from sqlite table</em></pre><pre><strong><em>fun</em></strong> with(id: Int): <strong><em>Order</em></strong> {<br>  return sqliteDatabase<br>     .rawQuery(&quot;select * from Orders where id = &#39;&quot; + id + &quot;&#39;&quot;, null)<br>     .<strong><em>toObject</em></strong>(EmptyOrder()) {<br>        <strong><em>Order</em></strong>(<strong><em>it</em></strong>)<br>      }<br>    }</pre><p>Here <strong>eachRow</strong> is extension of Cursor object. This eachRow iterates through cursor safely and then return the List of Orders(any pojo). :)</p><h3><strong>TabLayout Extension</strong></h3><p>Now instead of adding tab like this:</p><pre>tabLayout.addTab(<br>    tabLayout<br>        .newTab()<br>        .setText(&quot;Tab 1&quot;)<br>        .setIcon(R.drawable.<em>ic_add_24dp</em>)<br>);<br>tabLayout.addTab(<br>    tabLayout<br>        .newTab()<br>        .setText(&quot;Tab 2&quot;)<br>        .setIcon(R.drawable.<em>ic_add_24dp</em>)<br>);</pre><p><strong><em>but now with the help of Tab extension I do like this:-</em>-</strong></p><pre><em>tabLayout.</em><strong><em>add</em></strong><em> </em><strong><em>{<br>  tab</em></strong><em> </em><strong><em>{ </em></strong><em>setText(</em><strong><em>&quot;</em></strong><em>Tab 1</em><strong><em>&quot;</em></strong><em>).setIcon(R.drawable.ic_add_24dp) </em><strong><em>}<br>  tab</em></strong><em> </em><strong><em>{ </em></strong><em>setText(</em><strong><em>&quot;</em></strong><em>Tab 2</em><strong><em>&quot;</em></strong><em>).setIcon(R.drawable.ic_add_24dp) </em><strong><em>}<br>}</em></strong></pre><blockquote>Here <strong><em>add &amp; tab </em></strong>is extension of TabLayout object.</blockquote><p>It is so compact and makes sense to me! :)</p><p>There are several extensions on the project feel free to use it:)</p><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>.</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><p><em>Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0b234ccafe8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effective Java Picks]]></title>
            <link>https://medium.com/@kailash09dabhi/effective-java-picks-c5a9c5912863?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5a9c5912863</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Sun, 23 Apr 2017 15:31:48 GMT</pubDate>
            <atom:updated>2017-08-21T07:17:24.547Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Prefer Static member classes over non-static member class.</li><li>Never Use interface to define constants!(Favourite one)</li></ol><blockquote>Effective Methods</blockquote><ol><li>Check Parameter is valid in start of method</li><li>True Immutable object make defensive copies of its mutable property in constructor and provide defensive copies for accessor methods.(item 39)</li><li>Stay away from overloading as it creates confusion in long run should use naming pattern like readInt, readLong , writeFloat, writeLong, etc.</li><li>Best use of varargs… is to use with 2 parameters method so client cannot call the method without any parameter and so it also eliminates the need to check arguments. But Avoid as it can bring more confusion!</li><li>Never Return <strong>NULL </strong>from methods! (Item 43)</li></ol><blockquote>Effective Programming Tricks</blockquote><ol><li>Minimize the scope of local variable and declare only when it is first used!</li></ol><h4>( for loop has one nice feature so we can get high performance by not asking count everytime and can get rid of additional local variable by not doing like this!</h4><blockquote>for (int i = 0, n = expensiveComputation(); i &lt; n; i++) { doSomething(i); }</blockquote><p>2. Use for each loop wherever possible to avoid any error also simple for loop and for each loop is same in performance so no penalty to use it!</p><p>3. Use BigDecimal rather than float,double for exact calculation and correct rounding etc. doble, float are used for scientific reason.</p><p>4. Always use primitives types rather than boxed primitives.</p><p>5. Use StringBuilder rather than string when string concatenation used heavily.</p><p>6.If appropriate interface types exist, then parameters,return values, variables, and fields should all be declared using interface types!</p><blockquote>Effective Exception</blockquote><ol><li>Don’t use exception for flow control as its more verbose and bad approach</li><li>Use checked exceptions for recoverable conditions and runtime exceptions for programming errors</li><li>Use boolean method to avoid catching exception</li><li>Strive for failure atomicity</li><li>Favor the use of standard exceptions like IllegalStateException, etc.</li><li>Throw exception appropriate to the abstraction</li><li>Include failure capture information in detail message</li><li>Don’t ignore exceptions</li></ol><blockquote>Effective Concurrency</blockquote><ol><li>synchronization has no effect unless both read and write operations are synchronized.</li><li>Prefer Executor Framework’s ScheduledThreadPoolExecutor over Timer.</li><li>Use Runnable or Callable for task in Executor framework rather than working directly with threads.</li></ol><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>. Thanks!</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5a9c5912863" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Development approach of Opensource Om Recorder library to Record Wav / Pcm Audio]]></title>
            <link>https://medium.com/@kailash09dabhi/om-recorder-library-1-1-0-released-9805042e4448?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/9805042e4448</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androidarsenal]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Wed, 24 Aug 2016 17:58:47 GMT</pubDate>
            <atom:updated>2017-08-21T07:20:16.722Z</atom:updated>
            <content:encoded><![CDATA[<p>I think as android developer everybody mostly depends on opensource libraries and i always use libraries to ease the development. We should always use libraries when the solution is already available. It is waste of time to work on problem which is already solved!</p><blockquote>Do Not Reinvent The Wheel!</blockquote><p>But i think it is too selfish to utilize other people’s work and never share something we made. So I decided to give this simple recorder library to my android community to make the cumbersome record audio task easy!</p><blockquote>The Om Recorder is a simple library to record audio in Wav or Pcm Format. More you can know on this <a href="https://kailash09dabhi.github.io/OmRecorder/">link</a>. My main focus is here how the development done for this library.</blockquote><p>My main requirement is :-</p><ol><li>It should provide some mechanism to let the user know about the recently read audio bytes.</li><li>It should notify silence and can only produce noise.</li><li>A recorder which can be used to record Pcm or Wav format</li></ol><p>To implement this functionality I obviously have to go with android.media.AudioRecord class as that class only allows to read the data from audio source and can allow us to play with raw audio data in order to remove silence from the read bytes. So for that task i have defined <strong>AudioSource </strong>interface and then added necessary behavior accordingly like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*So9qgNcs2CeH55fvXLeydA.png" /><figcaption>AudioSource interface</figcaption></figure><p>Then , I have defined one interface <strong>PullTransport </strong>whose responsiblity is to pull the data from<em> AudioSource </em>and write it to <em>OuputStream.</em> so i have defined <em>start() </em>method to start pulling data and <em>stop() </em>method for stop pulling data from <em>AudioSource. </em>As the<em> PullTransport </em>pulls the data from<em> AudioSource</em> we have to get each read audio chunks and give that audio chunk to library users so they can show animation or may be process that audio chunk or whatever. So to satisfy our <em>1st requirement </em>i.e. to inform the read audio chunk i have defined <strong>OnAudioChunkPulledListener </strong>interface like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*zlpHuJsg58_UXm4Y6RAX-Q.png" /><figcaption>PullTransport interface</figcaption></figure><p>Now our <strong><em>2nd objective</em></strong> is to provide silence feature. So to achieve that we have already defined the PullTransport interface and so i have defined two concrete classes.</p><ol><li><strong>Default Class which only writes each pulled audio chunks from AudioSource to ouputStream.</strong></li><li><strong>Noise class as the name signifies it will only write the noisy chunks of audio.</strong></li></ol><p>Then, I have made one recorder interface to provide user a way to use the code like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*osyYQYdKjlY_JA3NaClvzg.png" /><figcaption>Recorder Interface</figcaption></figure><p>Then to fulfill <strong><em>3rd objective</em></strong> i have made two concrete class i.e. Pcm for pcm recording and Wav for wav recording. Also silence listener defined to detect silence.</p><p>I hope people will find this library easy to use and help them to get the recording wav/pcm task done in few minutes :)</p><p>This is the link to library :-</p><p><a href="https://github.com/kailash09dabhi/OmRecorder">kailash09dabhi/OmRecorder</a></p><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>.</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><p><em>Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9805042e4448" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVP With Better Naming of implementation classes & DRY Principle]]></title>
            <link>https://medium.com/@kailash09dabhi/mvp-with-better-naming-of-implementation-classes-dry-principle-e8b6130bbd02?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8b6130bbd02</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mvp]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Sat, 09 Jul 2016 12:30:19 GMT</pubDate>
            <atom:updated>2017-08-21T07:21:06.349Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays MVP is a very trending topic in android community. But No matter how many advantages it offers, we doomed with bad naming of our classes. And further more very hard to traverse through code!</p><p>But recently i read this <a href="https://www.novoda.com/blog/better-class-naming/">nice article</a> which helped me to make my code look better and make my client happy too :) But i want to extend <a href="https://www.novoda.com/blog/author/blundell/">Paul Blundell</a>’s article and want to present a beautiful naming of classes and plus refactoring the common code we usually implement in most <em>activities</em>.</p><p>When we implement MVP in our code we mostly see some operation is very common and they being replicated in each screen like <em>isInternetAvailable()</em>, <em>showProgressDialog()</em>, <em>dismissProgressDialog</em> etc. This is very bad!</p><p><strong><em>It violates the rule of DRY (Dont Repeat Yourself )</em></strong></p><blockquote>In our software a piece of knowledge should be in one single location.</blockquote><p>So I had extracted all the method which are getting duplicated in each activity, each presenter and each Model in their unique parent interface and called it <strong><em>Mvp </em></strong>Interface. And this is what my base MVP interface looks like:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*v2jscTQmFgV7YWm7LETQvQ.png" /><figcaption>Base Mvp model, view, and presenter interfaces</figcaption></figure><p>So now our Mvp interface contains all the common methods in its view, presenter and model interface. So we have saved lots of boilerplate code and followed the DRY practice very nicely:)</p><p>Then we can make the Login interface/contracts which extends the Mvp Interface to use the common functionalities defined. And this is Login Interface looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*O2zztIQTxvQib8b8-erExQ.png" /><figcaption>Login Contract</figcaption></figure><p>Now we <strong><em>don’t need to use</em></strong> LoginPresenterImpl Or SimpleLoginPresenter Or DefaultLoginPresenter but simply we can define LoginPresenter.java!</p><blockquote>Never Use Impl/Simple/Default as prefix/suffix for our classes!</blockquote><p>I can then just implement the <em>LoginModel </em>class and <em>LoginPresenter </em>class to implement my model and presenter functionality related to login!</p><p>And this is how we have better naming of MVP related classes!</p><p>Also I am using MVP in many projects and its easy to test and helps to decouple UI, Model and make methods smaller, but when app getting bigger its hard to go all over the code cause so many views presenter all becoming mess gradually.</p><p>And finally it became necessary to think about how to restructure our app so it gets easy to move around the code for doing real work! I think its better to use <em>package</em> for domain rather than common naming like (<em>activities</em>, <em>fragments</em>, <em>dialogs</em>, <em>services</em>,etc) which becomes tough when app getting bigger!</p><p>We should make package for each domain specific thing like if we have <strong><em>LoginActivity</em></strong><em>, </em><strong><em>LoginPresenter</em></strong><em>, </em><strong><em>LoginModel</em></strong><em>, </em><strong><em>LoginView </em></strong>then we should name the package <strong><em>Login </em></strong>as it serves the purpose of login the user!and we should move them into that domain centric login package, so it will be easy to find the classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*IxCxTn0q4S49dYOTqUrOSA.png" /><figcaption>MVP package structure</figcaption></figure><p>This package structure gives the developer very effective way to traverse through code. This structure helps to group the classes for same concept.</p><blockquote>So the package becomes a group of classes which works with each other to serve the single goal!</blockquote><p>This gives the developer very easy and sneak view of app functionality too in a single moment of sight!</p><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>.</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><p><em>Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8b6130bbd02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learned Points in Testing Playground]]></title>
            <link>https://medium.com/@kailash09dabhi/learned-points-in-testing-playground-410091be37cd?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/410091be37cd</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Tue, 14 Jun 2016 15:32:48 GMT</pubDate>
            <atom:updated>2017-08-21T07:18:28.764Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I am working in one app and in that app i decided to go with TDD Approach. Its seems complicated first but it gives a confidence on our written code!</p><p>I have employed</p><p>Two test framework for Unit testing my app :- Junit &amp; Mockito</p><p>And also Used <strong>Espresso</strong> for Ui testing with Jacoco coverage tool.</p><p>And I started to like them now:)</p><p>Important stuff learned:-</p><p>Unit testing actually helps us to think about program’s dependency and help us to make the software more cohesive and very straight to its dependencies.</p><blockquote>Use <strong>Fake Object </strong>to give fake response (RxJava’s testing problem forced me to try this and now i believe it is very good approach :) )</blockquote><blockquote>Use Unit test to check the desired method flow</blockquote><blockquote>Make Real Object to unit test its method and Mock all the dependencies of its method to test its behaviour!</blockquote><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>. Thanks!</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=410091be37cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Variable Naming Practice]]></title>
            <link>https://medium.com/@kailash09dabhi/variable-naming-practice-397715bb477e?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/397715bb477e</guid>
            <category><![CDATA[naming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Fri, 01 Apr 2016 14:08:31 GMT</pubDate>
            <atom:updated>2017-08-21T07:20:43.789Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Variable Naming Practice</strong></p><ul><li>It should have no Hungarian Notation</li><li>It should contain the meaning of it.</li><li>It should have no type information</li><li>It should follow naming convention of the particular language</li><li>A <em>boolean </em>variable should always have suffix like is/were/has/was or something like that.</li></ul><p>I will share my ideas here more ideas regarding best practices here to serve my programming community.:)</p><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>.</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><p><em>Thanks!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=397715bb477e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dagger2 Experience]]></title>
            <link>https://medium.com/@kailash09dabhi/dagger2-experience-fcf8cbf1acee?source=rss-2148b0c14807------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcf8cbf1acee</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dagger-2]]></category>
            <dc:creator><![CDATA[Kailash Dabhi]]></dc:creator>
            <pubDate>Sat, 30 Jan 2016 15:24:25 GMT</pubDate>
            <atom:updated>2017-08-21T07:19:23.186Z</atom:updated>
            <content:encoded><![CDATA[<p>Suppose we have 2 classes : A, B .</p><p>class A : — The class which can be dependency and we can use into other classes by using @Inject A variableA; (In Simple words,It is class which want to be injected into other classes )</p><p>class B: — The class who wants to inject the depencies. class B wants to inject other dependencies into itself. ( If you use Interface i.e. @Inject MyInterface then this will not work for sure!)</p><p>So now on the basis of this metaphor,</p><p>Class A can become injectable in only 2 ways:-</p><ol><li>By Providing its object using the method with @Provides or @Produces annotation.</li><li>By Providing the Injectable Constructor, So Dagger can automatically create the class A object implicity!</li></ol><p><strong>And finally We must provide the method in Component interface so Dagger can inject the dependcies in the component :)</strong></p><p>@Scope : We use scope annotation to better architecuring app.</p><p>The rules with scope is:-</p><ol><li>We have to add the @scope annotation to component interface &amp; also where we providing the object that wants to have scope.</li></ol><p>The other things notable i found during dagger2 implementation is:-</p><ol><li>We can use @Inject annotation for interface but if the implementor class of that interface also has injection dependencies then We cant provide object of interface. in short if the class we want to inject has also injectable dependency then that file should be declared in dagger2 with @provides or @produces.</li></ol><p>Update — -&gt; Dagger 2.6 05/09/2014</p><p>Rules:-</p><p>To use Dagger2 we have to remember 2 facts about Field injection when we use @inject AnObject iamObject;</p><blockquote>It should inject itself by using @component interface where we define inject method <strong>OR </strong>it should make the consturctor injectable by defining @inject annotation on top of constructor so Dagger2 can call it.!</blockquote><p>Very Important : —</p><pre>@Provides @Singleton File provideStorageDirectory(TimestampApplication app) {<br>  File storageDir =<br>      <strong>new </strong>File(Environment.<em>getExternalStorageDirectory</em>(), app.getString(R.string.<strong><em>app_name</em></strong>));<br>  storageDir.mkdirs();<br>  <strong>return </strong>storageDir;<br>}</pre><p>if we define provide method like this that is we are expecting Application object to be injected then we have to define the accessor method in @Component interface.</p><pre>TimestampApplication app();</pre><blockquote>so Dagger 2 know that it has to get TimestampApplication object using the provided method (i.e. method with @provide annotation). So Dagger2 automatically then <strong>inject </strong>the <strong>parameter </strong>:)</blockquote><p><em>If you found this article helpful, please do hit the heart button below and let me know on </em><a href="https://twitter.com/kailash09dabhi"><em>Twitter</em></a><em>. Thanks!</em></p><p>Let’s get connect on <a href="https://www.facebook.com/kailash09dabhi"><strong>facebook</strong></a><strong>, </strong><a href="https://twitter.com/kailash09dabhi"><strong>twitter</strong></a><strong>, </strong><a href="https://github.com/kailash09dabhi"><strong>github </strong></a>and<strong> </strong><a href="https://www.linkedin.com/in/kailash-dabhi-47926166/"><strong>linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcf8cbf1acee" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>