<?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 Mohak Puri on Medium]]></title>
        <description><![CDATA[Stories by Mohak Puri on Medium]]></description>
        <link>https://medium.com/@mohak.puri?source=rss-2438528dd12b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*scrQ6Oip4by0f7D6</url>
            <title>Stories by Mohak Puri on Medium</title>
            <link>https://medium.com/@mohak.puri?source=rss-2438528dd12b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:15:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohak.puri/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[Handling Null in kotlin]]></title>
            <link>https://medium.com/@mohak.puri/handling-null-in-kotlin-e9b3345f8411?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9b3345f8411</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Sun, 14 Oct 2018 17:38:32 GMT</pubDate>
            <atom:updated>2018-10-14T17:38:32.692Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><em>Safe call operator: “?.” — </em>If the value on which you’re trying to call the method isn’t null, the method call is executed normally. If it’s null, the call is skipped, and null is used as the value instead.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*Kg6oC-4YbXcL9MWJ3UPe7w.png" /></figure><p>2. <em>Elvis operator: “?:” —</em>The operator takes two values, and its result is the first value if it isn’t null or the second value if the first one is null.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*ubq4VUG-okVICtXBQZgtAQ.png" /></figure><p>3. <em>Not-null assertions: “!!” —</em>It’s represented by a double exclamation mark and converts any value to a non-null type. For null values, an exception is thrown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*X_8nBEye4K9OnS2FNnPJig.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9b3345f8411" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let in kotlin]]></title>
            <link>https://medium.com/@mohak.puri/let-in-kotlin-9aad2b4ff9d?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aad2b4ff9d</guid>
            <category><![CDATA[gojek-bootcamp]]></category>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Sun, 14 Oct 2018 17:24:28 GMT</pubDate>
            <atom:updated>2018-10-14T17:24:28.645Z</atom:updated>
            <content:encoded><![CDATA[<p>The let function makes it easier to deal with nullable expressions. Together with a safe-call operator, it allows you to evaluate an expression, check the result for null, and store the result in a variable, all in a single, concise expression.</p><p>This function is written in Kotlin and requires a non-null parameter:</p><pre>fun sendEmailTo(email: String) { /*...*/ }</pre><p>You can’t pass a value of a nullable type to this function:</p><pre>&gt;&gt;&gt; val email: String? = ...<br>&gt;&gt;&gt; sendEmailTo(email)<br>ERROR: Type mismatch: inferred type is String? but String was expected</pre><p>You have to check explicitly whether this value isn’t null:</p><pre>if (email != null) sendEmailTo(email)</pre><pre>                V/S</pre><pre>email?.let { sendEmailTo(it) }</pre><p>But you can go another way: use the let function, and call it via a safe call. All the let function does is turn the object on which it’s called into a parameter of the lambda.</p><p>The let notation is especially convenient when you have to use the value of a longer expression if it’s not null. You don’t have to create a separate variable in this case. Compare this explicit if check</p><pre>val person: Person? = getTheBestPersonInTheWorld()<br>        if (person != null) sendEmailTo(person.email)</pre><p>to the same code without an extra variable:</p><pre>getTheBestPersonInTheWorld()?.let { sendEmailTo(it.email) }</pre><p>This function returns null, so the code in the lambda will never be executed: fun getTheBestPersonInTheWorld(): Person? = null</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aad2b4ff9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pur]]></title>
            <link>https://medium.com/@mohak.puri/pur-b6859d42e0ee?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6859d42e0ee</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Fri, 12 Oct 2018 04:30:33 GMT</pubDate>
            <atom:updated>2018-10-12T04:44:38.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pure functions</h3><blockquote>In computer programming, a pure function is a function that has the following properties: Its return value is the same for the same arguments. Its evaluation has no side effects. Thus a pure function is a computational analogue of a mathematical function.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*MWvAcmZnEzq3Mz5X4z7bcg.png" /></figure><pre>const add = (x, y) =&gt; x + y // A pure function</pre><h3><strong>Why pure?</strong></h3><ol><li>Readability</li><li>Testability</li><li>A lot more…</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6859d42e0ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lambdas]]></title>
            <link>https://medium.com/@mohak.puri/lambdas-c3cc238de5f3?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3cc238de5f3</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Wed, 10 Oct 2018 04:26:10 GMT</pubDate>
            <atom:updated>2018-10-10T04:34:41.424Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Lambda expressions</em>, or simply <em>lambdas</em>, are essentially small chunks of code that can be passed to other functions. With lambdas, you can easily extract common code structures into library functions, and the Kotlin standard library makes heavy use of them. One of the most common uses for lambdas is working with collections.</p><pre>/* Java */<br>button.setOnClickListener(new OnClickListener() {@Override<br>    public void onClick(View view) {/* actions on click */<br>    }<br>});</pre><pre>/* kotlin */<br>button.setOnClickListener { /* actions on click */ }</pre><p>Collections and lambdas</p><pre>// manually</pre><pre>fun findTheOldest(people: List&lt;Person&gt;) {<br>    var maxAge = 0<br>    var theOldest: Person? = null<br>    for (person in people) {<br>    if (person.age &gt; maxAge) {<br>          maxAge = person.age<br>          theOldest = person<br>  }<br>}</pre><pre>println(theOldest)<br>}</pre><pre>// using lambdas</pre><pre>val people = listOf(Person(&quot;Alice&quot;, 29), Person(&quot;Bob&quot;, 31))<br>println(people.maxBy { it.age })<br>Person(name=Bob, age=31)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3cc238de5f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacktoberfest]]></title>
            <link>https://medium.com/@mohak.puri/hacktoberfest-f0bc2a88d0c0?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0bc2a88d0c0</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Sun, 07 Oct 2018 16:21:44 GMT</pubDate>
            <atom:updated>2018-10-07T16:21:44.972Z</atom:updated>
            <content:encoded><![CDATA[<p>Every October, Digital Ocean and GitHub ship out free Hacktoberfest shirts to thousands of people around the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eh51ClgdouCa4ri0SNxhw.png" /></figure><h3>Values</h3><p>Hacktoberfest guiding values:</p><ul><li>Everyone is welcome</li><li>Quantity is fun, quality is key</li><li>Short term actions, long term impact</li></ul><h3>Rules</h3><p>To get a shirt, you must make five pull requests (PRs) between October 1–31 in any timezone. PRs can be to any public repo on GitHub, not just the ones highlighted. The PR must contain commits you made yourself. PRs reported by maintainers as spam or that are automated will be marked as invalid and won’t count towards the shirt.</p><h3>Step 1: Register for Hacktoberfest</h3><p>You need a GitHub account. If you don’t have one yet, you can <a href="https://github.com/join">create one for free in just a few minutes</a>.Then go to the <a href="https://hacktoberfest.digitalocean.com/sign_up/register">Hacktoberfest registration page and follow the instructions</a>. It only takes a moment.</p><h3>Step 2: Contribute!</h3><p>Now you just have to contribute!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0bc2a88d0c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nandi hills - A break from Bootcamp]]></title>
            <link>https://medium.com/@mohak.puri/nandi-hills-a-break-from-bootcamp-40ff46f4ee84?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/40ff46f4ee84</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Sun, 07 Oct 2018 15:56:47 GMT</pubDate>
            <atom:updated>2018-10-07T15:56:47.835Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been almost 2 months and we have been busting our asses in the boot camp and we wanted a break. So we decided to get one!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*AUknOP7NtI4ETVp-IVwFOQ.gif" /><figcaption>Break from Bootcamp</figcaption></figure><p>We decided to go to Nandi Hills.</p><blockquote>Nandi Hills, or Nandidurg, is a hill fortress in the south Indian state of Karnataka. Tipu Sultan Fort, a summer retreat of the namesake 18th-century ruler, features stone carvings and wall paintings. Prisoners are said to have been thrown to their death from Tipu’s Drop, now known for its panoramic views. Local Hindu temples include the hilltop Yoga Nandeeshwara Temple, guarded by a huge statue of a bull (nandi).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfnvqP097fwJJlfJy91DwQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DwaKt18clGwcBdKFryz1w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WkEiLGuQs_CKSqxXxwKK5Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qyATpLTnvCvzc-w3d_G52g.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40ff46f4ee84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[View and View groups in android]]></title>
            <link>https://medium.com/@mohak.puri/view-and-view-groups-in-android-24d21f59a2e1?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/24d21f59a2e1</guid>
            <category><![CDATA[gojek-bootcamp]]></category>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Tue, 02 Oct 2018 18:05:24 GMT</pubDate>
            <atom:updated>2018-10-02T18:05:24.922Z</atom:updated>
            <content:encoded><![CDATA[<p>The Android View class and ViewGroup class are two very central classes in Android apps. An Android app contains one or more activities. An Android activity is a screen, similar to windows in a desktop application. Inside an activity you can have GUI components. The GUI components are instances of Viewor ViewGroup subclasses.</p><h3>View</h3><p>The View class is a superclass for all GUI components in Android. For instance, the TextView class which is used to display text labels in Android apps is a subclass of View. Android contains the following commonly used View subclasses:</p><ul><li>TextView</li><li>EditText</li><li>ImageView</li><li>ProgressBar</li><li>Button</li><li>ImageButton</li><li>CheckBox</li><li>DatePicker</li></ul><p>These are only some of the many, many subclasses of the View class.</p><h3>ViewGroup</h3><p>The ViewGroup class is a subclass of the View class. ViewGroup instances work as containers for Viewinstances to group View instances together. Android contains the following commonly used ViewGroupsubclasses:</p><ul><li>LinearLayout</li><li>RelativeLayout</li><li>ListView</li><li>GridView</li></ul><p>These are not the only ViewGroup subclasses Android contains. There are others but which are less used.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24d21f59a2e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ViewPager in Android]]></title>
            <link>https://medium.com/@mohak.puri/viewpager-in-android-b825db32e067?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b825db32e067</guid>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Tue, 02 Oct 2018 09:21:38 GMT</pubDate>
            <atom:updated>2018-10-02T09:21:38.448Z</atom:updated>
            <content:encoded><![CDATA[<p>Screen slides are transitions between one entire screen to another and are common with UIs like setup wizards or slideshows.ViewPagercan animate screen slides automatically. Here are the steps for creating your own Viewpager.</p><ol><li>Create activity — This activity is where your Viewpager resides</li><li>Create fragments — First is to create the fragments that will be the part of the Viewpager</li><li>Create adapter — The adapter is where the association of fragments with the Viewpager takes place.</li></ol><pre>import android.support.v4.app.Fragment;<br>import android.support.v4.app.FragmentManager;</pre><pre>public class ScreenSlidePagerActivity extends AppCompactActivity {<br>    <br>    private static final int NUM_PAGES = 5;<br>    <br>    private ViewPager mPager;<br><br>    private PagerAdapter mPagerAdapter;<br><br>    @Override<br>    protected void onCreate(Bundle savedInstanceState) {<br>        super.onCreate(savedInstanceState);<br>        setContentView(R.layout.activity_screen_slide);<br><br>        mPager = (ViewPager) findViewById(R.id.pager);<br>        mPagerAdapter = new  ScreenSlidePagerAdapter(getSupportFragmentManager());<br>        mPager.setAdapter(mPagerAdapter);<br>    }<br><br>    @Override<br>    public void onBackPressed() {<br>        if (mPager.getCurrentItem() == 0) {<br>            super.onBackPressed();<br>        } else {<br>            mPager.setCurrentItem(mPager.getCurrentItem() - 1);<br>        }<br>    }<br><br>    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {<br>        public ScreenSlidePagerAdapter(FragmentManager fm) {<br>            super(fm);<br>        }<br><br>        @Override<br>        public Fragment getItem(int position) {<br>            return new ScreenSlidePageFragment();<br>        }<br><br>        @Override<br>        public int getCount() {<br>            return NUM_PAGES;<br>        }<br>    }<br>}</pre><p>That&#39;s all you are done!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b825db32e067" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activity in Android]]></title>
            <link>https://medium.com/@mohak.puri/activity-in-android-9936e02fe612?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9936e02fe612</guid>
            <category><![CDATA[gojek-bootcamp]]></category>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Wed, 26 Sep 2018 03:51:38 GMT</pubDate>
            <atom:updated>2018-09-26T03:51:38.251Z</atom:updated>
            <content:encoded><![CDATA[<p>The Activity class is a crucial component of an Android app, and the way activities are launched and put together is a fundamental part of the platform&#39;s application model. Unlike programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle.</p><h3>The concept of activities</h3><p>The mobile-app experience differs from its desktop counterpart in that a user’s interaction with the app doesn’t always begin in the same place. Instead, the user journey often begins non-deterministically. For instance, if you open an email app from your home screen, you might see a list of emails. By contrast, if you are using a social media app that then launches your email app, you might go directly to the email app’s screen for composing an email.</p><p>The <a href="https://developer.android.com/reference/android/app/Activity.html">Activity</a> class is designed to facilitate this paradigm. When one app invokes another, the calling app invokes an activity in the other app, rather than the app as an atomic whole. In this way, the activity serves as the entry point for an app&#39;s interaction with the user. You implement an activity as a subclass of the <a href="https://developer.android.com/reference/android/app/Activity.html">Activity</a> class.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9936e02fe612" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[YAGNI]]></title>
            <link>https://medium.com/@mohak.puri/yagni-6b696da002f1?source=rss-2438528dd12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b696da002f1</guid>
            <category><![CDATA[gojek-bootcamp]]></category>
            <dc:creator><![CDATA[Mohak Puri]]></dc:creator>
            <pubDate>Mon, 24 Sep 2018 04:03:24 GMT</pubDate>
            <atom:updated>2018-09-24T04:03:24.422Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*gg7s2yi6sXiJdd7wYS9uhQ.png" /></figure><blockquote>“You aren’t gonna need it” is a principle of extreme programming that states a programmer should not add functionality until deemed necessary. XP co-founder Ron Jeffries has written: “Always implement things when you actually need them, never when you just foresee that you need them.</blockquote><p>This doesn’t mean you should avoid building flexibility into your code. It means you shouldn’t overengineer something based on what you <strong>think you might need later on</strong>. Keep the system uncluttered with extra stuff you guess will be used later. Only 10% of that extra stuff will ever get used, so you are wasting 90% of your time.</p><p>Keeping your code ready for unexpected changes is about simple design. Adding extra flexibility beyond what you need now always makes a design more complex.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b696da002f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>