<?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: Pedro Alarcon</title>
    <description>The latest articles on DEV Community by Pedro Alarcon (@pedroa54).</description>
    <link>https://dev.to/pedroa54</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%2F1268129%2F93ef30d2-e3c2-49c0-b2b6-135a191b3a19.jpeg</url>
      <title>DEV Community: Pedro Alarcon</title>
      <link>https://dev.to/pedroa54</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pedroa54"/>
    <language>en</language>
    <item>
      <title>React- Flask Communication</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Mon, 17 Jun 2024 16:28:03 +0000</pubDate>
      <link>https://dev.to/pedroa54/react-flask-communication-2b4e</link>
      <guid>https://dev.to/pedroa54/react-flask-communication-2b4e</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In modern web development, applications are often divided into two main parts: the frontend and the backend. Understanding how these two components communicate is crucial for creating dynamic and interactive web applications. Today we will talk about the Frontend Using React and the Backend using Flask.&lt;br&gt;
For a web application to function, the frontend and backend must communicate effectively. &lt;/p&gt;




&lt;h2&gt;
  
  
  Frontend
&lt;/h2&gt;

&lt;p&gt;The frontend, also known as the client-side, is the part of a web application that users interact with directly. It includes everything that users experience in their web browser, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;User Interface (UI)&lt;/em&gt; : The layout, buttons, forms, and other visual elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Client-Side Logic&lt;/em&gt; : Code that runs in the browser, typically written in JavaScript, along with libraries or frameworks like React&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Styling&lt;/em&gt; : CSS and frameworks like Bootstrap that ensure the application looks good across different devices and screen sizes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Backend
&lt;/h2&gt;

&lt;p&gt;The backend, or server-side, is the part of the application that runs on the server. It is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Database Management&lt;/em&gt; : Storing, retrieving, and updating data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Business Logic&lt;/em&gt; : The rules and operations that define how data can be manipulated and transformed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Server Configuration&lt;/em&gt; : Handling server setup, routing, and ensuring the application runs smoothly.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Setting up Backend using SQLite
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating Model- Table
&lt;/h3&gt;

&lt;p&gt;Let's start off by creating a model Called Animal and then create the tablename animals. We will create some columns and give them certain attributes like id (Integer), name (String), species (String) and age (Integer).&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%2Frngdbuu4174eijvqwb4l.jpeg" 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%2Frngdbuu4174eijvqwb4l.jpeg" alt="Model Setup" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;id: This is the primary key of the table. It's an integer that uniquely identifies each row.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;name: This is a string column with a maximum length of 100 characters. The nullable=False argument means that this field cannot be null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;species: Similar to name, this is a string column with a maximum length of 100 characters and cannot be null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;age: This is an integer column that cannot be null.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;repr Method: This method defines how the Animal object is represented as a string, which is useful for debugging. When you print an Animal object, it will display its id, name, species, and age in a readable format.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After running&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flask db init&lt;/li&gt;
&lt;li&gt;flask db migrate -m "initial migration"&lt;/li&gt;
&lt;li&gt;flask db upgrade head &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It should appear in database and now we can focus on the backend route and work on the CRUD sequences. Lets say for example we already seeded the database and our tables are now filled.&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%2F4gd2vieigv4oox19w8sc.jpeg" 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%2F4gd2vieigv4oox19w8sc.jpeg" alt="Animal-DataBase" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Backend route
&lt;/h3&gt;

&lt;p&gt;Here we Set up the backend route in a file called app.py.&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%2F40y875rcxc083fbvccuu.jpeg" 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%2F40y875rcxc083fbvccuu.jpeg" alt=" Backend-route " width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;AnimalList handles GET and POST requests for listing and creating animals&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GET method retrieves all animals and returns them as JSON.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;POST method creates a new animal based on JSON data and returns the created animal as JSON.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Api Setup
&lt;/h3&gt;

&lt;p&gt;The AnimalList resource is added to the Flask-RESTful API at the endpoint /animals. This setup provides a basic yet functional CRUD API for managing animals, suitable for integration into a larger Flask application. Adjustments can be made based on specific project requirements and additional features can be added as needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Setting up Frontend using react
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create a file
&lt;/h3&gt;

