<?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: Kwerenachi Utosu</title>
    <description>The latest articles on DEV Community by Kwerenachi Utosu (@kwereutosu).</description>
    <link>https://dev.to/kwereutosu</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%2F432524%2Fe2ef1e49-870b-4de7-82e5-41a95ded60fb.jpeg</url>
      <title>DEV Community: Kwerenachi Utosu</title>
      <link>https://dev.to/kwereutosu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kwereutosu"/>
    <language>en</language>
    <item>
      <title>Object Oriented Programming Summarised</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Sat, 12 Oct 2024 13:14:30 +0000</pubDate>
      <link>https://dev.to/kwereutosu/object-oriented-programming-summarised-3c87</link>
      <guid>https://dev.to/kwereutosu/object-oriented-programming-summarised-3c87</guid>
      <description>&lt;p&gt;Object oriented programming often written as OOP is a concept that every software engineer should understand. Being an engineer for a few years now, I can say that having an in-depth knowledge of OOP would set you up for success. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is Object Oriented Programming?
&lt;/h3&gt;

&lt;p&gt;Object Oriented Programming can be defined as a programming paradigm that to mimics or models entities. In OOP, we tend to reference real world entity behaviours and interactions, through the operations we perform on objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F0ny50npayki2zxzdgc5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F0ny50npayki2zxzdgc5r.png" alt="Why OOP image" width="800" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why bother learning about OOP?
&lt;/h3&gt;

&lt;p&gt;You may be asking yourself, why bother learning this? But the truth is, OOP have become a major anchor in modern software development. If you plan to build scalable applications, with reusable components that allows for ease of collaboration, you'd have to build on the core concepts and principles of OOP.&lt;/p&gt;

&lt;p&gt;Since we're keeping it short, I'd go straight into the basic terminologies or core concepts of object oriented programming. And then after that, I'd discuss the principles or feature of OOP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fz3o9uz472rwiogs1s9bn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fz3o9uz472rwiogs1s9bn.png" alt="Core Concepts of OOP" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Concepts of OOP
&lt;/h3&gt;

&lt;p&gt;There are 4 most commonly used terminologies or concepts of OOP. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;: A Class is a template or blueprint that define the behaviour, structure and properties of objects. It contains the data attributes and functions or methods that operate on that data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;: An Object is an instance of a specified class. It contains real values instead of variables. It also represent real-world interpretation of a Class and can perform operations defined by that class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Method&lt;/strong&gt;: A method is function. It can be defined within a class or implemented from an interface. Methods defines the behaviour of objects and can be used to perform operations and data manipulation on objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Property&lt;/strong&gt;: Properties are the data members or variables of a class. They are also knowns as fields and store the feature or data associated with an object.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fysmtvendyx6ssc2hrqx0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fysmtvendyx6ssc2hrqx0.png" alt="Principles of OOP" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Principles of OOP
&lt;/h3&gt;

&lt;p&gt;There are 4 major principles of OOP and I'd briefly explain each of them below. Since we're doing an OOP summary, I'm going to try to make it as simple and short as possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt;&lt;br&gt;
Encapsulation just like the English definition involves enforcing controls or hiding of data implementation of a class by restricting access to class methods. This principle helps to ensure that only the public methods and properties are available to the public. &lt;/p&gt;

&lt;p&gt;For Example, you don't need to understand the inner mechanical workings of a car to drive the car, or the hardware build process of a phone to use the phone to satisfy your need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt;&lt;br&gt;
Abstraction can also be explained in plain terms as reducing the complexity of an object or class by putting all the complex details in a different place, usually an abstract class or interface. &lt;/p&gt;

&lt;p&gt;This pattern enables high level thinking, and handling complex edge cases on a surface level. In most cases, abstract classes or interfaces would define some contract or rules that connecting classes must obey. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance&lt;/strong&gt;&lt;br&gt;
I love how these principles are self explanatory like their names 😀. Inheritance like the name implies involves passing knowledge or information down within classes. When class A inherits from class B, this simply means that, class A gets the attributes and methods with in class B for free.&lt;/p&gt;

&lt;p&gt;For Example, A class Shape which is the superclass has attribute &lt;code&gt;name&lt;/code&gt; and method &lt;code&gt;getArea()&lt;/code&gt;. If another class Circle which is the subclass inherits from Shape, it automatically get a the attribute and method within shape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Polymorphism&lt;/strong&gt; &lt;br&gt;
Polymorphism is the ability of an objects to take different forms. There's the static polymorphism and dynamic polymorphism. Polymorphism is closely related to Inheritance, so I'm going to use the example above to explain it better.&lt;/p&gt;

&lt;p&gt;If we had another class, say Triangle that inherits from Shape, this new class also gets the &lt;code&gt;name&lt;/code&gt; attribute and &lt;code&gt;getArea()&lt;/code&gt; function. While in the Circle class &lt;code&gt;getArea()&lt;/code&gt; would but implemented as &lt;code&gt;πr2&lt;/code&gt; where r is is the radius of the circle. In the triangle it would implemented as &lt;code&gt;1/2*b*h&lt;/code&gt; where b and h are the base and height of the triangle. The implementation could also introduce a new formula depending on the type of triangle.&lt;/p&gt;

&lt;p&gt;The ability to change the behaviour of methods or attributes in the different objects is called Polymorphic. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt; &lt;br&gt;
I hope this piece was helpful to you. There's still a lot to learn in OOP, but this is a summarised introduction.&lt;/p&gt;

</description>
      <category>oop</category>
      <category>programming</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Regular Expressions As Applied In Programming</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Tue, 30 Mar 2021 12:42:33 +0000</pubDate>
      <link>https://dev.to/kwereutosu/regular-expressions-as-applied-in-programming-3o3k</link>
      <guid>https://dev.to/kwereutosu/regular-expressions-as-applied-in-programming-3o3k</guid>
      <description>&lt;p&gt;Regular Expressions as also know as &lt;code&gt;Regex&lt;/code&gt;, work on the principle of providing characters that must be matched. Regular Expression is usually used especially when trying to work on a large number of data. &lt;/p&gt;

