<?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>Forem: Chibuzor Ojukwu</title>
    <description>The latest articles on Forem by Chibuzor Ojukwu (@codedken).</description>
    <link>https://forem.com/codedken</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%2F281907%2F8ad31066-6fa1-4bfe-b34a-56674293fccb.jpeg</url>
      <title>Forem: Chibuzor Ojukwu</title>
      <link>https://forem.com/codedken</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codedken"/>
    <language>en</language>
    <item>
      <title>Understanding Variables in Dart</title>
      <dc:creator>Chibuzor Ojukwu</dc:creator>
      <pubDate>Mon, 26 May 2025 18:55:06 +0000</pubDate>
      <link>https://forem.com/codedken/understanding-variables-in-dart-3bma</link>
      <guid>https://forem.com/codedken/understanding-variables-in-dart-3bma</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37jgasgfq21g5v8dwrjq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37jgasgfq21g5v8dwrjq.jpg" alt="Dart Logo" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, you are going to get a very simplified and clear knowledge of what a variable is in Dart programming language. I promise, you will love it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a variable?
&lt;/h2&gt;

&lt;p&gt;In its simplest form, a variable is a container that holds or stores a certain type of value. E.g string, integer, boolean etc.&lt;/p&gt;

&lt;p&gt;It does not literally store a value, but stores a reference to that value.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;String firstName = 'john';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the above code snippet, the variable name called ‘firstName’ contains a reference to a String object that holds a value of ‘john’. In dart, everything is an object.&lt;/p&gt;

&lt;p&gt;Dart can also infer the type of the value if the type isn’t specified. for example;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var firstName = 'john';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the above snippet, dart is able to detect the variable type of the value as String even though not specified, this is called Type Inference. Dart can infer a variable type only if it is initialized.&lt;/p&gt;

&lt;p&gt;If a variable object isn’t restricted to a single type, you can specify the type as Object or dynamic if necessary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Object firstName = 'john';
dynamic age = 23;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Null Safety
&lt;/h2&gt;

&lt;p&gt;Since Dart 2.12, null safety was introduced to help prevent an error that results from unknowingly accessing variables set to null. The error is known as null dereference error. It occurs when you access the property or call a method on an expression that evaluates to null.&lt;/p&gt;

&lt;p&gt;You can control whether a variable should be nullable by adding ‘?’ to the end of its type declaration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String? firstName; // This can either be null or of type String
String firstName; // Non-nullable, cannot be null but can be of type String
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Null safety flags a non-null variable;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;when it has not been initialized with a non-null value &lt;/li&gt;
&lt;li&gt;when it is assigned a null value&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A nullable variable has an initial value of null by default, but for a non-nullable variable, you will need to assign it a non-null value.&lt;/p&gt;

&lt;p&gt;Note: You don’t need to initialize a local variable even if it’s non-null, but you need to assign it a value before it is used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Late Variables
&lt;/h2&gt;

&lt;p&gt;If you are sure a variable will be initialized after its declaration and before usage, you can add the late modifier before the type declaration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;late String name;

