<?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"><channel><title><![CDATA[Javal Nanda]]></title><description><![CDATA[👋 Hi, I'm Javal Nanda, a Mobile Application Developer based in India. I've been in the world of mobile app development since 2010, and this blog is my space to]]></description><link>https://javalnanda.com</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 10:45:07 GMT</lastBuildDate><atom:link href="https://javalnanda.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[SwiftUI View Extensions vs ViewModifier vs Custom Views]]></title><description><![CDATA[We often need to modify the SwiftUI view in some way or the other. There are three ways in which we can achieve customization of the SwiftUI View:

View Extensions

ViewModifiers

Custom Views


We can almost produce the same results with the above a...]]></description><link>https://javalnanda.com/swiftui-view-extensions-vs-viewmodifier-vs-custom-views</link><guid isPermaLink="true">https://javalnanda.com/swiftui-view-extensions-vs-viewmodifier-vs-custom-views</guid><category><![CDATA[Swift]]></category><category><![CDATA[SwiftUI]]></category><category><![CDATA[iOS]]></category><category><![CDATA[Mobile Development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Thu, 08 Feb 2024 15:28:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707413885270/d6bf7bc6-cf4a-4a99-bf3d-4b00d8854c36.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We often need to modify the SwiftUI view in some way or the other. There are three ways in which we can achieve customization of the SwiftUI View:</p>
<ul>
<li><p>View Extensions</p>
</li>
<li><p>ViewModifiers</p>
</li>
<li><p>Custom Views</p>
</li>
</ul>
<p>We can <strong>almost</strong> produce the same results with the above alternatives, leading to confusion about when to use them. 🤔</p>
<p><strong>TL;DR:</strong></p>
<ul>
<li><p><em>View Extensions: To apply simple stylings (e.g. colour, padding, etc).</em></p>
</li>
<li><p><em>ViewModifiers: To apply state-based styling or complex styling(multiple modifiers).</em></p>
</li>
<li><p><em>Custom Views: For containers, when composing multiple views.</em></p>
</li>
</ul>
<p>Let's take a simple example of styling the <code>Text</code> label to be used as Headers.</p>
<p>Approach 1: Using View extension:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">View</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">applyHeaderStyle</span><span class="hljs-params">()</span></span> -&gt; some <span class="hljs-type">View</span> {
        lineLimit(<span class="hljs-number">1</span>)
        .font(.largeTitle)
        .fontDesign(<span class="hljs-type">Font</span>.<span class="hljs-type">Design</span>.serif)
    }
}
</code></pre>
<p>Approach 2: Using ViewModifier:</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">HeaderLabel</span>: <span class="hljs-title">ViewModifier</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">body</span><span class="hljs-params">(content: Content)</span></span> -&gt; some <span class="hljs-type">View</span> {
        content
            .lineLimit(<span class="hljs-number">1</span>)
            .font(.largeTitle)
            .fontDesign(<span class="hljs-type">Font</span>.<span class="hljs-type">Design</span>.serif)
    }
}
</code></pre>
<p>Both would give the same result visually if you check the following code in the preview:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">import</span> SwiftUI

<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ContentView</span>: <span class="hljs-title">View</span> </span>{
    <span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-comment">// Text styled using view extension</span>
            <span class="hljs-type">Text</span>(<span class="hljs-string">"Header Text"</span>)
                .applyHeaderStyle()

            <span class="hljs-comment">// Text styled using view modifier</span>
            <span class="hljs-type">Text</span>(<span class="hljs-string">"Header Text"</span>)
                .modifier(<span class="hljs-type">HeaderLabel</span>())
        }
    }
}

#<span class="hljs-type">Preview</span> {
    <span class="hljs-type">ContentView</span>()
}
</code></pre>
<p>We can further simply the API for accessing <code>HeaderLabel</code> modifier by extending the <code>View</code> with a function that applies the <code>.modifier()</code> . That is how it is demonstrated in Apple's <a target="_blank" href="https://developer.apple.com/documentation/swiftui/reducing-view-modifier-maintenance">documentation</a> also.</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">View</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">headerTextFormat</span><span class="hljs-params">()</span></span> -&gt; some <span class="hljs-type">View</span> {
        modifier(<span class="hljs-type">HeaderLabel</span>())
    }
}

<span class="hljs-comment">// Usage</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ContentView</span>: <span class="hljs-title">View</span> </span>{
    <span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-comment">// Text styled using view extension</span>
            <span class="hljs-type">Text</span>(<span class="hljs-string">"Header Text"</span>)
                .applyHeaderStyle()

            <span class="hljs-comment">// Text styled using view modifier</span>
            <span class="hljs-type">Text</span>(<span class="hljs-string">"Header Text"</span>)
                .headerTextFormat()
        }
    }
}
</code></pre>
<p>So, what's the difference between Approach 1 and Approach 2?</p>
<p>Visually, there is no difference for this simple customization which does not involve any states. But, we would notice a difference when you try to print the view if required for debugging as follows:</p>
<pre><code class="lang-bash">Type Of TextWithExtension::
 ModifiedContent&lt;ModifiedContent&lt;ModifiedContent&lt;Text, _EnvironmentKeyWritingModifier&lt;Optional&lt;Int&gt;&gt;&gt;, _EnvironmentKeyWritingModifier&lt;Optional&lt;Font&gt;&gt;&gt;, _EnvironmentKeyTransformModifier&lt;Array&lt;AnyFontModifier&gt;&gt;&gt;

Type Of TextWithModifier::
 ModifiedContent&lt;Text, HeaderLabel&gt;
</code></pre>
<p>As we can see, when muliple modifiers are applied the view modifier approach encapsulates the internals properly.</p>
<p>I would go for view extensions when applying simple customisation or adding syntactic sugar to existing modifiers as discussed in the previous <a target="_blank" href="https://javalnanda.com/mastering-conciseness-the-art-of-syntactic-sugar-in-code">blog</a>.</p>
<p>ViewModifier is the obvious choice when we want to apply styling based on <code>@State</code> . <code>ViewModifier</code> can have internal <code>@State</code> and it is mostly similar to <code>View</code> . Internal states are not possible with extensions. Note, we can still achieve it by passing the binding to the function in the extension but it would be ideal to use ViewModifier.</p>
<p>Suppose we want to allow the user to be able to drag the <code>Text</code> label and on release it should move back to its original position. We can define our custom <code>ViewModifier</code> in this case as follows:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">import</span> SwiftUI

<span class="hljs-keyword">private</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">SpringGesture</span>: <span class="hljs-title">ViewModifier</span> </span>{
    @<span class="hljs-type">State</span> <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> offset: <span class="hljs-type">CGSize</span> = .zero

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">body</span><span class="hljs-params">(content: Content)</span></span> -&gt; some <span class="hljs-type">View</span> {
        content
            .offset(x: offset.width, y: offset.height)
            .animation(.interactiveSpring(), value: offset)
            .simultaneousGesture(
                <span class="hljs-type">DragGesture</span>()
                    .onChanged { gesture <span class="hljs-keyword">in</span>
                        <span class="hljs-keyword">self</span>.offset = gesture.translation
                    }
                    .onEnded { value <span class="hljs-keyword">in</span>
                        offset = <span class="hljs-type">CGSize</span>.zero
                    }
            )
    }
}

<span class="hljs-keyword">private</span> <span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">View</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">applySpringGesture</span><span class="hljs-params">()</span></span> -&gt; some <span class="hljs-type">View</span> {
        modifier(<span class="hljs-type">SpringGesture</span>())
    }
}

<span class="hljs-comment">// Usage:</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ContentView</span>: <span class="hljs-title">View</span> </span>{
    <span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-type">Text</span>(<span class="hljs-string">"Drag me"</span>)
                .applySpringGesture()
        }
    }
}

#<span class="hljs-type">Preview</span> {
    <span class="hljs-type">ContentView</span>()
}
</code></pre>
<p>As we can see in the above example, we need an internal <code>@State</code> variable to keep track of <code>offset</code>.</p>
<p>Now, this can also be achieved by defining a custom <code>View</code> instead of <code>ViewModifier</code> . So, when to use custom views then?</p>
<p>If we take a look at SwiftUI's built-in API, containers such as <code>HStack</code> <code>VStack</code> are views whereas the styling API like <code>padding</code> <code>.background(content:)</code> are implemented as view modifiers.</p>
<p>So, whenever we are creating container views or creating views where defining its own type makes sence, we can use custom views instead of view modifiers.</p>
<p>For example, if we want to define a view that display's icon along with text:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">import</span> SwiftUI

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">TextWithIcon</span>: <span class="hljs-title">View</span> </span>{
    <span class="hljs-keyword">let</span> icon: <span class="hljs-type">Image</span>
    <span class="hljs-keyword">let</span> text: <span class="hljs-type">String</span>

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">init</span>(
        icon: <span class="hljs-type">Image</span>,
        text: <span class="hljs-type">String</span>
    ) {
        <span class="hljs-keyword">self</span>.icon = icon
        <span class="hljs-keyword">self</span>.text = text
    }

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">HStack</span>(alignment: .center, spacing: <span class="hljs-number">4</span>) {
            <span class="hljs-type">Text</span>(text)
            icon
                .resizable()
                .renderingMode(.template)
                .frame(width: <span class="hljs-number">16</span>, height: <span class="hljs-number">16</span>)
        }
    }
}

<span class="hljs-comment">// Usage:</span>
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ContentView</span>: <span class="hljs-title">View</span> </span>{
    <span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-type">TextWithIcon</span>(icon: <span class="hljs-type">Image</span>(systemName: <span class="hljs-string">"swift"</span>), text: <span class="hljs-string">"Hello Swift!"</span>)
        }
    }
}

