<?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: Michael Tanaka</title>
    <description>The latest articles on DEV Community by Michael Tanaka (@michae1tanaka).</description>
    <link>https://dev.to/michae1tanaka</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%2F1037436%2F6d018755-c6c5-4060-9a5a-9996fd050b7f.png</url>
      <title>DEV Community: Michael Tanaka</title>
      <link>https://dev.to/michae1tanaka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/michae1tanaka"/>
    <language>en</language>
    <item>
      <title>Deepening Our Grasp on React: State, Context, and Effects</title>
      <dc:creator>Michael Tanaka</dc:creator>
      <pubDate>Mon, 09 Oct 2023 02:05:21 +0000</pubDate>
      <link>https://dev.to/michae1tanaka/incoming-post-here-5637</link>
      <guid>https://dev.to/michae1tanaka/incoming-post-here-5637</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I recently had to relearn how to use React for my final project at Flatiron School. It was a bit difficult at first but once I got into it, it was smooth sailing. Felt like I should make this blog post because in case I need to revisit React after a while, I can always remember the basics.&lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;React is a powerful library for building dynamic web applications. But like any tool, its true strength is unlocked when you understand its core features deeply. Today, let's dive deeper into three of React's fundamental concepts: state, context, and effects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding State in React
&lt;/h2&gt;

&lt;p&gt;State is the heartbeat of a React application. It is the mechanism by which we store and manage dynamic data within our components. Let's unpack this.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. What is State?
&lt;/h3&gt;

&lt;p&gt;At its core, state is data that changes over time and affects your component's output.&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Using the useState Hook
&lt;/h3&gt;

&lt;p&gt;Introduced in React 16.8, the &lt;code&gt;useState&lt;/code&gt; hook provides a way to use state in functional components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;count&lt;/code&gt; is the current state value.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setCount&lt;/code&gt; is the function dedicated to updating this state.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  C. Key Insights on State
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Immutability&lt;/strong&gt;: Direct modification of the state is a strict no-go. Always leverage the designated state updating function, like &lt;code&gt;setCount&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is wrong&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// This is correct&lt;/span&gt;
&lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Asynchronous Nature&lt;/strong&gt;: State updates can be asynchronous. When the new state depends on the previous one, always use a functional approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Embracing the Power of Context
&lt;/h2&gt;

&lt;p&gt;The React context API is designed to share data that can be considered “global” for a tree of React components.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. What is Context?
&lt;/h3&gt;

&lt;p&gt;Since I haven't worked with React in a while, I had a problem that consisted of "prop drilling". Prop drilling is where you pass data from a parent to its child component and then to the child's child, and so forth. Context offers a way out.&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Context Implementation
&lt;/h3&gt;

&lt;p&gt;Here's a basic example illustrating how to implement context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setContent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;setContent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/UserContext.Provider&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This was taken from my last project. After doing some research on the topic, the way I used it might not have been the best. I should have created different contexts for different actions. However, since it was a relatively small application, this approach sufficed. Essentially, any of the values passed into the UserContext.Provider as props become available to whatever component you wrap the UserContext.Provider around. AVOID PROP DRILLING AT ALL COSTS. It's a pain to work backwards to undo it all. Believe me!&lt;/p&gt;

&lt;h3&gt;
  
  
  C. Points to Remember
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Sparingly&lt;/strong&gt;: Context is best suited for data like user authentication status or application themes — data that's pervasive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Implications&lt;/strong&gt;: Changing context can cause components consuming it to re-render. Avoid excessive changes to maintain good performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Managing Side Effects with useEffect
&lt;/h2&gt;

&lt;p&gt;React components can perform actions known as "side effects", which can affect components in ways beyond just rendering.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. What is a Side Effect?
&lt;/h3&gt;

&lt;p&gt;In the context of React, a side effect might be a network request, manual DOM manipulation, or attaching event listeners — essentially anything that interacts with the world outside of the component.&lt;/p&gt;

&lt;h3&gt;
  
  
  B. Illustrating useEffect
&lt;/h3&gt;

