<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Collins Etemesi</title>
    <description>The latest articles on DEV Community by Collins Etemesi (@collinsetemesi).</description>
    <link>https://dev.to/collinsetemesi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F531812%2F65180d35-e4ad-42b3-bbe7-da0e295a9532.png</url>
      <title>DEV Community: Collins Etemesi</title>
      <link>https://dev.to/collinsetemesi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/collinsetemesi"/>
    <language>en</language>
    <item>
      <title>Android Activity Lifecycle</title>
      <dc:creator>Collins Etemesi</dc:creator>
      <pubDate>Sun, 04 Feb 2024 18:07:20 +0000</pubDate>
      <link>https://dev.to/collinsetemesi/android-activity-lifecycle-5c6d</link>
      <guid>https://dev.to/collinsetemesi/android-activity-lifecycle-5c6d</guid>
      <description>&lt;p&gt;In an Android app, the Android system uses activities to run code. The activity lifecycle is the different states that an activity can go through, from when the activity first initializes to its destruction. &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fct5mw45dikwbglhnx23v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fct5mw45dikwbglhnx23v.png" alt="Image description" width="523" height="673"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;code&gt;Activity&lt;/code&gt; class provides 7 callback methods that let the activity know when a state changes:  &lt;code&gt;onCreate()&lt;/code&gt;,  &lt;code&gt;onStart()&lt;/code&gt;, &lt;code&gt;onResume()&lt;/code&gt;, &lt;code&gt;onPause()&lt;/code&gt;, &lt;code&gt;onStop()&lt;/code&gt;, &lt;code&gt;onRestart()&lt;/code&gt;, &lt;code&gt;onDestroy()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onCreate()&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;onCreate()&lt;/code&gt; lifecycle method is called once, just after the activity initializes—when the OS creates the new Activity object in memory. After &lt;code&gt;onCreate()&lt;/code&gt; executes, the activity is considered created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onStart()&lt;/strong&gt; &lt;br&gt;
The &lt;code&gt;onStart()&lt;/code&gt; lifecycle method is called just after &lt;code&gt;onCreate()&lt;/code&gt;. After &lt;code&gt;onStart()&lt;/code&gt; runs, your activity is visible on the screen to the user. Unlike &lt;code&gt;onCreate()&lt;/code&gt;, which is called only once to initialize your activity, &lt;code&gt;onStart()&lt;/code&gt; can be called by the system many times in the lifecycle of your activity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onResume()&lt;/strong&gt; &lt;br&gt;
This method is called when the activity will start interacting with the user. The user starts interacting with your app for this to happen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onPause()&lt;/strong&gt; &lt;br&gt;
Always called after &lt;code&gt;onResume()&lt;/code&gt; and when the user is no longer actively interacting with the activity but the activity is still visible on the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onStop()&lt;/strong&gt; &lt;br&gt;
This is called when the activity is no longer visible on the screen to the user. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onRestart()&lt;/strong&gt;&lt;br&gt;
Called when the current activity is being redisplayed to the user. From the Stopped state, if the activity comes back to interact with the user the system invokes &lt;code&gt;onRestart()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;onDestroy()&lt;/strong&gt; &lt;br&gt;
is called before the activity is destroyed. The system invokes this callback either because, the user dismisses the activity, or there is a configuration change such as device rotation.&lt;/p&gt;

&lt;p&gt;Thank you for reading this article. Happy Coding.&lt;/p&gt;

</description>
      <category>android</category>
      <category>androiddev</category>
    </item>
    <item>
      <title>Modern JavaScript for everyone: Mastering Modern JavaScript The Right Way</title>
      <dc:creator>Collins Etemesi</dc:creator>
      <pubDate>Fri, 04 Mar 2022 08:37:37 +0000</pubDate>
      <link>https://dev.to/collinsetemesi/modern-javascript-for-everyone-mastering-modern-javascript-the-right-way-5h35</link>
      <guid>https://dev.to/collinsetemesi/modern-javascript-for-everyone-mastering-modern-javascript-the-right-way-5h35</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