&lt;p&gt;Now that we have setup the Backend when we move to the client side, we use a React component to fetch and display the data. The component will make an HTTP GET request to the /animals endpoint when it mounts.&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%2Fh9p8yu0yjfdqzcxacj0a.jpeg" 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%2Fh9p8yu0yjfdqzcxacj0a.jpeg" alt="Frontend-Setup-pt1" width="800" height="884"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The useEffect hook is used to perform side effects, in this case, fetching data from the backend. The empty dependency array ([]) ensures that this effect runs only once when the component mounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Component Initialization&lt;/em&gt; :&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;When the AnimalList component is first rendered, it initializes its state using the useState hook. The animals state will hold the fetched data, loading indicates if the data is being fetched, and error will store any errors that occur during the fetch.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Effect Hook to Fetch Data&lt;/em&gt; :&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The useEffect hook is used to perform side effects, in this case, fetching data from the backend. The empty dependency array ([]) ensures that this effect runs only once when the component mounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Fetching Data&lt;/em&gt; :&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The fetch('/animals') function sends a GET request to the /animals endpoint of the backend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The then(response =&amp;gt; {...}) block checks if the response is okay (status code 200-299). If not, it throws an error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the response is okay, it converts the response body to JSON using response.json().&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second then(data =&amp;gt; {...}) block takes the parsed JSON data (the list of animals) and updates the animals state. It also sets loading to false since the data has been successfully fetched.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Error Handling&lt;/em&gt; :&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;If any error occurs during the fetch operation, the catch(error =&amp;gt; {...}) block catches the error, updates the error state with the error message, and sets loading to false.&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%2Fuploads%2Farticles%2F33fjumlhni97t14st6uw.jpeg" 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%2F33fjumlhni97t14st6uw.jpeg" alt="Frontend-Setup-pt2" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Rendering the Component&lt;/em&gt; :&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While the data is being fetched (loading is true), a loading message is displayed.&lt;/p&gt;

&lt;p&gt;If an error occurs (error is not null), an error message is displayed.&lt;/p&gt;

&lt;p&gt;If the data is successfully fetched (loading is false and error is null), the component maps over the animals array and renders a list of animals.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;We demonstrated how to connect a Flask backend with a React frontend for managing a list of animals. We started by setting up the Flask backend, defining a simple Animal model with SQLAlchemy, and creating RESTful API endpoints to retrieve and add animals. On the frontend, we developed a React component that fetches and displays the list of animals from the backend. Using the useEffect hook, the component makes an HTTP GET request to the "/animals" endpoint, processing the response, and updates the component's state with the fetched data while managing loading and error states. This setup allows for seamless communication between the backend and frontend, providing a robust and interactive user experience for managing animal data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/PedroA54/PetPal-Hotel"&gt;https://github.com/PedroA54/PetPal-Hotel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://flatironschool.com/"&gt;https://flatironschool.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>flask</category>
      <category>react</category>
    </item>
    <item>
      <title>Relationships In Python</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Mon, 20 May 2024 20:17:28 +0000</pubDate>
      <link>https://dev.to/pedroa54/relationships-in-python-g4a</link>
      <guid>https://dev.to/pedroa54/relationships-in-python-g4a</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As developers, mastering the use of table relations in Python is crucial for creating robust and efficient database systems. Table relations enable us to define connections and dependencies between tables, facilitating seamless data organization and retrieval. Relationships help maintain data integrity and consistency by ensuring that data in related tables remain synchronized. Relationships support the implementation of complex application logic that involves multiple data entities. For instance understanding &lt;br&gt;
one-to-one, one-to-many and many-to-many.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Relationships
&lt;/h2&gt;

&lt;p&gt;In database design, understanding different types of relationships is essential for structuring data effectively. Here are some of the primary types of relationships:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One-to-One Relationship:&lt;/strong&gt;&lt;br&gt;
A type of relationship between objects where one object in table A is connected to one and only one object in table B.&lt;br&gt;
Example: Each librarian has one profile and vice versa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One-to-Many Relationship:&lt;/strong&gt;&lt;br&gt;
A type of relationship between objects where one object in table A is connected to multiple objects in table B.&lt;br&gt;
Example : An author can write multiple books, but each book is written by only one author.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Many-to-Many Relationship:&lt;/strong&gt;&lt;br&gt;
A type of relationship between objects where multiple objects in table A are connected to multiple objects in table B.&lt;br&gt;
Example : A member can borrow multiple books, and a book can be borrowed by multiple members.&lt;/p&gt;

