<?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: wormondeck</title>
    <description>The latest articles on Forem by wormondeck (@wormondeck).</description>
    <link>https://forem.com/wormondeck</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%2F1181775%2Fa43896bd-760d-45a2-adc5-37f2a4872c15.png</url>
      <title>Forem: wormondeck</title>
      <link>https://forem.com/wormondeck</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/wormondeck"/>
    <language>en</language>
    <item>
      <title>I kept playing with my code and made a function to uppercase a letter instance in a string.</title>
      <dc:creator>wormondeck</dc:creator>
      <pubDate>Sat, 05 Oct 2024 17:55:46 +0000</pubDate>
      <link>https://forem.com/wormondeck/i-kept-playing-with-my-code-and-made-a-function-to-uppercase-a-letter-instance-in-a-string-5fj9</link>
      <guid>https://forem.com/wormondeck/i-kept-playing-with-my-code-and-made-a-function-to-uppercase-a-letter-instance-in-a-string-5fj9</guid>
      <description>&lt;p&gt;I was messing around with the &lt;code&gt;.upper()&lt;/code&gt; method in Codecademy and stumbled upon the forum section where a few devs were asking about uppercasing other letters in a string aside from the first. So I started testing different code and figured out a way to uppercase a specific letter. Here's the forum that inspired me to investigate:&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%2Fs4m5o1q3km0suprw5xvc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4m5o1q3km0suprw5xvc.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def upper_that_letter(some_str):
  upper_letter = ""
  for letter in some_str:
    if letter == "o":
      upper_letter = letter.upper()
      rep_letter_o = some_str.replace("o", upper_letter) 
  return rep_letter_o

