<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kevin</title>
    <description>The latest articles on Forem by Kevin (@kcastillo3).</description>
    <link>https://forem.com/kcastillo3</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%2F1247274%2Fcd2e8af8-ca9a-42a6-9bf8-6eaf28686b2e.jpeg</url>
      <title>Forem: Kevin</title>
      <link>https://forem.com/kcastillo3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kcastillo3"/>
    <language>en</language>
    <item>
      <title>User State Management in Web Applications: Login &amp; Signup</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Tue, 16 Apr 2024 08:51:13 +0000</pubDate>
      <link>https://forem.com/kcastillo3/user-state-management-in-web-applications-login-signup-11b</link>
      <guid>https://forem.com/kcastillo3/user-state-management-in-web-applications-login-signup-11b</guid>
      <description>&lt;p&gt;Managing user information in web apps, especially during login and signup, is key for keeping things safe, quick, and customized. This means the app remembers who's logged in, saves user preferences, and keeps track of session data to make the experience better and more secure.&lt;/p&gt;

&lt;p&gt;Setting up login and signup features properly is important for controlling who can access what and keeping sensitive information safe. This starts with using HTTPS to secure data being sent, and encrypting this information to prevent others from stealing or using it without permission.&lt;/p&gt;

&lt;p&gt;For password management, it's important to use strong hashing methods to keep passwords safe in the database. This means even if there's a data breach, the passwords are still protected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, request, redirect, url_for, render_template, flash
from flask_sqlalchemy import SQLAlchemy
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
db = SQLAlchemy(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password_hash = db.Column(db.String(128))

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

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

&lt;/div&gt;



&lt;p&gt;It's also key to make the signup process smooth and easy. This means creating a user-friendly interface that helps people register without too much trouble. Checking what users type as they type it can catch mistakes early and make the experience better. Plus, making sure that each user's email address or username is unique helps avoid duplicates and problems in the app.&lt;/p&gt;

&lt;p&gt;To illustrate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, render_template, request, redirect, url_for, flash
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, EqualTo, ValidationError
from werkzeug.security import generate_password_hash

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
db = SQLAlchemy(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password_hash = db.Column(db.String(128))

class RegistrationForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired()])
    confirm_password = PasswordField('Confirm Password', validators=[DataRequired(), EqualTo('password')])
    submit = SubmitField('Sign Up')

    def validate_email(self, email):
        user = User.query.filter_by(email=email.data).first()
        if user:
            raise ValidationError('That email is taken. Please choose a different one.')