#<span class="hljs-type">Preview</span> {
    <span class="hljs-type">ContentView</span>()
}
</code></pre>
<p>I hope this examples were helpful and clears the confusion of when to use view extensions, view modifiers and custom views in SwiftUI</p>
<p>Let me know if you found this helpful. Feel free to tweet me on <a target="_blank" href="https://twitter.com/javalnanda">Twitter</a> if you have any additional tips or feedback.</p>
<p>Thanks</p>
]]></content:encoded></item><item><title><![CDATA[Mastering Conciseness: The Art of Syntactic Sugar in Code]]></title><description><![CDATA[One of the main rules for writing clean code is that it should clearly show what it's meant to do. There are a few things to keep in mind when doing this. It means giving variables and function names that make sense, making sure each part of the code...]]></description><link>https://javalnanda.com/mastering-conciseness-the-art-of-syntactic-sugar-in-code</link><guid isPermaLink="true">https://javalnanda.com/mastering-conciseness-the-art-of-syntactic-sugar-in-code</guid><category><![CDATA[clean code]]></category><category><![CDATA[iOS]]></category><category><![CDATA[SwiftUI]]></category><category><![CDATA[Swift]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[software development]]></category><category><![CDATA[Mobile Development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 06 Feb 2024 09:27:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707211750252/51bb8ed7-6bed-4e90-a681-762254124a37.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the main rules for writing clean code is that it should clearly show what it's meant to do. There are a few things to keep in mind when doing this. It means giving variables and function names that make sense, making sure each part of the code only does one thing without causing other unexpected effects, keeping related code together so it's easier to understand when reading from the top down, etc. For a more detailed guide, I recommend checking out the Clean Code book.</p>
<p>In this blog, I want to talk about how we can make the code we write using the platform's built-in API more straightforward and concise. We often become accustomed to using the platform's native API in a certain way because that's how it's explained in the documentation or tutorials. As a result, we might not realize whether our code is clear or not because it seems obvious to us.</p>
<p>Let's take a look at an example of SwiftUI code below:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-comment">// some content</span>
        }
        .frame(maxWidth: .infinity)
    }
</code></pre>
<p>Can you determine the exact behavior of <code>.frame(maxWidth: .infinity)</code> if you're not familiar with SwiftUI? Does it expand to match the width of the parent container? Will it also change the parent container's width, causing it to expand?</p>
<p>Now, what about the code below:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> body: some <span class="hljs-type">View</span> {
        <span class="hljs-type">VStack</span> {
            <span class="hljs-comment">// some content</span>
        }
        .fillMaxWidth()
    }
</code></pre>
<p>Isn't <code>.fillMaxWidth()</code> more concise compared to the previous code? The initial code might not be confusing for an iOS developer, but it can be for someone coming from a different platform. I realized this when I was working on both Android and iOS apps, building UI in Jetpack Compose and SwiftUI, respectively. Drawing inspiration from Jetpack Compose, I created syntactic sugar extensions for SwiftUI View. This not only expresses the intent clearly but also reduces verbosity.</p>
<pre><code class="lang-swift"><span class="hljs-keyword">import</span> SwiftUI

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">extension</span> <span class="hljs-title">View</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">fillMaxSize</span><span class="hljs-params">(alignment: Alignment = .center)</span></span> -&gt; some <span class="hljs-type">View</span> {
        frame(maxWidth: .infinity, maxHeight: .infinity, alignment: alignment)
    }

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">fillMaxWidth</span><span class="hljs-params">(alignment: Alignment = .center)</span></span> -&gt; some <span class="hljs-type">View</span> {
        frame(maxWidth: .infinity, alignment: alignment)
    }

    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">fillMaxHeight</span><span class="hljs-params">(alignment: Alignment = .center)</span></span> -&gt; some <span class="hljs-type">View</span> {
        frame(maxHeight: .infinity, alignment: alignment)
    }
}
</code></pre>
<p>You can find the extension file with additional extensions <a target="_blank" href="https://gist.github.com/javalnanda/1f23107bf9a7cd0888c6e3cc99c4d975">here</a></p>
<p>I hope this example helps you look for areas where you can improve the code for more clarity. Looking at other platforms and frameworks also helps us gain a different perspective and draw inspiration from them.</p>
<p>Let me know if you found this helpful. Feel free to tweet me on <a target="_blank" href="https://twitter.com/javalnanda">Twitter</a> if you have any additional tips or feedback.</p>
<p>Thanks</p>
]]></content:encoded></item><item><title><![CDATA[Optimising Collaboration with Pull Request Templates]]></title><description><![CDATA[Pull requests are the standard way to request a change to be merged into the main or stable branch. Having fellow developers or maintainers review the change is crucial to ensure its quality, although exceptions may apply for teams using pair program...]]></description><link>https://javalnanda.com/optimising-collaboration-with-pull-request-templates</link><guid isPermaLink="true">https://javalnanda.com/optimising-collaboration-with-pull-request-templates</guid><category><![CDATA[Pull Requests]]></category><category><![CDATA[templates]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Thu, 01 Feb 2024 11:42:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706786987257/81edfeae-142d-40c4-99bc-52ef51a53775.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Pull requests are the standard way to request a change to be merged into the main or stable branch. Having fellow developers or maintainers review the change is crucial to ensure its quality, although exceptions may apply for teams using pair programming or mob programming approaches. Since changes shouldn't disrupt the existing working software, having an effective review process is vital.</p>
<p>During the review, reviewers need clear context about the changes being reviewed. Unclear information can lead to back-and-forth discussions, causing delays and unnecessary context switching, ultimately impacting team velocity.</p>
<p>To ensure that contributors provide sufficient information about the changes to be reviewed, it's ideal to use a standard pull request template that prompts them for the necessary details.</p>
<p>Both GitHub and GitLab supports pull request templates. The details can be found at the following links respectively:</p>
<ul>
<li><p><a target="_blank" href="https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository">GitHub</a></p>
</li>
<li><p><a target="_blank" href="https://docs.gitlab.com/ee/user/project/description_templates.html">GitLab</a></p>
</li>
</ul>
<p>Based on what suits your team needs and technology, various check lists and contextual questions can be added to the PR templates for the contributor.</p>
<p>Here is one such sample of the PR template:</p>
<pre><code class="lang-markdown"><span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">!</span> <span class="hljs-attr">--</span> <span class="hljs-attr">Remove</span> <span class="hljs-attr">sections</span> <span class="hljs-attr">that</span> <span class="hljs-attr">are</span> <span class="hljs-attr">not</span> <span class="hljs-attr">relevant</span> <span class="hljs-attr">to</span> <span class="hljs-attr">PR</span> <span class="hljs-attr">--</span>&gt;</span></span> 
<span class="hljs-section">## 🎯 Description, Motivation and Context</span>

<span class="hljs-section">## 🔗 Link to the resources (design, issue/feature ticket)</span>

<span class="hljs-section">## ✅ How has this been tested?</span>

<span class="hljs-section">## 📷/🎥 Screenshots:</span>

<span class="hljs-section">## ☑️ Checklist:</span>
You have to check all boxes before merging

[ ] Updated the PR name to follow our PR naming guidelines
[ ] Wrote unit tests and/or ensured the tests suite is passing
[ ] Checked linter on local.
[ ] If needed I updated documentation.

When working on UI: 
[ ] I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
[ ] I verified the UI on smaller devices
[ ] I verified the UI on devices with notch
[ ] I verified the UI on orientation changes

<span class="hljs-section">## 🚉 Which modules have been affected?</span>
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">!</span> <span class="hljs-attr">--</span> <span class="hljs-attr">In</span> <span class="hljs-attr">case</span> <span class="hljs-attr">of</span> <span class="hljs-attr">Monorepo</span> <span class="hljs-attr">--</span>&gt;</span></span> 
[ ] Core
[ ] UIKit
[ ] Module 1
[ ] Module 2
[ ] CI configuration

<span class="hljs-section">## 🧐 Any special note?</span>
</code></pre>
<p>The team can continually adjust this template to fit their needs better. They can remove sections that aren't very helpful and add sections that focus on the details important for the review.</p>
<p>There are various benefits of using a pull request template:</p>
<ol>
<li><p><strong>Standardisation</strong>: Pull request templates provide a standardised format for creating pull requests. This consistency ensures that essential information, such as the purpose of the changes, related issues, testing steps, and any necessary context, is included with each pull request. Standardization reduces confusion and ensures that contributors provide the necessary details for efficient code review.</p>
</li>
<li><p><strong>Clarity and Context</strong>: It helps reviewers understand the changes being proposed and provides them with the necessary context to provide valuable feedback.</p>
</li>
<li><p><strong>Efficiency</strong>: Templates prompts the contributors to provide essential information upfront. This reduces the back-and-forth communication between contributors and reviewers and speeds up the review process.</p>
</li>
<li><p><strong>Saves CI Cost:</strong> Many teams use CI integration, which kicks off when a pull request is created. This ensures that all workflow steps pass, such as lint checks and running test suites. If, for example, a lint check fails, it wastes CI credits/build time and adds unnecessary costs to the company. A checklist for contributors ensures they validate all necessary steps before creating pull requests, preventing oversights.</p>
</li>
</ol>
<p>Here are few more resources for the templates:<br /><a target="_blank" href="https://github.com/devspace/awesome-github-templates?tab=readme-ov-file">https://github.com/devspace/awesome-github-templates?tab=readme-ov-file</a></p>
<p><a target="_blank" href="https://github.com/TalAter/open-source-templates?tab=readme-ov-file">https://github.com/TalAter/open-source-templates?tab=readme-ov-file</a></p>
<p><a target="_blank" href="https://github.com/stevemao/github-issue-templates">https://github.com/stevemao/github-issue-templates</a></p>
<p>Let me know if you found this helpful. Feel free to tweet me on <a target="_blank" href="https://twitter.com/javalnanda">Twitter</a> if you have any additional tips or feedback.</p>
<p>Thanks</p>
]]></content:encoded></item><item><title><![CDATA[Preventing Code Execution While Running Tests from CLI for Swift Package]]></title><description><![CDATA[Ideally, you would not require conditional logic in your production code to check if tests are running or the main app target is running. But, there are situations where you can't get around it in case of Integration tests or UI Tests.
There are vari...]]></description><link>https://javalnanda.com/preventing-code-execution-while-running-tests-from-cli-for-swift-package</link><guid isPermaLink="true">https://javalnanda.com/preventing-code-execution-while-running-tests-from-cli-for-swift-package</guid><category><![CDATA[Testing]]></category><category><![CDATA[iOS]]></category><category><![CDATA[Swift Package Manager]]></category><category><![CDATA[Swift]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 30 Jan 2024 09:14:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706605913644/9dcb9d3a-2a55-4005-9050-013837e5c116.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ideally, you would not require conditional logic in your production code to check if tests are running or the main app target is running. But, there are situations where you can't get around it in case of Integration tests or UI Tests.</p>
<p>There are various solutions which you might have come across such as:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> isRunningTests: <span class="hljs-type">Bool</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-type">ProcessInfo</span>.processInfo.environment[<span class="hljs-string">"XCTestConfigurationFilePath"</span>] != <span class="hljs-literal">nil</span>
}

