<?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 Mishan Kavindu Perera on Medium]]></title>
        <description><![CDATA[Stories by Mishan Kavindu Perera on Medium]]></description>
        <link>https://medium.com/@mishanperera?source=rss-be0028a6d702------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ilrygrXhRxCI_nV0</url>
            <title>Stories by Mishan Kavindu Perera on Medium</title>
            <link>https://medium.com/@mishanperera?source=rss-be0028a6d702------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:52:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mishanperera/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[What Exactly is React Js?]]></title>
            <link>https://mishanperera.medium.com/what-exactly-is-react-js-89fb619dee03?source=rss-be0028a6d702------2</link>
            <guid isPermaLink="false">https://medium.com/p/89fb619dee03</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Mishan Kavindu Perera]]></dc:creator>
            <pubDate>Sun, 15 May 2022 15:42:45 GMT</pubDate>
            <atom:updated>2022-05-15T15:42:45.736Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*hqKmYVxnRIr7SgBXR9v_rA.png" /></figure><p>React is a front-end JavaScript library for creating user interfaces using UI components that is free and open-source. A JavaScript library for designing user interfaces also serves as an MVC view. React is well suited to massive online applications that use data and change over time without requiring a page reload. React Native creates mobile apps for various platforms, whereas React VR is used to create virtual reality apps. Speed, simplicity, and scalability are the goals.</p><h3><strong>Significant Characteristics</strong></h3><ul><li>Data flow is one-way.</li></ul><p>Single source of truth — Data is created and stored in one location, unchangeable. Data is passed from the parent to the child component. From the child component to the parent component, actions give.</p><ul><li>JSX</li></ul><p>The React JS language is used to create user interfaces. Syntax similar to HTML/XML. Converts expressions to strings to prevent cross-site scripting attacks.</p><ul><li>Virtual DOM</li></ul><p>Instead of DOM manipulation, react creates a virtual DOM tree and compares it to the rendered tree, updating only what has changed.</p><h3><strong>Props and State</strong></h3><p>Props are used to communicate data and behaviour between container and child components. Props can only be read. Data that can be updated is kept in state. The state is read-write. To update the status, use the setState() method. Because the setState method is asynchronous, you must use the second form of the method setState((state, props)=&gt;) to use the state and props within it.</p><h3><strong>Lifecycle of Components</strong></h3><ul><li>constructor</li></ul><p>Constructor in Java Script. Declare state and tie life cycle events to context. Do not call setState. Always call super(props) to bind this. Props.</p><ul><li>render</li></ul><p>The component is being rendered. When the state or props are modified, this method is called. Returns JSX, Portal, Fragments, Strings, and booleans, among other things.</p><ul><li>componentDidMount</li></ul><p>It fires once the component has been mounted to the DOM. Can communicate with the DOM. Ajax calls and state updates.</p><ul><li>componentDidUpdate</li></ul><p>After the component has been updated. If shouldComponentUpdate returns false, the program will not run. After a Component update, use this to interact with the DOM.</p><ul><li>shouldComponentUpdate</li></ul><p>To determine whether or not to update the component. If necessary, only as a performance boost.</p><ul><li>componentWillUnmount</li></ul><p>This component is utilized before the component is removed. SetState should not be called. Tasks will be cleaned up.</p><ul><li>getDerivedStateFromProps</li></ul><p>If you wish to update your state using props, this is the method. React strongly advises against using this. Conditionally setting state from props is strongly discouraged.</p><ul><li>componentDidCatch</li></ul><p>This component is used after a decedent component error. To get error-related State, use getDerivedStateFromError. For logging and side effects, use componentDidCatch.</p><h3><strong>Context API</strong></h3><p>API is relatively new. The primary goal was to prevent passing props through numerous tiers. React specifies that this usage should only be applied to context-level data. Authenticated users, for example. Context API should not be used to represent a state. Controlling the rendering is a challenge.</p><h3><strong>Babel</strong></h3><p>The most widely used JavaScript transpiler. Convert JavaScript es6 features and beyond to the most recent version that is compatible. To support new global objects, Babel polyfills are available. Polyfills from core-js are used. Babel’s compatibility with new features has been among the greatest so far. Source maps enable debugging. Optimization is incorporated into the code. FLOW and JSX (XML-like syntax extension) are supported (Static type checker).</p><h3><strong>Hooks</strong></h3><p>This functionality is new. This is a method of introducing state, as well as some life cycles, to functional components. This feature is frequently used to extend the functionality of functional components. Hooks should only be used in React functional components and custom hooks at the top level (not in loops). useStae and useEffect are mainly two popular hooks.</p><h3><strong>Webpack</strong></h3><p>The most well-known module bundler. Support for both the build system and module bundling. Split the code into several files. AMD and CommonJS are supported. Use loaders to extend (transpiring, CSS transformation, image optimization). Supports production improvements (minification, uglification). Simple configuration in four steps: entry, loaders, plugins, and output.</p><h3><strong>Parcel</strong></h3><p>Most efficient module bundler. Conventions take precedence over configurations. Support for JSX, SCSS, LESS, SVG, TypeScript, and more languages. Extensions and plugins are automatically detected.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89fb619dee03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Node.js?]]></title>
            <link>https://mishanperera.medium.com/what-is-node-js-f628eb01d19a?source=rss-be0028a6d702------2</link>
            <guid isPermaLink="false">https://medium.com/p/f628eb01d19a</guid>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Mishan Kavindu Perera]]></dc:creator>
            <pubDate>Sun, 15 May 2022 14:58:22 GMT</pubDate>
            <atom:updated>2022-05-15T14:58:22.294Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*HhX-fDHAfhzOiWviwLfiFw.png" /></figure><p>Node.js is a server-side platform based on the JavaScript Engine in Google Chrome (V8 Engine). Ryan Dahl created Node.js in 2009, and the most recent version is v0.10.36. Node.js is a cross-platform runtime environment for developing server-side and networking applications that are free source. Applications created in Node.js are written in JavaScript and can be run on any platform. Apple OS X, Microsoft Windows, and Linux using the Node.js runtime.Node.js also come with an extensive library of JavaScript modules to help you get started. To a large extent, Node.js is used to build online applications.</p><h3><strong>Characteristics of Node.js</strong></h3><p>The features that make Node.js the primary choice of software architects are listed below.</p><ul><li>Asynchronous and Event-Driven, The Node.js library’s APIs are all asynchronous or non-blocking. It means that a Node.js server never waits for data from an API. After accessing an API, the server moves on to the next one, and a notification mechanism in Node.js called Events assists the server in receiving a response from the previous API request. Node.js library is rapid in code execution because it is built on Google Chrome’s V8 JavaScript Engine.</li><li>Node.js uses a single-threaded structure with event looping, making it very scalable. In contrast to typical servers that create limited threads to process requests, the event mechanism allows the server to reply in a non-blocking manner and makes it more scalable. Node.js uses a single-threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server.</li><li>There is no data buffering in Node.js apps. The data is output in chunks by these apps.</li><li>The MIT license governs the distribution of Node.js.</li></ul><h3><strong>Where to Use Node.js?</strong></h3><p>The areas where Node.js is proving to be an excellent technology partner are as follows.</p><ul><li>I/O bound Applications</li><li>Data Streaming Applications</li><li>Data-Intensive Real-time Applications (DIRT)</li><li>JSON APIs based Applications</li><li>Single Page Applications</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjT3zvbkQG6Z1BSmnn3mlA.png" /></figure><h3><strong>Advantages of Node.js</strong></h3><p>1. A solid technological foundation</p><p>Among the most popular programming languages, JavaScript has proven to be the unchallenged king. As a result, Node.js has established itself as a brand name. According to the Node-by-numbers report 2018, the project is stronger than ever, with 368,985,988 downloads and over 750 new contributors. When you use Node.js for your backend, you receive all of the benefits of full-stack JavaScript development, including:</p><ul><li>Improved developer productivity and efficiency</li><li>Code reuse and sharing</li><li>A large number of free tools; speed and performance</li><li>Easy knowledge sharing within a team</li></ul><p>2. It is not a misconception that Node.js is quick. Check out toptal.com’s performance tests to see how GO, PHP, Java, and Node.js handle concurrent queries.</p><p>3. Microservices and scalable technologies</p><p>Node.js for microservices architecture is a beautiful choice because it is a lightweight technology platform.</p><p>4. A diverse ecosystem</p><p>5. Corporate support is vital.</p><p>6. JSON support is seamless.</p><p>Other backend technologies, such as PHP and Ruby on Rails, can communicate in JSON format. However, Node.js does so without translating between binary models and instead uses JavaScript.</p><h3><strong>Disadvantages of Node.js</strong></h3><ul><li>Heavy calculation activities cause performance constraints.</li></ul><p>Node.js’ major flaw is its inability to handle CPU-intensive activities. However, we need some background information to understand the origins of this problem. Let’s start with the fundamentals of JavaScript.</p><p>Node.js, as we all know, is a server-side runtime environment for JavaScript. As a front-end programming language, JavaScript processes tasks in a single thread. Because JavaScript jobs are lightweight and utilize little CPU, it does not require threading.</p><ul><li>Issue with callbacks</li></ul><p>Because of its asynchronous nature, Node.js mainly relies on callbacks, which are routines that run whenever each task in the queue has been completed. Keeping a multitude of queued activities running in the background, each with its callback, can lead to callback hell, which directly influences code quality.</p><ul><li>Tooling immaturity</li></ul><p>Even though the core Node.js modules are relatively stable and mature, numerous tools in the npm registry are either of poor quality or are not adequately documented/tested. Furthermore, the registry isn’t well-structured enough to allow users to search for tools depending on their rating or quality. As a result, if you don’t know what to look for, finding the ideal solution for your needs could be challenging.</p><ul><li>Demand for skilled workers is increasing.</li></ul><p>Despite popular perception, not all JavaScript engineers also work with Node.js. Mastering server-side JavaScript programming necessitates substantial time and experience with back-end development. The number of Node.js engineers is much smaller than the number of JS professionals due to the steep learning curve.</p><h3><strong>Node Package Manager</strong></h3><p>For the JavaScript runtime environment Node.js, the node package manager is the default package manager. It consists of a command-line client, the node package manager, and the node package manager registry, an online database of public and paid-for private packages. The client may visit the registry, and the node package manager website can be used to browse and search for available packages. The node package manager is in charge of the package management and the registry.</p><p>The Node Package Manager (npm) offers the following two primary features:</p><ul><li>Node.js package/module repositories that may be searched on search.nodejs.org</li><li>Install Node.js packages, control their versions, and manage dependencies with this command-line utility.</li></ul><h3><strong>Uses of Node Package Manager</strong></h3><ul><li>Packages that are local dependencies of a project and globally installed JavaScript tools can be managed with Node Package Manager.</li><li>When used as a dependency manager for a local project, Node Package Manager may install all of a project’s dependencies via the package in a single command.</li><li>Each dependency can designate a range of valid versions using the semantic versioning system in the package.json file, allowing developers to auto-update their packages while avoiding unnecessary breaking changes.</li><li>Developers can use Node Package Manager’s version-bumping tools to tag their packages with a specific version.</li><li>After reviewing semantic versioning in package.json, Node Package Manager additionally delivers the package-lock.json file, which contains the entry of the precise version utilized by the project.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f628eb01d19a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO BUILD A REST API WITH KOA.JS]]></title>
            <link>https://mishanperera.medium.com/how-to-build-a-rest-api-with-koa-js-7f162fea009a?source=rss-be0028a6d702------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f162fea009a</guid>
            <category><![CDATA[koajs]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[restful-api]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[application-frameworks]]></category>
            <dc:creator><![CDATA[Mishan Kavindu Perera]]></dc:creator>
            <pubDate>Sun, 15 May 2022 13:48:22 GMT</pubDate>
            <atom:updated>2022-05-15T13:48:22.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*suRbX8DrOS34P0NB_d9Bkw.jpeg" /></figure><h3><strong>RESTful Services</strong></h3><p><strong>REST which stands for </strong>REpresentational State Transfer, is used to work efficiently on the Web. It is a style of architecture, and it is not a type of protocol. It specifies constraints, one of which can be taken as a uniform interface. In REST, the resources named as data and functionality are being accessed using <strong>Uniform Resource Identifiers or else (URIs)</strong>, the links on the Web. These resources use operations which are well-defined and straightforward. REST use HTTP, which is a stateless communication protocol which is being designed as a client/server architecture. In its architecture, representations of resources are exchanged by clients and servers by using a standardized interface and protocol. RESTful web services are platform-independent, which can be written using any programming language &amp; can be executed on any platform. Also, it consumes less bandwidth and resources. RESTful web services <strong>Permit different data formats like </strong>Plain Text, HTML, XML and JSON.</p><p>RESTful applications have become simple, lightweight, and fast due to the below reasons.</p><p>•<strong> Identifying Resources through URI</strong>: A RESTful web service has a set of resources which identify the interaction targets with its clients. URLs identify these resources, providing a global addressing space for resource and service discovery.</p><p>• Uniform interface: PUT, GET, POST, and DELETE are the only four operations that can be used to create, read, update, or delete resources. PUT generates a new resource that can then be deleted using DELETE. The GET method retrieves the current status of a resource in some form. POST updates the status of a resource.</p><p>•<strong> </strong>Resources are detached from their representation, allowing their content to be accessible in various formats, including HTML, XML, plain text, PDF, JPEG, JSON, etc. The resource’s metadata is available and can be used to control caching, identify transmission faults, negotiate the best representation format, and perform authentication or access control, among other things.</p><p>•<strong> </strong>Stateful hyperlink interactions: Every interaction with a resource is stateless; request messages are self-contained. The principle of direct state transfer underpins stateful interactions. The several methods of exchanging states, including URI rewriting, cookies, and hidden form fields.</p><h3><strong>HTTP Messages</strong></h3><p>Messaging is the name for this method. HTTP protocols are used by RESTful Web Services to communicate between client and server. A client sends a message to the server in an HTTP Request, and the server answers with an HTTP Response. These messages include message data and metadata or information about the message. Let’s have a look at the HTTP Request and HTTP Response messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*EM56HHlCrsvnfvfK_s-SwA.png" /><figcaption><strong>HTTP Request</strong></figcaption></figure><p>•<strong> </strong>There are five major components to an HTTP request.</p><ol><li>Verb identifies HTTP methods like GET, POST, DELETE, and PUT.</li></ol><p>2. URI (Uniform Resource Identifier) identifies the server’s resource. This field indicates the HTTP version. Consider HTTP version 1.1.</p><p>3. The metadata of the HTTP Request message is stored as key-value pairs in the Request Header.</p><p>4. Client (or browser) type, the format supported by the client, message content format, cache settings, etc.</p><p>5. Message content or Resource representation in the Request Body.</p><p>•<strong> </strong>There are four primary components to an HTTP response.</p><ol><li>The Status/Response Code indicates the Server status for the requested resource. For example, 404 indicates that a resource was not found, and 200 indicates that the response was OK.</li></ol><p>2. This field indicates the HTTP version. Consider HTTP v1.1.</p><p>3. Metadata for the HTTP Response message is stored as key-value pairs in the Response Header. For instance, content length, type, response date, server type, etc.</p><p>4. Response Body Content of the response message or Resource representation.</p><h3><strong>HTTP Verbs</strong></h3><h4><strong>1. Method of HTTP GET</strong></h4><p>Use GET requests exclusively to get resource representations/information, not change it. GET requests are considered safe because they do not modify the resource’s state. Furthermore, GET APIs should be idempotent, which implies that making repeated identical queries should always return the same response until another API (POST or PUT) changes the resource’s state on the server.</p><p>GET returns a JSON or XML representation and the HTTP status code 200 if the address is successfully received (error-free) (OK). The error code 404 (NOT FOUND) or 400 (BAD REQUEST) is returned in most cases.</p><p>•<strong> Example for GET request URI:</strong></p><p><a href="http://www.usermanagement/api/users/%7Busername%7D/posts"><strong>http://www.usermanagement/api/users/{username}/posts</strong></a><strong> - </strong>Get posts created by user</p><h4><strong>2. POST Method on HTTP</strong></h4><p>The HTTP POST request is most typically used to generate new resources. POST methods are used to add a new resource to the collection of resources when speaking strictly in terms of REST.</p><p>An HTTP code 201 is returned upon successful creation, along with the address of the newly created resource in the ‘Location’ header.</p><p>•<strong> Examples for HTTP POST requests:</strong></p><p><a href="http://www.domain/api/posts"><strong>http://www.domain/api/posts</strong></a><strong> - </strong>Create Post</p><p><a href="http://www.domain/api/posts/%7BpostId%7D/comments"><strong>http://www.domain/api/posts/{postId}/comments</strong></a><strong> - </strong>Create new comment for post with id = postId</p><h4><strong>3. PUT Method on HTTP</strong></h4><p>PUT APIs are mainly used to update existing resources (if the resource does not exist, then API may decide to create a new resource or not). The origin server MUST inform the user agent via the HTTP response code 201 (Created) if the PUT API has created a new resource. If an existing resource has been modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request.</p><p>•<strong> Examples for HTTP PUT requests:</strong></p><p><a href="http://www.domain/api/posts/%7Bid%7D"><strong>http://www.domain/api/posts/{id}</strong></a><strong> - </strong>Update post by id</p><p><a href="http://www.domain/api/posts/%7BpostId%7D/comments/%7Bid%7D"><strong>http://www.domain/api/posts/{postId}/comments/{id}</strong></a><strong> - </strong>Update comment by id if it belongs to post with id = postId</p><p>The difference between the POST and PUT APIs can be observed in request URIs. POST requests are made on resource collections, whereas PUT requests are made on a single resource.</p><h4><strong>4. DELETE Method in HTTP</strong></h4><p>Use the DELETE APIs (identified by the Request-URI) to delete resources.</p><p>HTTP response code 200 (OK) if the response includes an entity specifying the status, 202 (Accepted) if the action has been queued, or 204 (No Content) if the action has been completed, but the response does not include an entity.</p><p>•<strong> Example for HTTP DELETE request:</strong></p><p><a href="http://www.domain/api/posts/%7Bid%7D"><strong>http://www.domain/api/posts/{id}</strong></a><strong> - </strong>Delete post</p><h4><strong>5. PATCH HTTP Method</strong></h4><p>PATCH requests are used to make incremental changes to a resource. To be clear, PUT requests also affect a resource object, so the PATCH method is the ideal choice for partially changing an existing resource, and PUT should only be used if you’re completely replacing a resource.</p><h3><strong>Constraints</strong></h3><h4><strong>1.</strong> <strong>Client-Server</strong></h4><p>The client and server are kept loosely linked by this requirement. In this situation, the client is unconcerned about the server’s implementation details, and the server is unconcerned about the client’s use of the data. A common interface is maintained between the client and the server to facilitate communication. This restriction is based on the separation of concerns principle.</p><p>Separates user interface problems from data storage concerns through separation of concerns.</p><p>• Improves interface portability across many platforms.</p><p>• Allows components to evolve independently and improves scalability by simplifying server components.</p><h4>2. Stateless</h4><p>The service should not be required to store user sessions. To put it another way, the constraint is that the server should not remember the application’s state. As a result, the client should transmit all relevant information with each request because the server cannot reuse data from prior requests because it does not remember it. The message has the all necessary information.</p><p>• The session state is retained solely on the client using the statelessness constraint.</p><p>• Visibility is improved because a monitoring system only needs to look at one request.</p><p>• Reliability is increased since partial failures are easier to recover from.</p><p>• Scalability is improved because resources for storing state are not required.</p><p>• The server does not need to manage anything.</p><h4>3. Cacheable</h4><p>This restriction must be compatible with a caching system. At various levels, the network infrastructure should support a cache. Repeated round trips between the client and the server to retrieve the same resource can be avoided via caching.</p><p>By enabling non-shared caching,</p><p>• Data in response to a request is cacheable or non-cacheable, either implicitly or explicitly.</p><p>• If a response is cacheable, a client cache is granted permission to reuse the response data for future, similar queries.</p><p>• Increases efficiency, scalability, and user satisfaction.</p><p>• The cacheable limitation lowers reliability.</p><h4>4. Uniform Interface</h4><p>This constraint denotes a generic interface that manages all client-server interactions uniformly, simplifying and decoupling the architecture. This constraint specifies that each resource supplied to the client must have a specific address and be accessible via a generic interface. A general collection of methods allows the client to act on the resources.</p><p>The entire system design is simplified, and interaction visibility is improved by using uniform interface constraints. Implementations are divorced from the services they deliver, allowing them to evolve independently.</p><p><strong>Trade-off:</strong> Reduces efficiency because data is delivered in a standard format rather than one tailored to the application’s requirements. A uniform interface contains four sub-constraints as well.</p><p>• Resource identification</p><p>• Resource manipulation via representations</p><p>• Self-descriptive communications</p><p>• Hypermedia as an application state engine (HATEOAS)</p><h4>5. Layered System</h4><p>For implementation, the server can have numerous layers. By allowing load balancing, this layered architecture aids in scalability. It also boosts performance by distributing shared caches at several levels.</p><p>Applying a layered system constraint enhances simplicity by separating concerns, similar to the client-server constraint.</p><p>• Legacy services can be encapsulated, and new services can be protected from legacy clients.</p><p>• By facilitating load balancing, intermediaries can help improve system scalability.</p><p>• Having shared caches at the organizational domain’s edges can benefit considerably. Security policies, such as firewalls can also be enforced.</p><p>• Because messages are self-descriptive and their semantics are visible to intermediates, intermediaries can actively modify message content.</p><p><strong>Tradeoff:</strong> Increases overhead and delay while lowering user perception.</p><h4>6. Code on Demand</h4><p>This restriction is not required. This restriction specifies that the client apps’ functionality can be expanded at runtime by enabling the server’s download and execution of code. Applets and JavaScript code are two examples of client-side code sent and performed at runtime.</p><p>Using the Code-on-Demand constraint</p><p>• Clients are simplified, resulting in less feature coupling.</p><p>• Increases scalability by offloading tasks from the server to the clients.</p><p><strong>Trade-off:</strong> Reduces visibility generated by the code, which is difficult to interpret for an intermediate.</p><h3><strong>Koa JS</strong></h3><p>The team behind express developed Koa.js, an open-source Node.js web framework. According to its official website, the framework aspires to provide a smaller, more expressive, and more robust base for web applications and APIs. Koa uses asynchronous functions to reduce the requirement for callbacks and improve error handling. Koa’s core does not include any middleware. It offers an improved set of ways for speeding up and exciting the server-building process.</p><h4><strong>Features</strong></h4><p>1. Koa.js is cutting-edge and future-ready — Unlike previous Node.js frameworks, Koa.js is built using ES6, which simplifies the construction of complicated applications by introducing new classes and modules. This aids in the development of maintainable apps.</p><p>2. Koa.js makes advantage of ES6 generators to make synchronous programming and control flow easier. These generators can also control code execution on the same stack as functions.</p><p>3. In comparison to other Node.js frameworks, Koa.js has a minimal footprint. It allows developers to create middleware that is lighter.</p><p>4. Koa.js includes an error catchall to assist prevent website crashes.</p><p>5. Koa.js makes use of a context object, which is a container for request and response objects.</p><h4><strong>Users of Koa.js</strong></h4><p>For their websites and online APIs, several companies use the Koa.js framework. The following is a list of five well-known companies that use the Koa.js framework.</p><p>1. Paralect</p><p>2. Pubu</p><p>3. Bulb</p><p>4. GAPO</p><p>5. Clovis</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f162fea009a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Version Controlling]]></title>
            <link>https://mishanperera.medium.com/version-controlling-8db817f3b33a?source=rss-be0028a6d702------2</link>
            <guid isPermaLink="false">https://medium.com/p/8db817f3b33a</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[application-frameworks]]></category>
            <dc:creator><![CDATA[Mishan Kavindu Perera]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 16:31:27 GMT</pubDate>
            <atom:updated>2022-03-17T16:31:27.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*Nrk2U38P3MMeaW3c4YknIw.jpeg" /></figure><p>Version control is the process of keeping track of changes to a source. A relevant revision number uses to identify the modifications. Each modification includes a timestamp and the identity of the person who made the change. It is possible to restore, compare, and merge revisions. Developers utilize version control because it allows for more accessible backups and a central source code repository. It is also a simple collaborative development. When new developers join the team, they can use the version control system to easily download the latest version of the program to their local environment and keep track of the version they are running. It also manages access.</p><h4><strong>1. Terminology of version controlling</strong></h4><p><strong>a. Commit</strong></p><p>Make a copy of the modifications to the files. Every time they are committed, it effectively takes a snapshot of all the files at the time and saves a reference to that snapshot.</p><p><strong>b. Repository</strong></p><p>A repository is a directory that includes the project’s work and all files used to communicate. Repositories can exist locally on the computer or as a remote copy on another machine.</p><p><strong>c. Branch</strong></p><p>Developers can use branches to generate different versions of their projects. They can work on new features and experiment with new ideas without affecting the original project when they branch.</p><p><strong>d. Trunk</strong></p><p>The unnamed branch of a file tree under revision control is the trunk. The trunk is typically intended to serve as the foundation for a project’s development.</p><p><strong>e. Merge</strong></p><p>A merge, also known as integration, is a process in which two sets of modifications are applied to a single file or a group of files.</p><p><strong>f. Conflict</strong></p><p>When many parties make modifications to the same document and the system cannot reconcile the changes, a conflict ensues. A user must choose between combining the modifications or selecting one change over the other to settle the conflict.</p><p><strong>g. Checkout</strong></p><p>A checkout is used to make a functional copy. Checkout takes a server revision and creates a local working copy with the information needed to link it to the server’s repository. It is possible to amend a checkout and then apply the changes to a repository.</p><h4><strong>2. Best practices</strong></h4><p>Commit changes automatically. Whether the team is big or small, every team should follow the best practices of version control. These include:</p><p><strong>a.</strong> <strong>Commit changes automatically</strong></p><p>In version control, one recommended practice is to commit changes atomically. A commit’s files are either committed all at once or not. No other user should be able to see changes that are only partially completed. To keep the project consistent, commit all files that relate to a task in a single process. When it comes to pledges, it’s critical to follow best practices. High-quality commits will help you increase your project’s productivity and success.</p><p><strong>b. Compose effective commit messages</strong></p><p>Writing good commit messages is another best practice. Each commit should have a description that indicates why the change was made, but not necessarily how it was made. (It is usually possible to figure out how by comparing the contents of the files before and after the change.)</p><p><strong>c. Commit files for a specific purpose</strong></p><p>Each commit should be the focus on a particular goal. Fixing a problem or creating a new feature, for example. Evaluating and reviewing the project can be challenging if a single change causes several independent changes. The procedure of undoing one of these changes becomes more difficult and time-consuming.</p><p><strong>d. Builds should not be broken</strong></p><p>Another excellent practice in version control is to avoid breaking builds by making complete commits. Provide test cases and stubs for new APIs. It ensures that other team members can use each commit without destroying their build. It is easier to propagate a complete commit between branches. For example, an incomplete API change might build locally in the work area and pass all tests. However, it may cause damage to another team member’s workspace.</p><p><strong>e. Before committing to a shared repository, do reviews</strong></p><p>Doing reviews before committing to a shared repository is also a best practice for version control. It is frequently inspected before merging an excellent commit to a shared repository. It can be accomplished using either a review system or a pull request. Reviews are an excellent approach for gaining a different perspective on a modification and improving the code’s quality. Code reviews can also help the team become more aware of the code. It improves the team’s productivity by allowing them to reuse code and produce higher-quality results.</p><p><strong>f. Make sure that every commitment can be tracked</strong></p><p>Traceability is another best practice for version control. Before and after the commit, the project should be able to build and pass its test cases. If the developer finds an issue and wants to figure out what changed to cause it, usually restore the working environment to a previous point to make sure the bug is still present. It is more challenging to track down a bug if earlier updates do not compile.</p><p><strong>g. Best branching practices to follow</strong></p><p>In version control, adhering to branching best practices is just as important. So, what is the optimal branching strategy?</p><p>There are numerous strategies.</p><p>Managing releases, new features, and bugs require the use of branches. However, branching can provide some difficulties. Changes in one branch, for example, must frequently propagate to other branches. It is vital to follow branching best practices to minimize merging conflicts, missing updates, and unintended overwriting of existing modifications.</p><p><strong>h. Secure the Assets</strong></p><p>Another recommended practice in version control is to use the appropriate security measures to safeguard the assets. The organization’s version control system is a critical repository. It stores and handles some of the company’s most valuable assets:</p><ul><li>The intellectual property (IP) comprises source code for internal and external applications.</li><li>The product designs are fantastic.</li><li>Documentation for export or compliance.</li><li>Videos, graphics, or photos that developers have created.</li><li>Documents of the business.</li></ul><h4><strong>GIT</strong></h4><p>Software development teams can use GitHub to communicate and keep track of all code changes. It can keep track of code changes, go back in time to fix mistakes, and share the work with other team members.</p><p>It is a place where Git projects can be stored. For those unfamiliar with Git, it is a distributed version control system. It is a free and open-source version control system with local branching, different workflows, and handy staging zones. Git version control is an easy-to-use option that provides for faster operation.</p><p>The standard Git command-line interface can be used to access and manage projects on GitHub.com; all standard Git commands work with it. Users can also look through public repositories on GitHub.com. There are also several desktop clients and Git plugins available.</p><p>Git has a feature called a “worktree” that allows running numerous branches simultaneously. It accomplishes this by establishing a new directory that contains a copy of the git repository that is synchronized between the two directories in which it is stored.</p><p>To transport data, Git supports four different protocols: local, HTTP, Secure Shell (SSH), and Git.</p><p>The concept of “saving” in Git or other version control systems is more subtle than in a word processor or other typical file editing applications. In traditional software, the term “saving” is synonymous with the Git term “committing.” The Git counterpart of a “save” is a commit. Traditional saving is a file system procedure that allows to overwrite an existing file or create a new one. Git committing, on the other hand, is a procedure that affects a set of files and folders.</p><p><strong>a. In git, what is a staging area?</strong></p><p>“Untracked files” is another term for these files. The staging area contains files that will be part of the next commit, letting Git know what modifications will be made in the file for the next commit. All project commits are stored in the repository.</p><p><strong>b. In git, what is stashing?</strong></p><p>Local commits in the staging area and Git stashed resulted in this image. The git stash command stores and reverts the working copy’s uncommitted changes.</p><p><strong>c. What is a local commit, and how does it work?</strong></p><p>To save the modifications to the local repository, use the “commit” command. Before performing the “git commit” command, you must specifically tell Git which changes you wish to include in the commit. It means it will not be automatically included in the following commit just because a file has been updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8db817f3b33a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Application Development Principles and JavaScript]]></title>
            <link>https://mishanperera.medium.com/application-development-principles-and-javascript-db072be0162b?source=rss-be0028a6d702------2</link>
            <guid isPermaLink="false">https://medium.com/p/db072be0162b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[application-frameworks]]></category>
            <category><![CDATA[classes-and-objects]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[principles-of-design]]></category>
            <dc:creator><![CDATA[Mishan Kavindu Perera]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 08:49:43 GMT</pubDate>
            <atom:updated>2022-02-26T08:59:07.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*srjeiRP5HnsjA7RYk8TEog.jpeg" /></figure><p>In the software development industry, application frameworks are utilized by industry standards. The industry should adhere to certain principles to design software properly. Those principles are shown below.</p><ul><li>S.O.L.I.D.</li><li>Approaching the solution</li><li>Implementing the solution</li><li>Practices</li></ul><h3><strong>1. S.O.L.I.D.</strong></h3><p>When designing software, the S.O.L.I.D. Object-oriented principles should be followed.</p><ul><li>Single responsibility</li><li>Open-close</li><li>Liskov substitution</li><li>Interface segregation</li><li>Dependency inversion</li></ul><h4>a. <strong>Single responsibility</strong></h4><p>A class should all have one responsibility, according to this principle. It should also only have one reason to alter.</p><h4>b. <strong>Open-close</strong></h4><p>Classes should be open for extension but closed for modification. Thereby, we avoid altering old code and perhaps introducing new issues into an otherwise stable program.</p><h4>c. <strong>Liskov substitution</strong></h4><p>This implies that each subclass should substitute for its parent class. Unimplemented methods should not be present in a child class. After overriding methods in the base class, the child class should not give them a different meaning.</p><h4>d. <strong>Interface segregation</strong></h4><p>This means more extensive interfaces should be divided into smaller ones. By doing so, we can ensure that implementing classes are only concerned with the appropriate methods. They are referred to as “fat interfaces”.</p><h4>e. <strong>Dependency inversion</strong></h4><p>This specifies that the high-level module should rely on abstractions instead of the low-level module.</p><h3>2. <strong>Approaching the solution</strong></h3><p>We aim to discover a technical solution for a business challenge in software engineering. The various options for achieving that goal are shown below.</p><ul><li>KISS</li><li>Think about the problem thoroughly.</li><li>Divide and conquer</li><li>Learn from the mistakes</li><li>Keep in mind why software exists</li><li>Always keep in mind that you are not the user</li></ul><h4><strong>a.</strong> <strong>KISS</strong></h4><p>Maintain a straightforward and understandable approach. Make your solution simple, not complicated<strong>.</strong></p><h4><strong>b.</strong> <strong>Consider the problem all the way through</strong></h4><p>Make sure you properly comprehend the problem you’re going to fix. Before creating the solution, make sure that any confusing parts are clarified.</p><h4><strong>c.</strong> <strong>Divide and conquer</strong></h4><p>Break the problem down into smaller pieces. Make it manageable and straightforward to comprehend. Try to strike the ideal balance between priority and clarity.</p><h4><strong>d.</strong> <strong>Learn from the mistakes</strong></h4><p>Accept the change. Always try to anticipate as many changes as possible.</p><h4><strong>e.</strong> <strong>Keep in mind why software exists</strong></h4><p>Keep in mind why this software exists in the first place. If you lose sight of the big picture, you can get on the wrong track.</p><h4><strong>f.</strong> <strong>Always keep in mind that you are not the user</strong></h4><p>The end-user does not have the same technical capabilities as the program creator. User-friendliness and experience are important factors to consider when developing software.</p><h3>3. <strong>Implementing the solution</strong></h3><p>There are several guidelines to remember when executing the designed solution. Those guidelines are shown below.</p><ul><li>YAGNI</li><li>DRY</li><li>Embrace abstraction</li><li>D.R.I.T.W.</li><li>Write code that is great for a single task</li><li>Debugging is more complicated than programming</li><li>Kaizen</li></ul><h4><strong>a.</strong> <strong>YAGNI</strong></h4><p>YAGNI is an acronym for “You ain’t gonna need it”. Write the code that isn’t useful right now, but you think it will be helpful in the future.</p><h4><strong>b.</strong> <strong>DRY</strong></h4><p>DRY is an acronym for “Don’t repeat yourself”. As much as feasible, code should be generalized and reusable.</p><h4><strong>c.</strong> <strong>Embrace abstraction</strong></h4><p>Make sure your system works correctly, even if you don’t know the implementation specifics of each component.</p><h4><strong>d.</strong> <strong>DRITW</strong></h4><p>DRITW is an acronym for “Don’t reinvent the wheel”. It’s possible that someone else has already solved that problem. Make the most of it.</p><h4><strong>e.</strong> <strong>Write code that is great for a single task</strong></h4><p>A single piece of code that does one thing and does it well.</p><h4><strong>f.</strong> <strong>Debugging is more complicated than programming</strong></h4><p>As much as possible, make the writing code readable.</p><h4><strong>g.</strong> <strong>Kaizen</strong></h4><p>Kaizen refers to “Leave it better than when you found it”. Bugs occur during the writing of the code. Then, it should be fixed, not just the bug but also the code surrounding it.</p><h3>4. Practices</h3><p>Practices are standards or principles that we should adhere to when writing code. Industry-wide, these approaches are regarded as best practices for software engineering.</p><p>· Unit Testing</p><p>· Code quality</p><p>· Code review</p><p>· Version controlling</p><p>· Continuous integration</p><h4>a. Unit testing</h4><p>Unit testing is a small code that checks certain aspects of your main program. A unit can be anything from a class to a function to a module to an API. Allows the developer to freely modify or improve the code while also ensuring that it does not damage anything by running unit tests. For developers, there is a verification mechanism. Early detection of integration difficulties is essential.</p><h4>b. Code quality</h4><p>Code quality is reduced by code complexity, huge methods and classes, meaningless identifiers, code duplication, and many method arguments. The code should be legible and straightforward to comprehend. Use tools to check the code quality regularly. Improve the code’s performance.</p><h4>c. Code review</h4><p>Find the best strategy to solve the problem and improve your performance by review. The goal is to enhance the code instead of criticizing the developer. Code reviews can be done in various ways, including peer reviews, lead reviews, and pair programming.</p><h4>d. Version controlling</h4><p>Version control should be applied to all code. Allow developers to update and improve the code freely. Allow several developers to work on the same codebase simultaneously. Remove the code base’s single point of failure. To keep the code base up to date, use various branch tags.</p><h4><strong>e.</strong> <strong>Continuous integration</strong></h4><p>Developers must check their code to a shared repository several times a day. This allows developers to spot problems early and fix them quickly.</p><h3>JavaScript</h3><p>A single thread is used to run JavaScript programs. As a result, JavaScript is classified as a single-threaded programming language. JavaScript does not wait for I/O operations to complete before continuing with the program’s execution. Non-blocking, I/O is what it’s called. Because of the NIO nature of JavaScript, it is asynchronous. Both OOP and functional programming are supported by JavaScript. Asynchronous operations in JavaScript are managed via an eventing mechanism.</p><pre>function getName(){<br>    return &quot;Hello World!&quot;<br>}<br>const print = function (){<br>    <em>console</em>.log(getName())<br>}<br>print()</pre><pre>//Output: Hello World!</pre><p><strong>Classes and objects in JavaScript</strong></p><p>Static methods and variables are supported in JavaScript. A constructor function is used with the ‘new’ key keyword when constructing an object in JavaScript. When a function is used with the ‘new’ keyword, it becomes a Class. Object literals (‘{}’) are another technique to create an object. These are referred to as singleton objects.</p><pre>function Country(name){<br>    this.name = name;<br>}<br><br>const <strong><em>country </em></strong>= new Country(&quot;Sri Lanka&quot;)<br><strong><em>console</em></strong>.log(<strong><em>country</em></strong>.name)</pre><pre>//Output: Sri Lanka</pre><pre>const <strong><em>Animal</em></strong>={<br>    name: &#39;Dog&#39;,<br>    getName : function () {<br>        return this.name;<br>    }<br>}<br><strong><em>console</em></strong>.log(<strong><em>Animal</em></strong>.name)</pre><pre>//Output: Dog</pre><p><strong>Prototypes</strong></p><p>JavaScript functions reference another object called prototype. It’s similar to how classes are defined in other languages. It’s just another instance of an object. A prototype object is utilized in JavaScript when creating objects, inheriting classes, and adding methods to a JavaScript class. Because of JavaScript’s flexibility, there are numerous ways to build and expand classes. A constructor function is a type of function used to make objects. A prototype is an object instance from which another object is constructed. The inherited properties of an object come from the object ‘__proto__’. The prototype of a function is used to pass properties to an instance of an object.</p><pre>function Animal(name){<br>    this.name = name;<br>    this.getName = function (){<br>        return this.name;<br>    }<br>}<br><br>const <strong><em>dog </em></strong>= new Animal(&#39;Dog&#39;)<br>const <strong><em>cat </em></strong>= new Animal(&#39;Cat&#39;)<br><strong><em>console</em></strong>.log(<strong><em>dog</em></strong>.getName === <strong><em>cat</em></strong>.getName);<br><strong><em>console</em></strong>.log(Animal.prototype === <strong><em>dog</em></strong>.__proto__);<br><br>/*output: false<br>          true */</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*LQuXeX0hf3eP_37WKG-KgA.png" /><figcaption>Diagram of the process</figcaption></figure><p><strong>‘this’ in JavaScript</strong></p><p>The word ‘this’ in the context of an object refers to the object itself. When a function utilizing the ‘this’ keyword is handed to another object, ‘this’ refers to that object instead of the original object where the function was declared. In JavaScript, the ‘this’ keyword behaves differently than it does in other languages.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db072be0162b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>