&lt;p&gt;Here is an example that will show all three relationships and how they interact in a database called "Library.db" with an explanation :&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%2Fr70cpaxsshxhl92hip6h.jpeg" 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%2Fr70cpaxsshxhl92hip6h.jpeg" alt="Borrows-Table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Association Table for Many-to-Many Relationship&lt;/strong&gt; &lt;br&gt;
The borrows table is an association table used to establish a many-to-many relationship between Member and Book entities. Many-to-many relationships in SQLAlchemy use intermediaries called association tables (also called join tables). These are tables that exist only to join two related tables together.&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%2F91isfliu8y2jmb0nnaaz.jpeg" 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%2F91isfliu8y2jmb0nnaaz.jpeg" alt="1-to-1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One-to-One Relationship&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A one-to-one relationship is established between Librarian and Profile. Each Librarian has one Profile. The uselist=False argument indicates a one-to-one relationship. Each Profile is linked to one Librarian. The back_populates argument ensures that the relationship is bidirectional, allowing access from both sides. A one-to-one relationship is also called a "has one/belongs to" relationship. With a one-to-one relationship, you will pick one model to be on the "belongs to" side of the relationship (you can pick either model). The model on the "belongs to" side will store the foreign key.&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%2F9o8drvnty9w093f2inry.jpeg" 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%2F9o8drvnty9w093f2inry.jpeg" alt="1-to-Many"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One-to-Many Relationship&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A one-to-many relationship is defined between Author and Book. Each Author can write multiple Books and Each Book is written by one Author. The back_populates argument makes the relationship bidirectional, so Author can access its books and each Book can access its author.&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%2Fpk6ito4olxen2il6kloi.jpeg" 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%2Fpk6ito4olxen2il6kloi.jpeg" alt="Many-to-Many"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Many-to-Many Relationship&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A many-to-many relationship is established between Member and Book through the borrows association table. Each Book can be borrowed by multiple Members and Each Member can borrow multiple Books. The secondary=borrows argument specifies that the relationship is mediated by the borrows table, while back_populates ensures the relationship is bidirectional.&lt;/p&gt;




&lt;h2&gt;
  
  
  Foreign Keys
&lt;/h2&gt;

&lt;p&gt;As you can tell from the examples above we notice there are some columns that say id as well as some columns referencing other tables, But what exactly are foreign keys and why are they important when creating tables? A foreign key is a relational concept used to establish a connection between two tables in a database. It essentially creates a link between a column or set of columns in one table to a column or set of columns in another table. They also enforce referential integrity, ensuring that relationships between tables remain valid. As well as indicating the relationships between tables and even help developers understand the structure of the database and how data is interconnected.&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%2F84vxwhryibvi26i8eka2.jpeg" 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%2F84vxwhryibvi26i8eka2.jpeg" alt="Foreign key example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Parent is the parent table with a primary key id.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Child is the child table with its own primary key and a foreign key parent_id, which references the id column of the Parent table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The relationship() function establishes a bidirectional relationship between Parent and Child, allowing easy navigation between associated records.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall foreign keys play a crucial role in maintaining data integrity, enforcing relationships between tables, optimizing queries, and ensuring data consistency in relational databases.&lt;/p&gt;




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

&lt;p&gt;Understanding how tables relate in Python is really important for developers who want to build good database systems. If developers know the different kinds of relationships between tables, they can organize their databases well to match real-life situations. This helps keep data correct and consistent. Foreign keys are key to making sure these relationships are set up and enforced properly. By using foreign keys well, developers can create database systems that work really well and handle lots of information. Having a thorough comprehension of table relations, coupled with the strategic use of foreign keys, enables developers to design and implement database systems that are both complex and efficient.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>python</category>
    </item>
    <item>
      <title>Intro to Python</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Thu, 02 May 2024 03:36:47 +0000</pubDate>
      <link>https://dev.to/pedroa54/intro-to-python-54em</link>
      <guid>https://dev.to/pedroa54/intro-to-python-54em</guid>
      <description>&lt;h3&gt;
  
  
  INTRODUCTION
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;S&lt;/strong&gt;o what exactly is Python and what does it do? Python is one of the more popular programming languages, and was created by Guido Van Rossum, and released in 1991. The main uses for using Python is web development (server-side), software development, mathematics, system scripting. Python is a very high-level, general-purpose programming language. Its design philosophy really emphasizes code readability with the use of significant indentation. This helps for navigating through such large chunks of code and understanding what your reading. Like many other programming languages Python has gone through numerous updates since its official release in February 1991. Python claims to strive for a simpler, less-cluttered syntax and grammar while giving developers a choice in their coding methodology,  Python embraces a "there should be one—and preferably only one—obvious way to do it." philosophy.&lt;/p&gt;