<span class="hljs-comment">// Usage</span>
<span class="hljs-keyword">if</span> isRunningTests {
} <span class="hljs-keyword">else</span> {
}
</code></pre>
<p>Or setting your own environment variable for the test scheme/configuration and check it as below:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> isRunningTests: <span class="hljs-type">Bool</span> {
    <span class="hljs-type">ProcessInfo</span>.processInfo.environment[<span class="hljs-string">"isRunningTest"</span>] != <span class="hljs-literal">nil</span> 
}
</code></pre>
<p>While these solutions work fine for unit tests when running tests from Xcode (⌘+ U), it does not work when running tests from command line for a swift package using following command: <code>swift test</code></p>
<h3 id="heading-solution">Solution:</h3>
<p>While running tests from the command line, the name of the process that is getting executed is <code>xctest</code> . So, we can check if the current process is running tests as follows:</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> isRunningTests: <span class="hljs-type">Bool</span> {
    <span class="hljs-type">ProcessInfo</span>.processInfo.processName == <span class="hljs-string">"xctest"</span>
}
</code></pre>
<p>Let me know if you found this helpful. Feel free to tweet me on <a target="_blank" href="https://twitter.com/javalnanda">Twitter</a> if you have any additional tips or feedback.</p>
<p>Thanks</p>
]]></content:encoded></item><item><title><![CDATA[Adding test target to Swift Package (--type executable)]]></title><description><![CDATA[If you have used SPM to create the command line application before Swift 5.9.0, the project structure used to be as follows:
Package.swift
README.md
.gitignore
Sources/
Sources/SamplePackage/main.swift
Tests/
Tests/LinuxMain.swift
Tests/SamplePackage...]]></description><link>https://javalnanda.com/adding-test-target-to-swift-package-type-executable</link><guid isPermaLink="true">https://javalnanda.com/adding-test-target-to-swift-package-type-executable</guid><category><![CDATA[Swift]]></category><category><![CDATA[spm]]></category><category><![CDATA[Swift Package Manager]]></category><category><![CDATA[command line application]]></category><category><![CDATA[cli]]></category><category><![CDATA[command line]]></category><category><![CDATA[Testing]]></category><category><![CDATA[test-automation]]></category><category><![CDATA[iOS]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Wed, 24 Jan 2024 16:27:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706113412752/e558e352-8fc2-4b7d-8ced-0d5f9ade95c0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you have used SPM to create the command line application before <code>Swift 5.9.0</code>, the project structure used to be as follows:</p>
<pre><code class="lang-swift"><span class="hljs-type">Package</span>.swift
<span class="hljs-type">README</span>.md
.gitignore
<span class="hljs-type">Sources</span>/
<span class="hljs-type">Sources</span>/<span class="hljs-type">SamplePackage</span>/main.swift
<span class="hljs-type">Tests</span>/
<span class="hljs-type">Tests</span>/<span class="hljs-type">LinuxMain</span>.swift
<span class="hljs-type">Tests</span>/<span class="hljs-type">SamplePackageTests</span>/
<span class="hljs-type">Tests</span>/<span class="hljs-type">SamplePackageTests</span>/<span class="hljs-type">SamplePackageTests</span>.swift
<span class="hljs-type">Tests</span>/<span class="hljs-type">SamplePackageTests</span>/<span class="hljs-type">XCTestManifests</span>.swift
</code></pre>
<p>The test target and the basic scaffolding for it were available on the package creation.</p>
<p>With the recent <a target="_blank" href="https://forums.swift.org/t/update-to-swift-package-init-templates/63145">changes</a> to simplify the templating of the package <code>--type</code> , test target is only added to the package <code>--type library</code> and not to <code>--type tool</code> and <code>--type executable</code>.</p>
<p><code>tool</code> is the newly added type that creates the package of type <code>executable</code> with the dependency for <a target="_blank" href="https://github.com/apple/swift-argument-parser">SwiftArgumentParser</a> already added to the package.</p>
<p>The new file structure looks as follows:</p>
<pre><code class="lang-bash">// --<span class="hljs-built_in">type</span> executable
./executable
./executable/.gitignore
./executable/Package.swift
./executable/Sources
./executable/Sources/executable.swift

// --<span class="hljs-built_in">type</span> tool
./tool
./tool/.gitignore
./tool/Package.swift
./tool/Sources
./tool/Sources/tool.swift

// --<span class="hljs-built_in">type</span> empty
./empty
./empty/Package.swift

// --<span class="hljs-built_in">type</span> library
./library
./library/Tests
./library/Tests/libraryTests
./library/Tests/libraryTests/libraryTests.swift
./library/.gitignore
./library/Package.swift
./library/Sources
./library/Sources/library
./library/Sources/library/library.swift
</code></pre>
<p>You can find more details about the change in this <a target="_blank" href="https://github.com/apple/swift-package-manager/pull/6144">PR</a>.</p>
<p>Now, if you want to add the test target to the package of <code>--type tool</code> or <code>--type executable</code> with newer tool-chain of <code>Swift 5.9.0</code>, you can follow these steps:</p>
<ol>
<li><p>Create the package:</p>
<pre><code class="lang-bash"> $ mkdir SamplePackage
 $ <span class="hljs-built_in">cd</span> SamplePackage
 $ swift package init --<span class="hljs-built_in">type</span> executable
</code></pre>
<pre><code class="lang-bash"> Creating executable package: SamplePackage
 Creating Package.swift
 Creating .gitignore
 Creating Sources/
 Creating Sources/main.swift
</code></pre>
</li>
<li><p>Open <code>Package.swift</code>. It should look like this:</p>
<pre><code class="lang-swift"> <span class="hljs-comment">// swift-tools-version: 5.9</span>
 <span class="hljs-comment">// The swift-tools-version declares the minimum version of Swift required to build this package.</span>

 <span class="hljs-keyword">import</span> PackageDescription

 <span class="hljs-keyword">let</span> package = <span class="hljs-type">Package</span>(
     name: <span class="hljs-string">"SamplePackage"</span>,
     targets: [
         <span class="hljs-comment">// Targets are the basic building blocks of a package, defining a module or a test suite.</span>
         <span class="hljs-comment">// Targets can depend on other targets in this package and products from dependencies.</span>
         .executableTarget(
             name: <span class="hljs-string">"SamplePackage"</span>),
     ]
 )
</code></pre>
</li>
<li><p>Update <code>Package.swift</code> as below:</p>
<pre><code class="lang-swift"> <span class="hljs-comment">// swift-tools-version: 5.9</span>
 <span class="hljs-comment">// The swift-tools-version declares the minimum version of Swift required to build this package.</span>

 <span class="hljs-keyword">import</span> PackageDescription

 <span class="hljs-keyword">let</span> package = <span class="hljs-type">Package</span>(
     name: <span class="hljs-string">"SamplePackage"</span>,
     targets: [
         <span class="hljs-comment">// Targets are the basic building blocks of a package, defining a module or a test suite.</span>
         <span class="hljs-comment">// Targets can depend on other targets in this package and products from dependencies.</span>
         .executableTarget(
             name: <span class="hljs-string">"SamplePackage"</span>,
             path: <span class="hljs-string">"Sources"</span>
         ),
         .testTarget(
             name: <span class="hljs-string">"SamplePackageTests"</span>,
             dependencies: [<span class="hljs-string">"SamplePackage"</span>],
             path: <span class="hljs-string">"Tests"</span>
         )
     ]
 )
</code></pre>
<p> Add <code>.testTarget</code> to the array of <code>targets</code> and add the main target <code>SamplePackage</code> to its dependencies list. Also, add the path to the <code>Tests</code> folder.</p>
</li>
<li><p>Add a sample test file with <code>@testable import &lt;main module&gt;</code> to validate that the tests can resolve the main module.</p>
<p> Example test file:</p>
<pre><code class="lang-swift"> <span class="hljs-keyword">import</span> XCTest
 <span class="hljs-meta">@testable</span> <span class="hljs-keyword">import</span> SamplePackage

 <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ExampleTests</span>: <span class="hljs-title">XCTestCase</span> </span>{
     <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">testExample</span><span class="hljs-params">()</span></span> {

     }
 }
</code></pre>
<p> The updated file structure should look as below:</p>
<pre><code class="lang-bash"> SamplePackage
 SamplePackage/.gitignore
 SamplePackage/Package.swift
 SamplePackage/Sources
 SamplePackage/Sources/main.swift
 SamplePackage/Tests/ExampleTests.swift