&lt;p&gt;React gives us the &lt;code&gt;useEffect&lt;/code&gt; hook to handle side effects in functional components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Clicked &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; times`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Executing cleanup procedures&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  C. Considerations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies&lt;/strong&gt;: List dependencies in the array to ensure the effect triggers correctly. If the effect only needs to run once, use an empty dependency array: &lt;code&gt;[]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useLayoutEffect&lt;/strong&gt;: While &lt;code&gt;useEffect&lt;/code&gt; actions occur post-render,&lt;code&gt;useLayoutEffect&lt;/code&gt; is available for actions before the screen updates. However, use it judiciously.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;React's component-based architecture and powerful hooks system provide developers with an unparalleled ability to build dynamic applications. Looking back at it, I wish I wrote this post before I worked on my project, as I probably wouldn't have had such a difficult time getting back into the swing of things, but better late than never!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Python Decorators: A Practical Introduction</title>
      <dc:creator>Michael Tanaka</dc:creator>
      <pubDate>Mon, 28 Aug 2023 05:23:35 +0000</pubDate>
      <link>https://dev.to/michae1tanaka/understanding-python-decorators-a-practical-introduction-ano</link>
      <guid>https://dev.to/michae1tanaka/understanding-python-decorators-a-practical-introduction-ano</guid>
      <description>&lt;h2&gt;
  
  
  What Are Decorators?
&lt;/h2&gt;

&lt;p&gt;In Python, functions are first-class citizens. This means they can be passed around as arguments to other functions, returned as values from other functions, and even assigned to variables. Decorators leverage this feature to extend or modify the behavior of target functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Syntax
&lt;/h2&gt;

&lt;p&gt;The basic syntax for decorators involves the "@" symbol, followed by the name of the decorator function. This is placed just above the function intended to be decorated. Think of decorator syntax as syntactic sugar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@decorator_function
def target_function():
    print("Target function executed.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How Does It Work?
&lt;/h2&gt;

&lt;p&gt;When you use a decorator, you are essentially doing three things:&lt;/p&gt;

&lt;p&gt;Passing the target function as an argument to the decorator function.&lt;br&gt;
Modifying or extending the behavior of the target function within the decorator function.&lt;br&gt;
Returning the modified function or even a completely new function from the decorator function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def decorator_function(target_function):
    def wrapper_function():
        print("Before the target function.")
        target_function()
        print("After the target function.")
    return wrapper_function

@decorator_function
def say_hello():
    print("Hello!")

say_hello()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you call &lt;code&gt;say_hello()&lt;/code&gt;, it actually executes &lt;code&gt;wrapper_function()&lt;/code&gt;. This, in turn, calls the original &lt;code&gt;say_hello()&lt;/code&gt; function between two print statements. The output would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before the target function.
Hello!
After the target function.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Chaining Decorators
&lt;/h2&gt;

&lt;p&gt;Decorators can be chained, meaning you can apply multiple decorators to a single function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def decorator_one(func):
    def wrapper_one():
        print("Decorator one: Before calling the function.")
        func()
        print("Decorator one: After calling the function.")
    return wrapper_one

def decorator_two(func):
    def wrapper_two():
        print("Decorator two: Before calling the function.")
        func()
        print("Decorator two: After calling the function.")
    return wrapper_two

@decorator_one
@decorator_two
def my_function():
    print("The original function.")

my_function()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;my_function&lt;/code&gt; is first passed to &lt;code&gt;decorator_two&lt;/code&gt;, and then the result is passed on to &lt;code&gt;decorator_one&lt;/code&gt;. The output for this code would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Decorator one: Before calling the function.
Decorator two: Before calling the function.
The original function.
Decorator two: After calling the function.
Decorator one: After calling the function.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Class Decorators
&lt;/h2&gt;

&lt;p&gt;During my time at Flatiron School, I came across a few useful class decorators:&lt;/p&gt;

&lt;h2&gt;
  
  
  @staticmethod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A static method is bound to the class itself and not to an instance of the class.&lt;/li&gt;
&lt;li&gt;These methods serve as utility functions that operate on their parameters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

    @staticmethod
    def capitalize_name(name):
        return name.capitalize()

instance1 = MyClass('john')
print(instance1.name)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output would be:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  @classmethod
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Similar to a static method, a class method is bound to the class and not an instance of the class.&lt;/li&gt;
&lt;li&gt;The first parameter for a class method is &lt;code&gt;cls&lt;/code&gt;, which stands for 'class'.&lt;/li&gt;
&lt;li&gt;Class methods can access or modify the class state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

    @classmethod 
    def create_with_capitalized_name(cls,name):
        name = name.capitalize()
        return cls(name)

instance1 = MyClass.create_with_capitalized_name('john')
print(instance1.name)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output would be:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;There's a whole world of decorators out there, but these are the key ones that I've encountered on my Python learning journey at Flatiron School. I genuinely hope you've found this article to be a helpful guide. I'm always open to feedback, so feel free to share your thoughts. Thanks so much for taking the time to read!&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>decorators</category>
      <category>flatironschool</category>
    </item>
    <item>
      <title>Unlocking JavaScript Magic: A Beginner's Guide to Closures</title>
      <dc:creator>Michael Tanaka</dc:creator>
      <pubDate>Mon, 03 Jul 2023 01:42:38 +0000</pubDate>
      <link>https://dev.to/michae1tanaka/unlocking-javascript-magic-a-beginners-guide-to-closures-2nnj</link>
      <guid>https://dev.to/michae1tanaka/unlocking-javascript-magic-a-beginners-guide-to-closures-2nnj</guid>
      <description>&lt;p&gt;Closures in JavaScript are one of those concepts that can seem a bit elusive when you're just starting out. Yet, once understood, they unlock a whole new level of possibilities and make JavaScript a truly powerful and dynamic language. So, let's dive into the magical world of closures and demystify them!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Closure?
&lt;/h2&gt;

&lt;p&gt;At its simplest, a closure is a function bundled together with references to its surrounding state, the so-called lexical environment. Put in other words, a closure gives you access to an outer function’s scope from an inner function. The term "closure" refers to the act of closing the function and its environment, encapsulating everything needed to execute the function later on.&lt;/p&gt;

&lt;h2&gt;
  
  
  An Example of a Closure
&lt;/h2&gt;

&lt;p&gt;Let's look at a simple example:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Michae1Tanaka/embed/qBQjbXO?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In the example above, if you click on the &lt;code&gt;JS&lt;/code&gt; tab, &lt;code&gt;innerFunction&lt;/code&gt; has access to &lt;code&gt;outerVariable&lt;/code&gt; even after &lt;code&gt;outerFunction&lt;/code&gt; has finished execution, thanks to closures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are Closures Important?
&lt;/h2&gt;

&lt;p&gt;Closures are everywhere in JavaScript. Every time we create a function inside a function, we are potentially creating a closure. Here's why they are important:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Privacy:&lt;/strong&gt; Closures allow variables to be kept private, creating a scope that’s inaccessible from the outside world.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Factories:&lt;/strong&gt; We can create multiple functions using closures and not only encapsulate data but also behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous JavaScript:&lt;/strong&gt; Closures are widely used in JavaScript for asynchronous tasks, callback functions, and event handlers where we need to maintain the state.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Things to Remember About Closures
&lt;/h2&gt;

&lt;p&gt;As powerful as closures are, it's important to remember a few key points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Closures have access to variables from three separate scopes: their own scope, the outer function's scope, and the global scope.&lt;/li&gt;
&lt;li&gt;Closures cannot access the arguments of outer functions.&lt;/li&gt;
&lt;li&gt;Be aware of the memory implications. Since closures capture and hold onto their outer scope, they can consume more memory than other functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Closures may seem complicated, but once you understand the basic principle of how functions in JavaScript remember their lexical scope, you've grasped closures. They are one of the many ways JavaScript allows for flexible, powerful programming patterns.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>closures</category>
      <category>flatironschool</category>
    </item>
    <item>
      <title>Introduction to The Box Model in CSS: A Crucial Concept for Beginners by a Beginner</title>
      <dc:creator>Michael Tanaka</dc:creator>
      <pubDate>Sun, 14 May 2023 22:08:10 +0000</pubDate>
      <link>https://dev.to/michae1tanaka/introduction-to-the-box-model-in-css-a-crucial-concept-for-beginners-by-a-beginner-1do6</link>
      <guid>https://dev.to/michae1tanaka/introduction-to-the-box-model-in-css-a-crucial-concept-for-beginners-by-a-beginner-1do6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I'm a student at Flatiron School, and part of our coursework involves writing blog posts on topics we're keen to learn. Being in the early stages of my development journey, I've found CSS (Cascading Style Sheets) somewhat intimidating. Therefore, I've decided to delve into one of the fundamental concepts in CSS - the Box Model - and share my findings. As a fellow beginner, I'll be learning and explaining as I go, so please feel free to correct me if you spot any inaccuracies!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is CSS?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the Box Model, it's essential to understand what CSS is. CSS is a stylesheet language used to control the visual presentation of HTML (HyperText Markup Language) elements in a browser. It's a powerful tool in the web developer's toolkit, enabling us to create visually appealing websites that meet specific design requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Box Model
&lt;/h2&gt;

&lt;p&gt;The Box Model is a fundamental concept in CSS. It's a theoretical construct that views each HTML element as a rectangular box, composed of four components: &lt;em&gt;content&lt;/em&gt;, &lt;em&gt;padding&lt;/em&gt;, &lt;em&gt;border&lt;/em&gt;, and &lt;em&gt;margin&lt;/em&gt;. We can manipulate each of these components individually, giving us granular control over the layout and appearance of our web pages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2rMeBTRE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0hywxvqaox0iu5mm9y0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2rMeBTRE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0hywxvqaox0iu5mm9y0.png" alt="Box Model Diagram" width="548" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Content
&lt;/h3&gt;

&lt;p&gt;The content area is where your actual content resides. This could be text, images, or even other HTML elements. You can manipulate its size using &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; properties. In my example below I've set the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; of the content area to 200 pixels each. The &lt;code&gt;padding&lt;/code&gt; is 20px , the &lt;code&gt;border&lt;/code&gt; is 5 pixels, and the margin is 20 pixels. You can now see how these properties affect the content area by changing their values.&lt;br&gt;
&lt;iframe height="600" src="https://codepen.io/Michae1Tanaka/embed/jOepLyM?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Padding
&lt;/h3&gt;

&lt;p&gt;Padding is the space between the content and the border. By adjusting the padding, we can control how much space exists between the content and the border, effectively pushing the content away from the border. As my example shows, by modifying the padding on any side of the box, the text was pushed by the property values amount of pixels away from the border box based on the property chosen. &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Michae1Tanaka/embed/WNaKOLN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Border
&lt;/h3&gt;

&lt;p&gt;The border surrounds the content and padding. It's the visible line that we see encapsulating the content and any padding. As my example shows, each border was colored a different color to showcase how you can target any side of the border box.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Michae1Tanaka/embed/jOepwmj?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Margin
&lt;/h3&gt;

&lt;p&gt;The margin is the outermost layer, surrounding the border. The margin doesn't have a visible outline like the border. Instead, it represents the space between different elements, allowing us to control how far apart different elements are from each other. In the example below, the border box of each list item is pushed away from the edges of the page based on the values I've assigned to their margin-bottom, margin-left, etc. properties. The transparent space between the page edge and the border box is the margin. By changing these margin values, we can control how far each element is from the edge of the page or from other elements.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Michae1Tanaka/embed/yLRqXEY?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;In this post, I've attempted to unpack the basics of the CSS Box Model, a key concept in web design. While we've only scratched the surface, understanding these foundational elements - content, padding, border, and margin - is a significant step towards mastering CSS. However, like any other skill, proficiency comes with practice. Happy coding!&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin"&gt;Margin&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/border"&gt;Border&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/padding"&gt;Padding&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flatironschool</category>
      <category>beginners</category>
      <category>css</category>
    </item>
  </channel>
</rss>
