<?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: Iftakher Hossen</title>
    <description>The latest articles on DEV Community by Iftakher Hossen (@iftakher_hossen).</description>
    <link>https://dev.to/iftakher_hossen</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%2F778081%2Fdaf60e6e-eabf-4627-afd2-ae8bab7fd2ed.jpeg</url>
      <title>DEV Community: Iftakher Hossen</title>
      <link>https://dev.to/iftakher_hossen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iftakher_hossen"/>
    <language>en</language>
    <item>
      <title>The Building Blocks of Python: Variables, I/O, and Operators</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Mon, 06 Jan 2025 22:50:32 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/the-building-blocks-of-python-variables-io-and-operators-2fli</link>
      <guid>https://dev.to/iftakher_hossen/the-building-blocks-of-python-variables-io-and-operators-2fli</guid>
      <description>&lt;p&gt;Hello, Python enthusiasts! 🌟 Are you ready to take your first steps into the exciting world of Python programming? In this blog, we’ll cover three fundamental concepts that form the building blocks of Python programming. By the end, you’ll have a solid foundation to build upon as you continue your coding journey. These are the basics of a programming language; while the structure may vary in different languages, the concepts remain the same.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Variables and Data Types&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Input and Output&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Operators&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s dive in!&lt;/p&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;1. Variables and Data Types:&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;What is Variable?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Variables are containers where you can store data in your programs. Just like giving a name to a box so you know what's inside, you give your variables names to help you use their data later. One interesting fact about Python is that it's smart enough to figure out what type of data you're storing - you don't have to tell it whether you're storing numbers, text, or something else!&lt;br&gt;
Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Hossen"     # String
grade = 97          # Integer
height = 6.1        # Float
is_student = True   # Boolean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Varibale Naming Conventions:&lt;/strong&gt;&lt;br&gt;
Variable naming conventions are essential to maintain code readability and follow best practices. Here are the rules and conventions for naming variables in Python:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Must start with a letter or the underscore character &lt;/li&gt;
&lt;li&gt;Cannot start with a number&lt;/li&gt;
&lt;li&gt;Can contain letters, numbers, and underscores (A-z, 0-9, and _)&lt;/li&gt;
&lt;li&gt;They are case-sensitive (age, Age and AGE are three different variables)&lt;/li&gt;
&lt;li&gt;Cannot use any reserved words or keywords&lt;/li&gt;
&lt;li&gt;If you have a longer name, use snake_case (preferred), camelCase, or PascalCase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Variable Casting:&lt;/strong&gt;&lt;br&gt;
If you want to specify the data type of a variable, it can be achieved by casting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = str(5)      # x will be '5'
y = int(5)      # y will be 5
z = float(5)    # z will be 5.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Get the Type of Variable:&lt;/strong&gt;&lt;br&gt;
You can get the data type of a variable with the type() function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 5
y = "Refat"
z = True
print(type(x))
print(type(y))
print(type(z))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Assign Multiple Variables&lt;/strong&gt;&lt;br&gt;
Python allows you to assign values to multiple variables in one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;N.B. String variables can be declared either by using single or double quotes.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Types of Data&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;In programming, data types are an important concept. Variables can store different types of data, and each type has its own unique capabilities. Python comes with several built-in data types by default, which can be organized into the following categories:&lt;br&gt;
Text Type:    &lt;code&gt;str&lt;/code&gt;&lt;br&gt;
Numeric Types:    &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;complex&lt;/code&gt;&lt;br&gt;
Sequence Types:   &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;tuple&lt;/code&gt;, &lt;code&gt;range&lt;/code&gt;&lt;br&gt;
Mapping Type:     &lt;code&gt;dict&lt;/code&gt;&lt;br&gt;
Set Types:    &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;frozenset&lt;/code&gt;&lt;br&gt;
Boolean Type:     &lt;code&gt;bool&lt;/code&gt;&lt;br&gt;
Binary Types:     &lt;code&gt;bytes&lt;/code&gt;, &lt;code&gt;bytearray&lt;/code&gt;, &lt;code&gt;memoryview&lt;/code&gt;&lt;br&gt;
None Type:    &lt;code&gt;NoneType&lt;/code&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;2. Input and Output&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt;&lt;br&gt;
Python’s &lt;code&gt;input()&lt;/code&gt; function allows you to capture input from the user. The input is always treated as a string unless explicitly converted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = input("What is your name? ")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;print()&lt;/code&gt; function is used to display information. You can combine strings and variables for a more interactive experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;age = 25
print("I am", age, "years old.")