</code></pre>
</li>
<li><p>Validate if tests are running successfully via Xcode <code>⌘ + U</code> and via the command line <code>swift test</code></p>
</li>
</ol>
<p>Let me know if you found this helpful. Feel free to tweet me on <a target="_blank" href="https://twitter.com/javalnanda">Twitter</a> if you have any additional tips or feedback.</p>
<p>Thanks.</p>
]]></content:encoded></item><item><title><![CDATA[Reading Standard Input (StdIn) in Swift]]></title><description><![CDATA[Hello! Swifty Buddies. If you have tried out some of the challenges on Hackerrank using Swift as a preferred language, you might have came across this situation of reading input from StdIn because that is how the Test case inputs are provided on Hack...]]></description><link>https://javalnanda.com/reading-standard-input-stdin-in-swift-45f81b3caf2c</link><guid isPermaLink="true">https://javalnanda.com/reading-standard-input-stdin-in-swift-45f81b3caf2c</guid><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Thu, 01 Jun 2017 11:51:39 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706115820784/83f4c1a2-3ed2-4196-bc8d-e4bb504d00e1.png" alt /></p>
<p>Hello! Swifty Buddies. If you have tried out some of the challenges on Hackerrank using Swift as a preferred language, you might have came across this situation of reading input from StdIn because that is how the Test case inputs are provided on Hackerrank.</p>
<p>For most of the languages, you will get a boilerplate code and you just need to write your logic but as soon as you select swift as a language, you will get this:</p>
<p>import Foundation;</p>
<p>// Enter your code here</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706115822292/1bf98977-2608-4036-bf8a-6b2baa8f6267.gif" alt /></p>
<p>Yeah, that’s all you got 🙂</p>
<p><strong>How to read Standard Input?</strong></p>
<p>To read standard input in swift you will need to use <a target="_blank" href="https://developer.apple.com/reference/swift/1641199-readline">readLine()</a> function.</p>
<p>Ok, where to write code?</p>
<p>One option is to create MacOS –&gt;Command Line Tool application but if you are used to only iOS applications, this will take some time to figure it out. Let us stick with Playgrounds only which is fun to work with for us.</p>
<p>But, readLine() always return nil in the playground. How do I test it? Don’t worry, I will come to that part. First, let us look at the logic that we will need to read inputs for Hackerrank.</p>
<h4 id="heading-reading-string">Reading string</h4>
<blockquote>
<p>let string = readLine(strippingNewline: true)!</p>
</blockquote>
<p>It is ok to use force wrap over here since on Hackerrank input values are always present. But, don’t do this in production code.</p>
<h4 id="heading-reading-int">Reading Int</h4>
<blockquote>
<p>let number = Int(readLine(strippingNewline: true)!)!</p>
</blockquote>
<h4 id="heading-reading-array-of-string">Reading array of string</h4>
<p>For inputs sample as below:</p>
<blockquote>
<p>a b c d b</p>
</blockquote>
<p>You can ready string array by splitting using the space character as below:</p>
<blockquote>
<p>let stringArray = readLine(strippingNewline: true)!.characters<br />.split {$0 == ” “}<br />.map (String.init)</p>
</blockquote>
<h4 id="heading-writing-to-standard-output">Writing to standard output</h4>
<p>You can write the final output using the same way we print to console using print() function.</p>
<h3 id="heading-example">Example</h3>
<p>Let us take one of the existing example from Hackerrank.</p>
<p>**Problem Description:**<em>Given two strings, and , that may or may not be of the same length, determine the minimum number of character deletions required to make and anagrams. Any characters can be deleted from either of the strings.</em></p>
<p><strong>Sample Input:</strong></p>
<pre><code class="lang-bash">cde  
abc
</code></pre>
<p>Write your solution in playground. Note that the playground will show error as it will encounter nil for readLine(). You can guard it or provide default value for coming up with the solution and can change it back to readLine() code when it is ready to paste it in Hackerrank’s editor.</p>
<p>Here is the solution which I came up with for this problem:</p>
<h3 id="heading-testing">Testing</h3>
<p>Now, to test it save it as Anagram.swift file at your preferred location. Go to that location on terminal and type:</p>
<blockquote>
<p>swift Anagram.swift</p>
</blockquote>
<p>Now, you are ready to give inputs and test it.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/0*NlksEhSi5hM2YVa1.png" alt /></p>
<p>Voila!! You are ready to paste your code in Hackerrank now. Test with few different inputs and once you are ready, make sure to comment all the print logs except the final answer one and paste it in Hackerrank to run and test it.</p>
<p>This might get you through most of the challenges by writing in swift.</p>
<p>Let me know your feedbacks and what solution did you come up with for this problem? 🙂</p>
]]></content:encoded></item><item><title><![CDATA[Creating optional protocol method in swift]]></title><description><![CDATA[If you are coming from Obj-C to Swift, you might have realized that there is no optional keyword available in Swift to define an optional protocol method in Swift Protocols.
We can achieve it via @objc attribute. But in this post, I will discuss the ...]]></description><link>https://javalnanda.com/creating-optional-protocol-method-in-swift-e34ae7f37d52</link><guid isPermaLink="true">https://javalnanda.com/creating-optional-protocol-method-in-swift-e34ae7f37d52</guid><category><![CDATA[Swift]]></category><category><![CDATA[iOS]]></category><category><![CDATA[ios app development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Thu, 18 May 2017 05:29:02 GMT</pubDate><content:encoded><![CDATA[<p>If you are coming from Obj-C to Swift, you might have realized that there is no optional keyword available in Swift to define an optional protocol method in Swift Protocols.</p>
<p>We can achieve it via @objc attribute. But in this post, I will discuss the alternative way of achieving it in a purely swift way using the power of extension.</p>
<p>Using protocol extension we can provide a default implementation of the method we want to treat as optional. This will allow user to opt out the implementation of the method as there is a default implementation provided for it.</p>
<p>Let us take following example from <a target="_blank" href="https://github.com/javalnanda/JNDropDownMenu">JNDropDownMenu</a> library:</p>
<p>public protocol JNDropDownMenuDataSource: class {<br />func numberOfRows(in column: NSInteger, for menu: JNDropDownMenu) -&gt; Int<br />func titleForRow(at indexPath: JNIndexPath, for menu: JNDropDownMenu) -&gt; String<br />func numberOfColumns(in menu: JNDropDownMenu) -&gt; NSInteger<br />func titleFor(column: Int, menu: JNDropDownMenu) -&gt; String<br />}</p>
<p>In above protocol, I wanted to keep the last two methods optional. To do that I can provide a default implementation of it in the protocol extension as follow:</p>
<p>public extension JNDropDownMenuDataSource {<br />func numberOfColumns(in menu: JNDropDownMenu) -&gt; NSInteger {<br />return 1<br />}<br />func titleFor(column: Int, menu: JNDropDownMenu) -&gt; String {<br />return menu.datasource?.titleForRow(at: JNIndexPath(column: column, row: 0), for: menu) ?? ""<br />}<br />}</p>
<p>Due to this default implementation, you are now allowed to opt out these methods in the class conforming to this protocol and can implement it only if you want to override the default implementation and provide your own value.</p>
<p>Hope this helps you to achieve the optional behavior in a pure Swift way.</p>
<p>Happy Coding! 🙂</p>
]]></content:encoded></item><item><title><![CDATA[How to use AlamofireObjectMapper?]]></title><description><![CDATA[If you are using Alamofire for Networking in Swift, this article will be helpful for you.
AlamofireObjectMapper is an extension to Alamofire which automatically converts JSON response data into swift objects using ObjectMapper
Usage
AlamofireObjectMa...]]></description><link>https://javalnanda.com/how-to-use-alamofireobjectmapper-c0d9820779bf</link><guid isPermaLink="true">https://javalnanda.com/how-to-use-alamofireobjectmapper-c0d9820779bf</guid><category><![CDATA[Swift]]></category><category><![CDATA[json]]></category><category><![CDATA[iOS]]></category><category><![CDATA[mobile app development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Wed, 10 May 2017 13:27:38 GMT</pubDate><content:encoded><![CDATA[<p>If you are using Alamofire for Networking in Swift, this article will be helpful for you.</p>
<p><a target="_blank" href="https://github.com/tristanhimmelman/AlamofireObjectMapper">AlamofireObjectMapper</a> is an extension to Alamofire which automatically converts JSON response data into swift objects using <a target="_blank" href="https://github.com/Hearst-DD/ObjectMapper/">ObjectMapper</a></p>
<h3 id="heading-usage">Usage</h3>
<p>AlamofireObjectMapper can be installed via <a target="_blank" href="https://cocoapods.org/">Cocoapods</a> or <a target="_blank" href="https://github.com/Carthage/Carthage">Carthage</a></p>
<p>Consider following sample JSON returned from an API</p>
<p>It returns an array of Projects along with some data relevant to it. Now I want to map this response directly to an array of custom object of type Project.</p>
<p>To map this response to our model class, we need our model class Project to conform to the Mappable protocol. Please find below how I defined Project model class. I have defined only relevant information I want to map.</p>
<p>Note: You can use this <a target="_blank" href="https://github.com/Ahmed-Ali/JSONExport">JSONExport</a> utility application available for mac which helps to auto-generate model classes for various formats.</p>
<p>AlamofireObjectMapper extension provides various ways to access response data.</p>
<ol>
<li>Directly map response to your model object if you wish to map entire response</li>
</ol>
<p>Alamofire.request(URL).responseObject { (response: DataResponse) in<br />let projectResponse = response.result.value<br />}</p>
<p>Here ProjectResponse will be your model object which will conform to the mappable protocol to map the entire response mentioned about.</p>
<p>2. Using <strong>Keypath</strong> to access required data. For e.g we want to access the result array. So, we can use keypath along with the <strong>responseArray</strong> function of AlamofireObjectMapper extension as follow:</p>
<p>Alamofire.request(URL).responseArray(keyPath: "result") { (response: DataResponse&lt;[Project]&gt;) in<br />let projects = response.result.value<br />}</p>
<p>You can find below working snippet of the function:</p>
<p>Don’t get confused by `.validate()` in above code. It is Alamofire function which validates the success or failure of a request based on HTTP Code.</p>
<h3 id="heading-alamofireobjectmapper-vs-swiftyjson">AlamofireObjectMapper Vs SwiftyJSON</h3>
<p>Now you might be confused whether to use AlamofireObjectMapper of SwiftyJSON? In fact, you can use both together also. SwiftyJSON is still helpful for you where you don’t want to create model classes and just want to retrieve values on demand from the response for e.g. checking status, error or getting pageSize of the response.</p>
<p>You can find the sample project for above example over <a target="_blank" href="https://github.com/javalnanda/AlamofireObjectMapperSample">here</a></p>
<p>Do comment if you have any questions or suggestions.</p>
]]></content:encoded></item><item><title><![CDATA[How to use Xcode Code Snippet Library?]]></title><description><![CDATA[Xcode Code Snippet Library is very useful and handy library of reusable code snippets.
For developers who are starting out iOS development and yet to explore all the features of Xcode, this article is for you.
Xcode Code Snippet Library is accessible...]]></description><link>https://javalnanda.com/how-to-use-xcode-code-snippet-library-8cd621028f0b</link><guid isPermaLink="true">https://javalnanda.com/how-to-use-xcode-code-snippet-library-8cd621028f0b</guid><category><![CDATA[Xcode]]></category><category><![CDATA[iOS]]></category><category><![CDATA[tips]]></category><category><![CDATA[mobile app development]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Sun, 30 Apr 2017 09:45:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706165851071/9ca3cbcb-9fce-44b8-b19a-3b1f863eb7a6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Xcode Code Snippet Library is very useful and handy library of reusable code snippets.</p>
<p>For developers who are starting out iOS development and yet to explore all the features of Xcode, this article is for you.</p>
<p>Xcode Code Snippet Library is accessible from the second tab beside the Object Library from where we grab all the UI components to drag and drop on Storyboard.</p>
<p>It already has some pre-defined code snippets which you can simply drag and drop on your source code and use it by editing as per your needs. You can search for available snippets from the Filter search bar available at the bottom of the library.</p>
<p>For e.g You can use a predefined snippet for swift for statement from the library as shown below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706116173020/9db69ef5-8f78-46d5-b2e3-2c31273c92b7.gif" alt /></p>
<p>predefined code snippet from library</p>
<p>Pretty hand right? But it is not just limited to predefined snippets available in the library. You can define your own code snippet and save it inside this library.</p>
<p>For e.g the most used snippets we might need are table view delegate methods. Let us see how we can add them to a library:</p>
<p><a target="_blank" href="http://screencast-o-matic.com/watch/cbfblwXhB4"><strong>Adding custom code snippet to Xcode snippet library</strong><br /><em>Edit description</em>screencast-o-matic.com</a></p>
<p>As seen in above video, you can simply drag and drop the snippet on Xcode Code Snippet Library and it will prompt a window to add a name for your snippet and there you go. You created your own custom snippet to reuse later.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706116174982/2b386f7f-2998-437d-8572-966873280762.gif" alt /></p>
<p>Wait! There is more to it :] Did you notice there were few other fields when you gave a name for your code snippets?</p>
<p><img src="https://cdn-images-1.medium.com/max/800/0*G4QB7FtZVuUIapR9.png" alt /></p>
<p>Double click on the snippet you just created and go to edit mode. You will see the window same as above screenshot. Here you can add more information like the summary, platform(ios, macOS, etc), Completion Shortcut and Completion Scopes.</p>
<p><strong>Completion Shortcut:</strong></p>
<p>This will help you to autocomplete your code snippet without the need of drag and drop from the library. Completion Scopes define where the completion shortcut will work. Let us see this in action based on values I have set as per above screenshot.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*3b9JMBDdhpgSf1Ck5MJP8A.gif" alt /></p>
<p>snippet auto-completion</p>
<p>As you can see, I defined the completion shortcut within Class Implementations Scope hence it is not available at Top Level scope but can be easily accessed at the class level.</p>
<p>If you find this useful, share with other fellow developers and spread the knowledge 🙂</p>
<p>Happy Coding!</p>
]]></content:encoded></item><item><title><![CDATA[Use SwiftyJSON to deal with JSON data in Swift]]></title><description><![CDATA[How many time did you get lost in optional chaining while dealing with JSON data in Swift? The struggle is real and code gets really messy while parsing complex JSON data.
Let us take an example of the following type of JSON data that you might recei...]]></description><link>https://javalnanda.com/use-swiftyjson-to-deal-with-json-data-in-swift-96d59663a378</link><guid isPermaLink="true">https://javalnanda.com/use-swiftyjson-to-deal-with-json-data-in-swift-96d59663a378</guid><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Mon, 03 Apr 2017 12:57:08 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706115829164/21a8b7cf-890b-4520-bd1d-45e709934012.png" alt /></p>
<p>How many time did you get lost in optional chaining while dealing with JSON data in Swift? The struggle is real and code gets really messy while parsing complex JSON data.</p>
<p>Let us take an example of the following type of JSON data that you might receive from API Call:</p>
<h3 id="heading-standard-way">Standard Way</h3>
<p>Now to access the “title” of the “glossary”, the standard way we would write is:</p>
<h3 id="heading-optional-chaining">Optional Chaining</h3>
<p>Or if we do optional chaining it will look messy even if we are just accessing first level element of JSON</p>
<h3 id="heading-swiftyjson-way">SwiftyJSON Way</h3>
<p>Now, let us see how to parse it using SwiftyJSON:</p>
<iframe src="https://giphy.com/embed/l0MYEqEzwMWFCg8rm/twitter/iframe" width="480" height="270"></iframe>