&lt;p&gt;Working on that much data, we're not expected to make updates or alter the data one after the other because it would take up too much of our time, so we use &lt;code&gt;Regex&lt;/code&gt; to group them together and make our update.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Regular Expression?
&lt;/h3&gt;

&lt;p&gt;A regular expression is a sequence of characters that specifies a search pattern. Regular expressions are also known as &lt;code&gt;patterns&lt;/code&gt; used to match character combinations in strings. Usually, such patterns are used by string-searching algorithms for &lt;code&gt;find&lt;/code&gt; or &lt;code&gt;find and replace&lt;/code&gt; operations on strings, or for input validation.&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%2Fh3xpvqz5ddatsggmb62p.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%2Fh3xpvqz5ddatsggmb62p.PNG" alt="Alt Text" width="543" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For Example, a simple Expression like &lt;strong&gt;[a-zA-Z]&lt;/strong&gt; would match all the alphabets. Every word containing simple plain alphabets without any tone marks would fall into that category, words like code, table, Markdown, and many more. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some Major Uses Of Regex In Programming&lt;/strong&gt;&lt;br&gt;
Regular Expressions as stated earlier are very useful to programmers for a variety of tasks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For implementing &lt;code&gt;find and replace&lt;/code&gt; function that identifies group or sequence of characters and replaces them with something else as specified by the expression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For &lt;code&gt;search operations&lt;/code&gt;, for example, being able to identify a single string in a whole document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For &lt;code&gt;Input Validation&lt;/code&gt;, for example, passwords, email addresses, and other input types that may require a special character.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Metacharacters In Regular Expressions
&lt;/h3&gt;

&lt;p&gt;Before we dive into writing some &lt;code&gt;Regex&lt;/code&gt; and explaining the various patterns, we must first understand the metacharacters involved in creating this expression. &lt;/p&gt;

&lt;p&gt;A &lt;code&gt;metacharacter&lt;/code&gt; is a character that has a special meaning to a computer program, such as a shell interpreter or a regular expression (regex) engine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       [  ]  -  +  *  ?  ^  $  (  )  {  }  |  .  \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each of these metacharacters above has a completely different meaning when interpreted in a &lt;code&gt;Regex&lt;/code&gt; enabled environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Square Bracket [ ]&lt;/strong&gt;&lt;br&gt;
This is used to group like data together and create a range. For example &lt;code&gt;[0-9]&lt;/code&gt; simple means every digit from 0 to 9.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hyphen -&lt;/strong&gt;&lt;br&gt;
This simple represents &lt;code&gt;to&lt;/code&gt;,i.e a range or an interval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plus Sign +&lt;/strong&gt;&lt;br&gt;
This matches One or more of the preceding character or group of characters. &lt;/p&gt;

&lt;p&gt;For example, a simple expression like &lt;code&gt;/ab+c/&lt;/code&gt; simply means that words gotten from this expression must start with an &lt;code&gt;a&lt;/code&gt;, have one or as many &lt;code&gt;b&lt;/code&gt;s as possible, and must always end with a &lt;code&gt;c&lt;/code&gt;. Some accepted outputs are &lt;code&gt;abc&lt;/code&gt;, &lt;code&gt;abbc&lt;/code&gt;, &lt;code&gt;abbbc&lt;/code&gt;, and many more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asterisk *&lt;/strong&gt;&lt;br&gt;
This matches Zero or more of the preceding character or group of characters. &lt;/p&gt;

&lt;p&gt;For example, a simple expression like &lt;code&gt;/ab*c/&lt;/code&gt; simply means that words gotten from this expression must start with an &lt;code&gt;a&lt;/code&gt;, have zero or as many &lt;code&gt;b&lt;/code&gt;s as possible, and must always end with a &lt;code&gt;c&lt;/code&gt;. Some accepted outputs are &lt;code&gt;ac&lt;/code&gt;, &lt;code&gt;abbc&lt;/code&gt;, &lt;code&gt;abbbc&lt;/code&gt;, and many more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question Mark ?&lt;/strong&gt;&lt;br&gt;
This matches Zero or one of the preceding character or group of characters. &lt;/p&gt;

&lt;p&gt;For example, a simple expression like &lt;code&gt;/ab?c/&lt;/code&gt; simply means that words gotten from this expression must start with an &lt;code&gt;a&lt;/code&gt;, have zero or one &lt;code&gt;b&lt;/code&gt;, and must always end with a &lt;code&gt;c&lt;/code&gt;. There are only 2 accepted outputs &lt;code&gt;ac&lt;/code&gt; and &lt;code&gt;abc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caret ^&lt;/strong&gt;&lt;br&gt;
The caret serves two different purposes. It is a special character that denotes &lt;em&gt;“the beginning of a line”&lt;/em&gt; and it is a &lt;em&gt;“not”&lt;/em&gt; operator inside of []s.&lt;br&gt;
Take a look at these three examples,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;/([^aeiou])/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/^([aeiou])/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/^([^aeiou])/&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first example simply matches any character that is not a vowel. &lt;br&gt;
The second one matches a vowel at the start of a line. &lt;br&gt;
And the third one matches any character that is not a vowel, at the start of a line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dollar Sign $&lt;/strong&gt;&lt;br&gt;
This matches the end of a line. For example, &lt;code&gt;/$([aeiou])/&lt;/code&gt; matches a vowel at the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parentheses ()&lt;/strong&gt;&lt;br&gt;
Parentheses in a regular expression usually indicate a ‘capture group’, or a subset of the string to be stored for later reference. &lt;/p&gt;