# Using f-strings for adding dynamic value:
print(f"I am {age} years old.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  &lt;strong&gt;3. Operators&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt; are special symbols or keywords that perform operations on data. They tell the computer what kind of operation or action to perform (eg. &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;).&lt;br&gt;
&lt;strong&gt;Operands&lt;/strong&gt; are the values or variables that operators work on - They're the data, the operator uses to do its job.&lt;br&gt;
Python divides the operators into the following groups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arithmetic operators:&lt;/strong&gt; Arithmetic operators are used with numeric values to perform common mathematical operations:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x + y      # Addition   
x - y      # Subtraction
x * y      # Multiplication 
x / y      # Division
x % y      # Modulus
x ** y     # Exponentiation
x // y     # Floor division
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Assignment operators:&lt;/strong&gt; Assignment operators are used to assign values to variables.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 8
x += 8
x -= 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Comparison operators:&lt;/strong&gt; Comparison operators are used to compare two values:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x == y     # Equal
x != y     # Not Equal
x &amp;gt; y      # Greater than
x &amp;lt; y      # Less then
x &amp;gt;= y     # Greater than or equal to
x &amp;lt;= y     # Less than or equal to
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Logical operators:&lt;/strong&gt; Logical operators are used to combine conditional statements:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x &amp;lt; 5 and  x &amp;lt; 10      
# Returns True if both statements are true
x &amp;lt; 5 or x &amp;lt; 4          
# Returns True if one of the statements is true
not(x &amp;lt; 5 and x &amp;lt; 10)   
# Reverse the result, returns False if the result is true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identity operators:&lt;/strong&gt; Identity operators are used to compare the objects, not if they are equal, but if they are the same object, with the same memory location:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x is y
# Returns True if both variables are the same object
x is not y
# Returns True if both variables are not the same object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Membership operators:&lt;/strong&gt; Membership operators are used to test if a sequence is presented in an object:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x in y
# Returns True if a sequence with the specified value is present in the object
x not in y
# Returns True if a sequence with the specified value is not present in the object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bitwise operators:&lt;/strong&gt; Bitwise operators are used to compare (binary) numbers:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x &amp;amp; y      
# AND - Sets each bit to 1 if both bits are 1
x | y      
# OR - Sets each bit to 1 if one of the two bits is 1
x ^ y      
# XOR - Sets each bit to 1 if only one of the two bits is 1
x ~ y      
# NOT - Inverts all the bits
x &amp;lt;&amp;lt; y     
# Zero fill left shift - Shift left by pushing zeros in from the right and letting the leftmost bits fall off
x &amp;lt;= y     
# Signed right shift - Shift right by pushing copies of the leftmost bit in from the left, and letting the rightmost bits fall off
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;br&gt;
Congratulations on taking your first steps in Python programming! You've now learned the fundamentals of &lt;strong&gt;Variables&lt;/strong&gt;, &lt;strong&gt;Input&lt;/strong&gt; and &lt;strong&gt;Output&lt;/strong&gt;, and &lt;strong&gt;Operators&lt;/strong&gt;—essential building blocks, that every programmer needs to master. With this knowledge, you’re well on your way to writing more complex and powerful programs.&lt;/p&gt;

&lt;p&gt;But don’t stop here! In the next blog of this series, we’ll dive into &lt;strong&gt;Control Flow&lt;/strong&gt;, where you’ll learn how to make your programs more interactive and decision-driven. Stay tuned! If you have any questions, feel free to comment below. Don’t try to memorize the rules—dive in, and you will learn them perfectly by failing.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python Tips to Make Your Code Shine! ✨</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Thu, 02 Jan 2025 19:55:54 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/tips-for-writing-cleaner-python-code-4f9g</link>
      <guid>https://dev.to/iftakher_hossen/tips-for-writing-cleaner-python-code-4f9g</guid>
      <description>&lt;p&gt;Clean code is essential for making Python applications manageable and scalable. Python values readability, therefore developing clean code is extremely crucial. In this post, I'll present ten ideas for writing cleaner Python code while boosting readability, efficiency, and maintainability. Let's get started:&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Use Meaningful Variable and Function Names&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In Python, variable names should reflect their purpose. Avoid single-character variables or ambiguous names.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2. Keep Functions Small and Focused&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python allows for flexibility, but it’s best practice to keep your functions small and focused. Each function should do one thing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def process_data():
    fetch_data()
    validate_data()
    save_data()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

def validate_data():
    pass

def save_data():
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Use Consistent Formatting&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Indentation is critical in Python, as it defines code blocks. Stick to 4 spaces per indentation level (PEP 8 standard). A consistent style makes your code easier to follow.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if x:
    print("Hello")
else:
print("Goodbye")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if x:
    print("Hello")
else:
    print("Goodbye")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;4. Avoid Magic Numbers&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Avoid using arbitrary numbers directly in the code. Instead, use constants with descriptive names.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;area = 3.14 * radius * radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PI = 3.14
area = PI * radius * radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;5. Use Default Parameters&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python allows default values for function parameters. This reduces the need for conditionals and makes your functions more concise.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def greet(name):
    if not name:
        name = 'Guest'
    print(f"Hello {name}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def greet(name="Guest"):
    print(f"Hello {name}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;6. Minimize Nested Loops and Conditionals&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python’s readability suffers from too much nesting. Reduce nesting with early returns or by breaking down logic into smaller functions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if x:
    if y:
        if z:
            print("Condition met!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if not x or not y or not z:
    return
print("Condition met!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;7. Leverage Python's Built-in Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python offers powerful built-in functions and libraries. For common tasks, use these built-in tools rather than writing your logic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;squared_numbers = []
for num in range(1, 6):
    squared_numbers.append(num ** 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;squared_numbers = [num ** 2 for num in range(1, 6)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;8. Avoid Global Variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In Python, global variables can lead to unexpected behavior and make debugging difficult. Keep variables within functions, or use classes if necessary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;counter = 0
def increment():
    global counter
    counter += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Counter:
    def __init__(self):
        self.counter = 0

    def increment(self):
        self.counter += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;9. Use List Comprehensions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;List comprehensions are a Pythonic way to create lists. They’re compact, easy to read, and more efficient than using loops.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = []
for i in range(1, 6):
    if i % 2 == 0:
        numbers.append(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [i for i in range(1, 6) if i % 2 == 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;10. Write Comments and Docstrings&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python developers rely on docstrings and comments for documentation. While the code itself should be self-explanatory, use docstrings to describe functions and classes, and add comments when logic is complex.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Increment counter
counter += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def increment_counter(counter):
    """
    Increments the counter by 1.

    Arguments:
    counter -- the current count to be incremented.
    """
    return counter + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;11. Handle Exceptions Properly&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Instead of letting your program crash when something goes wrong, handle exceptions properly. It improves the stability of your code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num = int(input("Enter a number: "))
print(10 / num)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try:
    num = int(input("Enter a number: "))
    print(10 / num)
except ValueError:
    print("Invalid input, please enter an integer.")
except ZeroDivisionError:
    print("Cannot divide by zero!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;12. Avoid Using &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;*kwargs&lt;/code&gt; Unnecessarily&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While &lt;code&gt;*args&lt;/code&gt; and &lt;code&gt;**kwargs&lt;/code&gt; are powerful, they should be used judiciously. Using them unnecessarily can make your function calls confusing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_numbers(*args):
    return sum(args)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_numbers(a, b):
    return a + b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;13. Use Type Hints&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Adding type hints makes the code easier to understand and helps tools like linters and IDEs provide better assistance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_numbers(a, b):
    return a + b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_numbers(a: int, b: int) -&amp;gt; int:
    return a + b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;14. Limit Side Effects in Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Side effects (e.g., modifying global variables or the state of objects) can make code harder to understand. Try to minimize them and keep functions pure, whenever possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

def add_ten():
    global x
    x += 10

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def add_ten(x: int) -&amp;gt; int:
    return x + 10

x = 10
x = add_ten(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;15. Use Python’s &lt;code&gt;with&lt;/code&gt; Statement for Resource Management&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Managing resources such as files, databases, or network connections, use the &lt;code&gt;with&lt;/code&gt; statement to ensure they are properly closed or cleaned up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file = open('example.txt', 'r')
data = file.read()
file.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open('example.txt', 'r') as file:
    data = file.read()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;16. Avoid Using &lt;code&gt;eval()&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;eval()&lt;/code&gt; can be dangerous because it executes arbitrary code. It's often unnecessary and should be avoided for security reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_input = input("Enter a Python expression: ")
result = eval(user_input)
print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_input = input("Enter a number: ")
try:
    result = int(user_input)
    print(result)
except ValueError:
    print("Invalid input, please enter a valid number.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;17. Avoid Repetition (DRY Principle)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don’t Repeat Yourself (DRY) is a principle that encourages using functions, classes, or other abstractions to avoid redundant code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def calculate_area(radius):
    return 3.14 * radius * radius

def calculate_circumference(radius):
    return 2 * 3.14 * radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

def calculate_area(radius):
    return PI * radius * radius

def calculate_circumference(radius):
    return 2 * PI * radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;18. Use Enumerate Instead of Range&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When looping over a list and needing both the index and the item, use &lt;code&gt;enumerate()&lt;/code&gt; to avoid manual indexing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i in range(len(my_list)):
    print(i, my_list[i])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i, item in enumerate(my_list):
    print(i, item)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;19. Group Related Code Into Classes&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your code has related functions, it’s often a good idea to group them into classes. This encapsulates related behaviors and makes the code more organized.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bad Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def calculate_area(radius):
    return 3.14 * radius * radius

def calculate_circumference(radius):
    return 2 * 3.14 * radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good Practice:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Circle:
    PI = 3.14

    def __init__(self, radius):
        self.radius = radius

    def calculate_area(self):
        return self.PI * self.radius * self.radius

    def calculate_circumference(self):
        return 2 * self.PI * self.radius
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;br&gt;
Writing clean code in Python is not just about following best practices—it’s about making your code easy to read, maintain, and scale. By applying these tips, you’ll be on your way to writing Python code that is both efficient and clean. The goal is to keep your code simple, readable, and efficient, and always strive to follow Python’s core philosophy: &lt;em&gt;Readability counts&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;What tips do you use to keep your Python code clean? Share your thoughts in the comments!&lt;/p&gt;




&lt;p&gt;After almost two years of being MIA, I’m back in the game! Ready to dive into Python with Django, and this time, I’m bringing the blog along for the ride. Buckle up—it's gonna be a bumpy (and hopefully not too buggy) journey. Let's learn, laugh, and make some magic happen!&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>learning</category>
      <category>programming</category>
    </item>
    <item>
      <title>Introduction to Mongoose</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Fri, 04 Mar 2022 14:20:33 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/introduction-to-mongoose-409g</link>
      <guid>https://dev.to/iftakher_hossen/introduction-to-mongoose-409g</guid>
      <description>&lt;p&gt;Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB. Mongoose is a JavaScript object-oriented programming library that creates a connection between MongoDB and the Express web application framework. &lt;/p&gt;

&lt;p&gt;MongoDB is a schema-less NoSQL document database. It means you can store JSON documents in it, and the structure of these documents can vary as it is not enforced like SQL databases. This is one of the advantages of using NoSQL as it speeds up application development and reduces the complexity of deployments.&lt;/p&gt;

&lt;p&gt;Mongoose uses schemas to model the data an application wishes to store and manipulate in MongoDB. This includes features such as type casting, validation, query building, and more.&lt;br&gt;
The schema describes the attributes of the properties (aka fields) the application will manipulate. These attributes include such things as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data type (e.g. String, Number, etc.).&lt;/li&gt;
&lt;li&gt;Whether or not it is required or optional.&lt;/li&gt;
&lt;li&gt;Is it’s value unique, meaning that the database is allowed to contain only one document with that value in that property.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A model is generated from the schema and defines a document the application will operating on. More precisely, a model is a class that defines a document with the properties and behaviors as declared in our schema. All database operations performed on a document using Mongoose must reference a model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A schema definition can be as simple as the following code snippet:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var userSchema = new mongoose.Schema({
  firstname: String,
  lastname: String,
  createdOn: Date
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A document in MongoDB created from this schema would be like the following code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ "__v" : 0, "_id" : ObjectId("51412597e8e6d3e35c000001"),"createdOn" : ISODate("2022-03-04T08:29:19.866Z"),"firstname" : "Iftakher", " lastname " : "Hossen" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is Mongoose good for?
&lt;/h3&gt;

&lt;p&gt;Mongoose is primarily useful when you want to interact with structured data in MongoDB. It allows you to define a schema for your data, so that you can interact with your MongoDB data in a structured and repeatable way. Mongoose helps with many common MongoDB tasks, and removes some of levels of complexity from the nested callbacks you find yourself getting lost in with the native MongoDB driver. Mongoose also returns the data to you as a JSON object that you can use directly, rather than the JSON string returned by MongoDB.&lt;br&gt;
Mongoose also has a whole suite of helper functions and methods that we'll explore throughout the subsequent chapters of this book.&lt;/p&gt;
&lt;h3&gt;
  
  
  What Mongoose is not ideally suited for
&lt;/h3&gt;

&lt;p&gt;Mongoose is probably not the answer for you if you are primarily working with the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Schema-less data&lt;/li&gt;
&lt;li&gt;Random documents&lt;/li&gt;
&lt;li&gt;Pure Key-Value pairs&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The cornerstones of Mongoose
&lt;/h3&gt;

&lt;p&gt;There are two aspects of Mongoose that we need to introduce you to before going much further:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Schemas&lt;/li&gt;
&lt;li&gt;Models&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Terminologies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collections&lt;/strong&gt; - ‘Collections’ in Mongo are equivalent to tables in relational databases. They can hold multiple JSON documents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documents&lt;/strong&gt; - ‘Documents’ are equivalent to records or rows of data in SQL. While a SQL row can reference data in other tables, Mongo documents usually combine that in a document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fields&lt;/strong&gt; - ‘Fields’ or attributes are similar to columns in a SQL table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Schema&lt;/strong&gt; - While Mongo is schema-less, SQL defines a schema via the table definition. A Mongoose ‘schema’ is a document data structure (or shape of the document) that is enforced via the application layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Models&lt;/strong&gt; - ‘Models’ are higher-order constructors that take a schema and create an instance of a document equivalent to records in a relational database.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The three main advantages of using Mongoose versus native MongoDB are:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;MongooseJS provides an abstraction layer on top of MongoDB that eliminates the need to use named collections.&lt;/li&gt;
&lt;li&gt;Models in Mongoose perform the bulk of the work of establishing up default values for document properties and validating data.&lt;/li&gt;
&lt;li&gt;Functions may be attached to Models in MongooseJS. This allows for seamless incorporation of new functionality.&lt;/li&gt;
&lt;li&gt;Queries use function chaining rather than embedded mnemonics which result in code that is more flexible and readable, therefore more maintainable as well.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The net result of these is the simplification of database access from applications. The main disadvantage of Mongoose is that abstraction comes at the cost of performance compared to that of native MongoDB.&lt;/p&gt;
&lt;h3&gt;
  
  
  Mongoose Schema
&lt;/h3&gt;

&lt;p&gt;As we saw earlier, a schema is fundamentally describing the data construct of a document. This schema defines the name of each item of data, and the type of data, whether it is a string, number, date, Boolean, and so on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var userSchema = new mongoose.Schema({
  name: String,
  email: String,
  createdOn: Date,
  verified: Boolean
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In most scenarios you would have one schema for each collection within the database. Schemas are a powerful aspect of Mongoose, which can also be extended with helper functions and additional methods. But we'll describe more about that in a later chapter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mongoose models
&lt;/h3&gt;

&lt;p&gt;A model is a compiled version of the schema. One instance of the model will map to one document in the database. Creating a User instance based on the schema userSchema is a one line task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const User = mongoose.model('User', userSchema);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is the model that handles the reading, creating, updating, and deleting of documents.&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://mongoosejs.com/" rel="noopener noreferrer"&gt;Mongoose.js&lt;/a&gt; official site to read the documentation and know more in detail.&lt;/p&gt;

&lt;p&gt;In this tutorial, I try to clarify What is Mongoose and it's features. If I made any mistakes pardon me! And I'd love to hear from you If you have any suggestions for me. Thank you for reading this blog!&lt;/p&gt;

&lt;p&gt;Find me on &lt;a href="https://github.com/iftakherhossen" rel="noopener noreferrer"&gt;Github&lt;/a&gt; and  &lt;a href="https://iftakher-hossen.vercel.app/" rel="noopener noreferrer"&gt;Portfolio&lt;/a&gt; or &lt;a href="//mailto:iftakher.one@gmail.com"&gt;Send a Mail&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow for more blogs!&lt;/p&gt;

</description>
      <category>mongoose</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Cope with Next.js</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Fri, 04 Mar 2022 08:40:33 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/cope-with-nextjs-4mm8</link>
      <guid>https://dev.to/iftakher_hossen/cope-with-nextjs-4mm8</guid>
      <description>&lt;p&gt;In the previous &lt;a href="https://dev.to/iftakher_hossen/go-next-with-nextjs-19l5"&gt;tutorial&lt;/a&gt; we learn about Next.js basics. Today we will learn about the core features of Next.js.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Evolution of Next.js
&lt;/h3&gt;

&lt;p&gt;Next.js is a React framework for developing single-page JavaScript applications. Today, Next.js is frequently associated with the Jamstack methodology for developing web applications. When it was launched in early 2016, however, it was originally just for server-side rendered apps. At the time, what made Next.js unique was that it handled both the frontend and the backend of your application and both were built using JavaScript and React. This allows developers to build full-stack applications using a single language and toolset while delivering an improved user experience that typically results in a faster initial render of the page. Next.js also gained popularity because it simplified building full-stack applications using React. It provided automatic routing for pages and built-in methods for server-side rendering (SSR) and data fetching. All of these features still exist in Next.js today, but many new features have been added and the existing ones have been dramatically enhanced. In particular, Next.js now handles multiple types of rendering methods. The simple fact is that Next.js has become so popular mainly because it solved the age-old issue developers had with JavaScript rendering in the browser itself. By doing a lot of the work on the server-side, the overall end-user experience is greatly improved – but at the same time, Next.js still allows that CSR.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Features of NEXT.JS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hot Code Reloading&lt;/strong&gt; - Next.js reloads the page when it detects any change saved to disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Routing&lt;/strong&gt; - Any URL is mapped to the filesystem, to files put in the pages folder, and you don't need any configuration (you have customization options of course).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single File Components&lt;/strong&gt; - Using styled-jsx, completely integrated as built by the same team, it's trivial to add styles scoped to the component.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server Rendering&lt;/strong&gt; - You can render React components on the server-side, before sending the HTML to the client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Code Splitting&lt;/strong&gt; - Pages are rendered with just the libraries and JavaScript that they need, no more. Instead of generating one single JavaScript file containing all the app code, the app is broken up automatically by Next.js in several different resources. Loading a page only loads the JavaScript necessary for that particular page. Next.js does that by analyzing the resources imported. If only one of your pages imports the Axios library, for example, that specific page will include the library in its bundle. This ensures your first-page load is as fast as it can be, and only future page loads (if they will ever be triggered) will send the JavaScript needed to the client. There is one notable exception. Frequently used imports are moved into the main JavaScript bundle if they are used in at least half of the site pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ecosystem Compatibility&lt;/strong&gt; - Next.js plays well with the rest of the JavaScript, Node, and React ecosystem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prefetching&lt;/strong&gt; - The &lt;code&gt;Link&lt;/code&gt; component, used to link together different pages, supports a &lt;code&gt;prefetch&lt;/code&gt; automatically prefetches page resources (including code missing due to code splitting) in the background.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Components&lt;/strong&gt; - You can import JavaScript modules and React Components dynamically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static Exports&lt;/strong&gt; - Using the &lt;code&gt;next export&lt;/code&gt; command, Next.js allows you to export a fully static site from your app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript Support&lt;/strong&gt; - Next.js is written in TypeScript and as such comes with excellent TypeScript support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  PROS &amp;amp; CONS of NEXT.JS
&lt;/h3&gt;

&lt;h4&gt;
  
  
  PROS
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Automatic Static Optimization.&lt;/li&gt;
&lt;li&gt;Adaptability.&lt;/li&gt;
&lt;li&gt;Security.&lt;/li&gt;
&lt;li&gt;Faster Dev Cycle.&lt;/li&gt;
&lt;li&gt;Truly Cross-Platform.&lt;/li&gt;
&lt;li&gt;Short Loading Times.&lt;/li&gt;
&lt;li&gt;Huge Support.&lt;/li&gt;
&lt;li&gt;TypeScript Support.&lt;/li&gt;
&lt;li&gt;Zero Configuration.&lt;/li&gt;
&lt;li&gt;Great user experience.&lt;/li&gt;
&lt;li&gt;Great SEO.&lt;/li&gt;
&lt;li&gt;Flexible UI &amp;amp; UX.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CONS
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Downside Of Flexibility.&lt;/li&gt;
&lt;li&gt;It Does What It Does.&lt;/li&gt;
&lt;li&gt;Lacks A Manager.&lt;/li&gt;
&lt;li&gt;Poor plugin ecosystem.&lt;/li&gt;
&lt;li&gt;No built-in state manager.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Benefits of Next.js for online businesses
&lt;/h3&gt;

&lt;p&gt;How Next.js can positively impact your business results and help you push your ideas further?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster time to market.&lt;/li&gt;
&lt;li&gt;Enhanced User Experience.&lt;/li&gt;
&lt;li&gt;Increased organic traffic.&lt;/li&gt;
&lt;li&gt;Fully omnichannel.&lt;/li&gt;
&lt;li&gt;Support on demand.&lt;/li&gt;
&lt;li&gt;Increased conversion rate.&lt;/li&gt;
&lt;li&gt;Community support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;It doesn’t matter if you are planning to build a huge and demanding app to serve millions of users, nor if you are a growing webshop on Shopify. In both cases, you can use the advantages of modern web technology to make your business more efficient online. Uplift your page speed, SEO, and User Experience, and remember that technologies such as Next.js are making the web a better, cleaner, and more user-centric place. And that will always be favorable, not only by Google but, most importantly, by users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/playlist?list=PLC3y8-rFHvwgC9mj0qv972IO5DmD-H0ZH" rel="noopener noreferrer"&gt;&lt;strong&gt;Next.js Tutorials for beginners&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://nextjs.org/docs/getting-started" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; official site to read the documentation and know more in detail.&lt;/p&gt;

&lt;p&gt;In the next tutorial, we will try to build a simple project with Next.js to clarify the project structures and how to start!&lt;br&gt;
I try to cover the features, PROS, CONS, and the benefits of Next.js. If I made any mistakes pardon me! And I'd love to hear from you If you have any suggestions for me. Thank you for reading this blog!&lt;/p&gt;

&lt;p&gt;Find me on &lt;a href="https://github.com/iftakherhossen" rel="noopener noreferrer"&gt;Github&lt;/a&gt; and  &lt;a href="https://iftakher-hossen.vercel.app/" rel="noopener noreferrer"&gt;Portfolio&lt;/a&gt; or &lt;a href="//mailto:iftakher.one@gmail.com"&gt;Send a Mail&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow for more blogs!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Go next with Next.js</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Fri, 25 Feb 2022 11:09:28 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/go-next-with-nextjs-19l5</link>
      <guid>https://dev.to/iftakher_hossen/go-next-with-nextjs-19l5</guid>
      <description>&lt;p&gt;Today in this blog we will learn about Next.js. Nowadays Next.js is the most popular framework of React.&lt;/p&gt;

&lt;p&gt;Next.js is a React framework created by Zeit. it's an open-source development framework built on Node.js enabling React-based web applications functionalities such as server-side rendering and generating static websites. &lt;/p&gt;

&lt;p&gt;Quite merely, Next.js is a React framework for developing single-page JavaScript applications. The benefits of this framework are numerous, both for our clients' applications as well as for our development team. You can write both frontend and backend in one folder in Next.js. It has many great features and advantages, which can make Next.js your first option for building your next web application. It's also &lt;strong&gt;SEO&lt;/strong&gt; friendly.&lt;/p&gt;

&lt;p&gt;Popular Apps like Tiktok, Hulu, Hashnode, Twitch Mobile, Starbucks, Uber, Netflix, Binance, Ticket Master, AT&amp;amp;T, Deliveroo, Docker, Realtor, Marvel, Typeform, Pusher, SumUp, NuBank etc. are made with Next.js. There are more apps/websites are creating daily with Next.js beacause of it's advance features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Next.js if you want to build websites such as:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Large multi-user websites&lt;/li&gt;
&lt;li&gt;Client-side rendered applications (SPA/MPA)&lt;/li&gt;
&lt;li&gt;Big eCommerce websites&lt;/li&gt;
&lt;li&gt;Web portals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;However, you can also use Next.js to build simpler websites, which is also possible with Gatsby.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These websites include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;B2B and SaaS websites&lt;/li&gt;
&lt;li&gt;Finance websites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next.js websites includes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High Performance&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Constant Rendering&lt;/li&gt;
&lt;li&gt;SEO Friendly&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Start with Next.js
&lt;/h3&gt;

&lt;p&gt;First of all for creating a Next.js Project type the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest
# or
yarn create next-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, you can create a Typescript project with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest --ts
# or
yarn create next-app --typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Options:
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;create-next-app&lt;/code&gt; comes with the following options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;--ts, --typescript - Initialize as a typescript project.&lt;/li&gt;
&lt;li&gt;-e, --example [name]|[github-url] - An example to bootstrap the app with from the following URL you provide.&lt;/li&gt;
&lt;li&gt;--example-path [path-to-example] - You can specify the path for the specified branch you want as an example.&lt;/li&gt;
&lt;li&gt;--use-npm - Explicitly convey the CLI to bootstrap the app using npm. To bootstrap using yarn, we suggest running &lt;code&gt;yarn create next-app&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Why use &lt;code&gt;create-use-next-app&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;create-next-app&lt;/code&gt; allows you to create a new Next.js app within seconds. It is officially maintained by the creators of Next.js, and includes several benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interactive Experience&lt;/li&gt;
&lt;li&gt;Zero Dependencies&lt;/li&gt;
&lt;li&gt;Offline Support&lt;/li&gt;
&lt;li&gt;Support for Examples&lt;/li&gt;
&lt;li&gt;Tested&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Next.js built-in components
&lt;/h3&gt;

&lt;p&gt;Next.js has some built-in components to use React-Router, HTML, Image, Script, etc. in Next.js. They are -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;next/router&lt;/strong&gt; - If you wanted to access the router object inside any functional component in your app, you can use the useRouter() hook, You can use React Router's features by using this component. Take a look at the following example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useRouter } from 'next/router';

const AboutPage = () =&amp;gt; {
  const router = useRouter();

  return (
    &amp;lt;button type="button" onClick={() =&amp;gt; router.push('/about')}&amp;gt;
      Click me
    &amp;lt;/button&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;next/link&lt;/strong&gt; - It's usually used to create Client-side transitions between routes via the Link component exported by next/link. You can  create dynamic link with this component. Generally it's an alternate of  or react-router  tag. Use this following code to create Link component:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link';

&amp;lt;Link href="https://iftakher-hossen.vercel.app/"&amp;gt;Visit&amp;lt;/Link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;next/image&lt;/strong&gt; - It's usually used to show images in Next.js. Using this component we can get optimized &amp;amp; preloaded pictures on our website. You can use this with the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Image from 'next/image';

&amp;lt;Image src="https://i.ibb.co/GnnCPMP/bg.jpg" alt="Nature" width="250px" height="150px" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you always have to use width and height either it will show an error. If you use an image from an external link you have to describe it at next.config.js like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  images: {
    domains: ['i.ibb.co'], //your-external-link-hostname
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;next/script&lt;/strong&gt; - Next.js has a built-in component to load an external scripts. Such as Stripe.js. Take a look at the following codes:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';
import Script from 'next/script';

const Payment = () =&amp;gt; {
  const [stripe, setStripe] = useState(null);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;Script
        id="stripe-js"
        src="https://js.stripe.com/v3/"
        onLoad={() =&amp;gt; {
          setStripe({ stripe: window.Stripe('ih_dev_5555') })
        }}
      /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;next/head&lt;/strong&gt; - It's used for appending elements to the head of the page. You can add separate titles, various kinds of CSS/scripts. Take a look at the following codes:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head';

&amp;lt;Head&amp;gt;
   &amp;lt;title&amp;gt;My page title&amp;lt;/title&amp;gt;
   &amp;lt;meta name="viewport" content="initial-scale=1.0", width="device-width" /&amp;gt;
&amp;lt;/Head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;next/amp&lt;/strong&gt; - AMP is an advanced features of NExt.js. With Next.js you can turn any React page into an AMP page, with minimal config, and without leaving React. You can read more about AMP in the official &lt;a href="https://amp.dev/" rel="noopener noreferrer"&gt;amp.dev&lt;/a&gt; site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;next/server&lt;/strong&gt; - next/server is a module that provides several exports for server-only helpers, such as middleware. You can use features like - NextMiddleware, NextRequest, NextFetchEvent, NextResponse, Public Methods &amp;amp; Static Methods.&lt;br&gt;
take a look at &lt;a href="https://nextjs.org/docs/api-reference/next/server" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; to know more!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;next/streaming&lt;/strong&gt; - The experimental next/streaming module provides streaming-related APIs to port the existing functionality of Next.js apps to streaming scenarios and reduce the usage of React Server Components. take a look at &lt;a href="https://nextjs.org/docs/api-reference/next/streaming" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; to know more!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Edge Runtime&lt;/strong&gt; - The Next.js Edge Runtime is based on standard Web APIs, which are used by Middleware. There are many kinds of Runtime API. Such as Globals, Base64, Encoding, Environment, Fetch, Streams, Timers, Web, Crypto, Logging. &lt;br&gt;
The Edge Runtime has some restrictions including Native Node.js APIs are not supported and JavaScript language features are disabled, and will not work &lt;code&gt;eval&lt;/code&gt; &amp;amp; &lt;code&gt;new Function(evalString)&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Fetching&lt;/strong&gt; - You can fetch data in Next.js using 4 built-in components. Such as &lt;code&gt;getInitialProps&lt;/code&gt;, &lt;code&gt;getServerSideProps&lt;/code&gt;, &lt;code&gt;getStaticPaths&lt;/code&gt;, &lt;code&gt;getStaticProps&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Static Optimization Indicator&lt;/strong&gt; - Next.js has features like when a page qualifies for &lt;a href="https://nextjs.org/docs/advanced-features/automatic-static-optimization" rel="noopener noreferrer"&gt;Automatic Static Optimization&lt;/a&gt; they show an indicator to let you know. This is helpful since automatic static optimization can be very beneficial and knowing immediately in development if the page qualifies can be useful. But in some cases, this indicator might not be useful, like &lt;strong&gt;Electron&lt;/strong&gt; Applications. Then we have to disable it from &lt;code&gt;next.config.js&lt;/code&gt; like the following code:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  devIndicators: {
    autoPrerender: false,
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;next.config.js&lt;/code&gt;&lt;/strong&gt; - Edit in &lt;code&gt;next.config.js&lt;/code&gt; this file For custom advanced configuration of Next.js. &lt;code&gt;next.config.js&lt;/code&gt; is a regular Node.js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser build.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Visit &lt;a href="https://nextjs.org/docs/getting-started" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; official site to read the documentation and know more in detail.&lt;/p&gt;

&lt;p&gt;In the next tutorial, we will learn the core features of Next.js.&lt;/p&gt;

&lt;p&gt;I try to cover the basics of Next.js. If I made any mistakes pardon me! And I'd love to hear from you If you have any suggestions for me. Thank you for reading this blog!&lt;/p&gt;

&lt;p&gt;Find me on &lt;a href="https://github.com/iftakherhossen" rel="noopener noreferrer"&gt;Github&lt;/a&gt; and &lt;a href="https://iftakher-hossen.vercel.app/" rel="noopener noreferrer"&gt;Portfolio&lt;/a&gt; or &lt;a href="//mailto:iftakher.one@gmail.com"&gt;Send a Mail&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow for more blogs!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>wevdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Explore Express.js</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Fri, 24 Dec 2021 17:55:55 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/explore-expreesjs-4mjo</link>
      <guid>https://dev.to/iftakher_hossen/explore-expreesjs-4mjo</guid>
      <description>&lt;p&gt;Today we will learn about the Node.Js web application framework Express.Js.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Express.js?
&lt;/h3&gt;

&lt;p&gt;Express.js is a free, open-source, simple, tiniest web application framework of Node.js. It is used for backend design &amp;amp; development.  Express.js requires only JavaScript that’s why it’s easier to build single-page, multiple-page, hybrid web applications &amp;amp; API without any effort. Express.js supports MVC architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we should use Express.js?
&lt;/h3&gt;

&lt;p&gt;JavaScript has Node.js for backend development. Node.js has many frameworks to make easier backend development. Such as Express.js, Koa.js, Meteor.js, Nest.js, Socket.io, Total.js, etc. So, if you are a JavaScript developer then it’s easier for you to use Express.js for backend development. Express.js offers simplicity, flexibility, efficiency, minimalism, and scalability that’s why it’s more popular.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;p&gt;Express.js has many features. Let’s learn about them -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Middleware - Middleware is a function that is used to get access request and response objects. &lt;/li&gt;
&lt;li&gt;Faster server-side development - Express.js provides many readymade functions from Node.js it’s made easier to develop.&lt;/li&gt;
&lt;li&gt;Routing - Express.js provides an admiringly advanced routing mechanism.&lt;/li&gt;
&lt;li&gt;Templating - Template engines allow you to build dynamic content in web applications.&lt;/li&gt;
&lt;li&gt;Debugging - Express.js has a debugging mechanism that can find bugs easily. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Express.js is fast &amp;amp; easier to learn.&lt;/li&gt;
&lt;li&gt;It’s easier to configure &amp;amp; customize.&lt;/li&gt;
&lt;li&gt;Huge community support.&lt;/li&gt;
&lt;li&gt;Supported by Google V8 Engine.&lt;/li&gt;
&lt;li&gt;Easy to connect with databases such as MongoDB, MySQL, etc.&lt;/li&gt;
&lt;li&gt;Easy to integrate with different templates.&lt;/li&gt;
&lt;li&gt;Allows you to define routes based on HTTP methods &amp;amp; URLs.&lt;/li&gt;
&lt;li&gt;Easy to serve static files and resources.&lt;/li&gt;
&lt;li&gt;Flexible middleware module.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
There are problems with the callback or event-driven nature but the last update of Node.js brings async/await that prevents this problem.&lt;/li&gt;
&lt;li&gt;Client request problem with middleware system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to Install Express
&lt;/h3&gt;

&lt;p&gt;Install with npm - &lt;strong&gt;&lt;code&gt;npm install express -g&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Start
&lt;/h3&gt;

&lt;p&gt;First, create a directory named &lt;strong&gt;simpleExpress&lt;/strong&gt;. Change to it, and run &lt;strong&gt;&lt;code&gt;npm init&lt;/code&gt;&lt;/strong&gt;. Then install express as a dependency. In the directory create a file named index.js and write the following code. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Feyfykux7z6umkaegp1sc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Feyfykux7z6umkaegp1sc.png" alt="Express Example Code" width="800" height="562"&gt;&lt;/a&gt;&lt;br&gt;Hello World Example with Express.js
&lt;/p&gt;

&lt;p&gt;Run the app with the following command - &lt;strong&gt;&lt;code&gt;$ node index.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Then open the browser and visit &lt;strong&gt;“localhost:5000”&lt;/strong&gt; to see the output.&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://expressjs.com/" rel="noopener noreferrer"&gt;Express.js&lt;/a&gt; official site to read documentations and know more in details.&lt;/p&gt;

&lt;p&gt;Thanks for reading this tutorial!&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Optimize React Application Performance</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Thu, 23 Dec 2021 20:16:39 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/optimize-react-application-performance-467d</link>
      <guid>https://dev.to/iftakher_hossen/optimize-react-application-performance-467d</guid>
      <description>&lt;p&gt;Today we will learn about Optimize React Application Performance in this tutorial.&lt;/p&gt;

&lt;p&gt;React.Js is an open-source JavaScript UI library for building user interfaces. Nowadays React is the most popular for frontend design. It’s especially used to building single-page applications. You can create large applications in React that can transform data without reloading the page. The main purpose of React is fast, scalable, and simple. Literally, React has the ability to use several clever technics to minimize costly DOM operations required to update the UI. But for some large applications, you need to optimize your React application performance. There are several ways to speed up your React applications, let’s learn about them -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Immutable Data Structures&lt;/strong&gt; - Data immutability is an inflexible way of writing code. It has many benefits such as Zero side effects, Easier to track changes, Simpler to create, test and use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production Build&lt;/strong&gt; - If you are experiencing performance problems in React assure that you are testing with the minified production build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependency Optimization&lt;/strong&gt; - It means removing the methods/functions that you never used in your application. It will optimize the bundle size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memorize React Components&lt;/strong&gt; - Use the &lt;code&gt;useMemo()&lt;/code&gt; hook to memorize/store the expensive functions result to use when the same input occurs again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Animations&lt;/strong&gt; - There are many packages/libraries for Animations. So don’t use CSS Animations instead use those libraries or packages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid using Index as key&lt;/strong&gt; - Using the key as the index can show wrong data as it is being used to identify DOM elements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React.PureComponent&lt;/strong&gt; - React.PureComponent optimizes components by reducing wasted renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtualize Long List&lt;/strong&gt; - It’s a way to improve performance when rendering a long list of data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-Side Rendering&lt;/strong&gt; - Server-side rendered applications have a better user experience because users receive viewable content faster than client-side rendered applications. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lazy Loading&lt;/strong&gt; - If you use numerous images in an application then you should use Lazy Loading to avoid rendering all of the images at once to improve the page load time. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple Chunk Files&lt;/strong&gt; - If you split your large files into smaller files it will help the browser to catch less and reduce loading time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reselect in Redux&lt;/strong&gt; - It’s a simple selector library for Redux, it’s used for building memorized selectors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using a CDN&lt;/strong&gt; - CDN delivers static content more quickly and efficiently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web Worker&lt;/strong&gt; - JavaScript is single-threaded. To prevent slowed/ blocked down, web workers run a script in background threads. We can create &amp;amp; run it parallel to the main thread without hampering the UI flow. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;useCallback()&lt;/code&gt;&lt;/strong&gt; - It’s same like &lt;code&gt;useMemo()&lt;/code&gt; but &lt;code&gt;useMemo()&lt;/code&gt; memorize the results and &lt;code&gt;useCallback()&lt;/code&gt; memorize the function declarations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are many ways to optimize a react application. You have to know the core concepts about React after optimization. Optimization without measuring is almost premature, so you should measure performance first so that you can easily figure it out.&lt;/p&gt;

&lt;p&gt;Thanks for reading this tutorial.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Explore API</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Wed, 22 Dec 2021 17:48:55 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/learn-about-api-1cae</link>
      <guid>https://dev.to/iftakher_hossen/learn-about-api-1cae</guid>
      <description>&lt;p&gt;&lt;strong&gt;Today we will learn What is an API? And The purpose of API &amp;amp; CRUD Operations.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What's an API
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt; stands for &lt;strong&gt;Application Programming Interface&lt;/strong&gt;. It’s a way to connect two applications for talking with each other. It helps you to embed content on your website from any website in a more efficient way. API is simple, flexible, and easier to use. The main purpose of the API is to create communication between two applications. API lets you call to send or receive information. The communication is done by &lt;strong&gt;JSON&lt;/strong&gt;. We fetch data with API requests in applications. API request has 4 components. They are Endpoint, Header, Method &amp;amp; Data. After calling those individually we can build an API request. &lt;/p&gt;

&lt;h3&gt;
  
  
  CRUD Operations
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;CRUD&lt;/strong&gt; Operations stands for &lt;strong&gt;Create&lt;/strong&gt;, &lt;strong&gt;Read&lt;/strong&gt;, &lt;strong&gt;Update&lt;/strong&gt; &amp;amp; &lt;strong&gt;Delete&lt;/strong&gt; operations. The fours basics and important methods in database operations. The purpose of CRUD operations is to modify the data in an application. Let’s explore CRUD Operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GET&lt;/strong&gt; - GET method allows you to get information from the source/database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;POST&lt;/strong&gt; - POST method allows you to add some information to the source/database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PUT&lt;/strong&gt; - PUT method allows you to update the existing information to the source/database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt; - DELETE method allows you to delete existing information from the source/database.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JSON
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;JSON&lt;/strong&gt; stands for &lt;strong&gt;JavaScript Object Notation&lt;/strong&gt;. It’s used to represent data on the server. It’s easy to read for humans and computers. Let’s see an example:&lt;br&gt;
&lt;a href="https://media2.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%2F36lys18lfkyj9ytkkdqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F36lys18lfkyj9ytkkdqk.png" alt="JSON Example Code" width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of API
&lt;/h3&gt;

&lt;p&gt;There are three types of API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open API&lt;/strong&gt; - Open API means an API that is free to use and everyone can use it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partner API&lt;/strong&gt; - Partner API means an API that makes a connection between the server and the clients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private API&lt;/strong&gt; - Private API means a secure API that can only be used for internal uses like payments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;API is a powerful tool for making connections between client and server applications. API provides more benefits like security, speed, &amp;amp; scalability for eCommerce applications. API helps developers send data to clients and is used every day in today’s world.&lt;/p&gt;

&lt;p&gt;Thank you for reading this!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>JavaScript Array Related Methods</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Tue, 21 Dec 2021 18:00:04 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/javascript-array-related-methods-4ajn</link>
      <guid>https://dev.to/iftakher_hossen/javascript-array-related-methods-4ajn</guid>
      <description>&lt;p&gt;In JavaScript, Array is a variable that stores multiple elements. We used Array to store the list of elements and access with a single name. An array is a reference type, which defines it’s a subclass of Object.&lt;/p&gt;

&lt;p&gt;Example of Array:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fozpzh63m8odfnhuuazb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fozpzh63m8odfnhuuazb2.png" alt="Array Code Example" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many array methods in JavaScript. Let’s know about them: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;isArray()&lt;/code&gt;: &lt;code&gt;isArray()&lt;/code&gt; method is used to know if the object is an array or not. When it returns true that means it’s an Array and when it returns false that means it’s not an Array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;concat()&lt;/code&gt;: &lt;code&gt;concat()&lt;/code&gt; method is used to concat/join two or more arrays together. After using this method it returns the new array.  It never changes the existing arrays.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;every()&lt;/code&gt;: &lt;code&gt;every()&lt;/code&gt; method is used to execute a specific function for every element of an array. If the function returns true it clarifies all the elements are true and if the function returns false it clarifies all the elements are false.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;filter()&lt;/code&gt;: &lt;code&gt;filter()&lt;/code&gt; method is used to filter out some elements in a specific condition. It creates a new array with the results. It returns all the elements that fulfill the condition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;find()&lt;/code&gt;: &lt;code&gt;find()&lt;/code&gt; method is used to find an element in a specific condition. It returns the first element that fulfills the condition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;findIndex()&lt;/code&gt;: &lt;code&gt;findIndex()&lt;/code&gt; method is used to find out the index of an element that fulfills the condition. If there’s no match it returns -1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;forEach()&lt;/code&gt;: &lt;code&gt;forEach()&lt;/code&gt; method is used to execute a function for each array element. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;indexOf()&lt;/code&gt;: &lt;code&gt;indexOf()&lt;/code&gt;is used to get the index of a specific value. If there’s no match it returns -1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;join()&lt;/code&gt;: &lt;code&gt;join()&lt;/code&gt; method is used to return the array as a string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;map()&lt;/code&gt;: &lt;code&gt;map()&lt;/code&gt; method is used to execute a function for each array element. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;lastIndexOf()&lt;/code&gt;: &lt;code&gt;lastIndexOf()&lt;/code&gt; is used to get the last index of a specific value. If there’s no match it returns -1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;pop()&lt;/code&gt;: &lt;code&gt;pop()&lt;/code&gt; method is used to delete the last element of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;push()&lt;/code&gt;: &lt;code&gt;push()&lt;/code&gt; method is used to add an element to the end of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Reduce()&lt;/code&gt;: &lt;code&gt;Reduce()&lt;/code&gt; method is used to execute a reducer function for an array element to calculate the numbers of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Reverse()&lt;/code&gt;: &lt;code&gt;Reverse()&lt;/code&gt; method is used to reverse the order of the items of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;shift()&lt;/code&gt;:  &lt;code&gt;shift()&lt;/code&gt; method is used to delete the first element of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;slice()&lt;/code&gt;: &lt;code&gt;slice()&lt;/code&gt; method is used to get specific elements in a new array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;sort()&lt;/code&gt;: &lt;code&gt;sort()&lt;/code&gt; method is used to sort the elements of an array in alphabetical and ascending order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;splice()&lt;/code&gt;: &lt;code&gt;splice()&lt;/code&gt; method is used to delete a specific element of an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;unshift()&lt;/code&gt;: &lt;code&gt;unshift()&lt;/code&gt; method is used to add an element to the beginning of an array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading this!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>iftakher</category>
    </item>
    <item>
      <title>Media Query (CSS)</title>
      <dc:creator>Iftakher Hossen</dc:creator>
      <pubDate>Tue, 21 Dec 2021 15:20:29 +0000</pubDate>
      <link>https://dev.to/iftakher_hossen/media-query-css-3akc</link>
      <guid>https://dev.to/iftakher_hossen/media-query-css-3akc</guid>
      <description>&lt;h3&gt;
  
  
  What is Media Query
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Media Query&lt;/strong&gt; is introduced on CSS3. Media Query is a very useful tool. Media Query in CSS is used to make responsive designs for various platforms. We use the &lt;code&gt;@media&lt;/code&gt; rule to include a block of CSS properties only if a particular condition is true. You have to mention &lt;code&gt;breakpoint&lt;/code&gt;'s, it defines where certain parts of the design will behave differently. Media queries can be used to check many things, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Width and height of the viewport&lt;/li&gt;
&lt;li&gt;Width and height of the device&lt;/li&gt;
&lt;li&gt;Orientation (Landscape/Portrait)&lt;/li&gt;
&lt;li&gt;Resolution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also use media queries to specify that specific styles are only for printed documents or for screen readers (media-type: print, screen, or speech). Media queries can also be used to change the layout of a page depending on the orientation of the browser.&lt;/p&gt;

&lt;h4&gt;
  
  
  Structure:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F3gjm1y5v6frpkq204wwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F3gjm1y5v6frpkq204wwj.png" alt="Structure" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Demo:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fdk9cm0bcrtyin0fpz8zz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fdk9cm0bcrtyin0fpz8zz.png" alt="Code Screenshot 02" width="800" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Meaning of and, only &amp;amp; not:
&lt;/h4&gt;

&lt;p&gt;And : For using two or more media query breakpoints or media types. &lt;br&gt;
Only    : For using media query on an Older version of browsers.&lt;br&gt;
Not : For inverting the meaning of an entire media query.&lt;/p&gt;

&lt;p&gt;You can use external CSS for different media to keep CSS file's more clean and organized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1tf0givs3z8wpw9eeqwi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1tf0givs3z8wpw9eeqwi.png" alt="Code Screenshot 03" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Typical Device Breakpoints
&lt;/h3&gt;

&lt;p&gt;There are tons of screens and devices of different sizes, so it is tough to create an exact breakpoint for each device. To keep things simple you could target five groups:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F087amm7obo4l2ge0mlr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F087amm7obo4l2ge0mlr8.png" alt="Code Screenshot 02" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser Support
&lt;/h3&gt;

&lt;p&gt;The table data define the first version of the browser support the Media Query -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fwn81661gnt8zvre8rjft.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fwn81661gnt8zvre8rjft.jpg" alt="Browser  Support Image" width="702" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