&lt;h3&gt;
  
  
  SYNTAX
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;P&lt;/strong&gt;ython is meant to be one of the more easily readable languages, But what exactly is syntax? The syntax of the Python programming language is the set of rules that defines how a Python program will be written and interpreted. While using indentation, english keywords, and fewer syntactic exceptions. Making writing code more understandable but even easier to remember. Python is even considered one of the more easier programming languages to learn as a new developer. For example lets talk about python indentation which refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. Python uses indentation to indicate a block of code.&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%2F61n68g30trzg5c6qu907.jpeg" 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%2F61n68g30trzg5c6qu907.jpeg" alt="Syntax example 1" width="742" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This line of code is written correctly, the only thing its missing is indentation. Python will give you an error if you skip the indentation.&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%2Fpumuk2g9twj7zolzca2s.jpeg" 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%2Fpumuk2g9twj7zolzca2s.jpeg" alt="Syntax example 2" width="696" height="169"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So lets fix this, The number of spaces is really up to you as the programmer, the most common use is four, but it has to be at least 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%2Fuploads%2Farticles%2F1gwvoc63l9huneng24q7.jpeg" 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%2F1gwvoc63l9huneng24q7.jpeg" alt="Syntax example 3" width="656" height="97"&gt;&lt;/a&gt;&lt;br&gt;
As you can see in the example above the function was fixed because we implemented indentation. Overall Python's syntax is designed to be clear and easy to understand, which makes it accessible for beginners and reduces the cost of program maintenance. Also Python is executed line by line by the Python interpreter. This makes development so much better for debugging and makes it easier to immediately see the results of your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  FUNCTIONS
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A&lt;/strong&gt; function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result. To create a function in Python you must define the function using the &lt;em&gt;DEF&lt;/em&gt; keyword.&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%2F0mu6g6iy9b0dv1znx73e.jpeg" 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%2F0mu6g6iy9b0dv1znx73e.jpeg" alt="Function example 1" width="542" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above you can see we declared a function using the def keyword and called the function as well. We can also still write functions taking in parameters. &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%2F5lrxd3hel87eashayz6g.jpeg" 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%2F5lrxd3hel87eashayz6g.jpeg" alt="Function example 2" width="518" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, the function greet takes one parameter name, which represents the name of the person to greet. When you call the function, you pass a value for the name parameter, and the function prints a greeting using that value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Object-Oriented Programming
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;O&lt;/strong&gt;bject-oriented programming (OOP) is a method of structuring a program by bundling related properties and behaviors into individual objects. For example, an object could represent a person with properties like a name, age, and address and behaviors such as walking, talking, breathing, and running. OOP models real-world entities as software objects that have some data associated with them and can perform certain operations. It aims to implement real-world entities like inheritance, polymorphisms, encapsulation, and Abstraction. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt; in Object-Oriented Programming (OOP) is like hiding the complicated stuff and showing only what's important. For example if you have a remote, You don't need to know how all the circuits and buttons inside it work. All you need to know are the buttons you press to change channels, adjust the volume, and turn it on or off. That's abstraction!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt; in Object-Oriented Programming (OOP) is like putting things in a box and only letting certain people access them. For example encapsulation works similarly. You have a class, which is like the treasure chest, and it contains data (like variables) and methods (like functions) that operate on that data. You "lock" the class by making some parts private, meaning they can only be accessed from within the class itself. Other parts are public, which means they can be accessed from outside the class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inheritance&lt;/strong&gt; in Object-Oriented Programming (OOP) is like passing down traits from parents to children. like creating new classes based on existing ones and the child inherits things from the parent class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Polymorphism&lt;/strong&gt; in Object-Oriented Programming (OOP) is like having one name with many forms.  For example, both a "Cat" class and a "Dog" class might have a "makeSound()" method. When you call "makeSound()" on a cat object, it meows, and when you call it on a dog object, it barks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall OOP helps you write code that's organized, reusable, and easy to understand. It's like building with Lego blocks, where each block (object) has its own shape, color, and function, and you can combine them to create something bigger and more complex.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;P&lt;/strong&gt;ython is a widely used programming language, favored for its simplicity, versatility, and readability. It's syntax, emphasizing code readability with significant indentation, English keywords, and fewer syntactic exceptions, simplifies learning and maintenance. Functions enable encapsulation of code blocks for reusability and organization, while Object-Oriented Programming (OOP) structures programs around objects, facilitating abstraction, encapsulation, inheritance, and polymorphism. Abstraction hides complex details, encapsulation bundles data with methods for controlled access, inheritance promotes code reuse, and polymorphism allows objects of different classes to be treated interchangeably. &lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Python_(programming_language)"&gt;https://en.wikipedia.org/wiki/Python_(programming_language)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/python/default.asp"&gt;https://www.w3schools.com/python/default.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/python-programming-language/"&gt;https://www.geeksforgeeks.org/python-programming-language/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Components &amp; Props in React</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Mon, 08 Apr 2024 17:45:17 +0000</pubDate>
      <link>https://dev.to/pedroa54/components-props-in-react-9j6</link>
      <guid>https://dev.to/pedroa54/components-props-in-react-9j6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction To React
