<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sai ambati on Medium]]></title>
        <description><![CDATA[Stories by Sai ambati on Medium]]></description>
        <link>https://medium.com/@nagasaidurga-502?source=rss-bc5337ea130f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*B7zHuPMc5lCiBS2V.</url>
            <title>Stories by Sai ambati on Medium</title>
            <link>https://medium.com/@nagasaidurga-502?source=rss-bc5337ea130f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 17:55:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nagasaidurga-502/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Singleton Design Practices]]></title>
            <link>https://nagasaidurga-502.medium.com/singleton-design-practices-1c36953fab09?source=rss-bc5337ea130f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c36953fab09</guid>
            <category><![CDATA[thread-safe-singleton]]></category>
            <category><![CDATA[singleton]]></category>
            <category><![CDATA[singleton-pattern]]></category>
            <category><![CDATA[singleton-design-pattern]]></category>
            <dc:creator><![CDATA[Sai ambati]]></dc:creator>
            <pubDate>Tue, 12 Jan 2021 10:36:45 GMT</pubDate>
            <atom:updated>2021-01-12T10:36:45.456Z</atom:updated>
            <content:encoded><![CDATA[<p>By hearing the design practices we think it would be tough and we don’t know how to do them.But in general we are all use them normally without knowing that this is called as one Design pattern.Even I am also used most of the singleton design practices without knowing about them.</p><p>Today I explored all the singleton design practices to implement the singleton design pattern in android.Let’s see the types of singleton design practices</p><ol><li><strong>Eager</strong> <strong>initialization</strong></li><li><strong>Using static block</strong></li><li><strong>Lazy</strong> <strong>initialization</strong></li><li><strong>Thread safe singleton</strong></li><li><strong>Lazy initialization with double check locking</strong></li><li><strong>Bill pugh singleton implementation</strong></li></ol><h3><strong>Eager initialization :</strong></h3><p>Simplest method to follow.It will create the object when the program loads into memory by JVM, so it costs memory even if there is no use of the class.It will useful when we use the class or resources all the time or more times.</p><pre>public class Sample {<br>    private static final Sample <em>instance </em>= new Sample();<br><br>    private Sample() {<br>    <em>//constructor<br>    </em>}<br><br>    public static Sample getInstance() {<br>        return <em>instance</em>;<br>    }<br>}</pre><h3>Using static block :</h3><p>It’s also similar to the Eager initialization but the instance creation will happen in static block to use exception handling.</p><pre>public class Sample {<br>    private static  Sample <em>instance</em>;<br><br>    private Sample() {<br>    <em>//constructor<br>    </em>}<br><br>   static {<br>        <em>instance</em>=new Sample();<br>   }<br>}</pre><h3>Lazy initialization :</h3><p>Object is created only when it is needed, so there is no resource wastage.GetInstance method is required to return the instance of the object and which needs the null check to create new instance otherwise returns already existed object.We should maintain the constructor and instance variable as private so that no outside resources access them directly.</p><p>But this is useful only in single threaded environment whereas multiple threads will break the singleton rules.</p><pre>public class Sample {<br>    private static Sample <em>instance</em>;<br><br>    private Sample() {<br>        <em>//constructor<br>    </em>}<br><br>    public static Sample getInstance() {<br>        if (<em>instance </em>== null) {<br>            <em>instance </em>= new Sample();<br>        }<br>        return <em>instance</em>;<br>    }<br>}</pre><h3><strong>Thread safe Singleton :</strong></h3><p>In this the getInstance() method is made with synchronized keyword so that multiple threads cant access the same instance at a time.It will not break the singleton property when multiple threads try to access it.But it will cause slow performance as it cant allow the multiple threads accessing.</p><pre>public class Sample {<br>    private static Sample <em>instance</em>;<br><br>    private Sample() {<br>        <em>//constructor<br>    </em>}<br><br>    synchronized public static Sample getInstance() {<br>        if (<em>instance </em>== null) {<br>            <em>instance </em>= new Sample();<br>        }<br>        return <em>instance</em>;<br>    }<br>}</pre><h3><strong>Lazy initialization with double check locking :</strong></h3><p>To overcome the overhead of synchronized, we should not make the getInstance() synchronized.Instead will make the initialization block as synchronized one, so that minimum number of threads have to wait and that’s only for first time.</p><pre>public class Sample {<br>    private static Sample <em>instance</em>;<br><br>    private Sample() {<br>        <em>//constructor<br>    </em>}<br><br>     public static Sample getInstance() {<br><br>        if (<em>instance </em>== null) {<br>            synchronized (Sample.class) {<br>                <em>instance </em>= new Sample();<br>            }<br>        }<br>        return <em>instance</em>;<br>    }<br>}</pre><h3><strong>Bill pugh Singleton implementation :</strong></h3><p>Prior to Java5, memory model had a lot of issues and above methods caused failure in certain scenarios in multithreaded environment. So, Bill Pugh suggested a concept of inner static classes to use for singleton.</p><pre>public class Sample {<br>    private static Sample <em>instance</em>;<br><br>    private Sample() {<br>        <em>//constructor<br>    </em>}<br><br>    public static class BillPughImplementation {<br>        private static final Sample <em>INSTANCE </em>= new Sample();<br>    }<br><br>    public static Sample getInstance() {<br>        return BillPughImplementation.<em>INSTANCE</em>;<br>    }<br>}</pre><p>When the singleton class is loaded, inner class is not loaded and hence doesn’t create object when loading the class. Inner class is created only when getInstance() method is called. So it may seem like eager initialization but it is lazy initialization.<br>This is the most widely used approach as it doesn’t use synchronization.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3osBL8wMQYQPYh0Jgs%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcurbyourenthusiasm-3osBL8wMQYQPYh0Jgs&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2F3osBL8wMQYQPYh0Jgs%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ca2cb599063866d1ac27676435125bb/href">https://medium.com/media/9ca2cb599063866d1ac27676435125bb/href</a></iframe><p>Let me know what are your <strong>thoughts</strong>|<strong>suggestions if any over this topic.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c36953fab09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Journey with Flutter]]></title>
            <link>https://nagasaidurga-502.medium.com/journey-with-flutter-69ebca3a8619?source=rss-bc5337ea130f------2</link>
            <guid isPermaLink="false">https://medium.com/p/69ebca3a8619</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mobileapptechnology]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Sai ambati]]></dc:creator>
            <pubDate>Sat, 23 Nov 2019 07:17:32 GMT</pubDate>
            <atom:updated>2019-11-23T07:17:32.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnH9jqNuMJeeo1NXTI7eXw.jpeg" /></figure><p>Today,fortunately I gone through the Flutter.I just want to share my knowledge with you guys.As it is my first day i just gone through basics of the Flutter and done with first hello world app.</p><p>Let’s get started with why we should go for Flutter as a developer…</p><p>For developers,Flutter lowers the bar to entry for building mobile apps. It speeds up development of mobile apps and reduces the cost and complexity of app production across iOS and Android.</p><p>Developers who wants a faster way to build beautiful mobile apps, or a way to reach more users with a single investment.Flutter is easy to learn who have prior knowledge on object-oriented concepts (classes, methods, variables, etc) and imperative programming concepts (loops, conditionals, etc). No need of any mobile development experience.</p><p>I followed the flutter dev site to installation process and how to create the app<br><a href="https://flutter.dev/docs/get-started/install">https://flutter.dev/docs/get-started/install</a></p><p>All the process went smooth,I used android studio as IDE and flutter SDK(which i was downloaded from flutter site). But I faced some problems while running the app in real device..I am mentioning those errors here so that if anyone facing the same issue they can resolve those issues easily.</p><blockquote>Issues I faced for the first app run in real mobile device<br>1.I tried to see the connected device in studio,but we should execute the following command in terminal to see the device in the studio IDE<br><em>$ flutter devices</em></blockquote><p>Some machines will get error like “Device is not authorized.You might need to check your device for an authorization dialog”. To resolve this error we should kill the adb server and restart the server by using the following steps.</p><ol><li>Unplug the connected the device</li><li>Execute adb kill-server</li><li>Execute adb start-server</li><li>Connect the device again with USB</li></ol><p>It will resolve that problem..Now you can see the device in the studio to run your first app.Make sure you set all the paths in PATH environment variable as mentioned in the installation steps.</p><p><strong>Basics of Flutter :<br></strong>Flutter uses dart as a programming language which itself is fairly easy to get started with and Dart language is neat,short and strongly typed objected oriented programming language.<br>Dart delivers high performance and predictable and it can be used as a cross platform language.<strong>Just in Time</strong>(compilation process) and <strong>hot reload</strong>(allows reloading the code on the running app without losing the state massively reducing development time),<strong>AOT (Ahead of Time-</strong>compiled to fast, predictable, native code<strong>)</strong> are essential features to the Dart.</p><p>In flutter,almost everything is widget.Widgets are the foundation of flutter apps ,the central idea is that you build your UI out of widgets, it describes how the view should like given their current configuration and <strong>state</strong>.</p><p>Widgets can be of two types either <strong>stateful</strong> or <strong>stateless.</strong></p><p><strong>Stateless widgets</strong></p><p>A widget that does not require mutable state or in other words <strong><em>static widget</em></strong> . There are cases where you’ll create widgets that don’t need to manage any form of internal state.</p><p>They do not depend on any data change or any behavior change. For Example. Text, Icon, Raised Button are Stateless Widgets.</p><p><strong>Stateful widgets</strong></p><p>A widget that has mutable state or in other words <strong><em>dynamic widget</em></strong> . They allow us to create widgets which can dynamically change their content over time.They can be updated during run-time based on user action or data change. If a Widget can change its state during run time it will be stateful widget.<br>Example :Image,Form,Checkbox.</p><p>That’s it for now. I hope you learned something from my words.</p><p>If you like my article, please don’t forget to click 👏👏👏 to recommend it to others 👏👏👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69ebca3a8619" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extensions and Infix Notations in Kotlin]]></title>
            <link>https://nagasaidurga-502.medium.com/extensions-and-infix-notations-in-kotlin-44f51c2d6c57?source=rss-bc5337ea130f------2</link>
            <guid isPermaLink="false">https://medium.com/p/44f51c2d6c57</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[infix-function]]></category>
            <category><![CDATA[string]]></category>
            <category><![CDATA[extension-functions]]></category>
            <dc:creator><![CDATA[Sai ambati]]></dc:creator>
            <pubDate>Thu, 03 Oct 2019 12:09:04 GMT</pubDate>
            <atom:updated>2019-10-03T12:09:04.485Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Everyone..I am new to writing the blogs.But I have enthusiasm to express my thoughts in blogs and explore more ideas by getting suggestions from readers.Please bear with my beginner articulate skills.</p><p>Have you ever come across the situation like,you want to add your own methods(functions) in existing classes or adding new functionalities to other’s classes in your project.</p><blockquote>To accomplish the above need,we have <strong>Extensions </strong>feature in Kotlin.In this article I will explain Extensions and infix functions also.</blockquote><p>Let’s dive into simple example of extensions.</p><p>var email=”sai@gmail.com” <br>You want to validate the email by using a function which like predefined functions in String class.<br>We can implement this one using Extensions like below</p><pre><strong>fun </strong>String.isValidEmail(): Boolean {<br>    <em>//you can write your email validation rules here <br>    </em><strong>return </strong>Patterns.<em>EMAIL_ADDRESS</em>.matcher(<strong>this</strong>).matches()<br>}</pre><p>We should mention the class name with the method name,then It treats the function belongs to that class and it treated as static function in that class.<br>(Here isValidEmail function is added to Predefined class String and it treated as static method in String class).</p><p>Now we can access the method like below</p><p>email.isValidEmail() or “sai@gmail.com”.isValidEmail()</p><h3>Infix Functions</h3><p>Infix functions are also used for the same purpose like Extension functions.Then you may have doubt like what is the need of infix functions and difference between them.Let’s get into it now.</p><p><strong>Kotlin Infix Notation — Make function calls more intuitive</strong></p><p>You can mark any member function or extension function with the <em>infix</em> modifier to allow it to be called using infix notation. The <strong><em>only requirement</em></strong> is that the<strong><em> function should have only one required parameter.</em></strong></p><p>These functions to be called without using the period and brackets.We can explore this one with some other example……</p><pre><strong>infix fun </strong>Int.isGreaterThan(number:Int):Boolean{<br>    <em>//It has only one parameter<br>    </em><strong>return this</strong>&gt;number<br>}</pre><pre>var<strong> </strong>number=20<br>val<strong> </strong>greaterCheck=number<strong> <em>isGreaterThan</em></strong><em> </em>30</pre><p>Hope you all get about the extensions and infix functions in kotlin.<br>This quick article shows some of the things that can be done with infix and extension functions, including how to make use of some existing ones and how to create our own to make our code cleaner and easier to read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44f51c2d6c57" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>