<?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: Justin Bigishiro</title>
    <description>The latest articles on DEV Community by Justin Bigishiro (@jbigishiro).</description>
    <link>https://dev.to/jbigishiro</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%2F1082231%2F1c76da88-c6e3-43a8-a563-0158c726d760.png</url>
      <title>DEV Community: Justin Bigishiro</title>
      <link>https://dev.to/jbigishiro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jbigishiro"/>
    <language>en</language>
    <item>
      <title>Ensuring Data Integrity: Constraints and Validations in Python Flask</title>
      <dc:creator>Justin Bigishiro</dc:creator>
      <pubDate>Mon, 09 Oct 2023 20:17:46 +0000</pubDate>
      <link>https://dev.to/jbigishiro/ensuring-data-integrity-constraints-and-validations-in-python-flask-55oj</link>
      <guid>https://dev.to/jbigishiro/ensuring-data-integrity-constraints-and-validations-in-python-flask-55oj</guid>
      <description>&lt;p&gt;Invalid data is the boogeyman of web applications: it hides in your database until the worst possible moment, then jumps out and ruins everything by causing confusing errors.It is essential to ensure data integrity and security in your applications. One crucial aspect of achieving this is through the use of constraints and validations. In this blog post, I will explore how to implement constraints and validations in Python Flask to ensure the reliability of your web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Constraints and Validations: Why Are They Important?
&lt;/h2&gt;

&lt;p&gt;Constraints and validations are essential for maintaining the quality and integrity of data within your web application. They help prevent incorrect or malicious data from entering your system, which can lead to various issues such as:&lt;br&gt;
&lt;strong&gt;Data Integrity:&lt;/strong&gt; Constraints and validations ensure that the data stored in your application's database is accurate, consistent, and follows predefined rules. This is crucial for reliable and trustworthy data.&lt;br&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Validations can help protect your application from common security vulnerabilities, such as SQL injection, cross-site scripting (XSS), and data tampering.&lt;br&gt;
&lt;strong&gt;User Experience:&lt;/strong&gt; Implementing constraints and validations can enhance the user experience by providing immediate feedback to users when they enter incorrect or invalid data. Now, let's dive into how to implement constraints and validations in Python Flask.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Constraints
&lt;/h3&gt;

&lt;p&gt;Invalid values in our database can cause all kinds of problems when we want to use the data. To keep invalid values out of our database we can use SQLAlchemy constraints. These constraints work at a database level to control the data we add to the database.&lt;/p&gt;
&lt;h4&gt;
  
  
  unique and nullable Constraints
&lt;/h4&gt;

&lt;p&gt;The nullable constraint allows us to make sure the values added to the columns are not null. We can define this by adding the argument nullable=False to the Column constructor. If it's required that the values in your columns must be unique then the unique constraint can be specified by adding the argument unique=True to the Column constructor.&lt;br&gt;
These two constraints are common in the login froms, the username must be unique to each user also, username and password must not be null. Here is a simple example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Users(base):
    __tablename__='users'
    username = Column(String, Unique=True, nullable=False)
    password = Column(String, nullable=False)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CheckConstraint
&lt;/h4&gt;

