<?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 Rookantha Madhushanka on Medium]]></title>
        <description><![CDATA[Stories by Rookantha Madhushanka on Medium]]></description>
        <link>https://medium.com/@rookantha?source=rss-39e1c37a299c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AqNL5PAVqKC7Lc7xvIkE_A.jpeg</url>
            <title>Stories by Rookantha Madhushanka on Medium</title>
            <link>https://medium.com/@rookantha?source=rss-39e1c37a299c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 03:56:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rookantha/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[Java static can be…]]></title>
            <link>https://medium.com/@rookantha/java-static-can-be-322d41504e78?source=rss-39e1c37a299c------2</link>
            <guid isPermaLink="false">https://medium.com/p/322d41504e78</guid>
            <category><![CDATA[static-variable]]></category>
            <category><![CDATA[static-block]]></category>
            <category><![CDATA[static]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[static-methods]]></category>
            <dc:creator><![CDATA[Rookantha Madhushanka]]></dc:creator>
            <pubDate>Sat, 01 Jan 2022 10:06:16 GMT</pubDate>
            <atom:updated>2022-01-01T10:08:32.090Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Static keyword</strong></p><blockquote><strong>“ The static keyword is a non-access modifier that lets the method run without any instance of the class. The static keyword can apply to the variables, methods, blocks, and nested classes.”</strong></blockquote><h3>Static Variables</h3><blockquote><strong>“ Static variables value is the same for all instances of the class”</strong></blockquote><p>All instances of the same class share a single copy of the static variables. Static variables will be created at the time of class loading and destroyed at the time of class unloading hence the scope of the static variable is exactly the same as the scope of the .class file. Static variables can be accessed from both instance and static areas directly. Static variables will be stored in the method area. Static variables should be declared within the class directly but outside of any method, block or constructor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*r3768h3Y_a8GJrBnX0KqHw.png" /><figcaption>Example code snippet.</figcaption></figure><p>In the above scenario, no matter what is assigned to the variable it always refers to the <strong>class level variable.</strong></p><h3>Static Method</h3><blockquote><strong>“ A static method means the behavior is not dependent on an instance variable, so no instance/object is required, the only need is the class”</strong></blockquote><p>Ex: <br>Methods in the Math class don’t use any instance variable values. because the methods are ‘static’, hence no need for an instance of Math only need is the Math class.<br>int x = Math.round(34.3);</p><h4><strong>Static and non-static method</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*-Dje1NF_m8TJ3axqJIS4LA.png" /><figcaption>Head First Java<br>Book by Bert Bates and Kathy Sierra</figcaption></figure><ul><li><strong>How JAVA Math Class Works — </strong>Constructor marked as a private means only code from within the class can invoke the constructor. JAVA the Math class, The constructor is private and cannot make a new instance of Math.</li><li><strong>Why Static methods can not use non-static (instance) variables and non-static methods—</strong> When using an instance variable inside a static method, the compiler is confused about which instance’s variable value to use. A static method is not associated with a particular instance it is only associated with the class. the class cannot access any instance variable values of its class. It wouldn’t know which instance’s values to use.</li></ul><h3>Static Control Flow and Static block</h3><p><strong>Read indirectly write-only state (or) RIWO </strong><br>Static Control Flow decides the sequence of steps executed in order to run a java class that contains static variables, methods, and blocks. in java, read and display values of variables within the static block are considered as direct read. if call a method from a static block, and within that method to read a variable that operation is considered as indirect read.<br>If a variable is in RIWO state then can not perform read operation directly otherwise, get a compile-time error that indicates an illegal forward reference.</p><blockquote><strong>“ Static blocks will be executed at the time of class loading hence if the programmer needs to perform any activity at the time of class loading that activity can define inside the static block. </strong>”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*aQSTsXbSzYYzOmlFaCMSVg.png" /><figcaption>Example code snippet.</figcaption></figure><p>Within a class, we can take any number of static blocks and all these static blocks will be executed from top to bottom.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=322d41504e78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Variables]]></title>
            <link>https://medium.com/@rookantha/java-variables-d08fc65b3fdd?source=rss-39e1c37a299c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d08fc65b3fdd</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[variables]]></category>
            <dc:creator><![CDATA[Rookantha Madhushanka]]></dc:creator>
            <pubDate>Fri, 31 Dec 2021 12:00:30 GMT</pubDate>
            <atom:updated>2021-12-31T12:00:30.581Z</atom:updated>
            <content:encoded><![CDATA[<h4>what is Variable</h4><blockquote>A variable is a container. It holds something.</blockquote><h4>Types of Variables</h4><p><strong>Based on the type</strong> of value represented by a variable all variables are divided into two types.</p><ul><li><strong>Primitive variables</strong> are full of bits representing the actual value of the variable.<br>Example: int x=10 (declare int named x, assign it the value 10 )</li><li><strong>Reference variables</strong> are full of bits representing ways to get the object to the variable. Reference variables are created in the stack and have a value of null when it is not referencing any object.<br>Example: Student s=new Student();</li></ul><p><strong>Based on the behavior and position of declaration</strong> all variables are divided into the following three types.</p><ul><li><strong>An instance variables</strong> are varied from object to object. variables are created at the time of object creation and destroyed at the time of object destruction hence the scope of instance variables is exactly the same as the scope of objects. Instance variables should be declared within the class directly but outside of any method or block or constructor. Instance variables can be accessed directly from the Instance area. But cannot be accessed directly from the static area. But by using object reference we can access instance variables from the static area. it is not required to perform initialization JVM will always provide default values.</li><li><strong>Static variables</strong> are declared If the value of a variable varied from object to object. Static variables will be created at the time of class loading and destroyed at the time of class unloading hence the scope of the static variable is exactly the same as the scope of the .class file. Static variables can be accessed from both instance and static areas directly.</li><li><strong>Local variables</strong> are declared inside the method or block or constructors by programmers for temporary requirements. also called local variables, automatic variables, temporary variables, or stack variables. Local variables store inside the stack. <br>The local variables will be created as part of the block execution in which it is declared and destroyed once that block execution completes. Hence the scope of the local variables is exactly the same as the scope of the block in which we declared</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d08fc65b3fdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The World Wide Web (WWW) and how to transfer data]]></title>
            <link>https://medium.com/@rookantha/the-world-wide-web-www-and-how-to-transfer-data-ab38a551ea1e?source=rss-39e1c37a299c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab38a551ea1e</guid>
            <category><![CDATA[world-wide-web]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[network]]></category>
            <category><![CDATA[data-communication]]></category>
            <category><![CDATA[internet]]></category>
            <dc:creator><![CDATA[Rookantha Madhushanka]]></dc:creator>
            <pubDate>Wed, 22 Dec 2021 09:37:15 GMT</pubDate>
            <atom:updated>2021-12-22T09:39:56.875Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Communication and Network</h3><h4>Data Communication</h4><blockquote>“ Data Communication refers to the exchange of data between a source and a receiver ”</blockquote><h4>Network</h4><blockquote>“ The interconnection of a set of devices capable of communication”</blockquote><p>A device can be A host<strong> </strong>(an end system) such as a large computer, desktop, laptop, workstation, cellular phone, or security system.<br>A connecting device such as a router (connects networks to other networks); a switch (connects devices together); a modem (modulator-demodulator).</p><p><strong>Transmission control </strong><br>Consider the transfer of data from one computer to another over a link. It is not satisfactory to transmit just the data on its own. For various reasons, it is necessary to exchange control information in addition to the data. The control information must usually be sent in both directions, even if the data is only one-way.</p><p><strong>Packets </strong><br>In most networks, data is NOT sent as a non-stop sequence of bits. But in groups of bits (variously called packets, blocks, frames, or protocol-data units).</p><p><strong>There are basically two types of connections:</strong></p><ol><li>Point-to-point — There is a dedicated link between the two nodes.</li><li>Point-to-multipoint — A single link is shared between devices.</li></ol><h4>Internetwork</h4><p>When two or more networks are connected they are called internetwork or internet.</p><h4>The Internet</h4><p>The Internet -is a term that’s used to refer to a massive network of millions of computers all over the world that are used to share and transmit information. This is done through various protocols and languages and includes things like email, SMS messaging, application data, as well as the web itself.</p><p><strong>Accessing the Internet</strong></p><ol><li>A dial-up service<br>Requires a computer, a modem and a telephone line. The modem converts the data signals to voice band frequencies.</li><li>A DSL service (DSL stands for Digital Subscriber Line)<br>Requires a computer, a DSL modem, and a telephone line. The modem converts the data signals to voice band frequencies.</li><li>Using cable networks (Example: Cable TV).</li><li>Using Wireless networks.</li><li>Direct connection using a high-speed leased line (Used by 6. Internet Service Providers).</li></ol><h3>The World Wide Web(WWW)</h3><blockquote>“ The World Wide Web, which is usually shortened to just the web, is a way of transmitting data over the Internet using the HTTP protocol and HTML ”</blockquote><p><strong>URI — Uniform Resource Identifier </strong><br>Identifies a “thing” on the web</p><p><strong>URL — Uniform Resource Locator</strong><br>A URI that starts with http. A URL contains information that directs a browser to the resource that the user wishes to access. Web servers make such resources available to web clients.</p><p><strong>URN — Uniform Resource Name</strong><br>The URN is the “globally unique” part of the identification; it’s a unique name. Ex: urn:isbn:0451450523</p><p><strong>Protocol</strong><br>A communications protocol is a set of rules that is Specifying how two or more computers interact By exchanging messages over some sort of communications network In order to achieve some agreed purpose.</p><p>Every time you click a link or type a URL into your browser, a request for that content is made to a server. As with most processes, there is a little bit more going on behind the scenes. When a browser makes a request, it uses a URL or uniform resource locator to locate the requested content. This request is usually passed on to a domain name server or DNS. The DNS then translates the URL into an IP address. The browser then uses this IP address to locate the host’s server and send a request for the content. Based on the type of files requested, several things take place next. If the request is a simple HTML page, the HTML text is sent to the browser where it’s rendered and presented to the user. If the page contains additional requests, such as CSS or images, those requests are presented to the server, the resources are downloaded, and the resulting content is rendered as well. Any client-side scripts such as JavaScript, triggered by the document loading, are also executed at this point. That’s how the process works for what we call static sites.</p><p>Dynamic site pages (such as PHP, .NET, or Ruby) first need to be processed by a web application. therefore the webserver processes the page and then the appropriate data is returned to the browser to be rendered. As before, requests such as style sheets, images, and client-side scripts are then executed.</p><p>The web can be summarized as a series of interactions between two types of systems, clients and servers.</p><p><strong>Clients</strong><br>Clients are the devices that request and render web content. Popular clients include browsers, mobile applications, screen readers, and various content aggregators.<br><strong>Servers.</strong><br>Servers are applications that deliver web content or services to clients. There is a wide range of web servers and types that specialize in specific types of data or specific processing capabilities.</p><p><strong>HTTP </strong><br>HTTP stands for hypertext transfer protocol. HTTP is a transaction-oriented client/server protocol. The most typical use of HTTP is between a Web browser and a Web server. To provide reliability, HTTP makes use of TCP. <br>Nevertheless, HTTP is a stateless protocol. Each transaction is treated independently. Accordingly, a typical implementation will create a new TCP connection between client and server for each transaction and then terminate the connection as soon as the transaction completes, although the specification.</p><p><strong>Reference texts</strong><br><a href="http://williamstallings.com/">Stallings, William, “Data and Computer Communications”, 10th Edition.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab38a551ea1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Desgin Patterns]]></title>
            <link>https://medium.com/@rookantha/software-desgin-patterns-495469d02a1d?source=rss-39e1c37a299c------2</link>
            <guid isPermaLink="false">https://medium.com/p/495469d02a1d</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[grasp]]></category>
            <category><![CDATA[gang-of-four]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Rookantha Madhushanka]]></dc:creator>
            <pubDate>Mon, 20 Dec 2021 07:30:41 GMT</pubDate>
            <atom:updated>2021-12-20T07:48:44.399Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is pattern</h4><p>Principles and idioms codified in a structured format describing the problem, solution, and given a name are called patterns. A “New Pattern” is an oxymoron. Patterns are tried and true, established ways of doing things. They are not new things or new ways of doing things.</p><blockquote><strong>Definition of pattern</strong></blockquote><blockquote>“The pattern is a named problem/solution pair that can be applied in new contexts, with advice on how to apply it in novel situations and a discussion of its trade-offs.”</blockquote><blockquote><strong>General Responsibility Assignment Software Patterns (GRASP)<br>Gang of Four Software Patterns (GoF)</strong></blockquote><h4>Design Activities</h4><p>During design and coding, we apply various OO design principles, among them software design patterns such as the GRASP and GoF patterns. Our metaphor is Responsibility Driven Design (RDD) because our chief design emphasis is on assigning responsibilities to objects.</p><p><strong>Responsibilities and Methods</strong></p><p><strong>Doing</strong></p><p><em>responsibilities of an object include :</em></p><ul><li>Doing something itself, such as creating an object or doing a calculation</li><li>Initialing action in other objects Controlling and coordinating activities in other objects</li></ul><p><strong>Knowing</strong></p><p><em>responsibilities of an object include :</em></p><ul><li>Knowing about private encapsulated data</li><li>Knowing about related objects</li><li>Knowing about things can derive or calculate</li></ul><h4>GRASP Software Patterns - Design objects with responsibilities</h4><p>GRASP was introduced by a computer scientist named ‘Craig Larman’.GRASP patterns are a learning aid to help one understand essential object design, and apply design reasoning in a methodical, rational, explainable way.</p><p>This design principle consists of nine major patterns:</p><ul><li><strong>Controller</strong> The controller pattern assigns the responsibility of dealing with system events to a non-UI class that represents the overall system or a use case scenario. A controller object is a non-user interface object responsible for receiving or handling a system event.</li><li><strong>Creator:</strong> Creator means one class or element is responsible for creating and maintaining another class or element.</li><li><strong>Indirection:</strong> As the name emphasizes, indirection is a GRASP design principle, that connects two-element or classes indirectly by having an intermediate class or an element.</li><li><strong>Information expert:</strong> A class that has the information necessary to fulfill the responsibility. An information expert is a principle used to determine where to delegate responsibilities for another class or not. These responsibilities include methods, data fields, and so on.</li><li><strong>High cohesion: </strong>Class or an element with highly dependent factors and strongly related responsibilities are referred to as high cohesion. Therefore, classes designed using high cohesion principles are not possible to decompose.</li><li><strong>Low coupling:</strong> Coupling simply means how strongly one class of a system is connected to another class. Low coupling is the opposite of that, it reduces the dependency between classes yet connected.</li><li><strong>Polymorphism:</strong> According to the polymorphism principle, responsibility for defining the variation of behaviors based on type is assigned to the type for which this variation happens. This is achieved using polymorphic operations. The user of the type should use polymorphic operations instead of explicit branching based on type.</li><li><strong>Protected variations:</strong> The protected variations pattern protects elements from the variations on other elements (objects, systems, subsystems) by wrapping the focus of instability with an interface and using polymorphism to create various implementations of this interface.</li><li><strong>Pure fabrication:</strong> A pure fabrication is a class that does not represent a concept in the problem domain, specially made up to achieve low coupling, high cohesion, and the reuse potential thereof derived (when a solution presented by the information expert pattern does not). This kind of class is called a “service” in domain-driven design.</li></ul><p>Each of the patterns is composed of an answer to a software problem.</p><h4>Gang of Four (GoF) Patterns</h4><p>Gang of four simply referred to a group of four members who wrote a book called “Elements of Reusable Object-Oriented Software” introducing 23 software design principles which were categorized under the following three headings:</p><p><strong>Creational patterns</strong></p><p>These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using the new operator.</p><ul><li><strong>Abstract factory</strong> groups object factories that have a common theme.</li><li><strong>Builder constructs</strong> complex objects by separating construction and representation.</li><li>The <strong>factory</strong><a href="https://en.wikipedia.org/wiki/Factory_method_pattern"><strong> </strong></a><strong>method </strong>creates objects without specifying the exact class to create.</li><li><strong>Prototype</strong> creates objects by cloning an existing object.</li><li><strong>Singleton</strong> restricts object creation for a class to only one instance.</li></ul><p><strong>Structural patterns</strong></p><p>These design patterns concern class and object composition.</p><ul><li><strong>Adapter </strong>allows classes with incompatible interfaces to work together by wrapping their own interface around that of an already existing class.</li><li><strong>Bridge decouples</strong> an abstraction from its implementation so that the two can vary independently.</li><li><strong>Composite</strong> composes zero-or-more similar objects so that they can be manipulated as one object.</li><li><strong>Decorator</strong> dynamically adds/overrides behaviour in an existing method of an object.</li><li><strong>Facade</strong> provides a simplified interface to a large body of code.</li><li><strong>Flyweight</strong> reduces the cost of creating and manipulating a large number of similar objects.</li><li><strong>Proxy</strong> provides a placeholder for another object to control access, reduce cost, and reduce complexity.</li></ul><p><strong>Behavioral patterns</strong></p><p>Most of these design patterns are specifically concerned with communication between objects.</p><ul><li><strong>Chain </strong>of responsibility delegates commands to a chain of processing objects.</li><li><strong>Command </strong>creates objects that encapsulate actions and parameters.<br>Interpreter implements a specialized language.</li><li><strong>Iterator </strong>accesses the elements of an object sequentially without exposing its underlying representation.</li><li><strong>Mediator </strong>allows loose coupling between classes by being the only class that has detailed knowledge of their methods.</li><li><strong>Memento </strong>provides the ability to restore an object to its previous state (undo).</li><li><strong>Observer </strong>is a publish/subscribe pattern, which allows a number of observer objects to see an event.</li><li><strong>State </strong>allows an object to alter its behavior when its internal state changes.</li><li><strong>Strategy </strong>allows one of a family of algorithms to be selected on the fly at runtime.</li><li><strong>Template </strong>method defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.</li><li><strong>Visitor </strong>separates an algorithm from an object structure by moving the hierarchy of methods into one object.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=495469d02a1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JAVA - Write once, run anywhere]]></title>
            <link>https://medium.com/@rookantha/java-write-once-run-anywhere-85737566cb1b?source=rss-39e1c37a299c------2</link>
            <guid isPermaLink="false">https://medium.com/p/85737566cb1b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jvm]]></category>
            <dc:creator><![CDATA[Rookantha Madhushanka]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 15:29:48 GMT</pubDate>
            <atom:updated>2021-12-20T13:35:14.032Z</atom:updated>
            <content:encoded><![CDATA[<p>A Java Programmer writes a program in a human-readable language called Source Code. Therefore, the CPU or Chips never understand the source code written in any programming language. These computers or chips understand only one thing, which is called machine language or code. These machine codes run at the CPU level. The machine understands this source code and translates them into machine understandable code, which is an executable code.</p><h4>Java is Programming Language and Platform (SE, EE, ME, FX)</h4><ol><li><strong>Java Standard Edition (SE)</strong></li></ol><ul><li>Core platform, Libraries, and API</li><li>Consist of JVM</li><li>Standalone applications, as well as GUI, or Graphical User Interface applications using FX, and can be used for gaming apps.</li></ul><p><strong>2. Enterprise Edition (EE)</strong></p><ul><li>Server-centric</li><li>For developing and running portable, robust, scalable, reliable, and secure server-side applications</li><li>Includes EJB (Enterprise JavaBeans)</li><li>Java Persistence API</li><li>Multi-tiered application (Client, middle and data tier)</li><li>Java EE components — clients and applets, Java Servlet, JSF, and JSP technology.</li></ul><p><strong>3. Java Micro Edition (ME)</strong></p><ul><li>a subset of Java SE</li><li>The big benefit of Java ME is the SDK provides device emulation.</li><li>The SDK supports a large range of devices in the IoT.</li><li>This includes, but is not limited to, microcontrollers, sensors, gateways, mobile phones, personal digital assistants, or PDAs, TV set-top boxes, printers, and more.</li></ul><p><strong>4. Java FX</strong></p><h4>What are JDK, JRE, and JVM</h4><p><strong>JDK</strong> is the software development kit to develop applications in Java. It contains tools for developing, debugging, and monitoring java code.JDK is platform-dependent and comes with the installer.</p><p><strong>JRE</strong> is a software bundle It contains class libraries and other supporting files that JVM requires to execute the java program.JRE is also platform-dependent and JRE only contains an environment to execute source code.</p><p><strong>Java Virtual Machine (JVM )</strong> is an Application based Virtual Machine and It is a process/specification of how java run. When installing the JRE, JRE deploys cords to create JVM. When running a java program JVM converts the byte cord to machine code.JVM is platform-independent and does not include software development tools. JVM died when the last non-demand trad died</p><h3>Write once, run anywhere</h3><p>Like the C compiler, the Java compiler does not produce native executable code for a particular machine. Instead, Java produces a unique format called bytecode. It executes according to the rules laid out in the virtual machine specification. Therefore, Java is a platform-independent language.</p><p>Bytecode is understandable to any JVM installed on any OS. In short, the java source code can run on all operating systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85737566cb1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>