<?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 Janith Gunawardana on Medium]]></title>
        <description><![CDATA[Stories by Janith Gunawardana on Medium]]></description>
        <link>https://medium.com/@mihiranga-official?source=rss-83359e182b42------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_Da8n1xjK9ldDG8lFAeRhg.jpeg</url>
            <title>Stories by Janith Gunawardana on Medium</title>
            <link>https://medium.com/@mihiranga-official?source=rss-83359e182b42------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 04:10:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mihiranga-official/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[EcmaScript vs JavaScript]]></title>
            <link>https://medium.com/@mihiranga-official/ecmascript-vs-javascript-a04d36597362?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/a04d36597362</guid>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 17:18:41 GMT</pubDate>
            <atom:updated>2022-01-19T17:18:41.232Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*nNHbiWzPdMji-noi.gif" /></figure><p>Everyone said ECMAscript is the same as js but it&#39;s not true so let&#39;s talk about Step by step</p><p><strong>JavaScript</strong></p><p>It&#39;s a general-purpose scripting language that conforms to the ECMA Script specification when we code the code in js we don&#39;t code it in ECMAScript</p><p>By reading an ECMAScript specification you learn<strong> how to create a scripting language</strong></p><p>By reading the JS documentation you learn <strong>how to use a scripting language</strong></p><h4>A JavaScript engine</h4><p><strong>A program or interpreter that understands and executes JavaScript code.</strong></p><p>JavaScript engines are often found in web browsers, such as Chrome’s V8, Firefox’s SpiderMonkey, and Edge’s Chakra. Each engine functions as a language module for its application, supporting a subset of the JavaScript language.<br>To a browser, a JavaScript engine is equivalent to language comprehension. If we return to our previous example of the activities “walk,” “run,” and “jump,” a JavaScript engine is the component of an “entity” that knows what these actions entail.</p><h4>Differences in browser support</h4><p>Consider the distinctions between persons who speak the same language. Even though many individuals speak English, some may be familiar with terms, idioms, and grammatical rules that others are unfamiliar with, and vice versa. Browsers behave similarly. Although all browser JavaScript engines comprehend JavaScript, certain browsers have a better comprehension of the language than others. Browsers support the language in a variety of ways.</p><p>People frequently talk about “ECMAScript compatibility” rather than “JavaScript compatibility” when it comes to browser support, even though JavaScript engines interpret and execute… well, JavaScript. This might be perplexing, but there is an answer.</p><p><strong>ECMA Script</strong></p><p>ECMAScript is an Organization that creates standers for technologies and they created many standards ECMA script is one of those standards and its based language for some scripting languages including js script coffee script and javascript</p><p><strong>&gt;&gt;Used in web browsers servers embedded technologies</strong></p><p><strong>&gt;&gt;It contains the specification for a general-purpose scripting language</strong></p><p><strong>&gt;&gt; Based on javascript(Netscape) and JScript(Microsoft)</strong></p><p><strong>&gt;&gt;provides rules, details, and guidelines</strong></p><p>Why use ECMA Script</p><p><strong>There are so many issues in JS; ECMA script or ES6 is brought solutions for it</strong></p><p><strong>ES6(ECMAScript) Support OOP Concepts</strong></p><p><strong>Used modern Frameworks</strong></p><h4>Babel</h4><p><strong>A transpiler that can convert ES6 code to ES5 code.</strong></p><p>Developers can employ the flashy new ES6 capabilities, but they may be concerned about cross-browser compatibility for their web projects. Edge and Internet Explorer do not fully implement features from the ES6 standard as of the writing of this article.</p><p>Developers that are concerned can use Babel to transform their ES6 code to a functionally identical version that only uses ES5 capabilities. All of the main browsers fully support ES5, thus the code will execute without difficulty.🤔</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a04d36597362" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototype Design Pattern]]></title>
            <link>https://medium.com/@mihiranga-official/prototype-design-pattern-5b340a1db1eb?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b340a1db1eb</guid>
            <category><![CDATA[prototype-design-pattern]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Sat, 01 Jan 2022 18:08:14 GMT</pubDate>
            <atom:updated>2022-01-01T18:08:14.938Z</atom:updated>
            <content:encoded><![CDATA[<p>Unlike other patterns, This Prototype design pattern is avoided creating new objects This design pattern can clone the existing object because creating a new object is expensive. This pattern is done when you create an object and register it and clone it from the original and it avoids new keywords, overheads, performance issues of the object creation process.</p><ul><li>Dealing with the cloning process we have shallow Copy and Deep Copy</li></ul><p><strong>What is shallow Copy</strong></p><p>An instance is produced in this case by copy-pasting the contents of all variables from the original object. If the data type is a reference, just the reference is copied, not the reference object itself. As a result, the unique and clone both refer to the same memory address, resulting in ambiguity and runtime issues with a dangling reference. A shallow copy is quicker. and faster</p><p><strong>What is Deep Copy</strong></p><p>In this case, an instance is formed by duplicating the contents of all variables, including their references, and allocating equivalent memory resources to the object with the same value. A deep copy is somewhat slower.</p><h3>Advantages of Prototype Design Pattern</h3><ol><li>Reduces the cost of creating objects. When it is not feasible to create new objects, this is also critical.</li><li>Reduce total operational costs by reducing the number of expensive external API calls.</li></ol><p><strong>Let’s have a look at how the scenario was implemented.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*iep_Jm7HVORbZYcR-EaHeg.png" /><figcaption><em>UserService.java</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*SzhR0vPknRaI6Lc2ps-gtA.png" /><figcaption><em>User.java</em></figcaption></figure><p>The first two classes offer the base object class User, which aids in the creation of a list of users. The second class developed above is a service that, in a real-world application, would assist in retrieving a list of users from the database. At the moment, it just mocks the service request and puts the data into the list by constructing it. We will now move on to creating the actual prototype class. The Java Clonable interface will be implemented by this class. This is an interface that requires the class to override the clone function (). This approach is used to allow object copying without having to get the data twice. Cloning creates a copy of an existing object in a new object instance. This indicates that all of the data in both objects is the same, yet they relate to different locations. Let us now build the class and learn more about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*dqrWBr71-w12ZyEpTX2ebA.png" /><figcaption><em>UserDetails.java</em></figcaption></figure><p>As observed, the class includes a function clone (). This function will be used to acquire cloned objects in the future. This method takes an existing user list and generates a new one. As can be seen, it does not go for a service call. This guarantees that the program does not touch the database several times and that all of the objects have the necessary data with a single hit. This reduces the overhead of database calls, resulting in exceptionally high speed.<br>Let us now write an implementation class that includes the main function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*9hTR4xJDmjYVJVp0hoLfwA.png" /><figcaption>Output</figcaption></figure><p>In frameworks like as Spring, Hibernate, and Struts, the prototype design pattern is frequently used and favored. It comes in handy when an application necessitates the generation of comparable items on a regular basis. Every class that requires prototyping in the prototype design pattern implements the Clonable interface and overrides the necessary method.😍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b340a1db1eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Sockets]]></title>
            <link>https://medium.com/@mihiranga-official/web-sockets-cb161fe4a92a?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb161fe4a92a</guid>
            <category><![CDATA[soket]]></category>
            <category><![CDATA[websocket]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Wed, 29 Dec 2021 18:22:11 GMT</pubDate>
            <atom:updated>2021-12-29T18:22:11.785Z</atom:updated>
            <content:encoded><![CDATA[<p>Its advanced Technology to Open a two-way interactive communication session between the user’s browser and a server</p><p><strong>What is session</strong></p><p><strong>A web session</strong> is a series of contiguous actions performed by a visitor on a single website within a specified time frame. This could include your search engine queries, completing a form to receive content, scrolling on a website page, adding items to a shopping cart, researching airfare, or which pages you viewed on a single website. Any interaction with a single website is recorded as a web session to that website’s property.</p><p><strong>Now Back to the topic</strong></p><p>WebSocket is a bidirectional, full-duplex protocol that is used in the same context as client-server communication; unlike HTTP, It is a stateful protocol, which implies that the connection between the client and server will remain active until either side terminates it (client or server). After either the client or the server closes the connection, the connection is ended from both ends.</p><p>Consider client-server communication. There is a client, which is a web browser, and a server. When we begin a connection between client and server, the client-server performs handshaking and decides to make a new connection, which will remain active until any of them terminates it. When the connection is created and active, communication takes happen over the same connection channel until it is terminated.</p><p>This is how, after client-server handshaking, the client-server decides to establish a new connection to keep it alive; this new connection is referred to as a WebSocket. Once the communication link is established and the connection is established, message exchange will occur in bidirectional mode till the connection between client and server is maintained. If any of them (client-server) dies or decides to disconnect, the connection is terminated by both parties. The switching protocol in WebSocket is denoted by the status code 101, which is slightly different from how HTTP operates.</p><p><strong>When to Avoid Using WebSocket</strong></p><p>Websocket can be used any real-time updated or continuous streams of data that is being transmitted over the network If we want to get old data or obtain the data only once to process it with an application, we should utilize HTTP protocol. Old data that is not required very frequently or fetched only once may be queried by a simple HTTP request, hence, in this case, we should avoid using WebSocket.</p><p><strong>The Usage of web socket</strong></p><ul><li>Chat app</li><li>Gamming App</li><li>Real-Time Web app</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb161fe4a92a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are HTTP headers?]]></title>
            <link>https://medium.com/@mihiranga-official/what-are-http-headers-e2607dce5ef6?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2607dce5ef6</guid>
            <category><![CDATA[http-headers]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Mon, 20 Dec 2021 20:14:10 GMT</pubDate>
            <atom:updated>2021-12-20T20:14:10.810Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I&#39;m going to teach you the concept of <strong>headers</strong> with some of the examples</p><p><strong>What is API</strong></p><p>API is a way to transfer data from one node to another (One machine to another machine )</p><p>When you transfer data you have some set of protocols Imagine you writing a letter to your Best friend and it is closed in an envelope and it is sent from you to your friend and now we replace them like the picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*pSOFLJTVVFl7E0utpuboAg.jpeg" /></figure><p>The context Inside the envelope is the data transfer in the <strong>Client and server (you and your friend) </strong>when the envelope is getting transferred in the real world we need the sender&#39;s address and receiver address The headers doing the kind of things.</p><p>Headers are a sort of indication metadata of what the response or request consists in the inside.</p><p><strong>There are 6 types of Headers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ee3RooYPZk6GuIjsKZrt9A.jpeg" /><figcaption>Type of Headers</figcaption></figure><p><strong>Let&#39;s go with one by one</strong></p><ol><li><strong>Request headers</strong></li></ol><p>It&#39;s a Key-value pair that is sent by the client who is requesting the data then the server can understand how the server has to send the response. and Gaining some knowledge about the requesting body or the client.</p><p><strong>(More information about the resource to be fetched, or about the client requesting the resource)</strong></p><p><strong>examples</strong></p><p>Host</p><p>User-Agent</p><p>Referer</p><p>Connection</p><p>Accept-Language</p><p>Let&#39;s get Language as en-US which means English that means the client is telling the server that I am going to understand the response in English</p><p>when clients send to request to the server can understand how the server has to from its response this is the rule of request headers</p><p><strong>2. Response Headers</strong></p><p>The same thing doing like in the request header but the server gives additional information about the data that it has sent</p><p><strong>examples</strong></p><p>Connection :keep-alive</p><p>Date:2021-DEC-20</p><p>Server: Apache/2.4.1</p><p>Content-type text/HTML</p><p>Transfer encoding: chunked</p><p>Usually, these values are giving some information about the response</p><p><strong>Date </strong>If the date giving the response that date is the date and time that I have to send the response.</p><p><strong>Last Modified</strong> this is the time that response had been updated or modified</p><p><strong>3. Representation Headers</strong></p><p>The data that has been transferred from one server to another can be different formats XML,JSON it could be encoded with the different format can be sent as one piece of data at a time or the response is so huge that has to be a lot and different lot or a different set of bytes then the server tells to a client I&#39;m going to send a lot of data for once the response</p><p><strong>examples</strong></p><p>Content-type: text/ HTML</p><p>Content-Encoding:gzip</p><p>content location /docs.fo.xml</p><p>Content location tell the alternate location of the resource the data that is available for the client to retrieve the information from can be URL where that particular resource is sitting</p><p><strong>4. Predefine Headers</strong></p><p>If you want to create a header for your work custom headers this can help to do that so on you can define and implement different headers that you are going to accept</p><p><strong>Example</strong></p><p><strong>Authorization headers are </strong>used to authenticate the user who are going to use their API’s and there are many more custom headers that you can use for implementing the logic of your site</p><p>5. <strong>End-to-end headers</strong></p><p>These headers <em>must</em> be transmitted to the final recipient of the message: the server for a request, or the client for a response. Intermediate proxies must retransmit these headers unmodified and caches must store them.</p><p>6. <strong>Hop-by-hop headers</strong></p><p>These headers are meaningful only for a single transport-level connection, and <em>must not</em> be retransmitted by proxies or cached. Note that only hop-by-hop headers may be set using the Connection header.</p><p>Hope you will understand the Headers.</p><p>Thank You</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2607dce5ef6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Types of JVM(3)]]></title>
            <link>https://medium.com/@mihiranga-official/data-types-of-jvm-3-672e4e068599?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/672e4e068599</guid>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Fri, 17 Dec 2021 08:28:42 GMT</pubDate>
            <atom:updated>2021-12-17T08:28:42.227Z</atom:updated>
            <content:encoded><![CDATA[<p>When we discuss memory area data will be residing in the memory area.Unlike the data type of java language this data type deals with <strong>JVM</strong></p><p><strong>There are two types of data types in JVM</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*F7VLMPnKJD33jtLHk64-1w.jpeg" /><figcaption>JVM Data Types</figcaption></figure><p><a href="https://www.linkedin.com/authwall?trk=bf&amp;trkInfo=AQGjborSo_RLFwAAAX3G6UxwFp4BJE_20SXpyWuaFqaPzD449hkdebaDkB8UAwTC9R13OYBrtSrCjGXoMVrOx72YVuUhQc-m7Cpu8JY4kkXuzAo4q3DL2nkPYthNCDIgXiH57-M=&amp;originalReferer=&amp;sessionRedirect=https%3A%2F%2Fwww.linkedin.com%2Fjobs%2Fview%2F2842707867"><strong>Primitive Types</strong></a></p><p>Its Holding value of the data itself.</p><p><strong>Reference Type</strong></p><p>Its always holding the Reference not holding the data by itself</p><p>All the language Primitive Types are deal the same way Primitive Types in the JVM but talking to about boolean its changes get very little support by its instructions (<strong>boolean false representing as Zero boolean true representing as none zero</strong> )if it&#39;s Operateable boolean its represent by int Value and if its array of boolean it represents by an array of the byte in bit value</p><p><strong>Size of these data types</strong></p><p>It&#39;s always the same in every environment. But there is only one difference Long is always used 64-bit 2s complements as its size its doesn&#39;t change on the platform every implementation its take the same size and</p><p><strong>Return Address Type</strong></p><p><strong>Final </strong>Keyword is implemented as this with the usage of the JVM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MAMEDEPUHvKpfUaUwS2kfQ.jpeg" /><figcaption>Detailed Review of JVM Data Types</figcaption></figure><p>And there is a special keyword called<strong> “Word size”</strong> it&#39;s based because you can&#39;t measure from word size. Word size is you need it&#39;s a based we need to assign a value into word size</p><p>The length of the word size is decided by the particular implementation but there are two rules to define the word size</p><ol><li><strong>The word size of a particular word should be able to hold primitive data type</strong></li><li><strong>Two words should be able to carry long or double value</strong></li></ol><p><strong>But According to these rules, at least word should be the length of 32 bit</strong></p><p>If you put the primitive type it should behold by one word and if you put long or double it would hold by two words.</p><p>Hope you are understanding about this article</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=672e4e068599" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Java Date and TimeClass]]></title>
            <link>https://medium.com/@mihiranga-official/what-is-java-date-and-timeclass-c2d4ced3493e?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2d4ced3493e</guid>
            <category><![CDATA[java-date-time]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 09:05:20 GMT</pubDate>
            <atom:updated>2021-12-16T09:09:12.698Z</atom:updated>
            <content:encoded><![CDATA[<p>It helps us to specify the Month, Year, Time the JCalander class Provides methods to convert date.Java provides the <strong>Date</strong> class available in <strong>java. util</strong> package, this class encapsulates the current date and time. In industries such as finance, aviation, medicine, and law, date and time are crucial. When we examine the importance of date and time in the legal field,</p><p><strong>In Java, there are four date and time classes to choose from.</strong></p><p>1. java.util.Date</p><p>2. java.sql.Date</p><p>3. java.util.Calendar</p><p>4. java.time</p><p><strong>Java. time</strong></p><p>Although Java lacks a built-in Date class, we may deal with the date and time API by importing the java.time package. Many date and time lessons are included in the bundle.in java time there 4 different classes for representing date and time</p><ol><li>LocalDate &gt;&gt; <strong>Represents a date (year, month, day (yyyy-MM-dd))</strong></li><li>LocalTime &gt;&gt;<strong>Represents a time (hour, minute, second and nanoseconds (HH-mm-ss-ns))</strong></li><li>LocalDateTime &gt;&gt;<strong> Represents both a date and a time (yyyy-MM-dd-HH-mm-ss-ns)</strong></li><li>DateTimeFormatter &gt;&gt; <strong>Formatter for displaying and parsing date-time objects</strong></li></ol><h3>Display Current Date(LocalDate.class)</h3><pre>import java.time.LocalDate; // import the LocalDate class<br><br>public class Main {<br>  public static void main(String[] args) {<br>    LocalDate myObj = LocalDate.now(); // Create a date object<br>    System.out.println(myObj); // Display the current date<br>  }<br>}</pre><p><strong>It will display the Current Date As Under</strong></p><p><strong>year, month, day (yyyy-MM-dd)</strong></p><p><strong>2021–12–16</strong></p><h3>Display Current Time(LocalTime.class)</h3><pre>import java.time.LocalTime; // import the LocalTime class<br><br>public class Main {<br>  public static void main(String[] args) {<br>    LocalTime myObj = LocalTime.now();<br>    System.out.println(myObj);<br>  }<br>}</pre><p>Display the Current time in</p><p><strong>(hour, minute, second, and nanoseconds (HH-mm-ss-ns))</strong></p><p><strong>The output As Under</strong></p><p><strong>13:21:29.534457</strong></p><h3>Display Current Date and Time(LocalDateTime.class)</h3><pre>import java.time.LocalDateTime; // import the LocalDateTime class<br><br>public class Main {<br>  public static void main(String[] args) {<br>    LocalDateTime myObj = LocalDateTime.now();<br>    System.out.println(myObj);<br>  }<br>}</pre><p><strong>the format(yyyy-MM-dd-HH-mm-ss-ns)</strong></p><p><strong>The output will be</strong></p><p><strong>2021–12–16T13:39:40.038847</strong></p><h3>Formatting Date and Time(DateTimeFormatter.class)</h3><pre>import java.time.LocalDateTime; // Import the LocalDateTime class<br>import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter class<br><br>public class Main {<br>  public static void main(String[] args) {<br>    LocalDateTime myDateObj = LocalDateTime.now();<br>    System.out.println(&quot;Before formatting: &quot; + myDateObj);<br>    DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern(&quot;dd-MM-yyyy HH:mm:ss&quot;);<br><br>    String formattedDate = myDateObj.format(myFormatObj);<br>    System.out.println(&quot;After formatting: &quot; + formattedDate);<br>  }<br>}</pre><p><strong>The output is</strong></p><p><strong>Before Formatting: 2021–12–16T13:39:40.039977<br>After Formatting: 16–12–2021 13:39:40</strong></p><p>In conclusion, while date and time are not renowned for being difficult, the truth is quite the reverse, as java language date and time datatypes demonstrate by their complexity, emphasizing the need of selecting the appropriate data types for the job.</p><p>in next chapter we will discuss other date and time formats</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d4ced3493e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1. Singleton Design Pattern]]></title>
            <link>https://medium.com/@mihiranga-official/1-singleton-design-pattern-c8c8306bfefb?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8c8306bfefb</guid>
            <category><![CDATA[singleton-pattern]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 06:25:18 GMT</pubDate>
            <atom:updated>2021-12-16T06:25:18.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Talking about the other 23 design patterns, this is the easiest and simplest. This design pattern limits the number of instances that may be created. If only one instance is required, it is preferable to utilize the Singleton design pattern. This pattern belongs to the category of Creational design patterns.</p><h3>What is Singleton? 🤔</h3><p>It means one instance per container. if you have a java program one instance for JVM likewise and remember if you implementing a singleton you should never take any arguments when you create an instance if you need to take arguments there are different patterns called Factory pattern we will focus on this in a later article. and also you do not overkill the singleton because it&#39;s very difficult to unit test because there are no instance variables and there no references to create that&#39;s why I call it a really hard to unit test. A singleton design pattern is defined as a single class that produces just one instance and gives a global point of access to it.</p><h4>Advantage of Singleton design pattern</h4><p>Because an object is not generated for each request, memory is saved. Only one instance is utilized over and over.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/0*guQXcvLZ2k2LKWg-.jpg" /><figcaption>Class Diagrams for singleton design patterns</figcaption></figure><p>Code of the Singleton design patterns</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*rgugw7oeVXSUpxT5zFmZrA.png" /><figcaption>SingleObject Class</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*6Zc4YHzZRxtQyWLrgIkHSg.png" /><figcaption>Get the only object from the singleton class.</figcaption></figure><p>Then What is the output 🤔</p><pre>Hello World!</pre><p>It just produces one instance. Only one instance is produced, regardless of how many the user requires.</p><p>This is the singleton design pattern</p><p>Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8c8306bfefb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Pattern in Java]]></title>
            <link>https://medium.com/@mihiranga-official/design-pattern-in-java-662b355b2ae7?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/662b355b2ae7</guid>
            <category><![CDATA[desgin-patterns]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 19:25:53 GMT</pubDate>
            <atom:updated>2021-12-15T19:25:53.035Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you are having a headache or something calls an illness in your body you suffer from it and need to meet a doctor. in that time doctor will ask some questions about your illness it seems like “do you have any difficulties breathing or eating food or something” better question list</p><p>why doctors ask every time when you have an illness they got to analyze the same kind of data every time with their experience and research of their medical life and figure out a pattern to how people are ill that&#39;s why they can figure out what&#39;s wrong with you or your body.</p><p>The same thing happens in the software engineering fields they got the same set of problems and they figure out what to and how to do with and find a solution and then solve the problem everything under the patterns.</p><p><strong>let&#39;s get back to the Subject</strong></p><p>we can divide it by 3 types for design pattern as under</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*qpCEHdkDzwkEdckBFoD1Wg.jpeg" /><figcaption>Design Patterns by Gang of four(Erich Gamma, Richard Helm, Ralph Johnson, Jhon Vlissides)</figcaption></figure><p><strong>There are 23 design patterns😒 Creational(5), Structural(7), Behavioural(10)</strong></p><p>If you know these design patterns no need to think what are the class to be created how to create variables. and also no need to worry about what language you know this is go with the OOP concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*uyrh2nkYA_TLSsxn" /><figcaption>Gang of four 23 designed patterns</figcaption></figure><p>so hope you are understanding the design patterns next story we will talk about singleton design patterns😍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=662b355b2ae7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Virtual Machine(3)]]></title>
            <link>https://medium.com/@mihiranga-official/java-virtual-machine-3-5ddf13df840f?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ddf13df840f</guid>
            <category><![CDATA[jvm]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 16:46:39 GMT</pubDate>
            <atom:updated>2021-12-15T16:46:39.187Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lets talk about the inside of the JVM</strong></p><p>A high-level picture of JVM is under</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*JtntvVuq3E1cp7dITdBmaQ.jpeg" /><figcaption>high-level picture of JVM</figcaption></figure><p>What is the inside of the JVM it has 3 components as Under</p><ol><li><strong>Load &gt;&gt;&gt; Class Loader</strong></li><li><strong>Store &gt;&gt;&gt; Memory Area</strong></li><li><strong>Execute &gt;&gt;&gt;Execution Engine</strong></li></ol><p>Let&#39;s discuss the <strong>Memory area</strong> (Later will discuss others)</p><p>We have 5 different areas in the<strong> Memory area</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*2cQPnt5-Gqze4sfuNllAGQ.jpeg" /><figcaption>5 different areas in the<strong> Memory area</strong></figcaption></figure><ol><li><strong>Method Area</strong> When you load the class it will load all the class information into <strong>Method area</strong></li><li><strong>Heap Area</strong> all the objects data will come here</li></ol><ul><li><strong>Each an every JVM we have only one heap area and one method area</strong></li></ul><p>3.<strong>Stack </strong>it will keep the method information</p><p>4.<strong>PC Registers </strong>Hold the information about next exuction</p><p>5.<strong>Native Mathod area </strong>This are will provide facility to hold that native method and method information stuff</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ddf13df840f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Virtual Machine (2)]]></title>
            <link>https://medium.com/@mihiranga-official/java-virtual-machine-2-45f1c66337b?source=rss-83359e182b42------2</link>
            <guid isPermaLink="false">https://medium.com/p/45f1c66337b</guid>
            <category><![CDATA[jvm]]></category>
            <dc:creator><![CDATA[Janith Gunawardana]]></dc:creator>
            <pubDate>Tue, 14 Dec 2021 18:28:53 GMT</pubDate>
            <atom:updated>2021-12-14T18:28:53.077Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous section, we talk about JVM basic structures and so on and there is nothing that exists called JVM. it&#39;s only virtual we can&#39;t touch it or feel it. JVM instant only exists on your computer until you run your program if you execute 2 or 3 different kinds of a program on your computer at the same time then there are 2 or 3 different JVM instances at your program&#39;s counts.</p><p><strong>When all programs exit no JVM instances on your computer left</strong></p><p>If the JVM starts its creates a none demon thread. And also your class needs to be a public static void method. It must be public and also void.it takes this method to execute.</p><p>And there are two ways for the program to get exits</p><ol><li>If no none demon threads are exits(all none demon threads are you created are destroyed then JVM instance get died )</li><li>And also the application can suicide😂 by itself that men it can call exit.</li></ol><p><strong>Rember this simple cycle</strong></p><p>When your application <strong>Run JVM was born JVM dies </strong>when your application ends😢</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45f1c66337b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>