&lt;p&gt;For an example like &lt;code&gt;/^([aeiou])([0-9])/&lt;/code&gt;&lt;br&gt;
This example matches a string starting with a single vowel (the first capture group is a single vowel), followed by any single digit (the second capture group is any digit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Curly Braces {}&lt;/strong&gt;&lt;br&gt;
This matches a specific range. It is used when you want to be very specific about the number of occurrences an operator or subexpression must match in the source string. Curly braces and their contents are known as interval expressions. For example &lt;code&gt;{n}&lt;/code&gt; matches preceding element or subexpression must occur exactly n times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pipe Symbol |&lt;/strong&gt;&lt;br&gt;
Two regular expressions separated by a pipe symbol match either an occurrence of the first or an occurrence of the second. &lt;/p&gt;

&lt;p&gt;For example, a simple expression like &lt;code&gt;/(a|b)*c/&lt;/code&gt; simply means that words gotten from this expression must start with either an &lt;code&gt;a&lt;/code&gt;, a &lt;code&gt;b&lt;/code&gt; or none, and must always end with a &lt;code&gt;c&lt;/code&gt;. Some accepted outputs are &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;ac&lt;/code&gt;, &lt;code&gt;bc&lt;/code&gt;, and many more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dot .&lt;/strong&gt;&lt;br&gt;
The dot operator matches any character. It has so many dynamic uses.&lt;/p&gt;

&lt;p&gt;For example, the expression &lt;code&gt;/^([0-9])(.)/&lt;/code&gt; simply matches a string that starts with a digit, followed by any character.  &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Backlash \*&lt;/em&gt;&lt;br&gt;
A Backlash is used to escape metacharacters. The term "to escape a metacharacter" means to make the metacharacter ineffective (to strip it of its special meaning), causing it to have its literal meaning. &lt;/p&gt;

&lt;p&gt;For example, a dot (".") stands for any single character as a metacharacter. So when we have an expression like &lt;code&gt;ab.&lt;/code&gt;, it matches an &lt;code&gt;a&lt;/code&gt;, a &lt;code&gt;b&lt;/code&gt; followed by any character. But when it's escaped like &lt;code&gt;ab\.&lt;/code&gt; it simply means &lt;code&gt;ab.&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Regular Expressions In Methods And Classes
&lt;/h3&gt;

&lt;p&gt;Now let's apply all we've learned in the examples below&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example 1&lt;/em&gt;&lt;br&gt;
The expression in this first example matches two different words in the string given as &lt;code&gt;str&lt;/code&gt; in the code snippet below. The program would return an affirmative alert.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var regex = /li[kv]e/;
var str = "They like the live show.";

// Test the string against the regular expression
if(regex.test(str)) {
    alert("Match found!");
} else {
    alert("Match not found.");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Match found!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Example 2&lt;/em&gt;&lt;br&gt;
In this next example, a &lt;code&gt;g&lt;/code&gt; was added to record every word occurrence of the sequence in the string given below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var regex = /[rt]?each/g;
var str = "To teach means to reach as many kids, each also reaching others";
var matches = str.match(regex);

if(regex.exec(str)) {
    alert(matches.length + " Matches found!");
} else {
    alert("Match not found.");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output for this example is &lt;code&gt;teach&lt;/code&gt;, &lt;code&gt;reach&lt;/code&gt;, &lt;code&gt;each&lt;/code&gt;, and &lt;code&gt;reach&lt;/code&gt; following the explanation given previously, which means they are 4 in number. You can try running this code snippet for confirmation.&lt;br&gt;
&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4 Matches found!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Character Classes
&lt;/h3&gt;

&lt;p&gt;A character class is the most basic regex concept after a literal match. It makes one small sequence of characters match a larger set of characters. For example, &lt;code&gt;[A-Z]&lt;/code&gt; basically be given as &lt;code&gt;\u&lt;/code&gt;, and &lt;code&gt;\d&lt;/code&gt; could mean any digit.&lt;/p&gt;

&lt;p&gt;See some character classes below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;\d&lt;/code&gt; represents digits. It is also written as [0-9].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\D&lt;/code&gt; represents Non-digits. It is also written as [^0-9].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\w&lt;/code&gt; represents alphanumeric characters and the underscore. It is also written as [A-Za-z0-9_].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\W&lt;/code&gt; represents non-word characters. It is also written as [^A-Za-z0-9_].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\s&lt;/code&gt; represents whitespace characters. It is also written as [ \t\r\n\v\f].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\S&lt;/code&gt; represents non-whitespace characters. It is also written as [^ \t\r\n\v\f].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\a&lt;/code&gt; represents alphabetic characters. It is also written as [A-Za-z].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\l&lt;/code&gt; represents lowercase characters. It is also written as [a-z].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\u&lt;/code&gt; represents uppercase characters. It is also written as [A-Z].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\x&lt;/code&gt; represents Hexadecimal digits. It is also written as [A-Fa-f0-9].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\b&lt;/code&gt; simply represents boundaries.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;\g&lt;/code&gt; simply represents global search. Meaning it'll match all occurrences.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that, these character classes might differ in some programming languages or test environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Character Classes In Programming
&lt;/h3&gt;

&lt;p&gt;We'd look at a few more examples that involve Character classes and other literals.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example 3&lt;/em&gt;&lt;br&gt;
The expression below splits the strings into an array of strings. According to the &lt;code&gt;Regex&lt;/code&gt;, the split criteria is any white space. I console logged so that you can see the list of strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var regex = /[\s,]+/;
var str = "My house is painted white, purple and blue";
var parts = str.split(regex);

// Loop through parts array and display substrings
for(var part of parts){
    console.log(part)
    document.write("&amp;lt;p&amp;gt;" + part + "&amp;lt;/p&amp;gt;");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Example 4&lt;/em&gt;&lt;br&gt;
In this next example, we replace all the digits in the &lt;code&gt;str&lt;/code&gt; variable with hyphens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var regex = /\d/g;
var replacement = "-";
var str = "There 3 kids, 4 adults and 98 animals";

// Replace digits with -
var matches = str.replace(regex, replacement);
console.log(matches)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Example 5&lt;/em&gt;&lt;br&gt;
For the fifth example, we also did a replace but replaced all lowercase vowels with an asterisk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var re = /[aeiou]/g;
var replace = "*";
var str2 = "Every one of them knows the answer to No 2";

// Replace lowercase vowels with *
var matches2 = str2.replace(re, replace);
console.log(matches2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also retest the given code snippets above and try out new expressions in your free time. As usual, the more you practise, the higher your chances of becoming an expert.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Regular Expressions can be applied to every aspect of computer programming and data management. It can be used to perform SQL or database operations. With &lt;code&gt;Regex&lt;/code&gt; there's always a lot of scenarios to try out. I hope this article has been very helpful to you. It doesn't stop here though, practice, practice and more practice.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Multi-threading and Parallel Programming</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Fri, 05 Feb 2021 07:34:20 +0000</pubDate>
      <link>https://dev.to/kwereutosu/multi-threading-and-parallel-programming-1l9m</link>
      <guid>https://dev.to/kwereutosu/multi-threading-and-parallel-programming-1l9m</guid>
      <description>&lt;p&gt;Multi-threading is a widespread programming and execution model that allows multiple threads to exist within the context of one process. Each of these threads can run in parallel and these thread share similar address space. Okay let's start from the very beginning.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Thread?
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;thread&lt;/code&gt; of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. Most times a thread exist within the process and multiple threads can exist within a single process, hence multi-threading.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwtqtgnrq62dh5n6io8a.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpwtqtgnrq62dh5n6io8a.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'd say a Computer Scientist would see A &lt;code&gt;Thread&lt;/code&gt; the same way a Chemist would see an An &lt;code&gt;Atom&lt;/code&gt; .&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These &lt;code&gt;threads&lt;/code&gt; run concurrently and they share resources. The implementation of &lt;code&gt;threads&lt;/code&gt; and processes differ between operating systems, but in most cases a thread is a component of a process.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Process?
&lt;/h3&gt;

&lt;p&gt;Processes are instances of programs which typically run independent from each other. For Example, if you start a Java program the operating system spawns a new &lt;code&gt;process&lt;/code&gt; which runs in parallel to other programs. Inside those processes we can utilize threads to execute code concurrently, so we can make the most out of the available cores of the CPU.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcudzw6gzhi20es4l3nvg.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcudzw6gzhi20es4l3nvg.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike Threads, processes do not share resource with one another. A &lt;code&gt;process&lt;/code&gt; is a unit of resources, while a thread is a unit of scheduling and execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thread Pool
&lt;/h3&gt;

&lt;p&gt;Creating a brand-new OS thread requires memory allocation and CPU instructions in order to set it up and also kill it down. In order to better handle the usage of a thread and also avoid the creation of new ones, the operating systems or platforms reckon with a &lt;code&gt;Thread Pool&lt;/code&gt; feature, which allows the application to take an already existing thread to use.&lt;/p&gt;

&lt;p&gt;That’s a much more efficient way to handle multiple threads without dealing with its creation or destruction. Furthermore, the OSs know when a thread from the thread pool is not actively in use thus, they can automatically “skip” it during the threads’ iteration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Descriptive Programming Representations Of Threads
&lt;/h3&gt;

&lt;p&gt;We'd take a look at threads as implemented from two classes in Java, &lt;code&gt;Executors&lt;/code&gt; and &lt;code&gt;Runnable&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Executors&lt;/strong&gt;
&lt;code&gt;Executors&lt;/code&gt; as a class in Java that abstracts most of the manual thread creation process. They are capable of running asynchronous tasks and typically manage a pool of threads, so we don't have to create new threads manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The class &lt;code&gt;Executors&lt;/code&gt; provides convenient factory methods for creating different kinds of executor services. In the sample below we use an executor with a thread pool of size one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5hbjoi52xqi9rw6osdwy.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5hbjoi52xqi9rw6osdwy.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result looks similar to the above sample but when running the code you'll notice an important difference, the java process never stops! &lt;code&gt;Executors&lt;/code&gt; have to be stopped explicitly - otherwise they keep listening for new tasks.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;ExecutorService&lt;/code&gt; provides two methods for that purpose: &lt;code&gt;shutdown()&lt;/code&gt; waits for currently running tasks to finish while &lt;code&gt;shutdownNow()&lt;/code&gt; interrupts all running tasks and shut the executor down immediately. This service is mostly used when working with socket connections, to facilitate asynchronous calls(Sink-Source connections). &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Runnable&lt;/strong&gt;
A &lt;code&gt;Runnable&lt;/code&gt; is functional interface defining a single void no-arguments method &lt;code&gt;run()&lt;/code&gt;. Before starting a new thread you have to specify the code to be executed by this thread, often called the task and this is done by implementing a &lt;code&gt;Runnable&lt;/code&gt;. Note that, you can have as many tasks as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz8r4h7b8gjhbt7ga4k4y.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz8r4h7b8gjhbt7ga4k4y.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the example above, we utilize Java 8 lambda expressions to print the current threads name to the console. First we execute the runnable directly on the main thread before starting a new thread. See the sample outputs below.&lt;/p&gt;

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

Hello main
Hello Thread-0
Done!


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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Or that:&lt;/em&gt;&lt;/p&gt;

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

Hello main
Done!
Hello Thread-0


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

&lt;/div&gt;

&lt;p&gt;We have two possible outputs because due to concurrent execution we cannot predict if the runnable will be invoked before or after printing &lt;code&gt;Done&lt;/code&gt;. The order is non-deterministic, thus making concurrent programming a complex task in larger applications. Although Threads can also be put to sleep for a certain duration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multi-threading in-depth
&lt;/h3&gt;

&lt;p&gt;Like we've clearly stated earlier, A &lt;code&gt;multi-threaded&lt;/code&gt; program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb9a62hzkm6gjaxff5e9g.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb9a62hzkm6gjaxff5e9g.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Multi-threading&lt;/code&gt; extends the idea of multitasking into applications where you can subdivide specific operations within a single application into individual threads. It enables you to write in a way where multiple activities can proceed concurrently in the same program.&lt;/p&gt;

&lt;p&gt;There are a handful of programming languages that give room for &lt;code&gt;multi-threading&lt;/code&gt;, and most of the languages are Object Oriented Programming languages(OOP). Languages like &lt;code&gt;Java&lt;/code&gt;, &lt;code&gt;C&lt;/code&gt;,&lt;code&gt;C++&lt;/code&gt; and even &lt;code&gt;.NET&lt;/code&gt; frameworks. Some other interpreted languages also made the cut, like &lt;code&gt;Ruby MRI&lt;/code&gt; for &lt;code&gt;Ruby&lt;/code&gt; and &lt;code&gt;CPython&lt;/code&gt; for &lt;code&gt;Python&lt;/code&gt;. If you were waiting to see &lt;code&gt;Javascript&lt;/code&gt;, well you won't because JavaScript does not support multi-threading and that's because the &lt;code&gt;JavaScript&lt;/code&gt; interpreter in the browser is a single thread.&lt;/p&gt;

&lt;h3&gt;
  
  
  Heavily Multi-threaded Applications
&lt;/h3&gt;

&lt;p&gt;Almost all well-built applications support multi-threading. Let's look at browsers. Most browsers are multi-threaded from &lt;code&gt;firefox&lt;/code&gt; to &lt;code&gt;Safari&lt;/code&gt; to &lt;code&gt;Chrome&lt;/code&gt; and many others. But today we'd talk more about &lt;code&gt;Chrome&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google Chrome&lt;/strong&gt;&lt;br&gt;
Chrome has a multi-process architecture and each process is heavily multi-threaded. The main goal is to keep the main thread (“UI” thread in the browser process) and IO thread (each process’ thread for handling IPC) responsive. This means offloading any blocking I/O or other expensive operations to other threads.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgp3ddpyezcuqmmomh349.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgp3ddpyezcuqmmomh349.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;Chrome&lt;/code&gt;, each and every tab you open gets its own content process. Five tabs, 5 processes, one hundred tabs, 100 processes. This approach maximizes performance, but you pay a hefty penalty in memory consumption and battery life. Ever wondered why the CPU consumption for Chrome on your task manager is always high? Well, here you go.&lt;/p&gt;

&lt;p&gt;Every chrome process has, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;main thread&lt;/code&gt;
This thread updates the UI and runs most of Blink.&lt;/li&gt;
&lt;li&gt;An &lt;code&gt;IO thread&lt;/code&gt;
This thread handles IPCs and network requests&lt;/li&gt;
&lt;li&gt;A few more &lt;code&gt;special-purpose threads&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A pool of &lt;code&gt;general-purpose threads&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Chrome Compared to Firefox&lt;/strong&gt;&lt;br&gt;
While &lt;code&gt;Chrome&lt;/code&gt; creates a content process for each tab, &lt;code&gt;Firefox&lt;/code&gt; instead spins up to four content process threads by default. In Firefox, the first 4 tabs each use those 4 processes and additional tabs then use threads within those processes. Multiple tabs within a process share the browser engine that already exists in memory, instead of each creating their own.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1357400668835823617-793" src="https://platform.twitter.com/embed/Tweet.html?id=1357400668835823617"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1357400668835823617-793');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1357400668835823617&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h3&gt;
  
  
  Threads Vs Processes
&lt;/h3&gt;

&lt;p&gt;Threads are different from the conventional multitasking process in so many ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Processes are typically independent, while threads exist as subsets of a process.&lt;/li&gt;
&lt;li&gt;Processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources.&lt;/li&gt;
&lt;li&gt;Processes have separate address spaces, whereas threads share their address space.&lt;/li&gt;
&lt;li&gt;Processes interact only through system-provided inter-process communication mechanisms.&lt;/li&gt;
&lt;li&gt;Context switching between threads in the same process typically occurs faster than context switching between processes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Parallelism
&lt;/h3&gt;

&lt;p&gt;Parallelism relate to the concept were the work is distributed in multiple units, in such a way that it doesn't compromise the final product but minimizing the total execution time.&lt;/p&gt;

&lt;p&gt;Parallel execution is the ability of two (or more) tasks to run at the very same time. While Concurrency stands for the possibility, Parallelism is the reality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Multithreading is now an important part of modern software development. It’s supported by many programming languages and platforms and goes all the way down to the operating system. Knowing how to work with multiple threads can definitely lead developers to build better applications.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>multithreading</category>
      <category>java</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Lambda Expressions In Simple Terms</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Wed, 27 Jan 2021 12:51:57 +0000</pubDate>
      <link>https://dev.to/kwereutosu/lambda-expressions-in-simple-terms-46af</link>
      <guid>https://dev.to/kwereutosu/lambda-expressions-in-simple-terms-46af</guid>
      <description>&lt;p&gt;A lambda expression is a short block of code which takes in parameters and returns a value. The sample expression below has one parameter. The expression can also contain two or more parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;parameter -&amp;gt; expression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A lambda expression can also be seen as an anonymous function. A function that doesn’t have a name and doesn’t belong to any class. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(parameter1, parameter2) -&amp;gt; expression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The concept of lambda expression was first introduced in LISP programming language. Expressions are limited. They have to immediately return a value, and they cannot contain variables, assignments or statements such as &lt;code&gt;if&lt;/code&gt; or &lt;code&gt;for&lt;/code&gt;. In order to do more complex operations, a code block can be used with curly braces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(parameter_list) -&amp;gt; {function_body}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the lambda expression needs to return a value, then the code block should have a return statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components Of Lambda Expression
&lt;/h2&gt;

&lt;p&gt;Lambda Expressions usually contain these 3 components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Argument-list&lt;/strong&gt;: This argument is usually a list. It can be empty or non-empty as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Arrow-token&lt;/strong&gt;: It is used to link arguments-list and body of expression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Body&lt;/strong&gt;: It contains expressions and statements for lambda expression. The body can be a simple statement or can contain a block of code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Some Sample Implementations and Outputs
&lt;/h3&gt;

&lt;p&gt;For the first example, We'd start with a list of numbers. We are going to do a couple of mathematical computations on the content of this list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// A Java program to demonstrate simple lambda expressions 
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    // Creating an ArrayList with elements  
    // And add elements{7,4,2} to the list
    ArrayList&amp;lt;Integer&amp;gt; numbers = new ArrayList&amp;lt;Integer&amp;gt;();
    numbers.add(7);
    numbers.add(4);
    numbers.add(2);

    //Using Lambda to print out all elements
    numbers.forEach( n -&amp;gt; System.out.println(n));

    //Using Lambda to print out the double value of each element
    numbers.forEach( n -&amp;gt; System.out.println(n+n));

    //Using Lambda to print all even elements
    numbers.forEach( n -&amp;gt; {if (n%2 == 0) System.out.println(n);});
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the Java class above we have three different Lambda Expressions. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first expression iterates through a list and prints out each value on a new line. &lt;/li&gt;
&lt;li&gt;The second one print out the value of each element plus itself.&lt;/li&gt;
&lt;li&gt;The third one prints out only the even numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Output 1&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7
4
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output 2&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;14
8
4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output 3&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lambda Expression in Functional Interfaces.
&lt;/h4&gt;

&lt;p&gt;For these next examples, We'd work with Functional Interfaces. &lt;br&gt;
A &lt;strong&gt;functional interface&lt;/strong&gt; in Java is an interface that contains only a single abstract (unimplemented) method. A functional interface can also contain default and static methods which do have an implementation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functional Interfaces with No Parameter
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface MyFunctionalInterface {

    //A method with no parameter
    public String sayHello();
}
public class ExampleOne {

   public static void main(String args[]) {
        // lambda expression
        MyFunctionalInterface message = () -&amp;gt; {
            return "Hello";
        };
        System.out.println(message.sayHello());
    }
}

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

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Functional Interfaces with One Parameter
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface MyFunctionalInterface {

    //A method with one parameter
    public String sayHelloName(String str);
}
public class ExampleTwo {

   public static void main(String args[]) {
        // lambda expression
        MyFunctionalInterface message = (str) -&amp;gt; {
            return "Hello " + str;
        };
        System.out.println(message.sayHelloName("Joy"));
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello Joy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Functional Interfaces with multiple Parameters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface MyFunctionalInterface {

    //A method with one parameter
    public String concatStrings(String str1, String str2);
}
public class ExampleThree {

   public static void main(String args[]) {
        // lambda expression
        MyFunctionalInterface message = (str1, str2) -&amp;gt; {
            return str1 + str2;
        };
        System.out.println(message.concatStrings("Good ","Day"));
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Good Day
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lambda Expression in Hash Maps.
&lt;/h4&gt;

&lt;p&gt;Lambda Expression can also be used in Hash Maps, to iterate or do computational alterations on the elements of a Map. Let's see this 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;public class HashMapExample{
  public static void main(String[] args) {
    // Creating a HashMap and putting in elements
    Map&amp;lt;String, Integer&amp;gt; prices = new HashMap&amp;lt;&amp;gt;();
    prices.put("Apple", 50);
    prices.put("Orange", 20);
    prices.put("Banana", 10);
    prices.put("Grapes", 40);

    //Using Lambda to print out all elements, k=key,v=value
    prices.forEach((k,v)-&amp;gt;System.out.println("Fruit: " + k + ", 
    Price: " + v));
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fruit: Apple, Price: 50
Fruit: Orange, Price: 20
Fruit: Banana, Price: 10
Fruit: Grapes, Price: 40
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lambda Expression For Running Threads
&lt;/h4&gt;

&lt;p&gt;You can use lambda expression to run threads. In the following example, we are implementing run method by using lambda expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ThreadExample{
  public static void main(String[] args) {
        //Thread Example without lambda  
        Runnable r1=new Runnable(){  
            public void run(){  
                System.out.println("Thread1 is running...");  
            }  
        };  
        Thread t1=new Thread(r1);  
        t1.start();  
        //Thread Example with lambda  
        Runnable r2=()-&amp;gt;{  
                System.out.println("Thread2 is running...");  
        };  
        Thread t2=new Thread(r2);  
        t2.start();  
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Thread1 is running...
Thread2 is running...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Lambda Expression to Compare and Filter Collection list
&lt;/h4&gt;

&lt;p&gt;Lambda Expression can also be used as a comparator and can also be used to filter through a list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Product{  
    int id;  
    String name;  
    float price;  
    public Product(int id, String name, float price) {  
        super();  
        this.id = id;  
        this.name = name;  
        this.price = price;  
    }  
}  

public class FilterListExample{
  public static void main(String[] args) {
        List&amp;lt;Product&amp;gt; list=new ArrayList&amp;lt;Product&amp;gt;();  
        list.add(new Product(1,"Volvo",19000f));  
        list.add(new Product(3,"Tesla",75000f));  
        list.add(new Product(2,"Toyota",38000f)); 

        // using lambda to filter data  
        Stream&amp;lt;Product&amp;gt; filtered_data = list.stream().filter(p -&amp;gt; 
        p.price &amp;gt; 3000);  

        // using lambda to iterate through collection  
        filtered_data.forEach(  
                product -&amp;gt; System.out.println(product.name+": 
        "+product.price)   
       );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Tesla: 75000.0
Toyota: 38000.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Some Points to note when using Lambda Expression
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The body of a lambda expression can contain zero, one or more statements.&lt;/li&gt;
&lt;li&gt;When there is a single statement curly brackets are not mandatory and the return type of the anonymous function is the same as that of the body expression.&lt;/li&gt;
&lt;li&gt;When there are more than one statements, then these must be enclosed in curly brackets (a code block) and the return type of the anonymous function is the same as the type of the value returned within the code block, or void if nothing is returned&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Use Lambda Expressions
&lt;/h3&gt;

&lt;p&gt;Here are some benefits of using Lambda Expressions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Fewer Lines of Code:&lt;br&gt;
One of the benefits of using lambda expression is the reduced amount of code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sequential and Parallel Execution Support by passing behavior in methods:&lt;br&gt;
With the introduction of Stream API in Java 8, functions can be passed to collection methods and now it is the responsibility of collection to process the elements either in a sequential or parallel manner.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher Efficiency (Utilizing Multicore CPU’s):&lt;br&gt;
Using Stream API’s and lambda expression we can achieve higher efficiency (parallel execution) in case of bulk operations on collections. Also, the lambda expressions can help in achieving internal iteration of collections rather than external iteration as shown in the above example. As nowadays we have CPUs with multicores, we can take advantage of these multicore CPU’s by parallel processing of collections using lambda.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Summary, Lambda Expressions are welcome additions to any code base and this article is just meant to show us pointers on how to use and apply them.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>beginners</category>
      <category>lambda</category>
    </item>
    <item>
      <title>Git Intro for Beginners</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Tue, 17 Nov 2020 09:45:09 +0000</pubDate>
      <link>https://dev.to/kwereutosu/git-intro-for-beginners-4pem</link>
      <guid>https://dev.to/kwereutosu/git-intro-for-beginners-4pem</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Git?&lt;/strong&gt;&lt;br&gt;
Git is a free, open source distributed version control system tool designed to handle everything from small to very large projects with speed and efficiency. Git has the functionality, performance, security and flexibility that most teams, individual developers and researchers need. It was created by Linus Torvalds in 2005 to develop Linux Kernel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of Git?&lt;/strong&gt;&lt;br&gt;
Git is primarily used to manage your project, comprising a set of code or text files that may change that may change over time.&lt;/p&gt;

&lt;p&gt;Git is also used to save your remotely and allow access to multiple individuals for updates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here are 15 git commands to master for a start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git init&lt;/strong&gt;&lt;br&gt;
This command is used to initialize or start a new git repo&lt;br&gt;
see sample below. Navigate into the folder you're initializing if it already exist, or simply create a new one.&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%2Fi%2F66z1itgenaz61t669qt3.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%2Fi%2F66z1itgenaz61t669qt3.PNG" alt="Alt git init" width="660" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git config&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;git config&lt;/code&gt; command sets the author name and email address respectively to be used with your commits.&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%2Fi%2Fdmf89qktsogytnu03ppu.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%2Fi%2Fdmf89qktsogytnu03ppu.PNG" alt="Alt git config" width="641" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git clone&lt;/strong&gt;&lt;br&gt;
This command is used to obtain or download a repository &lt;br&gt;
from an existing source.&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%2Fi%2Fyx4hxhkh0oeelzabvrbp.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%2Fi%2Fyx4hxhkh0oeelzabvrbp.PNG" alt="Alt git clone" width="654" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git add&lt;/strong&gt;&lt;br&gt;
This command is used to add a single file or multiple files to a staging area. Note that, the added file(s) won't be on your remote environment until they're pushed.&lt;/p&gt;

&lt;p&gt;Here are some &lt;code&gt;git add&lt;/code&gt; commands&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git add filename&lt;/code&gt; adds a file called "filename" to the staging 
area&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add .&lt;/code&gt; stages new files and modifications, without 
deletions&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add -A&lt;/code&gt; stages all changes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add -u&lt;/code&gt; stages modifications and deletions, without new 
files&lt;/li&gt;
&lt;/ul&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%2Fi%2F3whluzzsnsngt17eadts.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%2Fi%2F3whluzzsnsngt17eadts.PNG" alt="Alt git add" width="613" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git commit&lt;/strong&gt;&lt;br&gt;
This command records or snapshots the file permanently in the version history.&lt;/p&gt;

&lt;p&gt;Here are some &lt;code&gt;git commit&lt;/code&gt; commands&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git commit -m "My First Commit"&lt;/code&gt; gives you the opportunity to add a commit message.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git commit -a&lt;/code&gt; commits any files you’ve added with the git add command and also commits any files you’ve changed since then.&lt;/li&gt;
&lt;/ul&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%2Fi%2Ffwub2eaib5cbhqrsinh2.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%2Fi%2Ffwub2eaib5cbhqrsinh2.PNG" alt="Alt git commit" width="648" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git remote&lt;/strong&gt;&lt;br&gt;
This command is used to connect your local repository to the remote server.&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%2Fi%2Fd10wedh9d7a13i8upowi.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%2Fi%2Fd10wedh9d7a13i8upowi.PNG" alt="Alt git remote" width="738" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git status&lt;/strong&gt;&lt;br&gt;
This command lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.&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%2Fi%2Fxo3ekbjuc0b7q21hg0um.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%2Fi%2Fxo3ekbjuc0b7q21hg0um.PNG" alt="Alt git status" width="573" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git fetch&lt;/strong&gt;&lt;br&gt;
The command is a primary command used to download contents from a remote repository. This content includes branches and tags.&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%2Fi%2F511c7t3bac1015qaet5l.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%2Fi%2F511c7t3bac1015qaet5l.PNG" alt="Alt gitfetch" width="576" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git checkout&lt;/strong&gt;&lt;br&gt;
This command is used to switch from one branch to another. &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%2Fi%2Fkh09yhfsgnll9670p7nz.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%2Fi%2Fkh09yhfsgnll9670p7nz.PNG" alt="Alt git checlout" width="539" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command can be used to create a new branch. To create a new &lt;code&gt;git checkout -b my-new-branch&lt;/code&gt; where "my-new-branch" is the name of the new branch.&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%2Fi%2Fwnnuhplvn21p8aa6248q.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%2Fi%2Fwnnuhplvn21p8aa6248q.PNG" alt="Alt git checkout2" width="602" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git push&lt;/strong&gt;&lt;br&gt;
This command sends information committed  to your remote repository. when using &lt;code&gt;git push&lt;/code&gt; you can there are multiple way commits can be pushed to the remote.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git push [remote-variable-name] [branch-name]&lt;/code&gt; this command pushes commits staged on a particular branch to a remote origin, example &lt;code&gt;git push origin master&lt;/code&gt; we can also have &lt;code&gt;git push heroku my-new-branch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push all&lt;/code&gt; this command pushes all branches to your remote repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push -force&lt;/code&gt; or &lt;code&gt;git push -f&lt;/code&gt; this command forcefully send the current staged commit to the remote repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push -u origin master&lt;/code&gt; is used for pushing staged content to GitHub. In the code, the origin is your default remote repository name and &lt;code&gt;-u&lt;/code&gt; flag is upstream, which is equivalent to &lt;code&gt;-set-upstream&lt;/code&gt; and the master is the branch name.&lt;/li&gt;
&lt;/ul&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%2Fi%2Fiprabjbkccvvltxm5egr.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%2Fi%2Fiprabjbkccvvltxm5egr.PNG" alt="Alt gitpush" width="583" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git pull&lt;/strong&gt;&lt;br&gt;
This command fetches and merges changes on the remote server to your working directory.&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%2Fi%2Fu52fcrp6uwc69il3ehym.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%2Fi%2Fu52fcrp6uwc69il3ehym.PNG" alt="Alt gitpull" width="608" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git stash&lt;/strong&gt;&lt;br&gt;
This command temporarily stores all the modified tracked files. this command can also be used to check all new modifications and move them to a new branch.&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%2Fi%2Fm7gax2k3hasc8d6ni7dc.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%2Fi%2Fm7gax2k3hasc8d6ni7dc.PNG" alt="Alt git stash" width="611" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git stash pop&lt;/code&gt; this command restores the most recently stashed files on the current branch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash list&lt;/code&gt; this command lists all stashed changes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git stash drop&lt;/code&gt; this command discards the most recently stashed changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;git merge&lt;/strong&gt;&lt;br&gt;
This command merges the specified branch’s history into the current branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git branch&lt;/strong&gt;&lt;br&gt;
This command lists all the local branches in the current repository. This command can also be used to create a new branch or delete an existing branch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git branch new-branch-name&lt;/code&gt; this command creates a new branch called "new-branch-name".&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git branch -d [branch-name]&lt;/code&gt; this command deletes the feature branch.&lt;/li&gt;
&lt;/ul&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%2Fi%2F2rl9mvfjrl72ejifasbf.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%2Fi%2F2rl9mvfjrl72ejifasbf.PNG" alt="Alt git branch" width="528" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git log&lt;/strong&gt;&lt;br&gt;
This command is used to list the version history for the current branch.&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%2Fi%2Fhbxg07b354y416uxqya0.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%2Fi%2Fhbxg07b354y416uxqya0.PNG" alt="Alt git log" width="649" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can start by practicing these few git commands, using them constantly also helps to learn them faster. I hope you have a great learning experience. &lt;/p&gt;

&lt;p&gt;To get a more in-depth knowledge of git please click here &lt;a href="https://try.github.io/" rel="noopener noreferrer"&gt;learn git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>git</category>
      <category>programming</category>
    </item>
    <item>
      <title>The K.I.S.S Principle in Programming</title>
      <dc:creator>Kwerenachi Utosu</dc:creator>
      <pubDate>Wed, 15 Jul 2020 15:38:50 +0000</pubDate>
      <link>https://dev.to/kwereutosu/the-k-i-s-s-principle-in-programming-1jfg</link>
      <guid>https://dev.to/kwereutosu/the-k-i-s-s-principle-in-programming-1jfg</guid>
      <description>&lt;p&gt;KISS is an acronym which means &lt;em&gt;Keep It Simple Stupid&lt;/em&gt;. I don't  like to use the word Stupid because I know my readers aren't stupid, that’s why I choose to translate it to &lt;em&gt;Keep It Super Simple&lt;/em&gt;.🙂&lt;/p&gt;

&lt;p&gt;KISS is an important term in programming because it puts in your subconscious that every process you’re creating should be as simple as possible and also equally as efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  When we say ‘Simple’, what do we mean?
&lt;/h2&gt;

&lt;p&gt;Simple in this context doesn’t necessarily mean easy, It simply means producing the same results or a better result with less effort or complexity.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;In the concept of KISS, we neither want just less nor more, we simply wish to have only as much as is required.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you’re building a product that moves an object from point A to point B, then do that as efficiently as possible, while having simplicity at the back of your mind.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh8xueuwzgqyi7jkt6rut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh8xueuwzgqyi7jkt6rut.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Keep Simple Tasks Simple!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The KISS principle can also be applied in Artificial Intelligence and Machine Learning. When building a simple Artificial intelligent system, you may not necessarily need to create a machine learning model, if an &lt;em&gt;If Statement&lt;/em&gt; can do the job efficiently.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1272561538914750464-823" src="https://platform.twitter.com/embed/Tweet.html?id=1272561538914750464"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1272561538914750464-823');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1272561538914750464&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;In the programming context, there are a few points to note whenever we want to reduce complexity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure your variable names describes the variable it holds properly.&lt;/li&gt;
&lt;li&gt;Ensure your method names translates to the purpose of that method.&lt;/li&gt;
&lt;li&gt;Write comments within your method where necessary.&lt;/li&gt;
&lt;li&gt;Ensure your classes has a single responsibility.&lt;/li&gt;
&lt;li&gt;Avoid global states and behaviors like as much as you can.&lt;/li&gt;
&lt;li&gt;Delete instances, methods or redundant processes within the code base that are not in use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We should try to reduce complexity, while maintaining an efficient system. The British computer scientist, M. A Jackson actually wrote that,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Programmers often take refuge in an understandable, but disastrous, inclination towards complexity and ingenuity in their work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why is the KISS principle important in programming?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;One major challenge Developers face is working on an existing code base. But when the KISS principle is applied it tackles that issue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The KISS principle facilitates continuity when needed and gives room for other people to understand the process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simpler processes allow for greater efficiency in automated testing. It is easier to test a simple system than a complex one.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, we should strive to reduce complexity as much as we can, make our coding process very transparent, efficient and secure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg05bo6yjda22zr3gxh0g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg05bo6yjda22zr3gxh0g.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For me, KISS brings to mind and indestructible glass box, where all the processes can be clearly seen but is also very secure.&lt;/p&gt;

&lt;p&gt;On a lighter note, If you’re in a business meeting and you been cornered with some hard business questions that you barely understand but you’re expected to know, give Complex Technological Answers! 😂, Otherwise &lt;em&gt;keep it simple always!&lt;/em&gt;. 😉&lt;/p&gt;

&lt;p&gt;Adios.🙂&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>machinelearning</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