print(upper_that_letter("Hola Mundo"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The part mentioning coming up with your own function gave me my first line of code to work with, I realized a string is immutable so to begin I created an empty string variable and since strings work similar to lists its only right to iterate for a specific letter, hello &lt;code&gt;for loop&lt;/code&gt;. I then added a condition specifying if that letter is in our case: "o" then we would use the &lt;code&gt;upper()&lt;/code&gt; method on it and place it in a variable we would call &lt;code&gt;upper_letter&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;At this point I got stuck and tried different scenarios to include the string passed in when calling the function but only got the letter "O"s returned in caps. Then I thought about the &lt;code&gt;replace()&lt;/code&gt; method! I realized the method &lt;code&gt;replace()&lt;/code&gt; takes two arguments, the string to search and replace as well as the string to replace the old value with. There is also a third argument specifying how many occurrences of the old value you want to replace (this ones a plus!). This method made it all connect for my function.  &lt;/p&gt;

&lt;p&gt;Now to put our replace() method in to play I used it on the &lt;code&gt;some_str&lt;/code&gt; parameter with "o" as the first argument to be replaced and the &lt;code&gt;upper_letter&lt;/code&gt; variable as its new replacement. Now we shall return our variable &lt;code&gt;replace_letter_o&lt;/code&gt;, and call our function with "Hola Mundo" and get our desired output of "HOla MundO"!&lt;/p&gt;

&lt;p&gt;I'm sure there's been many ways of getting this done but I wanted to share this not only to provide a solution but most importantly to show how understanding the tools available to you and trying different things on your own can help you find ways to become better at problem solving and enjoying coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>upper</category>
      <category>method</category>
    </item>
    <item>
      <title>My first CLI.</title>
      <dc:creator>wormondeck</dc:creator>
      <pubDate>Wed, 02 Oct 2024 17:40:59 +0000</pubDate>
      <link>https://forem.com/wormondeck/my-first-cli-2if</link>
      <guid>https://forem.com/wormondeck/my-first-cli-2if</guid>
      <description>&lt;h2&gt;
  
  
  Opening Credits
&lt;/h2&gt;

&lt;p&gt;The second it all clicks, consider the project fun. I built a client friendly CLI project to grasp how a class, methods, and properties work.&lt;/p&gt;

&lt;p&gt;My directory structure was quite simple:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;└── lib&lt;br&gt;
    ├── models&lt;br&gt;
    │   ├── __init__.py&lt;br&gt;
    │   └── actor.py&lt;br&gt;
    |   └── movie.py&lt;br&gt;
    ├── cli.py&lt;br&gt;
    ├── debug.py&lt;br&gt;
    └── helpers.py&lt;br&gt;
├── Pipfile&lt;br&gt;
├── Pipfile.lock&lt;br&gt;
├── README.md&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
As you can see from the structure I built a one-to-many association where an actor has many movies. From this association my menu came into play.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Current list of actors&lt;/li&gt;
&lt;li&gt;Add an Actor&lt;/li&gt;
&lt;li&gt;Delete an Actor&lt;/li&gt;
&lt;li&gt;Exit the program&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My menu above was defined by a function called... &lt;code&gt;menu()&lt;/code&gt; which was located in my &lt;code&gt;cli.py&lt;/code&gt; file along with the &lt;code&gt;main()&lt;/code&gt; which shows the user the CLI menu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def main():
    while True:
        welcome()
        menu()
        choice = input("&amp;gt; ").strip()
        if choice == "1":
            actor_list()
        elif choice == "2":
            add_actor()
        elif choice == "3":
            delete_actor()
        elif choice == "4":
            exit_program()
            break
        else:
            print("Invalid choice. Try again.\n")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This particular function was the first of many where a while loop along with if/elif/else statements were executed to give our user the ability to navigate our menus with ease.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;cli.py&lt;/code&gt; is then concluded with some important code block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if __name__ == "__main__":
    main() 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code block tells our interpreter (Python) to only run our file if it is called from the command line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supporting Cast
&lt;/h2&gt;

&lt;p&gt;There were also helper functions involved in this project which also used a while loop along with if/elif/else statements. One in particular stands out in showing ease of navigation when selecting for example our current list of actors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def actor_list():

        actor_list = Actor.get_all()

        if actor_list:
            print("\n*** UPDATED LIST! ***")
            for i, actor in enumerate(actor_list, start=1):
                print(f"{i}. {actor.name}")  

            while True:
                choice = input("Press 'a' to add an actor\n"
                                "Press 'b' for actor profile\n"
                                "Press 'c' to return to the main menu.\n"
                                "Press 'd' delete an actor.\n").lower()
                if choice == 'a':
                    add_actor()
                    break
                elif choice == 'b':
                    actor_profile()
                    break
                elif choice == 'c':
                    return
                elif choice == 'd':
                    delete_actor()
                    break
                else:
                    print("Invalid choice. Please try again.") 
        else:
            print("List empty!")
            while True:
                choice = input("Press 'a' or to add an actor\n"
                        "Press 'b' for main menu.\n").lower()
                if choice == 'a':
                    add_actor()
                    break
                elif choice == 'b':
                    return
                else:
                    print("Invalid choice. Please try again.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here not only did I became accustomed of the while loop and if statements but also reap the benefits of appearance and order by using enumerate() with a for loop to iterate with an index in python allowing all the lists thru out the project to be an ordered list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Show Some Class
&lt;/h2&gt;

&lt;p&gt;Our two main characters of course are the Classes Actor and Movie. Both consist of similar code in terms of class methods when creating, updating or deleting an instance of that particular class, but there are differences:&lt;/p&gt;

&lt;p&gt;Let's take our Movie class for example:&lt;br&gt;
&lt;/p&gt;

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

    all_movies = {}

    def __init__(self, movie, genre, actor_id, id=None):
        self.id = id
        self.movie = movie
        self.genre = genre
        self.actor_id = actor_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we have our project setup where an actor has many movies, our movie class will have a unique &lt;code&gt;actor_id&lt;/code&gt; parameter/attribute to establish a link between the movie instance and a specific actor, allowing easy reference to the actor's information.&lt;/p&gt;

&lt;p&gt;Now look at this code block in our Actor class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   def movies(self):
        from models.movie import Movie
        sql = """
            SELECT * FROM movie
            WHERE actor_id = ?
        """
        CURSOR.execute(sql, (self.id,),)

        rows = CURSOR.fetchall()
        return [
            Movie.instance_from_db(row) for row in rows
        ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have our movies() method retrieve all the movies associated with the current Actor instance by querying the movie table using the actor's ID. This will then return a list of Movie objects, establishing a "has-many" relationship between Actor and Movie.&lt;/p&gt;

&lt;p&gt;The code blocks discussed were the primary areas of the project where I focused on grasping more understanding. Overall this project served as a good exercise to enhance my skills in python.&lt;/p&gt;

</description>
      <category>python</category>
      <category>cli</category>
      <category>sql</category>
    </item>
    <item>
      <title>Harnessing the Power of useEffect.</title>
      <dc:creator>wormondeck</dc:creator>
      <pubDate>Mon, 15 Apr 2024 16:50:29 +0000</pubDate>
      <link>https://forem.com/wormondeck/harnessing-the-power-of-useeffect-c9e</link>
      <guid>https://forem.com/wormondeck/harnessing-the-power-of-useeffect-c9e</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;React has revolutionized the way developers build user interfaces, offering a robust and efficient framework for creating dynamic web applications. Among its many features, React hooks stand out as a powerful tool for managing state and side effects in functional components. One such hook, useEffect, plays a crucial role in synchronizing component lifecycle events with external actions, offering developers unparalleled flexibility and control. In this blog, we'll delve into the coding experience involving React and explore the myriad benefits of leveraging useEffect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding React.js and useEffect
&lt;/h2&gt;

&lt;p&gt;React.js is a JavaScript library that allows developers to build reusable UI components. It employs a declarative approach, where developers describe how the UI should look at any given point in time, and React takes care of efficiently updating and rendering the components when the underlying data changes. However, managing state and side effects in React components can be challenging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coding with React.js and useEffect:
&lt;/h2&gt;

&lt;p&gt;Let us illustrate the coding experience involving React.js and useEffect with a practical example. Suppose we have a component that fetches data from an external API and displays it on the screen. We want to fetch the data when the component mounts and update it whenever a certain prop changes. Here's how we can achieve this using useEffect:&lt;br&gt;
&lt;/p&gt;

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

const DataComponent = ({ prop }) =&amp;gt; {
  const [data, setData] = useState(null);

  useEffect(() =&amp;gt; {
    const fetchData = async () =&amp;gt; {
      try {
        const response = await fetch(`https://api.example.com/data/${prop}`);
        const jsonData = await response.json();
        setData(jsonData);
      } catch (error) {
        console.error('Error fetching data:', error);
      }
    };

    fetchData();
  }, [prop]);

  return (
    &amp;lt;div&amp;gt;
      {data ? (
        &amp;lt;ul&amp;gt;
          {data.map(item =&amp;gt; (
            &amp;lt;li key={item.id}&amp;gt;{item.name}&amp;lt;/li&amp;gt;
          ))}
        &amp;lt;/ul&amp;gt;
      ) : (
        &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;
      )}
    &amp;lt;/div&amp;gt;
  );
};

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

&lt;/div&gt;



&lt;p&gt;Here we define a functional component called DataComponent that takes a prop as input. Inside the component, we use useState to manage the state of the fetched data. We then use useEffect to fetch the data from the API when the component mounts or when the prop changes. The useEffect hook ensures that the side effect (fetching data) is executed at the appropriate times, thus keeping our component logic concise and efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of useEffect:
&lt;/h2&gt;

&lt;p&gt;The useEffect hook offers several benefits that enhance the coding experience with React.js:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Declarative Side Effects: useEffect allows developers to declare side effects directly inside functional components, promoting a more declarative and readable coding style.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Efficient Lifecycle Management: By replacing traditional lifecycle methods, useEffect streamlines the management of component lifecycle events, leading to cleaner and more maintainable code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dependency Tracking: The optional dependency array in useEffect enables precise control over when the effect should run, minimizing unnecessary re-renders and improving performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexibility and Reusability: useEffect can be used to perform a wide range of side effects, such as data fetching, DOM manipulation, and subscription handling, making it a versatile tool for building complex applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks Composition: useEffect can be combined with other hooks like useState and useContext to create custom hooks, allowing developers to encapsulate and reuse logic across components.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, React.js and useEffect offer a powerful combination for building dynamic and efficient web applications. By leveraging useEffect, developers can manage side effects in functional components with ease, leading to cleaner code, improved performance, and enhanced developer productivity. Whether you're fetching data from an API, subscribing to events, or updating the DOM, useEffect provides a flexible and intuitive solution for handling side effects in React.js applications. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Showing Phase.</title>
      <dc:creator>wormondeck</dc:creator>
      <pubDate>Tue, 02 Jan 2024 17:48:25 +0000</pubDate>
      <link>https://forem.com/wormondeck/showing-phase-1i01</link>
      <guid>https://forem.com/wormondeck/showing-phase-1i01</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c2N6AMmd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://images.fineartamerica.com/images-medium-large-5/the-road-ahead-black-and-white-douglas-barnard.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c2N6AMmd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://images.fineartamerica.com/images-medium-large-5/the-road-ahead-black-and-white-douglas-barnard.jpg" alt="Trulli" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;The Road Ahead-Black and White is a photograph by Douglas Barnard which was uploaded on February 16th, 2013
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Ready?
&lt;/h2&gt;

&lt;p&gt;In this post I'll be discussing my journey thus far as I conclude my Phase 1 course in Flatiron School. &lt;/p&gt;

&lt;h2&gt;
  
  
  What did I get myself into?
&lt;/h2&gt;

&lt;p&gt;Let's be honest. The prep-work did not "prep" us for the mountain ahead. I'll admit, stepping into the software engineering realm for the first time built anxiety in a good way. Once prep-work was conquered with a few functions and objects becoming familiar Phase 1 was at the end of the road waiting for me with a toothpick in its mouth.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Struggle
&lt;/h2&gt;

&lt;p&gt;Clearly, as I fought my way thru Phase 1, it felt like the Rocky vs Drago bout, guess who played rocky? Honestly, I'm not here to instill how tough the field of software engineering is. This has been the smartest decision I've made for myself. I signed up literally for a bootcamp, and its been very militant since. As tough as its been I've learned a valuable lesson which in turn made learning to code thanks to Flatiron School, awesome!&lt;/p&gt;

&lt;h2&gt;
  
  
  Now I get it
&lt;/h2&gt;

&lt;p&gt;Aside from learning to code. I've learned mental techniques which as a result made coding a sport in my mind. Nothing made sense until I kept showing up for practice, plain and simple. Once distractions got eliminated, I learned the syntax, once I applied the importance of knowing the fundamentals in JavaScript, it became a language that made more sense. Basically, I gave my undivided attention to bits and pieces of the phase and suddenly the phase started giving back to me.&lt;/p&gt;

&lt;h2&gt;
  
  
  You're on your own, figure it out
&lt;/h2&gt;

&lt;p&gt;My main question has always been, how does one memorize all of this information? I had nightmares of array iterators chasing me out of my home. I stopped having those once I faced them on one of my labs. Now I'm great friends with the for...of and forEach loops, since they're my go to's for iterating thru arrays. Overall, one has the tools in front of them to sharpen their skill as a software engineer you just need to apply yourself and have fun!&lt;/p&gt;

&lt;h2&gt;
  
  
  Making it a habit
&lt;/h2&gt;

&lt;p&gt;Coding got much more kindly when Flatiron School made me realize that once you make it a habit to code "anything" things start to make sense. The tools at your disposal begin to lose dust as your able to put them to good use. I became aware of this as soon as I began to get a passing check on a lab in Codecademy. I made it a habit to figure out more ways to write code and achieve the same passing result within the same page and thru the use of DevTools. Suddenly I was retaining the language, I was problem solving on my own and most importantly, having fun!&lt;/p&gt;

&lt;h2&gt;
  
  
  To be continued
&lt;/h2&gt;

&lt;p&gt;As I conclude my Phase 1 course in Flatiron School I reflect on how far I've gotten and I realize the amount of progress I've made has been insurmountable. I've gained so much confidence going thru the ups and downs on figuring out how to get a code to work, how to debug and how to stay in the fight, I mean look how it turned out for Rocky.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Ready, set...code!</title>
      <dc:creator>wormondeck</dc:creator>
      <pubDate>Tue, 10 Oct 2023 16:24:51 +0000</pubDate>
      <link>https://forem.com/wormondeck/ready-setcode-13c4</link>
      <guid>https://forem.com/wormondeck/ready-setcode-13c4</guid>
      <description>&lt;p&gt;JavaScript, here, we...go!&lt;/p&gt;

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