&lt;p&gt;CheckConstraints can be created for columns and tables. The text of the CheckConstraint is passed directly through to the database. Some databases like MySQL do not support CheckConstraints. Here is an example of a Patient table that uses constraints to control input of birth_year and death_year.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Patient(base):
    __tablename__ = 'patient'
    name = Column(String(length=50), primary_key=True)
    # Constraint defined at the Column level
    birth_year = Column(Integer,
                        CheckConstraint('birth_year &amp;lt; 2023'),
                        nullable=False)
    death_year = Column(Integer)
    # Constraint defined at the Table level
    __table_args__ = (
        CheckConstraint('(death_year is NULL) or (death_year &amp;gt;= birth_year)'),
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have a column CheckConstraint which makes sure we cannot add a birth_year that is greater than 2023. We also have a table CheckConstraint that makes sure the death year is after the birth year or the death year is null (meaning that the patient is still alive).&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Validations
&lt;/h3&gt;

&lt;p&gt;In the context of Python, validations are special method calls that go at the top of model class definitions and prevent them from being saved to the database if their data doesn't look right.&lt;br&gt;
In general, validations consist of code that performs the job of protecting the database from invalid data.&lt;br&gt;
Here is a basic example how we can validate an email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class EmailAddress(Base):
    __tablename__ = 'address'

    id = Column(Integer, primary_key=True)
    email = Column(String)

    @validates('email')
    def validate_email(self, key, address):
        if '@' not in address:
            raise ValueError("failed simple email validation")
        return address

email = EmailAddress(email='banana')
session.add(email)
# =&amp;gt; ValueError: failed simple email validation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we wrote a validate_email() function, preventing the object from being saved if its email attribute does not include @. We can return a custom message by raising a ValueError with the message.&lt;/p&gt;

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

&lt;p&gt;Implementing constraints and validations in Python Flask is crucial for ensuring data integrity, security, and a better user experience. By using input validation libraries, database constraints, and custom validators, you can build robust web applications that handle data safely and reliably. Remember to always handle both front-end and back-end validations to provide a seamless user experience while maintaining data integrity.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Table JOIN in SQL</title>
      <dc:creator>Justin Bigishiro</dc:creator>
      <pubDate>Sun, 27 Aug 2023 14:49:59 +0000</pubDate>
      <link>https://dev.to/jbigishiro/table-join-in-sql-oeo</link>
      <guid>https://dev.to/jbigishiro/table-join-in-sql-oeo</guid>
      <description>&lt;p&gt;Tables are essential elements within a database.Tables are formed using columns, where each column must possess a name and a data type.A database can contain one or more tables and these tables can be modeled as relational. "In this blog, I will discuss how to establish relationships between multiple tables in SQL using JOIN operations.&lt;/p&gt;

&lt;p&gt;A join clause in the Structured Query Language (SQL) combines columns from one or more tables into a new table. The operation corresponds to a join operation in relational algebra. Informally, a join stitches two tables and puts on the same row records with matching fields. Different types of JOIN include INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN and NATURAL JOIN. &lt;br&gt;
I am going to use the following tables to expain each type of JOIN.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Student Table&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c_ByWVwt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a7c3o0s9lo5pa25ll00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c_ByWVwt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a7c3o0s9lo5pa25ll00.png" alt="Image description" width="640" height="318"&gt;&lt;/a&gt;                &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Student Course&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tnduD25a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2d87cvr4at5ft2zfqns2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tnduD25a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2d87cvr4at5ft2zfqns2.png" alt="Image description" width="361" height="310"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  1. INNER JOIN
&lt;/h3&gt;

&lt;p&gt;An INNER JOIN query will return all the rows from both tables you are querying where a certain condition is met. In other words, INNER JOIN will select all rows from both tables as long as there is a match between the specified columns of each table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table1.column1,table1.column2,table2.column1,....
FROM table1 
INNER JOIN table2
ON table1.matching_column = table2.matching_column;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that we can also write JOIN instead of INNER JOIN. JOIN is same as INNER JOIN. With our example of above, this query will show the names and age of students enrolled in different courses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM Student
INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_x_gD7KI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82ie4sosk8n7tfpa41lr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_x_gD7KI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82ie4sosk8n7tfpa41lr.png" alt="Image description" width="546" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. LEFT JOIN
&lt;/h3&gt;

&lt;p&gt;A LEFT JOIN query returns all rows from the left, or first, table, regardless of whether or not they met the JOIN condition. The query will also return the matched data from the right, or second, table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table1.column1,table1.column2,table2.column1,....
FROM table1 
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also use LEFT OUTER JOIN instead of LEFT JOIN, both are the same. In our example the query will become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Student.NAME,StudentCourse.COURSE_ID 
FROM Student
LEFT JOIN StudentCourse 
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3FKxGrvs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46p6uplxgk0dzj9es2ik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3FKxGrvs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46p6uplxgk0dzj9es2ik.png" alt="Image description" width="360" height="310"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  3.RIGHT JOIN
&lt;/h3&gt;

&lt;p&gt;RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the table on the right side of the join and matching rows for the table on the left side of the join. For the rows for which there is no matching row on the left side, the result-set will contain null. RIGHT JOIN is also known as RIGHT OUTER JOIN.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table1.column1,table1.column2,table2.column1,....
FROM table1 
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also use RIGHT OUTER JOIN instead of RIGHT JOIN, both are the same. In our example the code will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Student.NAME,StudentCourse.COURSE_ID 
FROM Student
RIGHT JOIN StudentCourse 
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rv51QTiw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l24diel53oha9zctc92q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rv51QTiw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l24diel53oha9zctc92q.png" alt="Image description" width="361" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. FULL JOIN
&lt;/h3&gt;

&lt;p&gt;FULL JOIN creates the result-set by combining results of both LEFT JOIN and RIGHT JOIN. The result-set will contain all the rows from both tables. For the rows for which there is no matching, the result-set will contain NULL values.&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table1.column1,table1.column2,table2.column1,....
FROM table1 
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our example the queries will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Student.NAME,StudentCourse.COURSE_ID 
FROM Student
FULL JOIN StudentCourse 
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yIGfZa_C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ittexzvasuvsnu5en1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yIGfZa_C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ittexzvasuvsnu5en1r.png" alt="Image description" width="338" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. NATURAL JOIN
&lt;/h3&gt;

&lt;p&gt;A natural join returns all rows by matching values in common columns having same name and data type of columns and that column should be present in both tables. Both table must have at list one common column with same column name and same data type.&lt;br&gt;
The final table will accommodate all the attributes of both the tables and doesn’t duplicate the column.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * 
FROM table1 NATURAL JOIN table2;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With our example the query will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * 
FROM Student NATURAL JOIN StudentCourse;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EW0NjyHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crbdaefdrmimpfv7pn07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EW0NjyHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crbdaefdrmimpfv7pn07.png" alt="Image description" width="471" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post aims to assist those learning SQL or any database-related courses. Feel free to leave comments if you spot any inaccuracies or if you'd like to share additional insights on the discussed topic. Your feedback is appreciated!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.sqlshack.com/an-introduction-to-sql-tables/"&gt;https://www.sqlshack.com/an-introduction-to-sql-tables/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Join_(SQL)"&gt;https://en.wikipedia.org/wiki/Join_(SQL)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/"&gt;https://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Event Listeners in React</title>
      <dc:creator>Justin Bigishiro</dc:creator>
      <pubDate>Thu, 06 Jul 2023 11:53:17 +0000</pubDate>
      <link>https://dev.to/jbigishiro/mastering-event-listeners-in-react-2jp2</link>
      <guid>https://dev.to/jbigishiro/mastering-event-listeners-in-react-2jp2</guid>
      <description>&lt;p&gt;Event listening is the process of creating event listeners in our code to listen for and react to events that happen on our webpage.&lt;br&gt;
Event listeners play a crucial role in handling user interactions in React applications.&lt;br&gt;
"Doing work" in response to "something happening" is known as event handling. Events are the "something the user does" and the "callback function" is the work that will happen in response to the event being triggered.&lt;br&gt;
In this blog I will discuss different types of event listeners that are used in React and give examples on each type.&lt;/p&gt;
&lt;h2&gt;
  
  
  onClick - Handling Button Click
&lt;/h2&gt;

&lt;p&gt;The onClick event listener is used to handle the click event on an element, such as a button. When the button is clicked, the specified function or method is executed. &lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Button = () =&amp;gt; {
  const handleClick = () =&amp;gt; {
    console.log('Button clicked!');
  };

  return (
    &amp;lt;button onClick={handleClick}&amp;gt;
     Click me
    &amp;lt;/button&amp;gt;
  );
};

export default Button;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we define a functional component called Button. Inside the component, we declare the handleClick function, which logs a message to the console. The onClick event listener is attached to the  element, and when the button is clicked, the handleClick function is called, resulting in the message being logged to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  onChange - Handling Input Change
&lt;/h2&gt;

&lt;p&gt;The onChange event listener is used to handle changes in an input element, such as a text field. Whenever the value of the input changes, the specified function or method is called.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Input = () =&amp;gt; {
  const handleChange = (event) =&amp;gt; {
    console.log('Input value:', event.target.value);
  };

  return (
    &amp;lt;input type="text" onChange={handleChange} /&amp;gt;
  );
};

export default Input;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have a functional component called Input. Inside the component, we define the handleChange function, which receives the event object. When the value of the input changes, the handleChange function is called, and the current value of the input is logged to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  onSubmit - Handling Form Submission
&lt;/h2&gt;

&lt;p&gt;The onSubmit event listener is used to handle form submissions. It is typically used in combination with the &lt;/p&gt; element. When the form is submitted, the specified function or method is executed.&lt;br&gt;
Example:&lt;br&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
const Form = () =&amp;gt; {
  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    console.log('Form submitted!');
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default Form;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;In this example, we define a functional component called Form. Inside the component, we declare the handleSubmit function, which takes the event object as an argument. When the form is submitted, the handleSubmit function is called, and it prevents the default form submission behavior using event.preventDefault(). Finally, a submit button is rendered within the form, and clicking it triggers the form submission and logs a message to the console.&lt;/p&gt;
&lt;h2&gt;
  
  
  onMouseOver - Handling Mouse Over
&lt;/h2&gt;

&lt;p&gt;The onMouseOver event listener is used to handle the event when the mouse pointer moves over an element. It triggers the specified function or method when the mouse enters the boundaries of the element.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Box = () =&amp;gt; {
  const handleMouseOver = () =&amp;gt; {
    console.log('Mouse over the box!');
  };

  return (
    &amp;lt;div onMouseOver={handleMouseOver} 
style={{ width: '200px', height: '200px', background: 'red' }}&amp;gt;
      Hover over me
    &amp;lt;/div&amp;gt;
  );
};

export default Box;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In this example, we have a functional component called Box. Inside the component, we define the handleMouseOver function. When the mouse pointer moves over the &lt;/p&gt; element, the handleMouseOver function is called, which logs a message to the console.
&lt;h2&gt;
  
  
  onKeyDown - Handling Key Down
&lt;/h2&gt;

&lt;p&gt;The onKeyDown event listener is used to handle keydown events, which occur when a keyboard key is pressed while an element has focus (e.g., an input field). It triggers the specified function or method when a key is pressed.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Input = () =&amp;gt; {
  const handleKeyDown = (event) =&amp;gt; {
    console.log('Key pressed:', event.key);
  };

  return (
    &amp;lt;input type="text" onKeyDown={handleKeyDown} /&amp;gt;
  );
};

export default Input;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In this example, we define a functional component called Input. Inside the component, we declare the handleKeyDown function, which receives the event object. When a key is pressed within the  element, the handleKeyDown function is called, and the pressed key is logged to the console.&lt;/p&gt;

&lt;p&gt;As I said at the beginning, the event listeners are very important to understand, because without them it is difficult or impossible for the user to interact with the User interface. &lt;br&gt;
I think this blog will be very useful to the readers and will help you to dive in deeper.&lt;/p&gt;

&lt;h2&gt;
  
  
  sources:
&lt;/h2&gt;

&lt;p&gt;-&lt;a href="https://www.learnhowtoprogram.com/introduction-to-programming/javascript-and-web-browsers/event-handling-with-event-listeners"&gt;https://www.learnhowtoprogram.com/introduction-to-programming/javascript-and-web-browsers/event-handling-with-event-listeners&lt;/a&gt;.&lt;br&gt;
-chat.openai.com&lt;/p&gt;

</description>
    </item>
    <item>
      <title>MAKING DECISONS: IF...ELSE STATEMENT.</title>
      <dc:creator>Justin Bigishiro</dc:creator>
      <pubDate>Sun, 14 May 2023 07:23:14 +0000</pubDate>
      <link>https://dev.to/jbigishiro/making-decisons-ifelse-statement-1g5d</link>
      <guid>https://dev.to/jbigishiro/making-decisons-ifelse-statement-1g5d</guid>
      <description>&lt;p&gt;In everyday life, we achieve something because we have made some decisions. Some decision we make can lead us to good results and other decisions can destroy our life forever. One of the current decisions I have made is to become a software Developer and now I am learning my first programming language, Javascript.&lt;br&gt;
In Javascript, like in any programming language, the code makes decisions depending on different inputs. &lt;br&gt;
In this blog, I am going to discuss, the decisions we make depending on conditions. &lt;br&gt;
Decision making will depend on the current situation or conditions for example when it is cold you turn on the heat, when feel hungry you cook or you make order at the restaurant.&lt;br&gt;
In Javascript conditional statements allow us to represent decision making from the choice that must be made, to the resulting outcome of those choices. &lt;br&gt;
The most common type of conditional statement in Javascript is IF...ELSE statement. The structure looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (condition) {
  // code to be executed if the condition is true
} else {
  // code to be executed if the condition is false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the if..else statement, sometimes we have two scenarios, for example if you are hungry, you cook, if you are not you watch TV. It is possible to have a lot of scenario.&lt;br&gt;
Let take the following example.&lt;br&gt;
&lt;/p&gt;

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

if (weather === "raining") {
  console.log("Don't forget your umbrella!");
} else if (weather === "sunny") {
  console.log("Enjoy the sunshine!");
} else {
  console.log("Well, at least it's not raining!");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The if...else statements can go from simple scenarios to very complex scenarios. we can have a situation in which a condition is depending on another condition; in some case we need to use a nested if...else block. Let us use this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (choice === "sunny") {
  if (temperature &amp;lt; 86) {
    console.log( `It is ${temperature} degrees outside — nice and sunny. Let's go out to the beach, or the park, and get an ice cream.`);
  } else if (temperature &amp;gt;= 86) {
    console.log(`It is ${temperature} degrees outside — REALLY HOT! If you want to go outside, make sure to put some sunscreen on.`);
  }
}

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

&lt;/div&gt;



&lt;p&gt;If you want to test multiple conditions without writing nested if...else statements, logical operators can help you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&amp;amp;&amp;amp; — AND; allows you to chain together two or more expressions so that all of them have to individually evaluate to true for the whole expression to return true.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;|| — OR; allows you to chain together two or more expressions so that one or more of them have to individually evaluate to true for the whole expression to return true.&lt;br&gt;
To give you an AND example, the previous example snippet can be rewritten to this:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (choice === "sunny" &amp;amp;&amp;amp; temperature &amp;lt; 86) {
  console.log(`It is ${temperature} degrees outside — nice and sunny. Let's go out to the beach, or the park, and get an ice cream.`);
} else if (choice === "sunny" &amp;amp;&amp;amp; temperature &amp;gt;= 86) {
  console.log(`It is ${temperature} degrees outside — REALLY HOT! If you want to go outside, make sure to put some sunscreen on.`);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's look at a quick OR example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (iceCreamVanOutside || houseStatus === "on fire") {
  console.log("You should leave the house quickly.");
} else {
  console.log("Probably should just stay in then.");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The if...else statement is very important in web development, for example we can use it in password validation when building a web application. we can make a function with if..else conditions that check the strength of the password whether it is easy, medium, difficult or extremely difficult to guess. This is an example of a function that checks if a user's password is strong enough.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; function checkPasswordStrength(password) {
  if (password.length &amp;lt; 8) {
    console.log("Password is too short!");
  } else if (!/\d/.test(password)) {
    console.log("Password should contain at least one number!");
  } else if (!/[A-Z]/.test(password)) {
    console.log("Password should contain at least one uppercase letter!");
  } else {
    console.log("Your password is strong!");
  }
}

checkPasswordStrength("WeakPwd1"); // Output: Password should contain at least one uppercase letter!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, If...else is very important in Javascript. It is used mostly in all web applications. Every web development student should have a strong understanding of this condition statement as the foundation of decision making scenarios.&lt;/p&gt;

&lt;p&gt;Sources:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals"&gt;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://marketsplash.com/tutorials/javascript/javascript-if-else/"&gt;https://marketsplash.com/tutorials/javascript/javascript-if-else/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
