<?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: Jotham Ntekim</title>
    <description>The latest articles on DEV Community by Jotham Ntekim (@jothamntekim1).</description>
    <link>https://dev.to/jothamntekim1</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%2F1003276%2Fb1628cc4-990f-4473-ab1c-10c91dd3cfbe.jpg</url>
      <title>DEV Community: Jotham Ntekim</title>
      <link>https://dev.to/jothamntekim1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jothamntekim1"/>
    <language>en</language>
    <item>
      <title>CineAgent: Bridging the Web and Conversational AI with a Concurrent Go ETL</title>
      <dc:creator>Jotham Ntekim</dc:creator>
      <pubDate>Fri, 06 Feb 2026 11:37:39 +0000</pubDate>
      <link>https://dev.to/jothamntekim1/cineagent-bridging-the-web-and-conversational-ai-with-a-concurrent-go-etl-5cgf</link>
      <guid>https://dev.to/jothamntekim1/cineagent-bridging-the-web-and-conversational-ai-with-a-concurrent-go-etl-5cgf</guid>
      <description>&lt;p&gt;Search engines are only as good as the data you feed them. For the &lt;strong&gt;Algolia Agent Studio Challenge&lt;/strong&gt;, I wanted to build more than just a chatbot; I wanted to build a &lt;strong&gt;living pipeline&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Introducing &lt;strong&gt;CineAgent&lt;/strong&gt;, a voice-powered cinema concierge grounded by &lt;strong&gt;Trawl&lt;/strong&gt;—a custom-built, high-concurrency ETL engine written in Go.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 The Vision: Beyond Static Data
&lt;/h2&gt;

&lt;p&gt;Most AI agents are limited by their training data or static JSON uploads. &lt;strong&gt;CineAgent&lt;/strong&gt; is different. It uses a "Trawler" approach to bridge the gap between unstructured web content and conversational discovery.&lt;/p&gt;

&lt;p&gt;The project solves three specific problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Freshness:&lt;/strong&gt; Trawl (the backend) can scrape and index thousands of records concurrently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grounding:&lt;/strong&gt; The AI Agent is strictly grounded in a curated index of 250+ cinematic masterpieces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The "Empty State" Problem:&lt;/strong&gt; In standard search, "No Results" is a dead end. In CineAgent, "No Results" is the beginning of a conversation.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🛠 The Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Engine (Trawl):&lt;/strong&gt; Built with &lt;strong&gt;Go&lt;/strong&gt;, utilizing Goroutines and Channels for high-concurrency web scraping and batch indexing via the &lt;strong&gt;Algolia Go API Client v5&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Brain:&lt;/strong&gt; &lt;strong&gt;Algolia Agent Studio&lt;/strong&gt;, configured as a "Film Discovery Expert" to handle complex, natural language queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Face:&lt;/strong&gt; A &lt;strong&gt;React&lt;/strong&gt; frontend styled with &lt;strong&gt;Chakra UI v3&lt;/strong&gt; for a premium, immersive dark-mode experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Interaction:&lt;/strong&gt; &lt;strong&gt;Web Speech API&lt;/strong&gt; for hands-free discovery and the &lt;strong&gt;Algolia InstantSearch Chat Widget (Beta)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Key Features &amp;amp; Originality
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The Trawl ETL Pipeline (Go)
&lt;/h3&gt;

&lt;p&gt;While most participants might upload a static file, I built an ETL (Extract, Transform, Load) engine. &lt;strong&gt;Trawl&lt;/strong&gt; follows a concurrent worker-pool pattern. It scrapes metadata (Title, Year, Rating, High-res posters), normalizes it into Go structs, and pipes it into Algolia in optimized batches.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Hybrid "Voice-to-Agent" UI
&lt;/h3&gt;

&lt;p&gt;I implemented a &lt;strong&gt;"NoResultsBoundary"&lt;/strong&gt; logic. If the local search grid can't find a specific niche movie, the UI doesn't just show an error. It proactively invites the user to "Ask CineAgent AI," handing off the search query to the conversational agent.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Voice-First Discovery
&lt;/h3&gt;

&lt;p&gt;Users can click the microphone icon to search. If the voice input is a short keyword (e.g., "Inception"), the movie grid updates. If the input is a complex question (e.g., "What is the best sci-fi movie from the 90s?"), CineAgent opens the conversational chat automatically.&lt;/p&gt;