<p>Yeah! no tension of optional unwrapping, simply access it via keys you want and SwiftyJSON takes care of the rest.</p>
<p>And guess what? Even if you access a wrong key by mistake, .string property takes care of safety.</p>
<p>Hence, SwiftyJSON makes our life easier to deal with JSON data compared to the standard way of dealing with it.</p>
<p>To use <a target="_blank" href="https://github.com/SwiftyJSON/SwiftyJSON">SwiftyJSON</a>, you can integrate it either via <a target="_blank" href="http://cocoapods.org/">Cocoapods</a> or <a target="_blank" href="https://github.com/Carthage/Carthage">Carthage</a>.</p>
<p>And finally, there is even an extension to make serializing <a target="_blank" href="https://github.com/Alamofire/Alamofire">Alamofire</a>‘s response with <a target="_blank" href="https://github.com/SwiftyJSON/SwiftyJSON">SwiftyJSON</a> easily: <a target="_blank" href="https://github.com/SwiftyJSON/Alamofire-SwiftyJSON">Alamofire-SwiftyJSON</a>.</p>
<p>Found it useful? Share it with other fellow developers to help them write more swiftier code.</p>
]]></content:encoded></item><item><title><![CDATA[How affordable are IoT solutions for those who actually need it?]]></title><description><![CDATA[Can farmers in developing/under developed country really afford IoT solutions?
Almost everyone in tech might be familiar with this term IoT (Internet of Things) which is the talk of the town from past few years.
IoT is considered as the future and al...]]></description><link>https://javalnanda.com/how-affordable-are-iot-solutions-for-those-who-actually-need-it-8e4ab55183b7</link><guid isPermaLink="true">https://javalnanda.com/how-affordable-are-iot-solutions-for-those-who-actually-need-it-8e4ab55183b7</guid><category><![CDATA[iot]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Mon, 20 Mar 2017 15:16:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706166279818/ac904740-0c64-4a06-b867-54d44a5a90cf.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Can farmers in developing/under developed country really afford IoT solutions?</p>
<p>Almost everyone in tech might be familiar with this term <a target="_blank" href="https://en.wikipedia.org/wiki/Internet_of_things">IoT</a> (Internet of Things) which is the talk of the town from past few years.</p>
<p>IoT is considered as the future and all most all tech companies are embracing it and providing different solutions using it. If I say it in a better way, few companies are actually working on providing usable solutions for IoT both in terms of hardware and software and rest of the companies are trying to be the part of the race by projecting as IoT application provider which is the client interface part of the IoT hardware, same as any other business application. Which is fine, I am not against that as a user-facing interface is also necessary to connect with IoT hardware and provide necessary info and take actions. But, IoT applications are not the heart of the IoT solutions.</p>
<p>Now, what am I trying to express by the title of this blog? Let me try to explain what I feel with context to various case studies and IoT solution articles I come across every day on LinkedIn and almost every tech blogs.</p>
<p>I would like to take as an example one particular area for which IoT solutions are proposed. That is: <strong>IoT is the Future of Farming.</strong></p>
<p>It is definitely the future of farming, I am not against that but I am saddened with the way IoT solutions are provided and I don’t see a way in which farmers of a developing country or an under-developed country can actually use it in near future. And these solutions are actually needed to be applied for them to cut down the cost. I will take an example of India over here in this article to see if it is applicable for our farmers.</p>
<p>Let me list down few points out of one of the IoT solutions available in the market:</p>
<p><em>The IoT platform can help you:</em></p>
<ul>
<li><p><em>Easily collect and manage the explosion of data from sensors, cloud services such as weather or maps, connected equipment and existing systems</em></p>
</li>
<li><p><em>Quickly build and bring to market new innovative IoT applications at 10 times the speed of other approaches with our rapid application development environment and drag and drop mashup builder</em></p>
</li>
<li><p><em>Leverage big data and analytics to provide new insights and recommendations to aid in better decision-making</em></p>
</li>
<li><p><em>Enable farmers to easily visualize data and take action on insights and recommendations</em></p>
</li>
</ul>
<p>Read the last point of the above IoT solution. As an IoT solution provider company what will be the user interface you are going to provide for the last part? Mostly it will be a mobile application or a web interface.</p>
<p>Now, let us analyze whether Indian farmers can actually use it?</p>
<ul>
<li><p>Average monthly income of India farmer is 6400 INR = 97 USD approx.</p>
</li>
<li><p>Most of the farmers are illiterate.</p>
</li>
<li><p>Suicide rates of farmers are increasing due to difficulties in earning a daily wage to feed their families.</p>
</li>
</ul>
<p>Can they afford IoT sensors? Can they buy a smartphone to analyze data? NO!</p>
<p>The real life situation is rich are getting richer and poor are getting poorer. Unless this kind of IoT solutions are not addressed at the level where the poor can benefit from it, it just stays as a tool for a richer audience and luxury homes being automated daily.</p>
<p>I am not writing this to rant about IoT solutions or IoT solution provider companies. I am just trying to express what I see as a real problem that needs to be solved and the better way in which we can think of making IoT solutions affordable and usable for those who can actually benefit from it and improve their lives.</p>
<p>So, what can be the solution for it? I also don’t know the concrete answer to it but it is something we can all collectively think of to start addressing the real life situation where IoT can be useful.</p>
<p>Just when I was researching for any affordable solutions available for farmers, I can across this one which actually connects with any device:</p>
<p><a target="_blank" href="https://www.good.is/articles/agricultural-apps-bridge-literacy-gaps-in-india"><strong>India's Rural Farmers Struggle to Read and Write. Here's How "AgriApps" Might Change That.</strong><br />*India has the highest adult illiteracy rate in the world. According to the latest report published by UNESCO, there are…*www.good.is</a></p>
<p>This might resolve the problem but not fully. We need more and more alternatives to affordable solution like this.</p>
<p>Can the Government team up with tech companies and along with smart city plans focus on providing smart farmer schemes also?</p>
<p>If Government agrees to spend for integrating the hardware and sensors for IoT solution to farmers, how can we design the visual part of it?</p>
<p>Can we use digital billboard which is common between say 10 farms which display information from those 10 farms iteratively where a farmer can read in their language?</p>
<p>Since farmers cannot afford smartphones and are even not literate, can we feed the analyzed data to a loud speaker which announces the state of crops, moisture, weather etc? Again this can be common between 10 farms to reduce cost and information can be broadcasted turn by turn.</p>
<p>Can we get rid of visual displays and smartphone connectivity and just use some simple color-coded indication based on which farmer can take action? Has anyone used Pureit Water filter? It indicates to change filter cartridge with a red dot after filtering 1500 liters of water.</p>
<p>I am not sure whether these can be feasible solutions or not but we definitely need to come up with such affordable alternatives and think about broader audience in terms of providing solutions.</p>
<p>Are you an IoT solution provider company? Did any affordable solution struck in your mind while reading this? Then please comment and share your views. Recommend and share this article if you feel it useful and think that it is important to get collective views. Let us all think of reaching a broader audience and provide affordable solutions to those who can benefit from it. I hope that government also teams up to sponsor IoT solutions for farmers in one of their schemes then the rest is on us regarding how to project to content in a farmer-friendly manner.</p>
]]></content:encoded></item><item><title><![CDATA[Why you need to educate your client?]]></title><description><![CDATA[YES? NO? Let’s talk and collaborate instead
So, what do I mean here by educating your client? I am trying to stress upon the situation where generally the outcome is simply YES/NO from the either side i.e either you agree with a client or say no OR e...]]></description><link>https://javalnanda.com/why-you-need-to-educate-your-client-75fc9415fe9c</link><guid isPermaLink="true">https://javalnanda.com/why-you-need-to-educate-your-client-75fc9415fe9c</guid><category><![CDATA[communication]]></category><category><![CDATA[software development]]></category><category><![CDATA[requirement analysis]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 07 Mar 2017 11:15:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706166314825/e7d7035d-4a5a-42bb-903b-32cb6e4d977c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>YES? NO? Let’s talk and collaborate instead</p>
<p>So, what do I mean here by educating your client? I am trying to stress upon the situation where generally the outcome is simply YES/NO from the either side i.e either you agree with a client or say no OR either client agrees/disagree with you and there is no further engagement to get into a deal.</p>
<p>How can we improve this situation and make it more collaborative approach?</p>
<p>First, let us try to understand the impact of always saying YES to a client.</p>
<p>Most new businesses try to satisfy their client as much as possible and try to get a deal by saying YES to everything that client demands: low budget, tech stack, iterations, design, etc.</p>
<p>This can be harmful to your business, your team and for a client as well in the longer term as follows:</p>
<ul>
<li><p>Agreeing to low budget which is not affordable for your business results in burning hole in your pocket, which will result in allocating affordable junior developers for client’s project or you will tend to keep that project in low priority as soon as you get a good deal from another client where you will try to allocate experience developers. This will eventually affect the quality of your client’s project with a lower budget and result in bad impression for your business. The point is to always give the best quality to a client and not to overcommit or agree to everything which is out of your reach.</p>
</li>
<li><p>If you agree to develop using tech stack which is not your team’s skill set, you are again putting the project at hand to risk and eventually spoiling relation with your client if you can’t deliver in what you agreed upon. Always know your strength and take up the task which you can properly execute.</p>
</li>
<li><p>Saying YES to impossible deadlines. This will put your team to stress and affect your company’s culture and the environment in longer run eventually resulting in lower quality and efficiency from the team due to burnouts.</p>
</li>
<li><p>Allowing a client to override your design teams proposal or your developer’s proposal without reason. Your client can be both technical/non-technical in terms of service he is getting from you, but simply saying yes to what client asks for will demoralize your team members for their creativeness in terms of design or for proposing the right solution in terms of development. It is always advisable to allow your team to be a part of a discussion.</p>
</li>
</ul>
<p>Allowing your team members to put their point forward is more important then concluding who is right or who is wrong.</p>
<p>These are just some of the examples where business tends to simply nod to what client asks for. This is really not advisable and can be risky to both your business and client in a longer run.</p>
<p>Does it mean you simply say no when a client asks something which is not feasible on your side due to whatever reason? No, you should always try to explain and discuss what is feasible and what is not in a constructive way.</p>
<p>Agree, that there are some situation in which you analyze a particular client as a red flag and not fit for long term association with you when you tend to simply close the deal by saying NO. But, in most of the situation things can be discussed and there can be a win-win situation for both the parties.</p>
<p>Here are some of the ways in which you can replace a NO with a more constructive approach:</p>
<ul>
<li><p>Understand that a client is not always familiar with the technologies or services you are offering and that is the reason that client has come to you in request of your service. So, try to explain things in which client can understand in a realistic way instead of using jargons.</p>
</li>
<li><p>If you give a quotation which a client cannot digest, try to break down your quotation feature wise which can show a clear picture to a client. Show them feature wise efforts in terms in terms of hours/days. Explain to them why your hourly rate is what it is due to the quality or the way you offer your service which justifies your rate.</p>
</li>
<li><p>When a design or logo is rejected, allow your design team to explain the aspects and thinking behind why they proposed it that way, this will allow client to have a more clear picture of the design thinking that went into the design that was proposed and if they don’t align with that, they will be open to provide their thinking into it resulting in a collaborative outcome.</p>
</li>
<li><p>Allow your developer to explain the standard way in which things need to be implemented to the client. For e.g it is a common situation in Mobile application development where the client expects to clone behavior of one platform to other even in terms of design but it may not be the standard way proposed by the platform and also their user will not be familiar with it. In this situation, it is always advisable to allow your expert developers to propose the standard guidelines in which things need to be developed.</p>
</li>
<li><p>If a client is technical and asks you to implement X framework instead of Y, always know the why behind it. It will help both the parties to understand which framework is advisable for your project. It often happens that people just go with the trend to use the latest tech and frameworks even if they don’t need it, resulting in complexing the situation unnecessarily. So, you should always know the why behind using the framework and discuss the same with a client if they have some different solutions.</p>
</li>
</ul>
<p>Even if you don’t get into a deal with a client, having a discussion with them and coming to a collaborative decision will allow both the parties to communicate in future if they close on a sweet note.</p>
<p>What are your experiences and how do you handle such situation? Comment your experiences about the same which can be helpful to others dealing with the similar situations.</p>
]]></content:encoded></item><item><title><![CDATA[Configuring “Product Flavors” in your Android app]]></title><description><![CDATA[Product Flavors: Image source: https://developer.android.com/
Product Flavors is a great way to generate multiple APK with different configurations or flavors(demo/full/staging/production/uat) of your application.
Listing down few scenarios where Pro...]]></description><link>https://javalnanda.com/configuring-product-flavors-in-android-6e62dfbee6a8</link><guid isPermaLink="true">https://javalnanda.com/configuring-product-flavors-in-android-6e62dfbee6a8</guid><category><![CDATA[Android]]></category><category><![CDATA[android app development]]></category><category><![CDATA[configuration]]></category><category><![CDATA[gradle]]></category><category><![CDATA[Android Studio]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 14 Feb 2017 14:44:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706166342864/ae2af053-28eb-419d-abff-230684f64d7b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Product Flavors: Image source: <a target="_blank" href="https://developer.android.com/">https://developer.android.com/</a></p>
<p>Product Flavors is a great way to generate multiple APK with different configurations or flavors(demo/full/staging/production/uat) of your application.</p>
<p>Listing down few scenarios where Product Flavors can be useful:</p>
<ol>
<li>Generate APK with different package name</li>
</ol>
<p>The most common scenario where Product Flavors can be useful is to maintain different package name for your Staging, UAT and Production builds so that you can install those builds on a single device without overriding different environment builds.</p>
<p>There are two ways to do it either you can set applicationId or you can set applicationIdSuffix. The ideal way would be to use applicationIdSuffix and define applicationId in the defaultConfig block in your build.gradle file</p>
<p>Refer to image below where I have defined two flavors (staging and production) for my application and have applied applicationIdSuffix for staging configuration. I have not set applicationIdSuffix for production configuration as I don’t want my live app on store to have package name ending with .production</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*iRqxOQPtlM_1fn-xKh4AZQ.png" alt /></p>
<p>As soon as you add productFlavors in your app’s build.gradle file. You will be able to select Build Variants related to productFlavor you defined as observed in image below.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*CPsh5dPN9Vb0MmO-gpc3bg.png" alt /></p>
<p>2. Defining different HOST/API URL</p>
<p>You can define different HOST url using productFlavors when you have separate url pointing to staging/dev/uat/product environments.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706116162313/0268e0db-024f-46ba-86b4-d13dcf042e87.png" alt /></p>
<p>You can then access this baseUrl in your ServiceGenerator class using BuildConfig.HOST.</p>
<p>3. Defining manifestPlaceholders</p>
<p>Refer to below image where I have applied different values for onesignal_app_id and onesignal_google_project_number for staging and production environment.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*LcLq7fY0hN3gO3H8PeyGrw.png" alt /></p>
<p>4. Applying different app name.</p>
<p>In point 1. we learned how to apply different package name to install different variants of app in same device but we didn’t change the app name which will confuse the user in determining which app is production version and which app is dev/staging version.</p>
<p>We can apply different name based on flavors as below:</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*3hJNusH3H6veVzhI9e-IEQ.png" alt /></p>
<p>These are some of the most common use cases where productFlavors can be useful. Product Flavors is very powerful and you can customize much more than these examples.</p>
<p>You can define all the properties used under defaultConfig for configuration of productFlavors as defaultConfig belongs to <a target="_blank" href="http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html">ProductFlavor</a> class.</p>
<p>Happy coding fellow developers. If you find this article helpful feel free to spread the info by hitting ♥ below.</p>
]]></content:encoded></item><item><title><![CDATA[Tips for a successful mobile application development]]></title><description><![CDATA[The study shows that 90 percent of users uninstalls an app after a single usage, 77 percent don’t use an app after a single usage. So, it is very important to analyze various factors to get your App development correct to keep rest of the users engag...]]></description><link>https://javalnanda.com/tips-for-a-successful-mobile-application-development-3e29a5e3d16d</link><guid isPermaLink="true">https://javalnanda.com/tips-for-a-successful-mobile-application-development-3e29a5e3d16d</guid><category><![CDATA[mobile app development]]></category><category><![CDATA[tips]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Fri, 27 Jan 2017 18:08:00 GMT</pubDate><content:encoded><![CDATA[<p>The study shows that 90 percent of users uninstalls an app after a single usage, <a target="_blank" href="http://www.androidauthority.com/77-percent-users-dont-use-an-app-after-three-days-678107/">77 percent</a> don’t use an app after a single usage. So, it is very important to analyze various factors to get your App development correct to keep rest of the users engaged with your application.</p>
<p>There are various factors which contribute to a success of a mobile application. To list down few of them:</p>
<ul>
<li>User Experience: App should be easy to use for the user and provide a proper user experience allowing the user to use your app comfortably instead of making them struggle to figure out how to interact with your app.</li>
<li>Design: Again this is dependent on point one. Design to simply user experience and have a proper intuitive UI. A simplistic UI which is easier to use is more important than having a funky UI with font size and color themes which are not comfortable to a user.</li>
<li>Functional app/QA: It is mandatory that your app performs the features which it describes to the user. If a user is not able to perform some action or your app is not behaving the way it is intended to, a user will simply delete your app. Having few features which are fully functional is better than having many features which are buggy. Make sure that proper testing/QA is done for your app and issues are addressed at earliest before adding a new feature. <a target="_blank" href="https://blog.faodailtechnology.com/how-to-apply-via-negativa-philosophy-in-software-development-d562bcb219e2#.aam7icfg6">Eliminate negative first before adding positive</a>.</li>
<li>Mobile Data usage: Make sure that app uses minimal mobile data as per the requirement. An app should be optimized to request new data only when it is required or requested by the user. Apply proper cache mechanism to avoid re-download of media again and again.</li>
<li>Battery Usage: Make sure that your app is not eating up too much battery. Performing unwanted background calls and not taking care of optimization can result in extra battery usage.</li>
<li>Don’t block your user: Time is very precious for your user. Don’t make them wait forcefully when it is not required. E.g forcing the user to view promotional video every time on splash screen. This is not a website where you keep showing promotional content to a user. A user should be able to access the features of the application within milliseconds of launching. Don’t implement time-consuming animations within the application. Load data on a background and unless it is not mandatory don’t block your user with synchronous calls. If you have ads as your revenue model make sure to integrate it in a way that user is not frustrated, leaving no option for them other than uninstalling your app.</li>
<li>Security: User’s data is precious. Make sure your application is not storing user’s private data and taking care of all the security measures to protect user’s data.</li>
<li>User feedback option: You should be open to take feedbacks from the user and provide an option within the app where a user can send bugs, feedbacks or queries.</li>
<li>App Size: Your app should be as small as possible in size. Use techniques like App thinning and on-demand resource download to minimize your app bundle size.</li>
<li>Responsiveness: Your app should function properly on various device sizes and also on various OS versions.</li>
<li>Caching: Most application these days uses cache mechanism to cache images and media so that they same resource does not get downloaded frequently. This is good to save users mobile-data but again this also results in an increase of App Size post installation when the media cached to local device storage keeps growing. The developer will need to apply this feature smartly to clear older caches the right way when not in use. Most of the users are not aware of clear cache settings available on Android device for an app and they simply delete an app when they feel application size is huge.</li>
</ul>
<p>These are some of the core factors to take care of as a part of app development process to keep your users happy. There are various other factors like ASO and different market strategies which fall under the marketing/SEO part for your application which is equally important for gaining traction but before that these points will make sure that your audience will love to use your app once they install it.</p>
<p>Feel free to share your feedbacks and suggest any points required to be added to the list. If you find these helpful, feel free to spread the info by hitting ❤ so that others can come across this info on medium.</p>
]]></content:encoded></item><item><title><![CDATA[How to apply Via Negativa philosophy in software development]]></title><description><![CDATA[Recently while browsing through one of the LinkedIn conversation, I came across the term Via Negativa and dived a bit deeper into it. If you go through that blog post, you will feel that you already know the things mentioned over there by some way or...]]></description><link>https://javalnanda.com/how-to-apply-via-negativa-philosophy-in-software-development-d562bcb219e2</link><guid isPermaLink="true">https://javalnanda.com/how-to-apply-via-negativa-philosophy-in-software-development-d562bcb219e2</guid><category><![CDATA[software development]]></category><category><![CDATA[Collaboration]]></category><category><![CDATA[Quality Assurance]]></category><category><![CDATA[prioritization]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Mon, 16 Jan 2017 07:41:02 GMT</pubDate><content:encoded><![CDATA[<p>Recently while browsing through one of the LinkedIn conversation, I came across the term <a target="_blank" href="http://optimizemyself.com/blog/via-negativa/">Via Negativa</a> and dived a bit deeper into it. If you go through that blog post, you will feel that you already know the things mentioned over there by some way or the other. The same is the case with any self-help or motivational content, you already know the message it is trying to convey but still it helps to refresh your concept and knowledge about it via different ways.</p>
<p>The important point here is we tend to forget what we already know to apply in our day to day life. Similarly, this Via Negativa philosophy struct me to find out ways how we can apply it in our work life (which is product development, software development for me).</p>
<p>Here, I will try to list down areas where we can apply this philosophy — “Eliminate negative first before adding positive” from the perspective of different roles in an organization.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706116198009/b1fb15d4-dc1c-4125-8b68-aa0e60fc0a8e.jpeg" alt /></p>
<p>image source: google</p>
<p><strong>As a developer</strong></p>
<ul>
<li>Focus on <strong>refactoring</strong> the code/module along with the development rather than delaying it to later stage. That later stage hardly comes in today’s agile environment where we are delivering softwares with tight deadlines.</li>
<li>Resolve existing <strong>bugs</strong> first before jumping into new feature.</li>
<li>Eliminate warnings, deprecated apis, scalability bottlenecks before jumping into next sprint.</li>
</ul>
<p><strong>As a product owner/ manager / lead</strong></p>
<ul>
<li>Focus on clearing <strong>back logs</strong> without leaving behind anything unaddressed for the later stage in a hurry to start next sprint.</li>
<li>Focus on eliminating any <strong>known</strong> blockers/hurdles/scalability issues at earlier stage before focusing on planning new features for the product.</li>
<li>Focus on resolving <strong>user feedbacks</strong> at earliest.</li>
<li>Focus on Eliminating/Replacing under performer/inexperienced resource with the one that is required for the product/project before things go out of hand.</li>
</ul>
<p><strong>As a company owner/CEO</strong></p>
<ul>
<li>It is always tough to let go your employees who is not performing. But it is equally important to <strong>eliminate under performer</strong> or the one who does not have matching skills for your requirement. This is important on both ends for employee also and company also. You might be thinking that how it is good for employee as they are the one who will get fired? It is good for them because there are various reasons they might not be performing well in the required situation. 1) They might have different skill set where they can perform great at some other organization. 2) The current situation might be demanding too much from them compared to their current experience. or there can be many more reasons.</li>
<li>This article is a great read which explains why you should not hire someone to fix under performer : <a target="_blank" href="https://www.linkedin.com/pulse/dont-hire-someone-fix-underperformer-spencer-rascoff">https://www.linkedin.com/pulse/dont-hire-someone-fix-underperformer-spencer-rascoff</a></li>
</ul>
<p><strong>In general</strong></p>
<ul>
<li>There can be various other roles also to which this philosophy can be applied ( QA/BA/UX etc). But I have just listed the ones that came to my mind quickly and the roles to which I am closely associated with.</li>
<li>In general terms, we should try and eliminate any negative things first before focusing on adding something to cover it up.</li>
<li>Get rid of all the distractions that come in your way to become more productive</li>
<li>Avoid procrastinating and start learning that new skill, that new tech that is required for you and your organization to scale up the game and give best quality product to the customer.</li>
</ul>
<p>Drop in your comments and suggestions to add any more points over here, I would be happy to include points which you feel are important as per your role.</p>
]]></content:encoded></item><item><title><![CDATA[Points which developers should not ignore and take ownership — part 2]]></title><description><![CDATA[In my previous post, I discussed about areas where developers become careless intentionally or unintentionally which affects the overall quality of the app/product being developed.
Now, let us talk about the reasons of such mistakes and how to preven...]]></description><link>https://javalnanda.com/points-which-developers-should-not-ignore-and-take-ownership-part-2-c2badb38951f</link><guid isPermaLink="true">https://javalnanda.com/points-which-developers-should-not-ignore-and-take-ownership-part-2-c2badb38951f</guid><category><![CDATA[mobile app development]]></category><category><![CDATA[tips]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Wed, 04 Jan 2017 09:52:33 GMT</pubDate><content:encoded><![CDATA[<p>In my previous <a target="_blank" href="https://goo.gl/mxqFKr">post</a>, I discussed about areas where developers become careless intentionally or unintentionally which affects the overall quality of the app/product being developed.</p>
<p>Now, let us talk about the reasons of such mistakes and how to prevent it.</p>
<p><strong>Reasons:</strong></p>
<ul>
<li>Feeling Ignored</li>
</ul>
<p>If developers have a feeling that they are ignored or their suggestions does not have weightage in brainstorming activity, they will not open up to provide their inputs.</p>
<ul>
<li>Bad Leadership / Product Management</li>
</ul>
<p>Again this point outcome is related to above point. Developers can become ignorant when they are forced to follow what leader’s / product owner ask them to do without having open discussing with them and listening to them.</p>
<ul>
<li>Culture where developers are given least important</li>
</ul>
<p>This again relates to point one. Environment has a lot of impact in the productivity of an employee, be it Designer, Developer, QA etc. This is also one of the major reason at many workplaces where Developers are given least important which may not be intentional but it just happens to be that way because developers are not client facing in all the scenarios so they may get less appreciation/recognition compared to someone who is client facing (BA / Design Team / Product Owner). In this situation developers feels demoralized and starts lacking initiatives to take that extra steps &amp; ownership for building great product.</p>
<ul>
<li>Developer lacks the knowledge or skills are not up to the mark</li>
</ul>
<p>This is mainly due to developer’s own fault when they do not upgrade their skills and keep learning best practices in the area they are working in.</p>
<p><strong>Preventions:</strong></p>
<ul>
<li>Give importance to your developers and have an open brainstorming meeting whenever required where everyone feels comfortable to share their own views and team can come to a conclusion with the best possible outcome that can be achieved depending on various factors like deadline, scalability, quality etc.</li>
<li>I strongly believe in this saying : “A leader doesn’t create followers but always gives birth to new leaders”. Leader’s role should not be just to delegate task to his team, but to extract the best out of the team members and drive them to lead and take initiatives in positive directions. Leader should take care whether the team is following the right practices or not and always guide the team in a way that team always stay motivated to take the right approach to deliver the best they can. Train the team to have a mindset till next iteration and not restrict to just the current deliverables.</li>
<li>Always give proper appreciation and recognition for the developers who deserve it. Appreciation can be in any form but it is important to convey it to the developers who have given their best by stretching nights to deliver a successful product.</li>
<li>Developers should be consistently pushed to upgrade the skills and provide an environment where they stay motivated to upgrade themselves. Arrange hackathon, meetups, training classes etc..</li>
</ul>
<p>To conclude everything, create an environment where developers feel self motivated. Have proper transparency. Lead them in a way to extract best out of them and guide them in a way that they always deliver the best from their side.</p>
]]></content:encoded></item><item><title><![CDATA[Points which developers should not ignore and take ownership — part 1]]></title><description><![CDATA[In a software development firm, specifically in service base company, everyone is in hurry to achieve the milestone before the deadline. Which results in compromising quality or ignoring important concepts which might affect the scalability of the pr...]]></description><link>https://javalnanda.com/points-which-developers-should-not-ignore-and-take-ownership-part-1-157655894df6</link><guid isPermaLink="true">https://javalnanda.com/points-which-developers-should-not-ignore-and-take-ownership-part-1-157655894df6</guid><category><![CDATA[mobile app development]]></category><category><![CDATA[tips]]></category><category><![CDATA[guidelines]]></category><category><![CDATA[properties]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 03 Jan 2017 10:54:40 GMT</pubDate><content:encoded><![CDATA[<p>In a software development firm, specifically in service base company, everyone is in hurry to achieve the milestone before the deadline. Which results in compromising quality or ignoring important concepts which might affect the scalability of the product/application. This article will cover various team members of the process but my main focus will be on what developers need to do as a part of their <strong>responsibility</strong> towards maintaining the <strong>best practices</strong>.</p>
<p>I have observed few areas where developers tend to ignore things and focus only on given task without raising concerns related to best practices or suggesting the alternative solutions and not show participation for the proposition the best possible way to build the <strong>right product</strong>.<br />For e.g:</p>
<ul>
<li><strong>Not questioning or brainstorming with the UX team</strong></li>
</ul>
<p>This usually occurs in a design-led environment where UX team plays a major role in research and comes up with a proposal the way they think is correct. Which is fine and this helps client also to visualize the bigger picture before things enter into development mode. But, there is also a need to do technical feasibility check for the User Experience and functionality which UX team drafts. Now, here the conflicts begin to take place. It can be due to various reasons:<br /># Complex UI &amp; UX with lot of micro animations<br /># Proposing things which are not feasible technically or there is no support for it<br /># UI which is not as per the OS design standard or mixing components from different OS like (field of Android style into iOS )<br />and there can be many more things…</p>
<p>Here, first thing is definitely UX team needs to educate themselves about various patterns and design guidelines and collaborate with dev team for the technical feasibility.<br />Now, as a developer your responsibility is to not blindly follow what is proposed. If you feel that something is not as per the OS standard or the proposed UX will cause an issue when the product scales further, it is your duty to discuss the same with the UX team or involve product lead/owner if required and come up with alternative and better solutions.<br />This ignorance may lead to extra efforts or unwanted hiccups when for product scalability.<br />For e.g: The MVP of your product does not have multiple options so UX team might have come up with a design of view pager with 2 tabs on top of the screen. But these options will be moving to the navigation drawer in the next release which as a developer you might not have realized and design team might have thought that it is easier to move the menu from view pager to navigation drawer going forward. But, what if the developer asks the UX team to get a brief of proposed design for the next phase? This will help the team to avoid extra efforts of technical refactoring and will help even design team to come up with a better alternative that can scale. Building a product/application is a team effort, everyone needs to propose the right solution as per their expertise &amp; skills and it can always result in a fruitful outcome.</p>
<ul>
<li><strong>Not taking the security issues in account</strong></li>
</ul>
<p>This occurs most of the time in MVP phase specifically for the Mobile Applications as they are small in size and needs to be delivered quickly.<br />Things which developer might ignore in terms of security can be:<br /># Using the same token for the user throughout the lifetime while designing API<br /># Not resetting token while changing password<br /># No encryption of passwords<br /># Saving important user details in plain text on device<br />etc..<br />Again, here it is developer’s duty to execute things in a right manner. Saving efforts of 2–3 days by thinking that it is just MVP will have a bigger impact moving forward when things need to be built on top of MVP and believe me there is no such thing as “refactor later”. You will always be in rush to achieve dead line for next phase to come and will never be able to figure out dedicated time for refactoring.</p>
<ul>
<li><strong>Compromising on data-modeling and db architecture</strong></li>
</ul>
<p>This is again very critical for the application to scale properly. While designing DB, your thought process should always be that the product you are working on will scale. Never assume and implement things just for the current working phase or current MVP.<br />For e.g: If your app will have a provision of multiple user access to the same account, design it according to from the very beginning. Even if your current phase requires just single user access per account.</p>
<ul>
<li><strong>Ignoring the performance of the application</strong></li>
</ul>
<p>Performance is one of the biggest factors that will determine whether the user of the application will stay engaged with your application or delete the application due to bad performance.<br />If not taken care properly, performance can be compromised in various ways like:<br /># Pulling entire content in single request instead of page based API request<br /># Improper refresh mechanism<br /># Doing network activities on main thread and blocking users where they shouldn’t be blocked</p>
<p>Again, the takeaway here is do not compromise on things to save time for current release that will have a bigger impact later on.</p>
<p>These are some of the areas where things can go wrong and software quality might be compromised when developers don’t take their responsibility of building the right product properly. Stay tuned for my upcoming post where I will be sharing points about why developers do such mistakes and how to prevent it to make sure that each product is crafted to perfection without compromise on quality.</p>
]]></content:encoded></item><item><title><![CDATA[Thought process behind design]]></title><description><![CDATA[We are working on building one interesting product for one of our client where we are taking care of everything : Design, web, backend, front-end, mobile development and have flexibility of choosing our own technological stack.
This article is mainly...]]></description><link>https://javalnanda.com/thought-process-behind-design-5e18c58670fe</link><guid isPermaLink="true">https://javalnanda.com/thought-process-behind-design-5e18c58670fe</guid><category><![CDATA[Design]]></category><category><![CDATA[Collaboration]]></category><category><![CDATA[user experience]]></category><dc:creator><![CDATA[Javal Nanda]]></dc:creator><pubDate>Tue, 03 Jan 2017 10:53:23 GMT</pubDate><content:encoded><![CDATA[<p>We are working on building one interesting product for one of our client where we are taking care of everything : Design, web, backend, front-end, mobile development and have flexibility of choosing our own technological stack.</p>
<p>This article is mainly focused on importance of <strong>sharing thought process behind your design</strong> with the client.</p>
<p>So, we had our first iteration of designs for the Web part of the product from our design team who is working <strong>remotely.</strong> We were happy with the options design team has shared and were eager to get it confirmed and have feedbacks as early as possible from the client to get things rolling on the development side. But!! Is it ok just to share the links of the design options with the client and wait for feedbacks on mail? The answer is no. But, we did that because it was late night and we were not sure of getting connected with client on urgent basis.</p>
<p>Our design team insisted us to get on call with the client as it was the first design iteration we were sharing. It is very important for the client to understand the though process of the designer that went into the design process related to why the color theme is the way it is or why the font size is small, why the panels on left and right are of the same width and many more factors that designer might have thought of for creating the designs/mocks. So, we tried to get on a call with client and luckily all the team members were available to get on a quick call for design discussion.</p>
<p>And on the call we realized how important it was to have that brainstorming session on design with the client. He was very happy with the options we shared and gave some good suggestions. Overall it was a very fruitful call and we were on roll for the next step ahead.</p>
<p><strong>Take Aways:</strong></p>
<ul>
<li>Discuss the thought process behind design with the client instead of just sharing it and going back and forth with feedbacks and more iterations. Once design and theme is finalized it is ok to share minor updates on design for new modules.</li>
<li>Have few options and invest effort only on things that are mandatory to be confirmed first. For e.g it is not required to create design for entire product and all responsive devices in first iteration. Once colour theme and approach is confirmed for the web design, we can go ahead with creating mocks for other screen sizes.</li>
<li>Treat design process as one of the important part of your product and always keep in mind user experience and behaviour while designing.</li>
</ul>
]]></content:encoded></item></channel></rss>