&lt;/h2&gt;

&lt;p&gt;For this Blog i will be going over the importance of Components &amp;amp; Props in the world of React. So what exactly is React?? Well React was first introduced back in May 2013. Surpassing other front-end libraries to become the most commonly used library for web development. React is a free and open-source front-end JavaScript library for building user-interfaces(UI) based on components, React organizes UI into reusable components, making it easier to manage and maintain large-scale applications. Very Important to learn early on that React is NOT a programming language. React uses JSX, which is a syntax extension that allows developers to write HTML-like code within JavaScript. JSX is a mix of JavaScript and XML. Having one of the largest ecosystems of libraries, tools, and community support, making it so much easier for developers to build and scale complex applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components Basics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1
&lt;/h3&gt;

&lt;p&gt;Lets create some components to better understand this concept.&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%2Fwsb3qhoow32n8yhsjjz2.jpeg" 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%2Fwsb3qhoow32n8yhsjjz2.jpeg" alt="Components Example" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the example above we were able to declare a couple of functions called "Sport,Team, TopThreePlayers". Now i know it seems a bit confusing but lets go over what we see. When using React one of the first things you may notice is that the function names start with a capital and not a lower case. Something else you will learn quickly is that JSX functions can only take in one argument which are usually props. When using functions in react they must have a return statement. React takes in JavaScript code and also interpreting JSX’s special syntax within the return() statement, But now lets utilize then functions so they can have some use.&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%2Fofqehvehasiucp7m1sq9.jpeg" 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%2Fofqehvehasiucp7m1sq9.jpeg" alt="Components example" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So with all 3 of the components that were written out by implementing those components within a return statement. We can see that Sport(),Team(), TopThreePlayers() are being used inside the App() return statement. App is our top level component and Sport,Team,TopThreePlayers are lower. If it were to be displayed and turned into HTML App would be the parent and Sport,Team,TopThreePlayers would be the child component.&lt;br&gt;
A quick fun fact: Writing our functions starting off in  Capital Letters and not CamelCase is necessary because it helps react differentiate between regular JavaScript and React components and it is a must to follow this syntax in order for React to work properly and render in the components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Props Basics
&lt;/h2&gt;