JavaScript is a scripting language you can use to make web pages interactive. To write javascript code you need a code editor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Editor For JavaScript&lt;/strong&gt;&lt;br&gt;
A code editor is a text editor also designed to help you write code. A code editor is one of the essential tools for programmers designed to edit the source code of computer programs. For javascript I recommend using Visual studio code.&lt;a href="https://code.visualstudio.com/download"&gt;Download visual studio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JavaScript can be written in two ways in your HMTL code: &lt;br&gt;
&lt;strong&gt;Internal Javascript&lt;/strong&gt;&lt;br&gt;
A JavaScript function is placed in the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; section of an HTML page&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;script&amp;gt;
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed.";
}
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;External Javascript&lt;/strong&gt;&lt;br&gt;
Scripts can also be placed in external files. External file: myScript.js&lt;br&gt;
&lt;code&gt;function myFunction() {&lt;br&gt;
  document.getElementById("demo").innerHTML = "Paragraph changed.";&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
External scripts are practical when the same code is used in many different web pages. JavaScript files have the file extension &lt;code&gt;.js&lt;/code&gt;. To use an external script, put the name of the script file in the src(source) attribute of a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag:&lt;br&gt;
&lt;code&gt;&amp;lt;script src="myScript.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modern Javascript concepts&lt;/strong&gt;&lt;br&gt;
Some of the javascript concepts that this article will cover include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;br&gt;
To declare a variable in JavaScript, there are three keywords available, each with its own set of peculiarities. &lt;em&gt;var, let,&lt;/em&gt; and &lt;em&gt;const&lt;/em&gt; are the three variables.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(myNum); //&lt;/code&gt;undefined&lt;code&gt;&lt;br&gt;
var myNum = 5;&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;code&gt;function myFunc() {&lt;br&gt;
    let myFunc = 'Mary';&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;code&gt;const person = {&lt;br&gt;
  name: 'Mary'&lt;br&gt;
};&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Objects&lt;/strong&gt;&lt;br&gt;
In JavaScript, an object is a standalone entity, with properties and type. They include: string, number, boolean, null and undefined. For example a user object can have the following properties: username, email and gender.&lt;br&gt;
You can define a property of an object by assigning it a value. To demonstrate this, here’s a sample object &lt;code&gt;myDog&lt;/code&gt;&lt;br&gt;
&lt;code&gt;const myDog = {&lt;br&gt;
“name”: “Joe”,&lt;br&gt;
“legs”: 4,&lt;br&gt;
“tails”: 1,&lt;br&gt;
“friends”:[“everyone”]&lt;br&gt;
};&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Promises&lt;/strong&gt;&lt;br&gt;
In JavaScript, promises are the most prevalent approach to handle asynchronous tasks. A promise established in JavaScript is primarily built on the idea that when the time comes, it will either be resolved or rejected. A promise exists in the following three states:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fulfilled - the promised task was completed successfully.&lt;/li&gt;
&lt;li&gt;Rejected - the promised task was not completed or is unsuccessful.&lt;/li&gt;
&lt;li&gt;Pending - the promised task has neither been fulfilled nor rejected.
Example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function work() {
    return true;
}
const myPromise = new Promise((resolve, reject) =&amp;gt; {
    let isopen = work();

    if(isopen === true) {
        resolve('Shop is open!')
    }
    else {
        reject('Shop is closed now!')
    }
});

myPromise.then((order) =&amp;gt; {
    console.log(order);
}).catch((order) =&amp;gt; {
    console.log(order);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Classes&lt;/strong&gt;&lt;br&gt;
ECMAScript 2015, also known as ES6, introduced JavaScript Classes. A JavaScript class is just a template for constructing objects.&lt;br&gt;
Example&lt;br&gt;
&lt;code&gt;class Car {&lt;br&gt;
  constructor(name, year) {&lt;br&gt;
    this.name = name;&lt;br&gt;
    this.year = year;&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
When you have a class, you can use the class to create objects. The example below uses the Car class to create two Car objects.&lt;br&gt;
&lt;code&gt;let myCar1 = new Car("Ford", 2014);&lt;br&gt;
let myCar2 = new Car("Audi", 2019);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
That brings me to the end of my article; I hope it explains modern javascript in a way that you have understood. Happy Coding.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms With Modern Javascript</title>
      <dc:creator>Collins Etemesi</dc:creator>
      <pubDate>Mon, 21 Feb 2022 12:01:40 +0000</pubDate>
      <link>https://dev.to/collinsetemesi/introduction-to-data-structures-and-algorithms-with-modern-javascript-3kl1</link>
      <guid>https://dev.to/collinsetemesi/introduction-to-data-structures-and-algorithms-with-modern-javascript-3kl1</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Data Structure and Algorithms&lt;/strong&gt;&lt;br&gt;
A data structure (DS) is a way of organising data so that it can be used effectively.&lt;br&gt;
An algorithm is a series of step-by-step instructions that describe how to do something.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Data Structures and Algorithms are important&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning data structures will help to write clean and consistent code.&lt;/li&gt;
&lt;li&gt;Effective algorithms helps to break a problem down into smaller parts and think carefully about how to solve each part with code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article will go through a list of following Data Structures and Algorithms: Arrays, Queue, Stack, Linked list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrays&lt;/strong&gt;&lt;br&gt;
An array is a special variable, which can hold more than one value.&lt;br&gt;
Using an array literal is the easiest way to create a JavaScript Array.&lt;br&gt;
&lt;code&gt;const array_name = [item1, item2, ...];&lt;/code&gt;&lt;br&gt;
Example:&lt;br&gt;
&lt;code&gt;const snacks = ["Ice cream", "Nuggets", "Popcorn"];&lt;/code&gt;&lt;br&gt;
Operations available in an array include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accessing Array Elements&lt;/li&gt;
&lt;li&gt;Changing an Array Element&lt;/li&gt;
&lt;li&gt;Looping Array Elements&lt;/li&gt;
&lt;li&gt;Adding Array Elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Queue&lt;/strong&gt;&lt;br&gt;
A queue is an ordered list of elements where an element is inserted at the end of the queue and is removed from the front of the queue. A queue works based on the first-in, first-out (FIFO) principle, which is different from a stack, which works based on the last-in, first-out (LIFO) principle.&lt;br&gt;
A queue has two main operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enque. Insert a new element at the end of the queue. &lt;/li&gt;
&lt;li&gt;Dequeue. Remove an element from the front of the queue.
Enqueue
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enqueue(element){
         this.items[this.count] = element;
         this.count ++;
     }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Dequeue&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dequeue(){
         if (this.isEmpty()) {
             return undefined;
         }
         let result = this.items[this.lowestCount]; 
         delete this.items[this.lowestCount]; 
         this.lowestCount ++; 
         return result; 

     }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stack&lt;/strong&gt;&lt;br&gt;
Stack is a linear data structure in which addition or removal of element follows a particular order i.e. LIFO(Last in First Out) AND FILO(First in Last Out).&lt;br&gt;
The following is an example of a stack class using array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Stack class
class Stack {

    // Array is used to implement stack
    constructor()
    {
        this.items = [];
    }

    // Functions to be implemented
    // push(item)
    // pop()
    // peek()
    // isEmpty()
    // printStack()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following is a list of operations available in implementing a stack&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Push : Insert an element.&lt;/li&gt;
&lt;li&gt;Pop : Remove an element&lt;/li&gt;
&lt;li&gt;Peek : Get the topmost element.&lt;/li&gt;
&lt;li&gt;Size : Get size of the stack.&lt;/li&gt;
&lt;li&gt;isEmpty : Check if the stack is empty if empty return true else false.&lt;/li&gt;
&lt;li&gt;Clear : Reset the stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Linked List&lt;/strong&gt;&lt;br&gt;
A linked list is a linear data structure where  each element is a separate object that contains a pointer or a link to the next object in that list. Each element (commonly called nodes) contains two items: the data stored and a link to the next node. &lt;br&gt;
The following an example of a Linked List Node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// User defined class node
class Node {
    // constructor
    constructor(element)
    {
        this.element = element;
        this.next = null
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List Of Operations Available in linked list &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Push: Insert an element at the end of the linked list.&lt;/li&gt;
&lt;li&gt;Insert: Insert an element at the given index of the linked list.&lt;/li&gt;
&lt;li&gt;Remove: Remove the end element of the linked list.&lt;/li&gt;
&lt;li&gt;RemoveAt: Remove the element at the given index of the linked list.&lt;/li&gt;
&lt;li&gt;GetElementAt: Get the element at the given index of the linked list.&lt;/li&gt;
&lt;li&gt;IndexOf: Return the index of the element in the linked list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Data structures will help to write clean and consistent code and algorithms helps to break a problem down into smaller parts and think carefully about how to solve each part with code. Some of these data structures and algorithms are: Arrays, Queue, Stack, Linked list. I hope this article has introduced them to your understanding and satisfaction.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Javascript Objects</title>
      <dc:creator>Collins Etemesi</dc:creator>
      <pubDate>Fri, 11 Feb 2022 22:51:53 +0000</pubDate>
      <link>https://dev.to/collinsetemesi/javascript-objects-2gig</link>
      <guid>https://dev.to/collinsetemesi/javascript-objects-2gig</guid>
      <description>&lt;p&gt;Javascript works on the basis of object oriented programming. This article describes how to use objects, properties and methods, and how to create your own objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is an object?&lt;/strong&gt;&lt;br&gt;
In JavaScript, an object is a standalone entity, with properties and type. They include: string, number, boolean, null and undefined. For example a user object can have the following properties: username, email and gender.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objects and properties&lt;/strong&gt;&lt;br&gt;
A JavaScript object has properties associated with it. A property of an object is a variable that is attached to the object. The properties of an object define the characteristics of the object. You access the properties of an object with a simple dot-notation:&lt;br&gt;
&lt;code&gt;objectName.propertyName&lt;/code&gt;&lt;br&gt;
Like all JavaScript variables, both the object name and property name are case sensitive.&lt;br&gt;
You can define a property by assigning it a value. To demonstrate this, here’s a sample object &lt;code&gt;myDog&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myDog = {
“name”: “Joe”,
“legs”: 4,
“tails”: 1,
“friends”:[“everyone”]
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“Name”, “legs”, “tails” and “friends” are properties while “Joe” “4” “1” and “everyone” are values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object Methods&lt;/strong&gt;&lt;br&gt;
Methods are actions that can be performed on objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const person = {
  firstName: "John",
  lastName: "Doe",
  id: 5566,
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating a JavaScript Object Using an Object Literal&lt;/strong&gt;&lt;br&gt;
This is the easiest way to create a JavaScript Object.&lt;br&gt;
Using an object literal, you both define and create an object in one statement.&lt;br&gt;
&lt;code&gt;const person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Objects in JavaScript can be compared to objects in real life. The concept of objects in JavaScript can be understood with real life, tangible objects. In JavaScript, an object is a standalone entity, with properties and type. Compare it with a chair, for example. A chair is an object, with properties. A chair has a color, a design, weight, a material it is made of. The same way, JavaScript objects can have properties, which define their characteristics.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