&lt;h2&gt;
  
  
  📺 Demo &amp;amp; Visuals
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Live URL: &lt;a href="//trawl-ui.vercel.app"&gt;trawl-ui.vercel.app&lt;/a&gt;
&lt;/h3&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%2Fmkvgbz42ycvshm5l9cb2.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%2Fmkvgbz42ycvshm5l9cb2.png" alt=" " width="705" height="1479"&gt;&lt;/a&gt;&lt;br&gt;
![Image Description: A sleek dark-mode movie library with a floating AI Assistant bubble.]&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Integrating a Beta widget like the Algolia Chat component into a modern React 18 / Chakra UI v3 environment was a challenge in state management. I learned that isolating the AI handshake from the main search lifecycle is key to maintaining a responsive, "hang-free" user experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Frontend (UI)&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/ntekim/trawl-ui" rel="noopener noreferrer"&gt;github.com/ntekim/trawl-ui&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Backend&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/ntekim/trawl" rel="noopener noreferrer"&gt;github.com/ntekim/trawl&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Algolia Agent ID:&lt;/strong&gt; &lt;code&gt;4ddf0636-38b2-4578-a98f-8715efde81ca&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  algoliachallenge #devchallenge #agents #webdev #golang #react
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>devchallenge</category>
      <category>go</category>
      <category>algoliachallenge</category>
    </item>
    <item>
      <title>Linux User Creation Bash Script</title>
      <dc:creator>Jotham Ntekim</dc:creator>
      <pubDate>Wed, 03 Jul 2024 16:32:47 +0000</pubDate>
      <link>https://dev.to/jothamntekim1/linux-user-creation-bash-script-509a</link>
      <guid>https://dev.to/jothamntekim1/linux-user-creation-bash-script-509a</guid>
      <description>&lt;p&gt;Hey guys, been a while since my last article on Network Programming Series. While I'll very much start writing soon and continue the next article on the series, let me quickly walk you through how I did my HNG stage 1 task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hng.tech/"&gt;HNG&lt;/a&gt; is a set of program designed for intermediate to advanced learners who want to rapidly move forward in their career - and end up in jobs in the best international companies. To achieve their mission of enhancing the skills of developers and make them Job ready, they arranged a 2-month transformative internship, widely known as &lt;a href="https://hng.tech/internship"&gt;HNG INTERNSHIP&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As part of the custom, we're to complete a task every week to move up the stages and I guess this is me about to walk you through how I did my Stage 1 task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task Description
&lt;/h2&gt;

&lt;p&gt;Your company has employed many new developers. As a SysOps engineer, write a bash script called create_users.sh that reads a text file containing the employee’s usernames and group names, where each line is formatted as user;groups.&lt;/p&gt;

&lt;p&gt;The script should create users and groups as specified, set up home directories with appropriate permissions and ownership, generate random passwords for the users, and log all actions to /var/log/user_management.log. Additionally, store the generated passwords securely in /var/secure/user_passwords.txt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Each User must have a personal group with the same group name as the username, this group name will not be written in the text file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A user can have multiple groups, each group delimited by comma ","&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Usernames and user groups are separated by semicolon ";"- Ignore whitespace e.g.  light; sudo,dev,www-data  idimma; sudo  mayowa; dev,www-data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the first line, light is username and groups are sudo, dev, www-data&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Solution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//create_users.sh file
#!/bin/bash //add this to the top of the file to indicate how it should be interpreted