&lt;p&gt;React props is short for properties and they are essentially function arguments with some attributes in HTML. In order to send down a props into a component, you must use syntax as HTML attributes. To simplify it they are a way of passing data from parent components to child components, The only way for a parent component to pass data to its child components is via props. They are immutable and are used to communicate between components. Props are similar to function arguments in JavaScript. Fun fact: They can be any data type, for example we can pass "strings, numbers, booleans, object, and functions" as props.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&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%2Fr4e0zcub6pq334ajkv4t.jpeg" 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%2Fr4e0zcub6pq334ajkv4t.jpeg" alt="Props Example" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above the prop has been sent down to the component and receives it. Props are fundamental in using react for passing data down from one component to another. So from the example above in the provided code snippet, a React component named Fruit is defined. This component takes a prop named fruit and renders a message indicating the favorite fruit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;React, a powerful JavaScript library for building user-interfaces(UI), revolves around the concept of components and props. Components are modular, reusable pieces of code that encapsulate specific UI elements and functionalities. Props, short for properties,They enable customization and configuration of components. By passing props down the component hierarchy, data and behaviors can be efficiently communicated between different parts of the application, enabling seamless interaction and data flow. Components and props promote code organization, reusability, and maintainability, making React a popular choice for developing modern web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://legacy.reactjs.org/docs/components-and-props.html"&gt;https://legacy.reactjs.org/docs/components-and-props.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://react.dev/learn/passing-props-to-a-component"&gt;https://react.dev/learn/passing-props-to-a-component&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/react/react_components.asp"&gt;https://www.w3schools.com/react/react_components.asp&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Scope in JavaScript??</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Mon, 18 Mar 2024 23:17:42 +0000</pubDate>
      <link>https://dev.to/pedroa54/scopes-in-javascript-3c9f</link>
      <guid>https://dev.to/pedroa54/scopes-in-javascript-3c9f</guid>
      <description>&lt;p&gt;Scoping is a fundamental concept to understand when learning to code super early on, why is this? It is because understanding the concept of scopes  will ensure you to write more organized code and understanding  when and where certain variables can be used and accessed within your code. This ensures that your code is well maintained and is a bug free code. In JavaScript, objects and functions are also variables. Scoping will determine the accessibility of variables, objects, and functions from different parts of the code and where they are located. Here is a simple analogy to understand it a bit more...&lt;/p&gt;

&lt;p&gt;Now imagine you're in a big building with many different rooms. The &lt;strong&gt;&lt;em&gt;Global Scope&lt;/em&gt;&lt;/strong&gt; is The building's lobby. Everyone in this building can see the lobby, and things placed here can be accessed by anyone in the building.&lt;br&gt;
Now there is a something called a &lt;strong&gt;&lt;em&gt;Function Scope&lt;/em&gt;&lt;/strong&gt; where there are specific room's in the building. When you're in a room, you can see and interact with everything inside that room, but you can't see what's in other rooms unless you go into them. Now for the final one which is &lt;strong&gt;&lt;em&gt;Block Scope&lt;/em&gt;&lt;/strong&gt; just Imagine you're organizing your stuff in boxes. Each box represents a &lt;strong&gt;&lt;em&gt;block scope&lt;/em&gt;&lt;/strong&gt;. When you open a box, you can see and use what's inside it, but you can't access the contents of other boxes unless you open them. Just like in programming scoping in this analogy helps you keep everything organized and prevents mixing up items from different areas. Each scope has its own set of rules and boundaries for what can be accessed. Scope can be better explained and understood by breaking it up to global, local, and block scopes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Global Scope
&lt;/h2&gt;

&lt;p&gt;The Global Scope in programming refers to the area of a program where variables and functions are accessible from anywhere in the codebase, This means its Accessibility is in every scope and is the outermost scope. The variables and functions declared in the global scope are available to all parts of the program.  &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%2F2p6bmpw00kmnlikt0tm3.jpeg" 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%2F2p6bmpw00kmnlikt0tm3.jpeg" alt="Image description" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above the globalVariable is declared outside of any function or block, making it a global variable. Also The function foo() is able to access the globalVariable even though it's declared outside of the function. This is because globalVariable is in the global scope and can be accessed from anywhere within the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Scope
&lt;/h2&gt;

&lt;p&gt;The function scope refers to the area within a function where the variables and functions are accessible, any variables declared within the function are now function scoped. Each function creates a new scope. This meaning they are now only visible and accessible within that function. This concept is to ensure no confusion because now that the variables declared within a function do not have any conflict with variables outside of the function.&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%2F9e87rb5062z4vkj7ch7a.jpeg" 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%2F9e87rb5062z4vkj7ch7a.jpeg" alt="Image description" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above localVar is declared inside the foo() function making it a local variable with function scope and also The variable localVar is accessible only within the foo() function. Attempting to access it outside of the function will result in a reference error because it's not defined in the outer scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  Block Scope
&lt;/h2&gt;