void main(){
  name = 'Chibuzor';
  print(name);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above code, since the &lt;code&gt;initState()&lt;/code&gt; method is the first method that runs when a widget starts, it is advisable to do all initial configurations needed by the widget. It is the best place to initialize the late variable before it is used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final and Const
&lt;/h2&gt;

&lt;p&gt;Declare a variable either ‘final’ or ‘const’ if you don’t intend for it to change. &lt;strong&gt;Final&lt;/strong&gt; should be used when you are not sure of what the value will be at the start of your application. For example, when you want set a class constructor’s properties, setting them as final is suitable because you don’t know the exact value that will be received when the code is ran.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User{
  final String name;

  User({required this.name});

  void setName(){
   print(name); 
   name = 'Kennedy'; // error: final variable can only be set once
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Const&lt;/strong&gt; should be used when the value of the variable is constant, meaning the exact value is known and will not change at anytime within the program. Const variable cannot be assigned a value after initialization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const String name = 'Chibuzor'; 

name = 'Kennedy'; // error: constant variables can't be assigned a value after initialization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value of a ‘final’ variable is known at runtime while that of a ‘const’ at compile time.&lt;/p&gt;

&lt;p&gt;If you intend for a variable to change, you can use the ‘&lt;strong&gt;var&lt;/strong&gt;’ keyword before the variable name. Note, you can’t specify ‘var’ alongside a type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var String name = 'Chibuzor'; // This won't work
var name = 'Chibuzor'; // This will work
name = 'Kennedy'; // This will work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Kindly note — for a data type like List, if marked as final, it can be modified but not reassigned. But if marked as const, it can neither be modified nor reassigned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final myList = [2, 4];
myList.add(6); // This will work
myList = [1, 7, 8]; // This won't work

const myList = [2, 4];
myList.add(6); // This won't work
myList = [1, 7, 8]; // This won't work
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Variable is a core component of a program. Understanding its dynamics is very important. I hope I’ve been able to demystify any conundrum hinged on the subject of variables.&lt;/p&gt;

&lt;p&gt;Happy Coding &amp;lt;/&amp;gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Concept of Expansion in the Linux Command Line</title>
      <dc:creator>Chibuzor Ojukwu</dc:creator>
      <pubDate>Fri, 19 Apr 2024 20:48:44 +0000</pubDate>
      <link>https://forem.com/codedken/the-concept-of-expansion-in-the-linux-command-line-13kb</link>
      <guid>https://forem.com/codedken/the-concept-of-expansion-in-the-linux-command-line-13kb</guid>
      <description>&lt;p&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%2F3twq4bd3lmtmskpiodys.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%2F3twq4bd3lmtmskpiodys.png" alt="Linux Command Line" width="800" height="598"&gt;&lt;/a&gt;&lt;br&gt;
In this short article, we will be exploring an important concept in linux shell called expansion.&lt;/p&gt;

&lt;p&gt;When you type a command and press the Enter key, bash performs several processes upon the argument text before it executes the command. This process is called “expansion”.&lt;/p&gt;

&lt;p&gt;Let’s see the different types of expansion within the shell.&lt;/p&gt;

&lt;p&gt;1)  &lt;strong&gt;Pathname expansion:&lt;/strong&gt; The shell first expands the path (current directory) to get all the files that end with .js (see image below) after which the ls command is performed on the result.&lt;/p&gt;

&lt;p&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%2F2ne167bd4hqxu0i1fteb.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%2F2ne167bd4hqxu0i1fteb.png" alt="pathname expansion" width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2)  &lt;strong&gt;Tilde expansion:&lt;/strong&gt; From the example below, the shell expands the tilde (~) sign to get the home directory of the user before executing the echo command on its result.&lt;/p&gt;

&lt;p&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%2Fqzdxr0drl6j9tpxmf71t.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%2Fqzdxr0drl6j9tpxmf71t.png" alt="tilde expansion" width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3)  &lt;strong&gt;Arithmetic expansion:&lt;/strong&gt; From the screenshot below, the shell performs the computation (expansion) before the echo command is executed on its result.&lt;/p&gt;

&lt;p&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%2Fetueppqxlohhz0lssdq6.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%2Fetueppqxlohhz0lssdq6.png" alt="arithmetic expansion" width="800" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4)  &lt;strong&gt;Brace expansion:&lt;/strong&gt; This is the most fascinating expansion. It simplifies complex tasks with just a single command. After expansion, dir-{1..5} becomes dir-1 dir-2 dir-3 dir-4 dir-5, before the mkdir is performed on them, creating 5 directories.&lt;/p&gt;

&lt;p&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%2F2czbhq4hmrfq4hx8n9mi.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%2F2czbhq4hmrfq4hx8n9mi.png" alt="brace expansion" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5) &lt;strong&gt;Parameter expansion:&lt;/strong&gt; This is more useful in shell scripts than directly on the command line. It is also known as variables. From the image below, the shell expands $USER to get its value and passes it to the echo command. Use the printenv command to see all variables.&lt;/p&gt;

&lt;p&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%2Fp60slebpzxfnq5o7xwki.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%2Fp60slebpzxfnq5o7xwki.png" alt="parameter expansion" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6) &lt;strong&gt;Command substitution:&lt;/strong&gt; This allows you to use the output of a regular shell command as an expansion. See example below&lt;/p&gt;

&lt;p&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%2F97ykdpxnubtvtuv0m9ao.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%2F97ykdpxnubtvtuv0m9ao.png" alt="command substitution expansion" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly for this session, we will discuss a concept called “quoting” used to control expansion performed in shell. It is used to suppress unwanted expansions. There are 2 types of quoting, double and single quotes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Double quotes:&lt;/strong&gt; This will suppress any kind of special characters usually meant for expansion and treat them as ordinary characters except for $ (dollar), \ (backslash), and ` (back tick) signs.&lt;/p&gt;

&lt;p&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%2F10sp30jg0tqljgbq12qi.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%2F10sp30jg0tqljgbq12qi.png" alt="double quoting" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single quotes:&lt;/strong&gt; With this, you can suppress all expansions.&lt;/p&gt;

&lt;p&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%2Fessrjy3xiftr5se228yh.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%2Fessrjy3xiftr5se228yh.png" alt="single quoting" width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you learnt about a few of the superpowers that the Linux Shell embodies.&lt;/p&gt;

&lt;p&gt;Thanks for your time. Your feedback will be much appreciated.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Concept of Virtualization</title>
      <dc:creator>Chibuzor Ojukwu</dc:creator>
      <pubDate>Thu, 11 Apr 2024 16:45:13 +0000</pubDate>
      <link>https://forem.com/codedken/concept-of-virtualization-2c69</link>
      <guid>https://forem.com/codedken/concept-of-virtualization-2c69</guid>
      <description>&lt;p&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%2Fzna1r0kxjvno98cf1lft.jpg" 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%2Fzna1r0kxjvno98cf1lft.jpg" alt="Image description" width="750" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Virtualization?
&lt;/h3&gt;

&lt;p&gt;Virtualization is a technology you can use to create a virtual representation of servers, networks, storage and other physical machines.&lt;/p&gt;

&lt;p&gt;It uses a software known as hypervisor to mimic the functions of physical hardware to run multiple virtual machines concomitantly on a single physical machine.&lt;/p&gt;

&lt;p&gt;Businesses take advantage of virtualization to use their hardware resources efficiently and to get greater returns from their investments. It also powers cloud computing services that helps organizations manage their infrastructures more efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is virtualization important?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;It gives you the ability to interact with hardware resources with greater flexibility&lt;/li&gt;
&lt;li&gt;Physical servers consume electricity, take up storage space, and need maintenance. Virtualization eliminates the aforementioned challenges by abstracting the physical systems into a software&lt;/li&gt;
&lt;li&gt;If you want to access physical systems, you are often limited by proximity and network design. With Virtualization, you can access your servers from anywhere using your host machine. You can manage, maintain, and use your hardware infrastructure like an app on the web.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Virtual Machines and Hypervisors are 2 important concepts in Virtualization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Machine aka VM:&lt;/strong&gt; A virtual machine is a software-defined computer that runs on a physical computer with a separate operating system and computing resources. In virtualization, the physical machine is known as the host machine, while the virtual machines are called the guest machines. You can run multiple VMs on a single physical machine. Virtual machines are abstracted from the computer hardware by a hypervisor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hypervisor:&lt;/strong&gt; A hypervisor is software application for managing multiple VMs. It ensures that each VM gets its allocated resources and does not interfere with the operations of the other VMs. It is the software layer that acts as an intermediary between the VMs and the underlying hardware or the host operating system.&lt;/p&gt;

&lt;p&gt;There are two types of hypervisors: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Type 1 hypervisor:&lt;/strong&gt; This is also known as bare-metal hypervisor. It is a hypervisor program installed directly on the computer's hardware instead of the operating system. It is said to have better performance and commonly used by enterprise applications. KVM uses the type 1 hypervisor to host multiple VMs on the Linux operating system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Type 2 hypervisor:&lt;/strong&gt; It is also known as hosted hypervisor. This is installed on the operating system. It is suitable for end-user computing.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Benefits of Virtualization
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Automated IT Management&lt;/strong&gt; - Since the physical machines are now virtual, you can configure and manage them using software tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Resource Use&lt;/strong&gt; - Instead of having one server on a computer system, you can create a virtual server pool on that computer system by using and returning servers to the pool as required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Disaster Recovery&lt;/strong&gt; - When the physical server is affected by natural disaster or cyberattacks, regaining access to IT infrastructure and replacing or fixing the physical server can take a long time. But with virtualization, this process takes few minutes which improves efficiency and facilitates business continuity so that operations can continue as scheduled. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Types of Virtualization
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Server Virtualization&lt;/strong&gt; - This is the process of partitioning a physical server into multiple virtual servers. It is efficient and cost-effective.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage Virtualization&lt;/strong&gt; - This consolidates all your physical data storage into a single large unit of virtual storage that you can assign and control using management software tools. IT admins can now decide on how to streamline the storage activities, such as archiving, backup and recovery, because they have the liberty to consolidate multiple network storage devices virtually into a single storage device.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network Virtualization&lt;/strong&gt; - Any computer network has hardware elements such as switches,  routers, and firewalls. An organization that has offices in multiple geographic locations can have several different network technologies that makes up its enterprise network. Network virtualization is the process of consolidating all these network resources to centralize administrative tasks. Admins can adjust and control these elements virtually without touching the physical devices, which greatly simplifies network management. There are 2 approaches to network virtualization; they are Software-defined networking and Network function virtualization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Virtualization&lt;/strong&gt; - Modern organizations collect data from several sources and store them in different formats. They might also store data in different places such as a cloud infrastructure or an on-premise data center. Data virtualization provides a software later between this data and the applications that needs it. Data virtualization tools processes an application data request and returns results in a suitable format. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application Virtualization&lt;/strong&gt; - This type of virtualization pulls out the functions of applications to run on operating systems other than the operating systems for which they were designed. For example, you can run a Microsoft window application on a Linux machine without changing the machine configuration. This is the technology behind containerization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Desktop Virtualization&lt;/strong&gt; - You run different desktop operating systems using this type of virtualization. E.g you could have windows 10 for your customer service team, and window vista for your sales team. There are 2 type of desktop virtualization; they are Virtual Desktop Infrastructure and Local Desktop Virtualization. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is just a succinct explanation of what virtualization is all about.&lt;br&gt;
I hope you learnt a thing or two.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Linked List Data Structure Simplified</title>
      <dc:creator>Chibuzor Ojukwu</dc:creator>
      <pubDate>Tue, 18 Jul 2023 03:02:11 +0000</pubDate>
      <link>https://forem.com/codedken/linked-list-data-structure-simplified-4g3</link>
      <guid>https://forem.com/codedken/linked-list-data-structure-simplified-4g3</guid>
      <description>&lt;p&gt;Many developers run away from data structures and algorithms because of how difficult it is perceived to be. In this article, I will try my best to make you understand one of the data structures called Linked List.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linked List&lt;/strong&gt; is a non-contiguous data structure, and a collection of nodes in which each node consists of a data and a reference or pointer to the next node. The first node is called Head while the last node is called Tail with its next node pointing to None.&lt;/p&gt;

&lt;p&gt;There are not too many places where you can utilize a linked list, but as a good developer, it is important to get a good grasp of it to enable you understand how data structures are created along with the different operations that are performed on them.&lt;/p&gt;

&lt;p&gt;In this article, we will be using the python programming language to create a Linked List with various operations that can be performed on it such as reading, modification, and deletion.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You need to create a Node class with a data and next_node properties.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# A Node class.
class Node:
    data = None
    next_node = None

    # Initializes this class with a data argument whenever an object is created
    def __init__(self, data):
        self.data = data

    # Provides a more readable string representation of the class object
    def __repr__(self):
        return "&amp;lt;Node Data: %s&amp;gt;" %self.data

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

&lt;/div&gt;



&lt;p&gt;The init method is python's built-in method called anytime an instance of the Node class is created. &lt;br&gt;
The repr method is a python built-in method that gives the liberty to produce a more readable representation of the Node class. You can test your code using the python interpreter.&lt;br&gt;
To access the interpreter, you need to have python installed on your PC. You download it from &lt;a href="https://www.python.org/downloads/"&gt;here&lt;/a&gt;&lt;br&gt;
Open your terminal, and type in the below code and click enter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -i &amp;lt;the name of your file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure you are on the directory where your code file is located.&lt;br&gt;
The interpreter will open, and you can go ahead to test your code, like the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -i linked_list.py 
&amp;gt;&amp;gt;&amp;gt; N1 = Node(20)
&amp;gt;&amp;gt;&amp;gt; N1
&amp;lt;Node Data: 20&amp;gt;
&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a LinkedList class and set head to None
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# A Linked list class 
class LinkedList:
    # Initializes class whenever an instance is created
    def __init__(self):
        self.head = None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will start creating the different operations that can be carried out on a Linked List. After the init method, let's start by creating an &lt;strong&gt;add&lt;/strong&gt; method that will add a node to the beginning of the List.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Adds a node to the start of a list
    def add(self, data):
        new = Node(data)
        new.next_node = self.head
        self.head = new


    # Adds a node to the end of a list and returns its new size
    def addToEnd(self, data):
        current = self.head
        new = Node(data)
        count = 0
        added = False
        if current is None:
            self.head = new
        else:
            while current and not added:
                count += 1
                if current.next_node is None:
                    current.next_node = new
                    added = True
                else:
                    current = current.next_node
        return count + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;implementation on python's interpreter&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -i linked_list.py
&amp;gt;&amp;gt;&amp;gt; l = LinkedList()
&amp;gt;&amp;gt;&amp;gt; l.add(2)
&amp;gt;&amp;gt;&amp;gt; l.add(5)
&amp;gt;&amp;gt;&amp;gt; l.add(3)
&amp;gt;&amp;gt;&amp;gt; l
[HEAD: 3]--&amp;gt;[5]--&amp;gt;[TAIL: 2]
&amp;gt;&amp;gt;&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above example, you will notice a chain-like representation of the class instance. Like the Node class, it is created using the python's built-in repr method. see code below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Provides a more readable string representation of the class instance
    def __repr__(self):
        nodes = []
        current = self.head

        while current:
            if current is self.head:
                nodes.append("[HEAD: %s]" %current.data)
            elif current.next_node is None:
                nodes.append("[TAIL: %s]" %current.data)
            else:
                nodes.append("[%s]" %current.data)
            current = current.next_node
        return "--&amp;gt;".join(nodes)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, is an insert method which creates and inserts a node at a specified index argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Adds a node at a specified index in the list.
    def insert(self, data, index):
        current = self.head

        if index == 0:
            self.add(data)
        else:
            new = Node(data)
            while index &amp;gt; 1:
                index -= 1
                current = current.next_node
            prev = current
            next_node = current.next_node
            prev.next_node = new
            new.next_node = next_node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Testing with interpreter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python -i linked_list.py
&amp;gt;&amp;gt;&amp;gt; l = LinkedList()
&amp;gt;&amp;gt;&amp;gt; l.add(2) 
&amp;gt;&amp;gt;&amp;gt; l.add(5)
&amp;gt;&amp;gt;&amp;gt; l.add(12)
&amp;gt;&amp;gt;&amp;gt; l.add(6)
&amp;gt;&amp;gt;&amp;gt; l
[HEAD: 6]--&amp;gt;[12]--&amp;gt;[5]--&amp;gt;[TAIL: 2]
&amp;gt;&amp;gt;&amp;gt; l.insert(88, 1)
&amp;gt;&amp;gt;&amp;gt; l
[HEAD: 6]--&amp;gt;[88]--&amp;gt;[12]--&amp;gt;[5]--&amp;gt;[TAIL: 2]
&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's add a method that will return the length of the list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Counts and returns the total number of nodes in a list by traversing through it 
    def size(self):
        count = 0
        current = self.head

        while current:
            count += 1
            current = current.next_node

        return count
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can test it using the interpreter following the way we did earlier.&lt;br&gt;
Next, let's add a method that deletes a node from the list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Traverses through the list and removes the first node which data corresponds to a given or specified argument.
    # It returns the removed node.
    def remove(self, key):
        current = self.head
        prev = None
        found = False

        while current and not found:
            if current.data == key and current is self.head:
                found =True
                self.head = current.next_node
            elif current.data == key:
                found = True
                prev.next_node = current.next_node
            else:
                prev = current
                current = current.next_node
        return current

    # Removes a node at a specified index from the list. It returns the removed node.
    def removeAtIndex(self, index):
        current = self.head
        prev = None

        if index == 0:
            self.head = current.next_node
        else:
            while index &amp;gt; 0:
                index -= 1
                prev = current
                current = current.next_node
            prev.next_node = current.next_node
        return current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go back, study and practice the code as many times as you can so as to enable you get a good grasp of Linked List and its common operations.&lt;/p&gt;

&lt;p&gt;Congratulations for adding the knowledge of Linked List to your skillset.&lt;/p&gt;

&lt;p&gt;Happy coding...&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>datastructures</category>
      <category>linkedlist</category>
      <category>python</category>
    </item>
    <item>
      <title>React useEffect hook</title>
      <dc:creator>Chibuzor Ojukwu</dc:creator>
      <pubDate>Sun, 08 Jan 2023 15:27:55 +0000</pubDate>
      <link>https://forem.com/codedken/react-useeffect-hook-6io</link>
      <guid>https://forem.com/codedken/react-useeffect-hook-6io</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xLh7g5Zi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha3jrwg4xp8imznnrjbf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xLh7g5Zi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha3jrwg4xp8imznnrjbf.jpg" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React is a Javascript library for building user interfaces. It is the most popular Javascript library. This is not an article for learning react from scratch. If you intend to start from scratch, I recommend this youtube &lt;a href="https://youtu.be/bMknfKXIFA8"&gt;video&lt;/a&gt;. We will be discussing of one of the React hooks -&amp;gt; &lt;strong&gt;&lt;em&gt;useEffect&lt;/em&gt;&lt;/strong&gt;. In version 16.8 of React, hooks were added to react.&lt;/p&gt;

&lt;h3&gt;
  
  
  What to learn
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What are react hooks?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Importance of react hook&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rules of hooks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some other popular hooks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Role of the &lt;em&gt;useEffect&lt;/em&gt; hook&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  → What are React hooks?
&lt;/h2&gt;

&lt;p&gt;React hooks are functions that provides function components with access to states and other React features. They don’t work inside classes. Before the advent of React hooks, states can only be managed within class components and with some external libraries. But, since react hooks was introduced, class components have almost become unnecessary. &lt;/p&gt;

&lt;h2&gt;
  
  
  → Importance of React hooks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Hooks allows you to reuse stateful logic without changing your component hierarchy. This means that with hooks you can remove stateful logic from a component so that it can be reused. This makes sharing Hooks among components easy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks makes our code organised, neat, readable and maintainable even when it scales. With the class component lifecycle, complex components become hard to understand. For example, the &lt;em&gt;componentDidMount&lt;/em&gt; method mostly have a mix of unrelated logic, some data fetching might be performed in it and also in &lt;em&gt;componentDidUpdate&lt;/em&gt;. Also, &lt;em&gt;componentDidMount _method may contain mix of unrelated logic that sets up event listeners with clean up done in _componentWillUnmount&lt;/em&gt; method, having related code that changes together being split apart but completely unrelated code being put together in a single method. This can easily introduce bugs and inconsistencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks makes testing stateful logic easy. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks let you use more of React features without classes&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  → Rules of hooks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Only call hooks at the top level of your code. Don’t call hooks inside a loop, conditional, or nested function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Only call hooks from a React function component. Don’t call hooks inside a regular javascript function. You can call hooks in your custom hooks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  → Some other popular hooks
&lt;/h2&gt;

&lt;p&gt;There are quite a number of React hooks, but I will do my best to list the most commonly used ones. We won’t be discussing them in-depth because this article is about the &lt;em&gt;useEffect&lt;/em&gt; hook.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useState&lt;/strong&gt;→ It is used for managing states in a function component and to preserve it between renders.  It returns a pair; the current state value and a function that updates it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useEffect&lt;/strong&gt;→ This is used for handling side effects (eg. Data fetching, event handling, changing DOM manually from React components etc) in function components. It serves the same purpose as &lt;em&gt;componentDidMount&lt;/em&gt;, &lt;em&gt;componentDidUpdate&lt;/em&gt;, and &lt;em&gt;componentWillUnmount&lt;/em&gt; in React classes combined together.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useReducer&lt;/strong&gt; → Just like the _useState _hook, this is used for managing state but for more complex ones. It takes in a reducer function as its first parameter and an initial state value as its second parameter. It returns an array that holds its current state and a dispatch function to which you can pass an action and later invoke it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useRef&lt;/strong&gt; → This allows to directly create a reference to the DOM element in a functional component. It return a mutable ref object with a property of .current. It persists state between renders without causing a re-render.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useContext&lt;/strong&gt; → To return the current value for a context&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;useCallback&lt;/strong&gt; → It return a memorized version of a callback to prevent an unnecessary re-render of a child component.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  → The Role of the useEffect hook
&lt;/h2&gt;

&lt;p&gt;Now, let’s have an in-depth understanding of the &lt;em&gt;useEffect&lt;/em&gt; hook. &lt;/p&gt;

&lt;p&gt;It provides the ability to perform side effects in function components. Side effects are anything that affect something outside the scope of the function being executed. for example, making an API call, subscribing to a listener, manually changing DOM from a function component, timers etc.&lt;/p&gt;

&lt;p&gt;In a class component, side effects are handled inside of it lifecycle methods such as &lt;em&gt;componentDidMount&lt;/em&gt;, &lt;em&gt;componentDidUpdate&lt;/em&gt;, and &lt;em&gt;componentWillUnmount&lt;/em&gt;. For instance, if you decide to set up a subscription, you will do that in &lt;em&gt;componentDidMount&lt;/em&gt; method and cancel it in &lt;em&gt;componentWillUnmount&lt;/em&gt; method. On the other hand, the &lt;em&gt;useEffect&lt;/em&gt; hook can handle both setting up of the subscription, its update, and its cancellation.&lt;/p&gt;

&lt;p&gt;Effects are declared inside the component, so they have access to its props and state. By default, React runs the effect after every render.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s look at a use case
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {useState, useEffect} from "react"

const FriendStatusWithCounter = (props) =&amp;gt; {
  const [count, setCount] = useState(0);
  useEffect(() =&amp;gt; {
    document.title = `You clicked ${count} times`;
  }, [count]);

  const [isOnline, setIsOnline] = useState(null);
  useEffect(() =&amp;gt; {
    ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
    return () =&amp;gt; {
      ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);
    };
  }, []);

  const handleStatusChange = (status) =&amp;gt; {
    setIsOnline(status.isOnline);
  }

    return (
        &amp;lt;button onClick={() =&amp;gt; setCount(prevCount =&amp;gt; prevCount + 1)}&amp;gt;Click&amp;lt;/button&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above sample code, we have a FriendStatusWithCounter component with a count state initialized to 0, it is for keeping track of how many times we click the button. Noticed we introduced another hook called &lt;em&gt;useState&lt;/em&gt; which I have briefly explained.&lt;/p&gt;

&lt;p&gt;As you can see, we are accessing the document’s title which is outside the component to be executed, that’s why we are using the &lt;em&gt;useEffect&lt;/em&gt; hook. For the second &lt;em&gt;useEffect&lt;/em&gt; hook, we set up the chatApi subscription inside the hook’s function body (in &lt;em&gt;componentDidMount&lt;/em&gt; method for a class component) and then cancel subscription inside the body of its return function (in &lt;em&gt;componentWillUnmount&lt;/em&gt; method for a class component). The second parameter of the &lt;em&gt;useEffect&lt;/em&gt; hook is an array that will contain the dependencies (e.g the count state) that should trigger the &lt;em&gt;useEffect _any time it changes (in _componentDidUpdate&lt;/em&gt; method for a class component).&lt;br&gt;
So, in summary;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
//componentDIdMount 
//componentDidUpdate
return () =&amp;gt; {
                //componentWillUnmount
            }
}, [//dependencies)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  → Conclusion
&lt;/h2&gt;

&lt;p&gt;We have come to the end of this article. We were able to understand the basics of hooks and what you need to know about the _useEffect _hook. I hope you find this article helpful. &lt;/p&gt;

&lt;p&gt;🙂 Happy coding &amp;lt;/&amp;gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reacthooks</category>
      <category>useeffect</category>
      <category>hooks</category>
    </item>
  </channel>
</rss>