# Check if the user list file is provided as an argument
if [ $# -ne 1 ]; then
  echo "Usage: $0 &amp;lt;user_list_file&amp;gt;"
  exit 1
fi

# Define the user list file from the argument
USER_FILE="$1"

# Check if the user list file exists
if [ ! -f "$USER_FILE" ]; then
  echo "User list file $USER_FILE not found!"
  exit 1
fi

LOG_FILE="/var/log/user_management.log"
PASSWORD_FILE="/var/secure/user_passwords.txt"

# Ensure the log and password files exist
sudo touch $LOG_FILE
sudo chmod 666 $LOG_FILE
mkdir -p /var/secure
sudo touch $PASSWORD_FILE
sudo chmod 666 $PASSWORD_FILE

# Function to generate a random password
generate_password() {
  &amp;lt; /dev/urandom tr -dc 'A-Za-z0-9!@#$%^&amp;amp;*()_+=' | head -c 12
}

# Read the user file
while IFS=';' read -r username groups || [ -n "$username" ]; do
    if id "$username" &amp;amp;&amp;gt;/dev/null; then
        echo "User $username already exists." | tee -a $LOG_FILE
    else
    # Create the user with a home directory
    sudo useradd -m -s /bin/bash "$username"
    echo "Created user $username." | tee -a $LOG_FILE

    # Generate and set a random password
    password=$(generate_password)
    echo "$username:$password" | sudo chpasswd
    echo "$username:$password" &amp;gt;&amp;gt; $PASSWORD_FILE
    echo "Password for user $username set." | tee -a $LOG_FILE

    # Set ownership and permissions for the home directory
    sudo chown "$username:$username" /home/$username
    sudo chmod 700 /home/$username
    echo "Home directory permissions set for $username." | tee -a $LOG_FILE

    # Handle groups
    IFS=',' read -ra group_list &amp;lt;&amp;lt;&amp;lt; "$groups"
    for group in "${group_list[@]}"; do
      if getent group "$group" &amp;amp;&amp;gt;/dev/null; then
        echo "Group $group already exists." | sudo tee -a $LOG_FILE
      else
        sudo groupadd "$group"
        echo "Created group $group." | tee -a $LOG_FILE
      fi
      sudo usermod -aG "$group" "$username"
      echo "Added user $username to group $group." | sudo tee -a $LOG_FILE
    done
  fi
done &amp;lt; "$USER_FILE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here's what each line does...&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;#!/bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This is the shebang line that tells the system to use the Bash interpreter to execute this script.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [ $# -ne 1 ]; then
  echo "Usage: $0 &amp;lt;user_list_file&amp;gt;"
  exit 1
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This section checks if exactly one argument (the user list file) is provided when the script is run. If not, it prints a usage message and exits with an error code.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USER_FILE="$1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This line assigns the provided argument to the USER_FILE variable, which will be used to refer to the user list file throughout the script.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [ ! -f "$USER_FILE" ]; then
  echo "User list file $USER_FILE not found!"
  exit 1
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This section checks if the specified user list file exists. If not, it prints an error message and exits.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOG_FILE="/var/log/user_management.log"
PASSWORD_FILE="/var/secure/user_passwords.txt"
sudo touch $LOG_FILE
sudo chmod 777 $LOG_FILE
mkdir -p /var/secure
sudo touch $PASSWORD_FILE
sudo chmod 777 $PASSWORD_FILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;These lines define the paths for the log file and the password file and then create the log and password files if they do not already exist and set their permissions to be writable by any users.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generate_password() {
  &amp;lt; /dev/urandom tr -dc 'A-Za-z0-9!@#$%^&amp;amp;*()_+=' | head -c 12
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This function generates a random 12-character password using characters from a specified set. It reads from /dev/urandom, which is a pseudo-random number generator.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while IFS=';' read -r username groups || [ -n "$username" ]; do

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This line starts a while loop that reads each line from the user list file. The IFS=';' sets the internal field separator to ;, so the line is split into username and groups. The || [ -n "$username" ] part ensures the last line is processed even if it doesn't end with a newline character.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if id "$username" &amp;amp;&amp;gt;/dev/null; then
        echo "User $username already exists." | tee -a $LOG_FILE
    else

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This block checks if the user already exists using the id command. If the user exists, it logs a message to the log file and continues to the next iteration.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    sudo useradd -m -s /bin/bash "$username"
    echo "Created user $username." | tee -a $LOG_FILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If the user does not exist, this block creates the user with a home directory and sets the default shell to Bash. It then logs the action.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    password=$(generate_password)
    echo "$username:$password" | sudo chpasswd
    echo "$username:$password" &amp;gt;&amp;gt; $PASSWORD_FILE
    echo "Password for user $username set." | sudo tee -a $LOG_FILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This section generates a random password using the generate_password function, sets the user's password, and logs the password in the password file and the action in the log file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo chown "$username:$username" /home/$username
    sudo chmod 700 /home/$username
    echo "Home directory permissions set for $username." | sudo tee -a $LOG_FILE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This block sets the ownership of the user's home directory to the user and sets the permissions to 700 (read, write, and execute only by the owner). It then logs the action.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    IFS=',' read -ra group_list &amp;lt;&amp;lt;&amp;lt; "$groups"
    for group in "${group_list[@]}"; do
      if getent group "$group" &amp;amp;&amp;gt;/dev/null; then
        echo "Group $group already exists." | sudo tee -a $LOG_FILE
      else
        sudo groupadd "$group"
        echo "Created group $group." | sudo tee -a $LOG_FILE
      fi
      sudo usermod -aG "$group" "$username"
      echo "Added user $username to group $group." | sudo tee -a $LOG_FILE
    done
  fi
done &amp;lt; "$USER_FILE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This section handles group assignments for the user. It splits the groups field into an array using , as a separator and iterates over each group. For each group, it checks if the group exists; if not, it creates the group. Then, it adds the user to the group and logs the actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So that's it. I want to point out though that the internship is a great opportunity to both learn and network, and interestingly, even if you couldn't finish, you can remain connected to their community and enjoy the same benefits as the finalists if you upgrade your account to premium. Check out their Premium benefits &lt;a href="https://hng.tech/premium"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll keep you posted on my next article.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Network Programming: The OSI Model</title>
      <dc:creator>Jotham Ntekim</dc:creator>
      <pubDate>Wed, 25 Oct 2023 03:31:33 +0000</pubDate>
      <link>https://dev.to/jothamntekim1/network-programming-the-osi-model-2a1o</link>
      <guid>https://dev.to/jothamntekim1/network-programming-the-osi-model-2a1o</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. INTRODUCTION&lt;br&gt;
 2. Networking Model&lt;br&gt;
 3. Layers of the OSI model&lt;/p&gt;

&lt;p&gt;       3.1. Layer 7: Application Layer&lt;/p&gt;

&lt;p&gt;       3.2. Layer 6: Presentation Layer&lt;/p&gt;

&lt;p&gt;       3.3. Layer 5: Session Layer&lt;/p&gt;

&lt;p&gt;       3.4. Layer 4: Transport Layer&lt;/p&gt;

&lt;p&gt;       3.5. Layer 3: Network Layer&lt;/p&gt;

&lt;p&gt;       3.6. Layer 2: Data Link Layer&lt;/p&gt;

&lt;p&gt;       3.7. Layer 1: Physical Layer&lt;/p&gt;

&lt;p&gt; 4. Conclusion&lt;/p&gt;

&lt;p&gt; 5. Reference&lt;/p&gt;

&lt;h2&gt;
  
  
  INTRODUCTION
&lt;/h2&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/jothamntekim1/network-programming-the-computer-network-312m"&gt;last&lt;/a&gt; article, I talked about how different hosts can communicate with the help of a computer network. I gave background information on computer networks, their types, and their importance in distributed systems.&lt;/p&gt;

&lt;p&gt;In this article, I will walk you through the 7 Layers of the &lt;strong&gt;OSI model&lt;/strong&gt;, and in subsequent articles, we will explore the different network protocols.&lt;/p&gt;

&lt;p&gt;Before we get right into it, here are a few points to keep in mind as you follow along:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hosts&lt;/strong&gt;: any device that sends or receives traffic(data) - desktop, laptop, phones, printers, servers, Smart TV, Smart Watches, Speakers etc. They are often referred to as &lt;strong&gt;nodes&lt;/strong&gt;. So when I mention hosts or computers later in this article, I am referring to no specific device(s). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network:&lt;/strong&gt; consists of two or more computers that are linked to share resources (such as printers and CDs), exchange files, or allow electronic communications. The computers on a network may be linked through cables, telephone lines, radio waves, satellites, or infrared light beams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Protocol&lt;/strong&gt; is a set of rules defining how software and devices in a network should work including how they should work together. These are &lt;em&gt;logical rules&lt;/em&gt;* though, not physical ones. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxenjv5z6acrd8avdpja5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxenjv5z6acrd8avdpja5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The devices on the left may be able to communicate with each other and those on the right too, but those on the left won't be able to communicate with those on the right due to differences in standards. However various devices are expected to communicate with each other. To enable such communication, hence &lt;strong&gt;Networking Models&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Networking Model
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Networking model&lt;/strong&gt; is a set of guidelines and standards that defines how data is transmitted and received &lt;strong&gt;over&lt;/strong&gt; a network. It is also known as a &lt;strong&gt;networking architecture&lt;/strong&gt; or a &lt;strong&gt;networking blueprint&lt;/strong&gt;. It provides a common framework for network devices and software to communicate with each other.&lt;/p&gt;

&lt;p&gt;Networking models categorise and provide a structure for various networking standards and protocols.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;OSI model&lt;/strong&gt; is one attempt at &lt;strong&gt;standardization&lt;/strong&gt;, created by &lt;strong&gt;International Organisation of Standardization&lt;/strong&gt;(ISO).&lt;/p&gt;

&lt;h2&gt;
  
  
  Layers of the OSI model
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febm12lojqwudvhzozvrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febm12lojqwudvhzozvrx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Network Functions are divided into 7 layers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 7: Application Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is the layer closest to the end users. Software applications - web browsers, for example, interact with this layer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP and HTTPS protocols fall under this layer. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It does not include the application itself(internet browser in this situation), but rather just the protocols(HTTP and HTTPS).&lt;/p&gt;

&lt;p&gt;Functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identifying communication partners - figuring destination host(s) IP address(es) in the network.&lt;/li&gt;
&lt;li&gt;Synchronizing communications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's say an internet browser wants to send data into the system on the right(image below). The data is processed through the OSI stack, each layer adding something to the original data(Encapsulation - the original data encapsulated inside the additional information added on). By the time it reaches the physical layer, it is electrical signals to be sent to the destination host(s). The destination system then reverses the process by de-encapsulating the data, stripping off all the additional information added at each layer until it reaches the final layer(application layer). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3cosa5p1rlyccpzoz76.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3cosa5p1rlyccpzoz76.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interaction between layer 7 in the two systems(host) is called same-layer interaction. It is what enables the application layer to identify communication partners and synchronize communication.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 6: Presentation Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This layer is responsible for data formatting, such as character encoding and conversions, and data encryption.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data in the application layer is in application format, one that only the application understands. It thus has to be translated to a format before being sent to the network layer. The presentation layer's job is to translate between application and network format. For example, encryption of data before being sent to the network layer for processing and decryption before being received by the application layer in the destination host. &lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 5: Session Layer
&lt;/h3&gt;

&lt;p&gt;This layer establishes, maintains, and terminates &lt;strong&gt;sessions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;session&lt;/strong&gt; is a mutually agreed upon connection that is established between two network applications.&lt;/p&gt;

&lt;p&gt;So a &lt;strong&gt;session&lt;/strong&gt; is a connection that is established between two &lt;strong&gt;specific&lt;/strong&gt; end-user applications. This connection can be in two forms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Client and server model&lt;/strong&gt;: the application requesting the information is called the client, and the application that has the requested information is called the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Request and response model&lt;/strong&gt;: while a session is being established and during a session, there is a constant back-and-forth of requests for information and responses containing that information or a response like, “Hey, I don’t have what you’re requesting.”&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sessions may be open for a very short amount of time or a long amount of time.&lt;/p&gt;

&lt;p&gt;So this layer...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Controls dialogue(session) between communicating hosts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Establishes, manages, and terminates the connection between local application(e.g. Your internet browser) and remote application(e.g. YouTube).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For each established connection, a session is created. Session Layer helps to manage all sessions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NB:&lt;/strong&gt; Network engineers don't usually work with the top three layers, rather application developers do - to connect their applications over the network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 4: Transport Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This layer segments and reassembles data for communication between end hosts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Breaks large sets of data into smaller segments which can be more easily sent over the network with a low possibility of causing transmission problems even if an error occurs. It is why videos skip for a second and continue just fine if a particular segment is not sent, unlike when not segmented, the whole video cannot be watched.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It provides host-to-host(end-to-end/process-to-process) connections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It supports connection-oriented(TCP) and connectionless(UDP) communication.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the layer, the packaged data is called &lt;strong&gt;segment&lt;/strong&gt; - &lt;strong&gt;Data&lt;/strong&gt; + &lt;strong&gt;layer 4 header&lt;/strong&gt;(L4 Header).&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 3: Network Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It provides connectivity between end hosts on different networks(i.e. hosts outside the LAN). &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides path selection - routing with the aid of routers. It provides Logical addressing(IP addressing).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Routers are the workhorse of Layer 3 - we couldn’t have Layer 3 without them. They move data packets across multiple networks. &lt;/p&gt;

&lt;p&gt;Routers do not only connect to Internet Service Providers (ISPs) to provide access to the Internet, they also keep track of what’s on its network same way switches keep track of all MAC addresses on a network (Switches exist in Layer 2), what other networks it’s connected to, and the different paths for routing data packets across these networks.&lt;/p&gt;

&lt;p&gt;The packaged data at this stage is called &lt;strong&gt;packet&lt;/strong&gt; - Data + layer 4 header + layer 3 header. &lt;br&gt;
The IP address is included in this layer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2: Data Link Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This layer defines how data is formatted for transmission, how much data can flow between nodes, for how long, and what to do when errors are detected in this flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It provides node-node connectivity and data transfer(for example, PC to Switch, Switch to Router or Router to Router). It defines how data is formatted for transmission over a physical medium(copper UTP cables for example). It detects and possibly corrects physical layer errors. It uses layer 2 addressing, which is separate from layer 3 addressing. &lt;strong&gt;Switches&lt;/strong&gt; operate at this layer. &lt;/p&gt;

&lt;p&gt;The packaged data is called &lt;strong&gt;Frame&lt;/strong&gt; - Layer 2 trailer + Data + L4 header + layer 3 header + layer 2 header.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 1: Physical Layer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Layer 1 contains the infrastructure that makes communication on networks possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It defines the physical characteristics of the medium used to transfer data between devices - for example, voltage level, maximum transmission distances, physical connectors, cable specification etc. &lt;/p&gt;

&lt;p&gt;There’s a lot of technology in Layer 1 - everything from physical network devices, and cabling, to how the cables hook up to the devices. Plus if we don’t need cables, what the signal type and transmission methods are (for example, wireless broadband)?&lt;/p&gt;

&lt;p&gt;Layer 1 defines the electrical, mechanical, procedural, and functional specifications for activating, maintaining, and deactivating physical links between network devices.&lt;/p&gt;

&lt;p&gt;The data unit on Layer 1 is the &lt;strong&gt;bit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A bit is the smallest unit of transmittable digital information. Bits are binary, so either a 0 or a 1. Bytes, consisting of 8 bits, are used to represent single characters, like a letter, numeral, or symbol.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At this level, digital bits are converted into electrical(for wired connections) or radio(for wireless connections) signals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complete frame is then sent from one host to the other through ethernet cable for example or wireless broadband. The Data Link Layer translates the raw physical layer into a frame  ... The layer 2 header and trailer are removed at layer 2, leaving a packet. Layer 3 removes the layer 3 header, leaving the layer 4 segment, and layer 4 removes the layer 4 header leaving the original data prepared by the upper layers(top 3 layers) of the original device(De-encapsulation).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NB:&lt;/strong&gt; Data + Segment + Packet + Frame are all called &lt;strong&gt;Protocol Data Units(PDUs)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrx2skh5qw4zubnbd2eh.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrx2skh5qw4zubnbd2eh.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We've discussed the need for Networking models, and the part each layer of the OSI model plays in ensuring communication within and/or over a network. Recall, that we agreed in the last article that the hardware part of a computer network is beyond the scope of this article series so our focus would be on the first 3 Layers(Application, Presentation and Session layers) of the OSI model since they are more concerned with the Software part of a computer network. But since I've always been intrigued to know how IP addressing works - subnetting and masking, I'll be making an exception for the transport and network layer.&lt;/p&gt;

&lt;p&gt;In the next article, we will talk about an interesting topic - &lt;strong&gt;IP addresses&lt;/strong&gt;, a Layer 3 Protocol. It is one of the reasons behind my focus in &lt;strong&gt;Network programming&lt;/strong&gt; and the need to write these articles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/osi-model-networking-layers-explained-in-plain-english/#:%7E:text=There%20are%20two%20distinct%20sublayers,have%20the%20same%20MAC%20address" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/osi-model-networking-layers-explained-in-plain-english/#:~:text=There%20are%20two%20distinct%20sublayers,have%20the%20same%20MAC%20address&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=t-ai8JzhHuY" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=t-ai8JzhHuY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.computernetworkingnotes.com/ccna-study-guide/what-is-a-networking-model-explained.html" rel="noopener noreferrer"&gt;https://www.computernetworkingnotes.com/ccna-study-guide/what-is-a-networking-model-explained.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>networking</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>osi</category>
    </item>
    <item>
      <title>Network Programming: The computer network.</title>
      <dc:creator>Jotham Ntekim</dc:creator>
      <pubDate>Tue, 10 Oct 2023 23:29:38 +0000</pubDate>
      <link>https://dev.to/jothamntekim1/network-programming-the-computer-network-312m</link>
      <guid>https://dev.to/jothamntekim1/network-programming-the-computer-network-312m</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Introduction&lt;br&gt;
 2. What is a Computer Network?&lt;br&gt;
 3. Types of Computer Networks&lt;br&gt;
 4. Conclusion&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;You have probably worked into several internet cafes in an attempt to photocopy or print a document. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; You walk straight to the person in charge and tell him you need a printed copy of the document you have on your device. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; You send him the document. After a few minutes, he walks to the printer and gets you a copy of the document you sent him.&lt;/p&gt;

&lt;p&gt;But how exactly did the document you sent to his computer get to the printer?&lt;/p&gt;

&lt;p&gt;Well, the computer connects to the printer's IP address and sends the data in a language the printer knows. This is possible with the help of &lt;strong&gt;Computer Network.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Computer Network?
&lt;/h2&gt;

&lt;p&gt;A computer network is a bunch of devices connected to exchange information — emails, documents, audio/video data — or to share a resource — printers, storage and other physical devices. Typically, computers in a network are called &lt;strong&gt;hosts&lt;/strong&gt;, while &lt;strong&gt;links&lt;/strong&gt; are the elements that connect them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The scenario painted above about the connection between a printer and a computer is one example of a computer network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Receiving files from a friend's device through Bluetooth or Xender connection is another example of a computer network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The connection between your favourite browser(chrome for example) and the servers where the data you request are stored is yet another example. The list is endless.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Types of Computer Networks
&lt;/h2&gt;

&lt;p&gt;Computer networks range from very small to very large. Based on size, they're referred to as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Local Area Network (LAN)&lt;/strong&gt; - Few hosts(computers) connected over a limited area. Like the ones we find inside houses, schools or offices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Metropolitan Area Network (MAN)&lt;/strong&gt; - A larger network that extends across a city and can be conceptually seen as many smaller LANs connected together.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Wide Area Network (WAN)&lt;/strong&gt; - an even bigger network, which connects multiple &lt;strong&gt;MANs or LANs&lt;/strong&gt; and can span the whole world.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Engineers are also working on a type of &lt;strong&gt;interplanetary computer network&lt;/strong&gt; that connects satellites, planetary rovers and the Earth,  which at this time is not of our interest.&lt;/p&gt;

&lt;p&gt;Computer networks can be analysed both at a hardware and software level. Physically, a network is made of computers, cables and other machinery that makes it work correctly. Understanding computer networks on the hardware level involves a lot of physics, mathematics and electronics to describe how the signal travels around, along with the technology behind components and computers. The software level on the other hand involves programs, instructions and algorithms(a set of step-by-step instructions for solving a problem) that give life to the physical counterpart - computers, cables, routers, etc.&lt;/p&gt;

&lt;p&gt;The hardware part of a computer network is beyond the scope of this article series. Our focus will be on the software level which involves &lt;strong&gt;Network Programming:&lt;/strong&gt; writing programs that communicate with other programs across a computer network.&lt;/p&gt;

&lt;p&gt;All networks are based on one or more &lt;strong&gt;network protocols&lt;/strong&gt; - a set of rules that determine how information should be transmitted between different computers in the same network.&lt;/p&gt;

&lt;p&gt;For example, the &lt;strong&gt;HyperText Transfer Protocol (HTTP)&lt;/strong&gt; describes how to fetch and share resources, such as text documents, over a network. It also describes all the hardware components required for the resource exchange to work correctly. Thanks to the HTTP you can browse this page on your device, add comments in the box below or share it on social media.&lt;/p&gt;

&lt;p&gt;The list of existing network protocols is quite huge and spans across multiple domains. While the list may be a long one, they all follow the &lt;strong&gt;Open System Interconnection(OSI) model&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wCHme9xw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x85ipfutd64xmslo2prx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wCHme9xw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x85ipfutd64xmslo2prx.png" alt="Image description" width="600" height="764"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We have established that computer networks are crucial in modern systems and applications. While a few standalone systems like Microsoft Word, Calculator app, Adobe Photoshop etc., can operate without the need to connect to other hosts/applications, most systems require some sort of connection to other hosts to function hence the need for a Computer Network.&lt;/p&gt;

&lt;p&gt;In future articles, we will explore some of the different layers of computer protocols - &lt;strong&gt;network layer(IP),&lt;/strong&gt; &lt;strong&gt;transport layer(TCP/UDP)&lt;/strong&gt; and &lt;strong&gt;application layer(HTTP/FTP),&lt;/strong&gt; and how they follow the &lt;strong&gt;OSI&lt;/strong&gt; model.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>network</category>
    </item>
    <item>
      <title>Golang : The OOP Pattern.</title>
      <dc:creator>Jotham Ntekim</dc:creator>
      <pubDate>Tue, 10 Jan 2023 07:14:43 +0000</pubDate>
      <link>https://dev.to/jothamntekim1/golang-the-oop-pattern-2oil</link>
      <guid>https://dev.to/jothamntekim1/golang-the-oop-pattern-2oil</guid>
      <description>&lt;p&gt;Programming is a creative task: there is no right or wrong way to solve a problem, in the same way, that there is no right or wrong way to paint a picture.&lt;/p&gt;

&lt;p&gt;In this article, I will walk you through how I did my AltSchool Project. We'll learn about some OOP Concepts - Encapsulation, Abstraction, Inheritance, and Polymorphism.&lt;/p&gt;

&lt;p&gt;But before I get started, let me brief you on what the project is about...&lt;/p&gt;

&lt;p&gt;John has just opened up his car selling shop, to sell different cars. He gets the cars he needs to sell from different people and they all bring it to him. He needs to manage the list of cars he has, attach a price to them, and put them on display to be sold, basically John needs an inventory to manage cars &amp;amp; to manage sales.  For instance,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;He needs to see the number of cars that are left to be sold&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;He needs to see the sum of the prices of the cars left&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;He needs to see the number of cars he has sold&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sum total of the prices of cars he has sold&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A list of orders that for the sales he made&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using the knowledge of OOP in Go, Build simple classes for the following “objects”&lt;/p&gt;

&lt;p&gt;● Car&lt;br&gt;
● Product&lt;br&gt;
● Store&lt;/p&gt;

&lt;p&gt;The Car class can have any car attributes you can think of.&lt;/p&gt;

&lt;p&gt;The Product class should have attributes of a product i.e (theproduct, quantityofthe&lt;br&gt;
productinstock,priceoftheproduct).&lt;/p&gt;

&lt;p&gt;A car is a product of the store, but there can be other products so the attribute of the car can be promoted to the Product. The Product class should have methods to display a product, and a method to display the status of a product if it is still in stock or not.&lt;/p&gt;

&lt;p&gt;The Store class should have attributes like&lt;/p&gt;

&lt;p&gt;● Number of products in the store that are still up for sale&lt;br&gt;
● Adding an Item to the store&lt;br&gt;
● Listing all product items in the store&lt;br&gt;
● Sell an item&lt;br&gt;
● Show a list of sold items and the total price&lt;/p&gt;

&lt;p&gt;So basically we'll be building a mini-ecommerce platform that will help John make sales and at the same time keep track of his sales.&lt;/p&gt;

&lt;p&gt;Let me point out a few things, though Car is the main Product  John deals on, he sells other Car accessories such as headlights, tyres etc so our Car class here will cover for all items John sells.&lt;/p&gt;

&lt;p&gt;Defining the deliverables or functionalities of this app will be our first task. We’ll do this by creating a Store Interface. Interface basically helps us define a set of attributes or behaviors that a class implements. So instead of creating a function for each type of Product(Camry Car, Tyres, Car Headlights etc), whatever form the Product class takes, they'll be able to extend the interface functions. Attributes like "adding an item to the store" ,  "selling an item" will be common to any product whether an actual car or car accessories  hence the need for interfaces. Interfaces is one way Go implements Polymorphism – one of the concept in Objected Oriented Programming.&lt;/p&gt;

&lt;p&gt;Here is the Store definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Store&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;AddProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
    &lt;span class="n"&gt;SellProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
    &lt;span class="n"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
    &lt;span class="n"&gt;OnSaleProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
    &lt;span class="n"&gt;SoldProductList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
    &lt;span class="n"&gt;OnSaleProductPriceTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="n"&gt;SoldProductPriceTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="n"&gt;DisplayStatus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step is to create Car, and Product class. Go does not support the actual Class keyword as in other languages like JavaScript, so we'll be using struct to define each of this classes. Like Class/Object in JavaScript and Dictionary in python, Go’s structs are typed collections of fields. They’re useful for grouping data together to form records.&lt;/p&gt;

&lt;p&gt;So in case of Car and Product collection, the class will be defined as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Id&lt;/span&gt;        &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;Name&lt;/span&gt;      &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;Model&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt;     &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="n"&gt;IsCarType&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="n"&gt;DateAdded&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;Color&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Id&lt;/span&gt;         &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="n"&gt;Item&lt;/span&gt;       &lt;span class="n"&gt;Car&lt;/span&gt;
    &lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="kt"&gt;uint64&lt;/span&gt;
    &lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;While declaring the Car and Product class, I capitalized "C" and "P" as well as the first letter for each of the field in each collection to make it accessible aside that package/file. Instead of "public" and "private" keyword like in other language, use of uppercase and lowercase for the first letter of any keyword is Go's way of encapsulation. Also, if you note, I used the "Car" struct as the type for "Item" in the "Product" struct, that's one way of implementing Inheritance(The Product class inherited the attributes of the Car class). &lt;/p&gt;

&lt;p&gt;Now let’s extend the methods we defined in the Store Interfaces, that way our program can know what each method is supposed to do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;soldProducts&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;AddProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
            &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;

            &lt;span class="k"&gt;break&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;strconv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Itoa&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rand&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Intn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1000000000&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
        &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Product added successfully!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;SellProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;//availableProducts := availProductList&lt;/span&gt;
    &lt;span class="n"&gt;isEqual&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;greaterThanOne&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
    &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;isEqual&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
            &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;greaterThanOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;isEqual&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;greaterThanOne&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;
            &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
                    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;
                    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;

                    &lt;span class="k"&gt;break&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
                    &lt;span class="k"&gt;break&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
            &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;soldProducts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
                    &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;

                    &lt;span class="k"&gt;break&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;productExists&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;soldProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;soldProducts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;QtyInStock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;soldProducts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;soldProducts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prod&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="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Sale successful!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;prod&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OnSaleProductPriceTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;totalPrice&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;totalPrice&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;totalPrice&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;DisplayStatus&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutOfStock&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Still on sale!"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Out of stock!"&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="n"&gt;status&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;SoldProductPriceTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;totalPrice&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;soldProducts&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;totalPrice&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalPrice&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;totalPrice&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;SoldProductList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;soldProducts&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;OnSaleProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;availableProducts&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So far we’ve been able to create a set of classes and functions that will help John record and track his sales. We learnt about basic types such as Struct and Interfaces as well as some OOP concepts in Go.&lt;br&gt;
Hopefully, I’ll write another article on other Go types like maps, pointers as well as how Go implements concepts like Constructors, Abstraction etc. Meanwhile do well to drop any questions on the comment section.&lt;/p&gt;

&lt;p&gt;Thank You.&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