&lt;p&gt;The block scope refers to the area within a block of code where variables are accessible. Any Variables declared inside a { } block cannot be accessed from outside the block.&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%2Fxpz04hjvuavn1f1ip7fm.jpeg" 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%2Fxpz04hjvuavn1f1ip7fm.jpeg" alt="Image description" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above the "blockVar" is declared within the if block making it a block-scoped variable, It is inside { } brackets and The variable "blockVar" is accessible only within the if block. Attempting to access it outside of the block will result in a reference error because it's not defined in the outer scope.&lt;/p&gt;

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

&lt;p&gt;Overall Scopes is vital to coding to understanding the visibility and accessibility of variables and functions within a program as well as writing clean, prevent variable conflicts, and organized code. Keep in mind that every function creates its own scope, and any variables or functions you declare inside of the function will not be available outside of it. Always use const and let to declare variable. By understanding and properly utilizing scopes, developers can reduce the likelihood of bugs and improving overall code quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.w3schools.com/js/js_scope.asp"&gt;https://www.w3schools.com/js/js_scope.asp&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Scope"&gt;https://developer.mozilla.org/en-US/docs/Glossary/Scope&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>What are functions???</title>
      <dc:creator>Pedro Alarcon</dc:creator>
      <pubDate>Mon, 05 Feb 2024 02:37:33 +0000</pubDate>
      <link>https://dev.to/pedroa54/what-are-functions-17lh</link>
      <guid>https://dev.to/pedroa54/what-are-functions-17lh</guid>
      <description>&lt;p&gt;Functions??? What are they exactly... the simple explanation is functions are blocks of reusable code that can be called and executed whenever they are needed. Functions must be given a proper set of instructions so they can be used and most importantly a name of what this function will do. Given the type of code you are writing it will be important. Lets get even more simple, functions is to programming the way recipes is to cooking. Just like a recipe tells you how to cook a specific dish, a function will tell the computer how to perform a specific task.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do i create a function?
&lt;/h2&gt;

&lt;p&gt;Creating a function is actually quite simple. To create a function in JavaScript all you have to do is use the function keyword-&amp;gt; followed by the name of what this function will do-&amp;gt; parentheses for parameters (Parameters are variables that are defined in the function declaration and are used to receive input values when the function is called)-&amp;gt; the return statement is used to specify the value that the function should output-&amp;gt; and curly braces {} to enclose the function body. The example below is a function declaration that adds 2 numbers together.&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%2Fyiuljsifbkk1os2dsp9r.jpeg" 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%2Fyiuljsifbkk1os2dsp9r.jpeg" alt="Image description" width="515" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now what if we want to test that this function is working properly? Well all we have to do is console.log it. The whole purpose of this function is to add a + b. In order to do this look below at the example.&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%2F3hd1djgmrq15pytiew3k.jpeg" 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%2F3hd1djgmrq15pytiew3k.jpeg" alt="Image description" width="510" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example we used console.log(addNumbers(21, 4)); to get the result of adding a + b. We could use any two numbers not just 21 and 4. Console.log allows us to print display information in the console of a web browser or a Node.js environment. It's a very helpful tool for debugging and understanding how our code is working. Something to get used to because its a tool that will be used a lot. In the example above the result (25) would be displayed in the console bar, By using console.log we can verify that our function is working as expected and see the output of our calculations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are functions so important?
&lt;/h2&gt;

&lt;p&gt;To start off functions are a huge part of writing code and to break it down even more Functions help break down really big and complex programs into smaller, more manageable pieces of code. By dividing our code into functions, we can organize and structure our program's logic, making it easier to read and maintain. Well-named functions with clear purposes can make our code more easy to read and make them self-explanatory. This is important because best believe that depending on the type of code you are writing for your program it will make it a whole lot easier to navigate through it the more neat and in order your code is. A major tip is to never write a huge function that could confuse you, in fact by dividing our code into smaller functions, each function can have a specific responsibility or task, making it easier to read and maintain. Remember the more organized the better!&lt;/p&gt;

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