@app.route('/signup', methods=['GET', 'POST'])
def signup():
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = generate_password_hash(form.password.data)
        user = User(email=form.email.data, password_hash=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Account created!', 'success')
        return redirect(url_for('login'))
    return render_template('signup.html', title='Sign Up', form=form)

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

&lt;/div&gt;



&lt;p&gt;Once a user logs in, it's important to keep track of their session securely. When they log in, the server gives them a unique code, usually saved in a cookie, which helps the server remember who they are without making them log in again for every action. It's crucial to manage these sessions safely by changing the code each time they log in and setting an expiration on how long they can stay logged in. This prevents others from sneaking in using old sessions.&lt;/p&gt;

&lt;p&gt;Let’s illustrate session management in Flask, ensuring secure session handling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, session, redirect, url_for, request, flash
from flask_session import Session

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key'
app.config['SESSION_TYPE'] = 'filesystem'
Session(app)

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        # Here you should verify the username and password with the database
        if username == "admin" and password == "secret":
            session['logged_in'] = True
            session.regenerate()  # Regenerate session ID to prevent fixation
            return redirect(url_for('dashboard'))
        else:
            flash('Invalid credentials')
    return render_template('login.html')

@app.route('/logout')
def logout():
    session.pop('logged_in', None)
    session.regenerate()  # Regenerate session ID on logout for security
    return redirect(url_for('login'))

@app.route('/dashboard')
def dashboard():
    if not session.get('logged_in'):
        return redirect(url_for('login'))
    return render_template('dashboard.html')

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

&lt;/div&gt;



&lt;p&gt;In this example, session.regenerate() is a made-up function used to show how changing session IDs can stop certain security attacks. The actual way to change session IDs might vary depending on the tools you're using. For example, Flask, a popular tool for building websites, doesn't have a regenerate() function. Instead, you can change the session ID yourself or log the user out and back in to get a new one.&lt;/p&gt;

&lt;p&gt;Error handling and user feedback are crucial for login and signup processes. It's important to give clear and simple messages when users make mistakes, like entering the wrong password or filling out a form incorrectly. This helps users fix their errors without getting too frustrated. However, it's also important to make sure these messages don't give away too much information about the security setup or the user's account details to keep things safe.&lt;/p&gt;

&lt;p&gt;When you're running a web application with different parts, like the main app, login, and signup sections, it's really important to keep user information consistent everywhere. Using a centralized way to manage this information helps make sure that the user's login status and other details are the same across the whole application. This approach makes the user experience smoother, no matter where they navigate on the website.&lt;/p&gt;

&lt;p&gt;React, which is often paired with Flask to build web applications, provides different ways to keep data in sync across the app. A common method is using React's Context API with hooks like useState and useContext. This lets you set up a global state that any component in the app can reach and change. This helps keep all parts of the app updated with the latest user data and settings.&lt;/p&gt;

&lt;p&gt;Here's how you can implement a simple user state management system using React Context API in conjunction with a Flask backend:&lt;/p&gt;

&lt;p&gt;Setting Up the User Context&lt;br&gt;
First, define a UserContext to hold the user's state and a method to update it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/contexts/UserContext.js
import React, { createContext, useState, useContext } from 'react';

const UserContext = createContext();

export function UserProvider({ children }) {
  const [user, setUser] = useState(null);

  return (
    &amp;lt;UserContext.Provider value={{ user, setUser }}&amp;gt;
      {children}
    &amp;lt;/UserContext.Provider&amp;gt;
  );
}

export function useUser() {
  return useContext(UserContext);
}

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

&lt;/div&gt;



&lt;p&gt;Integrating Context in the Application&lt;br&gt;
Wrap your application's component tree with the UserProvider to make the user state accessible throughout your application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/App.js
import React from 'react';
import { UserProvider } from './contexts/UserContext';
import Login from './components/Login';
import Signup from './components/Signup';

function App() {
  return (
    &amp;lt;UserProvider&amp;gt;
      &amp;lt;div&amp;gt;
        {/* Routes and other components */}
        &amp;lt;Login /&amp;gt;
        &amp;lt;Signup /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/UserProvider&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;Using the User State in Components&lt;br&gt;
In your Login and Signup components, use the useUser hook to access and update the user state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/components/Login.js
import React from 'react';
import { useUser } from '../contexts/UserContext';

function Login() {
  const { setUser } = useUser();

  const handleLogin = async () =&amp;gt; {
    // Perform the login process (e.g., using fetch API to communicate with Flask backend)
    // On successful login:
    setUser({ name: 'John Doe', email: 'john@example.com' });
  };

  return (
    &amp;lt;button onClick={handleLogin}&amp;gt;Log In&amp;lt;/button&amp;gt;
  );
}

export default Login;

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

&lt;/div&gt;



&lt;p&gt;This setup ensures that when a user logs in or signs up, the user state is updated globally across all components that consume the UserContext. As a result, components can react to changes in the user's authentication state, enabling features like conditional rendering based on whether the user is logged in.&lt;/p&gt;

&lt;p&gt;Using React's Context API together with a Flask backend helps keep a consistent state across all parts of a web application. This means no matter where users enter or how they move around the site, they see the same interface and have the same access rights. This approach makes it easier for developers to keep track of user states throughout the application, improving the overall user experience.&lt;/p&gt;

&lt;p&gt;In conclusion, handling user state management well means combining secure and efficient login and signup processes with consistent state management throughout the application. This approach ensures that users have a secure and smooth experience on the website.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Flask Responses: A Guide to Using jsonify and make_response for API Development</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Tue, 26 Mar 2024 14:41:52 +0000</pubDate>
      <link>https://forem.com/kcastillo3/mastering-flask-responses-a-guide-to-using-jsonify-and-makeresponse-for-api-development-3n26</link>
      <guid>https://forem.com/kcastillo3/mastering-flask-responses-a-guide-to-using-jsonify-and-makeresponse-for-api-development-3n26</guid>
      <description>&lt;p&gt;During my coding journey, I've come to a place where I'm having one issue when going about completing projects, which I will try to clarify through this beginner's blog. Do I use jsonify? Or do I use make_response?&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%2Fqjuxeuoz8g1ja2qt05g7.gif" 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%2Fqjuxeuoz8g1ja2qt05g7.gif" alt="Neo Chooses Blue or Red Pill"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To be honest, initially, when completing assignments and trying to make API requests, I began with jsonify to render data from my models, this was until I discovered make_response and my mind entirely changed...kind of. &lt;/p&gt;

&lt;p&gt;It seemed like some of the code I was having problems trying to complete using jsonify was being passed relatively easily when I began using make_response instead. But I was blindly plugging it in, without necessarily understanding, why it was working better than when I used jsonify.&lt;/p&gt;

&lt;p&gt;So let's clarify what each does and their use cases, starting with jsonify.&lt;/p&gt;

&lt;p&gt;jsonify is a function provided by Flask, designed specifically for converting data into JSON format. Consider the following JSON representation of a character, which might be similar to what you'd want to send back to a client in a web application:&lt;/p&gt;

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

{
  "character": {
    "name": "Ted Mosby",
    "occupation": "Architect",
    "education": "Wesleyan University",
    "friends": ["Marshall Eriksen", "Lily Aldrin", "Robin Scherbatsky", "Barney Stinson"],
    "interests": ["Architecture", "Teaching", "Finding true love"],
    "favoritePlaces": ["MacLaren's Pub", "The Empire State Building"],
    "quotes": [
      "Sometimes things have to fall apart to make way for better things.",
      "If you're not scared, you're not taking a chance. And if you're not taking a chance, then what the hell are you doing?"
    ]
  }
}


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

&lt;/div&gt;

&lt;p&gt;This JSON example shows how data can be structured in a clear, readable format for both people and computers. Using jsonify in Flask allows this data to be converted and returned as a response object to the client, with the Content-Type header automatically set to application/json. This simplifies the process. Not only does it make sure that the data is correctly formatted—as as it is in the example above—but it also takes care of setting the necessary HTTP headers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra Information:&lt;/strong&gt;&lt;/p&gt;

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

Some common HTTP headers that might be relevant, but are not necessarily set by jsonify:

1. Content-Length: The size of the response body in octets (bytes).
2. Cache-Control: Directives for caching mechanisms in both requests and responses.
3. Set-Cookie: Used to send cookies from the server to the user agent.
4. Access-Control-Allow-Origin: Specifies which domains can access the resources in a cross-origin request.
5. ETag: An identifier for a specific version of a resource, allowing for more efficient caching and resource updates.
6. Expires: The date/time after which the response is considered stale.
7. Last-Modified: The date and time at which the server believes the resource was last modified.
8. Location: Used in redirections or when a new resource has been created. This header indicates the URL to which the request should be redirected.
9. Authorization: Contains the credentials to authenticate a user agent with a server.
10. WWW-Authenticate: Defines the authentication method that should be used to access a resource.

"Setting the necessary HTTP headers" means that the server includes in its response additional metadata about the response itself (like content type, caching policies, authentication requirements, etc.). This information helps the client (e.g., a web browser or another server) to correctly interpret the response, manage caching, handle security, and more.


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

&lt;/div&gt;

&lt;p&gt;So what exactly did I just say here?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In simpler terms, using jsonify means:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You don't need to manually convert your data (like Python dictionaries or lists) into a JSON string as in our above example; jsonify does that for you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You don't have to worry about setting HTTP headers to tell the client that you're sending JSON data. jsonify automatically adds the Content-Type: application/json header, which is essential for web clients (like browsers or other servers) to understand that the data you're sending is in JSON format.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The data processed by jsonify is wrapped in a Flask Response object. It's a full HTTP response that includes the status code, headers, and the body. This means Flask takes care of the complexities of creating HTTP responses, allowing you to focus on your application logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So that's jsonify and now I will explain make_response which is another Flask function, but offers more flexibility compared to jsonify. It allows you to build a response object from various types of return values, not just JSON. You can use it to set additional headers, change the status code of your response, or even attach cookies.&lt;/p&gt;

&lt;p&gt;For instance, suppose you want to return a JSON response but also need to set a custom cookie or a specific status code. Make_response lets you do that. You could first use jsonify to convert your data into JSON format and then wrap it with make_response, where you can further manipulate the response by adding headers or changing the status code as needed.&lt;/p&gt;

&lt;p&gt;Let's integrate it into the context of our discussion on jsonify and make_response to give a clearer understanding of how make_response can be utilized:&lt;/p&gt;

&lt;p&gt;After exploring and using jsonify, I discovered the flexibility of make_response, which broadened my understanding of handling HTTP responses in Flask. Make_response offers more  control over the response, including setting custom status codes and modifying headers. This is useful in scenarios where more than just JSON data needs to be sent back to the client.&lt;/p&gt;

&lt;p&gt;Consider if we're developing a web service using Flask, to retrieve character information from a database by their unique ID.&lt;/p&gt;

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

from flask import Flask, make_response
from your_model import Character  # Assuming you have a Character model defined

app = Flask(__name__)

@app.route("/characters/&amp;lt;int:id&amp;gt;", methods=["GET"])
def character_by_id(id):
    # Attempt to find the character by its ID
    character = Character.query.filter(Character.id == id).first()

    # If the character isn't found, return an error message with a 404 status code
    if character is None:
        return make_response({"error": "Character not found"}, 404)

    # If Ted Mosby is found, convert his details to a dictionary (excluding some relations if needed) and return it with a 200 status code
    response = make_response(character.to_dict(rules=("-unwanted_relations",)), 200)
    return response


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;In this example, make_response is used in two key ways:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Handling Not Found Cases:&lt;/strong&gt; When the character with the specified ID does not exist in the database, make_response is employed to construct a well-formed HTTP response. This response comprises a JSON body with an error message ("Character not found") and sets the HTTP status code to 404. This status code is crucial for client-side error handling, as it universally indicates that the requested resource could not be found.&lt;/li&gt;
&lt;/ul&gt;

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

if character is None:
    return make_response({"error": "Character not found"}, 404)



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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Successful Response:&lt;/strong&gt; Conversely, when the character is found, the code demonstrates how to prepare and send a successful response back to the client. In this case, character.to_dict(rules=("-unwanted_relations",)) is called to convert the character's details into a dictionary format, excluding certain relations or fields dictated by the provided rules. The make_response function then wraps this dictionary, setting the HTTP status code to 200 to signal a successful operation.&lt;/li&gt;
&lt;/ul&gt;

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

response = make_response(character.to_dict(rules=("-unwanted_relations",)), 200)
return response



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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Using jsonify for Simple JSON Responses&lt;/strong&gt;&lt;br&gt;
jsonify is most effective for straightforward cases where your primary goal is to return JSON data to the client. It is a high-level function that abstracts away the details of setting the correct headers and converting your data structure (like a Python dictionary or list) into JSON format. It's the go-to choice when you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Need to quickly return JSON data with minimal fuss.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Are not concerned with setting custom status codes or headers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want to ensure the response has the correct Content-Type: application/json header automatically.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Case:&lt;/strong&gt; Returning a list of items from a database that the front end will use to display a simple list. The simplicity of jsonify makes it a good fit here.&lt;/p&gt;

&lt;p&gt;Make_response is better in scenarios requiring more control over the HTTP response. This includes setting custom HTTP headers, changing the status code, attaching cookies, or even returning different types of responses (not just JSON). It's the tool of choice when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Customize the response’s status code based on the outcome of a request. For example, returning a 201 for a successful resource creation or a 404 when a resource cannot be found.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add specific headers to a response, such as Cache-Control for caching strategies, or Set-Cookie for session management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return content types other than JSON, like HTML or plain text, while still being able to easily return JSON when necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choosing between jsonify and make_response in Flask comes down to simplicity versus flexibility. Use jsonify for straightforward JSON responses, and make_response when you need more control over your response, like setting custom status codes and headers. &lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Python Objects &amp; Functions: A Technical Dive</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Fri, 09 Feb 2024 15:30:35 +0000</pubDate>
      <link>https://forem.com/kcastillo3/python-objects-functions-a-technical-dive-21hp</link>
      <guid>https://forem.com/kcastillo3/python-objects-functions-a-technical-dive-21hp</guid>
      <description>&lt;p&gt;So far in my journey coding with Python one of the lessons I enjoyed learning about so far was how to remember objects. Let's look at some code and break down some of the topics. For disclosure, to make this entertaining for myself and you (the reader), I choose to write some of the code myself (Python experts have mercy). However, we will be looking at some fun places to go for a night out in Brooklyn, and if you look through some of what I've written, you might find a fun place to go to if you happen to visit NYC. The treasure for you here (if you're 21+) is that if you reach the end of the blog, I won't gatekeep..oh and you might learn a thing or two about Python also.&lt;/p&gt;

&lt;p&gt;To begin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bar:
    def __init__(self, name, music_type):
        self.name = name
        self.music_type = music_type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above defines a Python class named Bar. This class serves as a blueprint for creating objects (instances) that represent various bars, taking in each bar's characteristics: its name, and the type of music it plays. Let's break down the components of this class definition to understand its structure and purpose:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The easiest one to start with is the class. In Python, the class keyword is followed by the class name (Bar here), and a colon begins the definition of a Bar class, serving as a template for creating objects.&lt;/p&gt;

&lt;p&gt;Next, we have this string of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def __init__(self, name, music_type):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whose method and its set-up you will become very familiar with in Python. This line introduces a method you'll frequently encounter in Python: the constructor. Known as &lt;strong&gt;init&lt;/strong&gt;, this special method is triggered automatically whenever a new instance of the class is created. It serves to initialize the new object with its distinct characteristics— the bar's name and the type of music it plays for example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;self&lt;/strong&gt;: Represents the instance of the class and allows access to the attributes and methods of the class. It's how you refer to the instance within the class's scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;name and music_type&lt;/strong&gt;: These parameters are passed to the &lt;strong&gt;init&lt;/strong&gt; method and are used to set up the new object with its specific name and music type, making each instance unique.&lt;/p&gt;

&lt;p&gt;Next, we have the:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        self.name = name
        self.music_type = music_type
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;self&lt;/strong&gt;: This keyword refers to the instance of the Bar class that's currently being created. It's how we access attributes and methods within the class instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.name&lt;/strong&gt;: By appending .name to self, we specify that we're dealing with the name attribute of this particular instance. It's like saying, "In this bar object, there's an attribute named name."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;= name&lt;/strong&gt;: The assignment operator (=) is used here to assign the value passed into the name parameter of the &lt;strong&gt;init&lt;/strong&gt; method to the instance's name attribute. The name on the right side of = is the argument supplied when a new Bar instance is being instantiated.&lt;/p&gt;

&lt;p&gt;For the &lt;strong&gt;self.music_type&lt;/strong&gt; assignment, you would follow the same guidelines.&lt;/p&gt;

&lt;p&gt;However, let's make a slight modification here now that you know some of the breakdown of the original code, which might make this part a bit easier to understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bar:
    all = []  # Class variable to store instances

    def __init__(self, name, music_type):
        self.name = name
        self.music_type = music_type
        Bar.all.append(self)  # Adding each new instance to our class variable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this modification, every new Bar instance created is automatically remembered by appending itself to the "all" list. This method allows us to easily manage and access the list of bars I've been hinting at, making it possible to iterate over them, display their details, or even filter them based on certain criteria like music type. Let's take a look at what this looks like:&lt;/p&gt;

&lt;p&gt;(What you've been waiting for, but please read until the end) The list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pencil_factory = Bar("Pencil Factory", "Indie Rock")
twinz_lounge = Bar("Twinz Lounge", "Reggae")
jupiter_disco = Bar("Jupiter Disco", "Electronic")
public_records = Bar("Public Records", "Various Live Music")
bar_schimanski = Bar("Bar Schimanski", "Techno")
carousel = Bar("Carousel", "Pop")
westlight = Bar("Westlight", "Jazz")

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

&lt;/div&gt;



&lt;p&gt;To reiterate, by adding each new instance of Bar to the "all []" class variable, we create a dynamic list that grows every time a new bar is introduced to our list above. &lt;/p&gt;

&lt;p&gt;To further refine this, I implemented class methods to interact with our collection of bars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bar:
    all = []

    def __init__(self, name, music_type):
        self.name = name
        self.music_type = music_type
        Bar.add_bar_to_all(self)

    @classmethod
    def add_bar_to_all(cls, bar):
        cls.all.append(bar)

    @classmethod
    def show_bar_names(cls):
        for bar in cls.all:
            print(f"{bar.name} plays {bar.music_type} music.")

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

&lt;/div&gt;



&lt;p&gt;Let's break down the elements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@classmethod&lt;/strong&gt;: This is a decorator in Python that alters the way the method add_bar_to_all(cls, bar) is called and used. Unlike regular methods, which take the instance self as the first argument, a class method takes the class cls as the first argument. This means that the method belongs to the class rather than any individual instance of the class. It can be called on the class itself, rather than on an instance, affecting all instances of the class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;def add_bar_to_all(cls, bar)&lt;/strong&gt;: This defines a class method named add_bar_to_all. The method is designed to take two arguments: cls, which is a reference to the class, and bar, which is an instance of the Bar class to be added to the class variable all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;cls&lt;/strong&gt;: This is a conventional name for the first argument to class methods (similar to how self is used for instance methods). It refers to the class on which the method is called. This allows the method to access class variables and other class methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;bar&lt;/strong&gt;: This is the second argument to the method, which is expected to be an instance of the Bar class. This bar instance is what will be added to the list of bars stored in the class variable all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;cls.all.append(bar)&lt;/strong&gt;: This line of code performs the action of appending the given bar instance to the class variable all. Since cls refers to the class itself, cls.all accesses the class variable all that is meant to store a list of all bar instances. The append() method then adds the bar instance to the end of this list.&lt;/p&gt;

&lt;p&gt;This method provides a structured way to manage a collection of Bar instances at the class level, allowing all instances of the class to be easily accessed and manipulated through class methods.&lt;/p&gt;

&lt;p&gt;By adding this, the Bar class not only keeps track of each bar instance but also offers a class method show_bar_names to print out the names and music types of all bars.&lt;/p&gt;

&lt;p&gt;When we execute the code with our Brooklyn bars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pencil_factory = Bar("Pencil Factory", "Indie Rock")
twinz_lounge = Bar("Twinz Lounge", "Reggae")
jupiter_disco = Bar("Jupiter Disco", "Electronic")
public_records = Bar("Public Records", "Various Live Music")
bar_schimanski = Bar("Bar Schimanski", "Techno")
carousel = Bar("Carousel", "Pop")
westlight = Bar("Westlight", "Jazz")

Bar.show_bar_names()

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

&lt;/div&gt;



&lt;p&gt;This will output a list of bars along with their music types, providing a good reference for anyone exploring Brooklyn's nightlife and wanting to cut loose and vibe with friends strangers, and anything in between.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pencil Factory plays Indie Rock music.
Twinz Lounge plays Reggae music.
Jupiter Disco plays Electronic music.
Public Records plays Various Live Music music.
Bar Schimanski plays Techno music.
Carousel plays Pop music.
Westlight plays Jazz music.

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

&lt;/div&gt;



&lt;p&gt;Hopefully, you learned a thing about Python&lt;/p&gt;

&lt;p&gt;P.S.&lt;/p&gt;

&lt;p&gt;A nod to my favorite place, but you'll have to visit each place on the list to know which I'm talking about. My challenge to you. Cheers!&lt;/p&gt;

&lt;p&gt;
  summary
  &lt;a href="https://www.youtube.com/watch?v=XEjLoHdbVeE"&gt;https://www.youtube.com/watch?v=XEjLoHdbVeE&lt;/a&gt; 

&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>React: Understanding Props and Components</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Thu, 18 Jan 2024 14:51:33 +0000</pubDate>
      <link>https://forem.com/kcastillo3/react-understanding-props-and-components-154d</link>
      <guid>https://forem.com/kcastillo3/react-understanding-props-and-components-154d</guid>
      <description>&lt;p&gt;Understanding props, components, and the transfer of props from parent to child. If you're new to React like I am, you might be thinking to yourself "What does this all mean"?&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%2F2idgzdu7mtfijop65uy6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2idgzdu7mtfijop65uy6.jpg" alt="Oppenheimer Thinking" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you begin with React, think of it like working with a special kind of puzzle. In this puzzle, each piece can change and update itself. It's a way to build websites where parts of the page can change without needing to replace the whole puzzle. Then you might think to yourself, again. "What"?&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%2Fzxy7u6kwg8bbjoft7jl8.gif" 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%2Fzxy7u6kwg8bbjoft7jl8.gif" alt="Shocked fan" width="480" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, if you're familiar with JavaScript, you know that an object is a kind of variable that holds multiple values as key-value pairs, known as properties, which we'll be looking at soon. Let's use a dating app profile as an example. &lt;/p&gt;

&lt;p&gt;A profile object might have properties like name, age, and hobbies, each representing a piece of information about the user. These properties are accessed using dot notation. If you're not already familiar with JavaScript, don't worry—understanding this concept is helpful since React is a library built on JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dot Notation Example:&lt;/strong&gt;&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%2Fyrrnknlf46icd8cbi1dm.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%2Fyrrnknlf46icd8cbi1dm.png" alt="Dot Notation Example" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, the profile object represents a user on a dating app. We use the dot notation to grab the name, age, and hobbies properties of the profile. Simply by writing the name of the object, followed by the (.) and then the properties of said object.  &lt;/p&gt;

&lt;p&gt;In reality, this is similar to how you would view different details of someone's dating profile on an app like Tinder, Bumble, or Hinge. Understanding how to access properties in JavaScript objects is similar to how you'll use props to pass data in React components as you'll soon see.&lt;/p&gt;

&lt;p&gt;In React, props work similar to objects in JavaScript. They are used to pass data from one component to another. It's useful to think of props as the arguments that a component accepts, provided using JSX syntax, much like how you'd set attributes in HTML. When writing a function for a component, you use the keyword 'props' to handle this passed data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Props Example&lt;/strong&gt;&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%2Femc2w1z8e1bsdeauoxhs.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%2Femc2w1z8e1bsdeauoxhs.png" alt="Match Notification Component" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;MatchNotification is a functional component that takes props as its only argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It uses a conditional rendering based on props.hasNewMatch. If hasNewMatch is true, it displays a message about a new match; otherwise, it shows a message indicating there are no new matches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;props.matchName is used to display the name of the new match.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our MatchNotification component, we use props to make decisions about what to display.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Destructuring in React Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While the MatchNotification component uses the props object directly, another common pattern in React is called destructuring. This approach can make your code cleaner and more intuitive, especially when a component deals with multiple props.&lt;/p&gt;

&lt;p&gt;In React, props work similarly to objects in JavaScript as you might have already started to notice (recall the dot-notation example). They are used to pass data from one component to another. This concept becomes especially clear when we look at how the Profile component is structured in our 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%2Fob84ipwevqfg9pkxxbk1.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%2Fob84ipwevqfg9pkxxbk1.png" alt="Child Component - Profile" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, a Profile component represents a user's profile. It receives data such as the user's name, age, and hobbies through props, very similar to what we did with the JavaScript dot notation. These props are then used within the component to render the profile information dynamically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Breaking Down the Profile Component:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the Profile component, we use destructuring to directly extract properties from props: { name, age, occupation, location, interests }.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This allows us to access each piece of the user information directly, without repeatedly prefixing them with props.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using Props Inside JSX:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inside the JSX, we use curly brackets {} to insert these JavaScript expressions, such as {name}, {age}, and {occupation}.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, {name} in the JSX will dynamically display the user's name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The interests prop, an array, is joined into a single string for display.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Rendering with Props:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just like in a dating app, where each profile has unique details about a person, the Profile component can display various information based on the props it receives. This dynamic rendering is achieved through the props passed down from a parent component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parent-Child Relationship&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's consider the parent component in our app, which uses the Profile component to display a user's profile:&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%2Fpc4bz63r7lrqv0ewlzlu.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%2Fpc4bz63r7lrqv0ewlzlu.png" alt="Parent Component" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, the parent component App renders the Profile component, passing data such as name, age, occupation, location, and interests. This demonstrates the one-way data flow from parent to child in React, where App is the parent and Profile is the child.&lt;/p&gt;

&lt;p&gt;Now, let's incorporate MatchNotification into the App component along with the Profile component for our user Charlie Kelly&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%2Ffbjeozj5bvtxg7flc14n.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%2Ffbjeozj5bvtxg7flc14n.png" alt="Final App Component" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the final App component, we have two child components: MatchNotification and Profile. Each child component plays a different role in the App, showing the versatility of React components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final App Component Breakdown: How the App Component Integrates Child Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The App component passes down specific data to each child component through props. For example, it provides the MatchNotification component with hasNewMatch and matchName, and the Profile component with user details.&lt;/p&gt;

&lt;p&gt;This demonstrates how React's component structure allows for reusability and flexibility. Each component can be thought of as a building block, which when put together, forms the complete application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rendering in App Component:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Within the App's JSX, we see the usage of , which passes the relevant props to the MatchNotification component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Similarly,  passes the required props to the Profile component.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React's design emphasizes a one-way data flow, which is evident in this structure. The App component (parent) passes data down to its child components, but these children do not pass data back up to the parent.&lt;/p&gt;

&lt;p&gt;This design makes the data flow in the application predictable and easier to debug, as data always flows in one direction.&lt;/p&gt;

&lt;p&gt;In conclusion, through these examples, you can see how React allows for the creation of interactive and dynamic user interfaces. Each component can have its own state and logic, which can be combined to build a dynamic web application. Hopefully, this helps a bit in your journey with React. Cheers&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%2Fdxvesbicrf0h4xsp8tbk.gif" 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%2Fdxvesbicrf0h4xsp8tbk.gif" alt="Cheers" width="600" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Balancing Learning, Life and Stress: Navigating the Coding Bootcamp Experience</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Wed, 03 Jan 2024 09:07:09 +0000</pubDate>
      <link>https://forem.com/kcastillo3/balancing-learning-life-and-stress-navigating-the-coding-bootcamp-experience-45i0</link>
      <guid>https://forem.com/kcastillo3/balancing-learning-life-and-stress-navigating-the-coding-bootcamp-experience-45i0</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;"The problem with the future is that it keeps turning into the present." - Bill Watterson&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As a first-time blogger trying to come up with a topic to write about for my coding boot camp, the first topic that immediately comes to mind is time and stress management. &lt;strong&gt;&lt;em&gt;Why?&lt;/em&gt;&lt;/strong&gt; If you’re anything like me, it’s the first thing that will take you by surprise. &lt;/p&gt;

&lt;p&gt;In a coding bootcamp, you might often think to yourself, &lt;strong&gt;&lt;em&gt;"When did time start going by so fast?"&lt;/em&gt;&lt;/strong&gt; One hour, you're getting up, shuffling out of bed, preparing coffee, and the next, it’s dark outside. Your roommates or parents, with whom you may be living, are coming back from their jobs, and there you are, doing stand down already - with cold, stale coffee from the morning at hand, thinking to yourself, &lt;strong&gt;&lt;em&gt;"Wasn’t it just 11 in the morning only an hour ago, and now it’s 6 pm? My gosh, what did I do in those hours? Am I going to remember everything I did? Shoot! What were everyone's names that I met today? Oh no! Panic - Anxiety - Dread..."&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Well, the first thing I would say here - &lt;strong&gt;&lt;em&gt;take a breather&lt;/em&gt;&lt;/strong&gt;. You need one, and you’ve sure earned it, friend. There’s no drill sergeant breathing down your neck, and nothing dreadful is going on anywhere else that isn’t inside your mind at this moment.&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%2F96tzy8orhbea6vsr8hio.gif" 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%2F96tzy8orhbea6vsr8hio.gif" alt="Drill Seargent giving orders"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is an intensive bootcamp, after all. This is what you signed up for, but you also didn’t sign away your mental stability - &lt;strong&gt;&lt;em&gt;or maybe you did&lt;/em&gt;&lt;/strong&gt;, but I think you’ll find the answer to that question later down the road. Regardless, take a breather, take in some fresh air, and remember to feed your cats or dog, maybe even yourself. Go out and remember there is life outside the bootcamp. Maybe take a bath or shower and destress your mind to get ready for the next couple of hours of studying. And really commit and understand that you will be studying.&lt;/p&gt;

&lt;p&gt;However, especially in the beginning, &lt;em&gt;don’t make the initial mistake I did and get lost in this time of taking a break&lt;/em&gt;. It’s very tempting to go and step away from the labs for a very long time, or to take naps that end up being full-blown sleeping, only to repeat the same process from the second paragraph. Thirty minutes can become multiple 3-hour increments of sleep very quickly, so make sure you have your alarms set if you do decide to take a nap. If you’re a heavy sleeper, maybe set up a couple.&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%2Fl952fqgp4ey20qz77tbl.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%2Fl952fqgp4ey20qz77tbl.jpeg" alt="Fry from Futurama unsure of whether or not he heard his alarm or turned it off in his sleep"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But, another thing I would recommend, especially very early on, is to create a purposeful schedule&lt;/strong&gt;. &lt;em&gt;Begin this before the first day of class and, if I could go back in time, I would have gotten a head start on the daily labs so I could always be one day ahead of the labs that are supposed to be finished that day.&lt;/em&gt; The good thing about my bootcamp is that they highlight labs you should be doing and place extra emphasis on labs that should be looked at a little more closely than others. &lt;/p&gt;

&lt;p&gt;While writing out your time management schedule, take into consideration every hour of your day, and commit at a minimum to completing the highlighted labs and reviewing them as best as you can for that day's daily labs, and if possible, prepare and look over and begin on the next day's daily labs, if you haven’t already gotten a head start, but only if your time allows.&lt;/p&gt;

&lt;p&gt;After this, you'll step into the real world to showcase what you've learned and achieved, especially to yourself and perhaps to anyone who knows you were in a bootcamp. &lt;strong&gt;So my advice, for these however many weeks you have in bootcamp, make it a point to give it your all and try to manage your time effectively, as it’s the only thing that's truly yours to help you succeed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set a schedule for taking breaks at fixed hours. I like Cal Newport's method of doing deep work for a set amount of time, and then taking a break.&lt;/p&gt;

&lt;p&gt;Setting a schedule for breaks using Cal Newport's method isn't just about discipline; it's about self-care. Remember, working non-stop can lead to burnout. Try to mitigate this by knowing how your time will be spent and how you want to unwind afterward.&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%2F69rh02f9eqpxuci4b163.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%2F69rh02f9eqpxuci4b163.jpeg" alt="Comedic comic strip of someone who experienced burnout so bad they literally burned out "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weekends are great for this&lt;/strong&gt;. Create a schedule for them too, and review the highlighted labs of the week. &lt;strong&gt;My preferred method of studying on weekends involves going through 2.5-hour sessions, followed by a 30-minute break, for three sessions throughout the day.&lt;/strong&gt; Then, I engage in an activity completely unrelated to coding to decompress. Often, this helps me retain what I've learned when I return to it later in the night.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Embracing this journey in a coding bootcamp is more than learning to code; it's about learning to manage your life under a new set of intense circumstances.&lt;/strong&gt; &lt;em&gt;Take comfort in knowing that you are not alone in this process&lt;/em&gt;. Your cohort will likely express similar feelings and frustrations. Learn from their mistakes as much as they will learn from yours. Even though it's a cohort, it often feels like you're in a team.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In summary, get a hold of your time to better grasp your success.&lt;/strong&gt; There are many factors at play in bootcamp beyond just coding. However, that doesn’t mean you should neglect your mental stability and head straight for burnout. As long as you can manage your stress and plan your time during these intensive weeks, you'll be on a better track to understanding the material and succeeding in your new coding journey!&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%2Fejiec3uet6lv03hdnggc.gif" 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%2Fejiec3uet6lv03hdnggc.gif" alt="Gatsby toasting"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
