<?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: Dylan </title>
    <description>The latest articles on DEV Community by Dylan  (@dylantv).</description>
    <link>https://dev.to/dylantv</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%2F1434954%2Fb72927ab-6eb6-4a68-a203-bd186965d2a2.PNG</url>
      <title>DEV Community: Dylan </title>
      <link>https://dev.to/dylantv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dylantv"/>
    <language>en</language>
    <item>
      <title>Connecting the Future: Implementing an MCP Server Compatible with Clients like Claude and VSCode</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Sun, 06 Jul 2025 02:58:22 +0000</pubDate>
      <link>https://dev.to/dylantv/connecting-the-future-implementing-an-mcp-server-compatible-with-clients-like-claude-and-vscode-n70</link>
      <guid>https://dev.to/dylantv/connecting-the-future-implementing-an-mcp-server-compatible-with-clients-like-claude-and-vscode-n70</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Interoperability between AI tools and development environments is more important than ever. The Model Context Protocol (MCP) allows servers to securely interact with AI clients and dev tools. The 🎯 punkpeye/awesome-mcp-servers repository is a curated collection of production-ready and experimental MCP servers that demonstrate the wide range of what’s possible &lt;/p&gt;

&lt;p&gt;In this article, you’ll implement a simple MCP server that connects with clients like Claude Desktop or VSCode extensions, using the examples highlighted in the Punkpeye list as inspiration. You’ll also host a public example on GitHub to replicate the setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is MCP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MCP is an open, lightweight protocol for exchanging structured messages between a server and multiple clients. Servers can offer capabilities like accessing files, performing database queries, or integrating with external APIs. Clients—such as AI models, Claude Desktop, Cursor, and others—use MCP to trigger these actions &lt;/p&gt;

&lt;p&gt;The punkpeye/awesome-mcp-servers repo categorizes servers by functionality: browser automation, databases, developer tools, and more. This library shows that MCP servers can be used across various domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo MCP Server Overview&lt;/strong&gt;&lt;br&gt;
Example Repo: &lt;a href="https://github.com/punkpeye/awesome-mcp-servers" rel="noopener noreferrer"&gt;https://github.com/punkpeye/awesome-mcp-servers&lt;/a&gt;&lt;br&gt;
It uses the Node.js WebSocket API to create a lightweight MCP server. The server is inspired by and listed in the open-source collection: punkpeye/awesome-mcp-servers.&lt;/p&gt;

&lt;p&gt;MCP Server Capabilities&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepts incoming WebSocket connections.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Handles MCP-style messages in the format: # command: parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports basic commands:&lt;br&gt;
 -ping – replies with pong&lt;br&gt;
 -date – replies with current timestamp&lt;br&gt;
 -echo – echoes back the message&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can be extended with custom logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Testing the Server&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone or fork the base repo:
&lt;code&gt;git clone https://github.com/punkpeye/awesome-mcp-servers&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Or create your own fork and add this Node.js server:
&lt;code&gt;mkdir mcp-node-server
cd mcp-node-server
npm init -y
npm install ws
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create server.js:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', ws =&amp;gt; {
  ws.on('message', msg =&amp;gt; {
    const text = msg.toString();
    const match = text.match(/^#(\d+)\s+(\w+):\s*(.*)$/);
    if (!match) return ws.send('error: invalid format');

    const [, tag, command, params] = match;
    let response = '';

    switch (command) {
      case 'ping':
        response = `#${tag} pong: ${params}`;
        break;
      case 'date':
        response = `#${tag} date: ${new Date().toISOString()}`;
        break;
      case 'echo':
        response = `#${tag} echo: ${params}`;
        break;
      default:
        response = `#${tag} error: unknown command "${command}"`;
    }

    ws.send(response);
  });
});

console.log('MCP server running on ws://localhost:8080');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Testing with MCP Clients&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude Desktop&lt;/strong&gt;&lt;br&gt;
Connect Claude to ws://localhost:8080&lt;br&gt;
Send: #101 ping: Hello from Claude&lt;br&gt;
Response: #101 pong: Hello from Claude&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VSCode&lt;/strong&gt;&lt;br&gt;
Install the “WebSocket Client” extension.&lt;br&gt;
Open new request and connect:&lt;br&gt;
&lt;code&gt;ws://localhost:8080&lt;/code&gt;&lt;br&gt;
Send:&lt;br&gt;
&lt;code&gt;#200 echo: Hello VSCode&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This project demonstrates the practical implementation of an MCP server capable of communicating with various MCP-compatible clients, such as Claude Desktop and VSCode. By using a lightweight Node.js + WebSocket setup, we created a functional and extensible server that adheres to the MCP message structure.&lt;/p&gt;

&lt;p&gt;Through this work, we gained hands-on experience with:&lt;/p&gt;

&lt;p&gt;Designing message-driven protocols,&lt;/p&gt;

&lt;p&gt;Managing real-time bidirectional communication,&lt;/p&gt;

&lt;p&gt;Integrating AI agents and developer tools through a unified server interface.&lt;/p&gt;

&lt;p&gt;By referencing the public repository &lt;em&gt;punkpeye/awesome-mcp-servers&lt;/em&gt;, this project aligns with the wider MCP ecosystem and can serve as a foundation for more advanced use cases—such as automation, AI-driven development workflows, and plugin-style architectures.&lt;/p&gt;

&lt;p&gt;In short, this project proves that any developer can build their own MCP server to enhance and extend the capabilities of modern AI and code tools in a modular, flexible way.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring CSV Data Visually with Streamlit: A Simple Interactive Dashboard</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Tue, 29 Apr 2025 19:28:07 +0000</pubDate>
      <link>https://dev.to/dylantv/exploring-csv-data-visually-with-streamlit-a-simple-interactive-dashboard-1390</link>
      <guid>https://dev.to/dylantv/exploring-csv-data-visually-with-streamlit-a-simple-interactive-dashboard-1390</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Data exploration is one of the first and most critical steps in any data analysis process. But doing this through code or spreadsheets can be repetitive, slow, or hard to share with non-technical users. This is where Streamlit comes in.&lt;/p&gt;

&lt;p&gt;In this article, I’ll walk you through how to build and deploy a simple, interactive CSV Data Explorer using Streamlit. With this dashboard, you can upload a .csv file, preview its contents, explore statistics, and generate dynamic visualizations — all from a clean and fast web interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Streamlit?&lt;/strong&gt;&lt;br&gt;
Streamlit is an open-source Python library that turns data scripts into shareable web apps with minimal effort. It’s ideal for dashboards, quick data tools, and prototyping.&lt;/p&gt;

&lt;p&gt;Other great tools for data visualization include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dash (by Plotly) – flexible, ideal for production dashboards.&lt;/li&gt;
&lt;li&gt;Bokeh – powerful for interactive plotting.&lt;/li&gt;
&lt;li&gt;Gradio – often used in machine learning demos.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But Streamlit stands out for its simplicity and speed of development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of Our App&lt;/strong&gt;&lt;br&gt;
Our CSV Data Explorer app includes the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📂 Upload any .csv file from your computer&lt;/li&gt;
&lt;li&gt;👀 Preview the data in a table&lt;/li&gt;
&lt;li&gt;📊 View descriptive statistics (mean, std, min, max…)&lt;/li&gt;
&lt;li&gt;📈 Generate histograms and scatter plots&lt;/li&gt;
&lt;li&gt;💾 Export a copy of the data (optional)&lt;/li&gt;
&lt;li&gt;🖥️ Hosted live via Streamlit Cloud&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Demo: Using the App&lt;/strong&gt;&lt;br&gt;
Once deployed, the app allows the user to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upload a CSV file (e.g. ventas_tienda.csv)&lt;/li&gt;
&lt;li&gt;View the first few rows and basic statistics&lt;/li&gt;
&lt;li&gt;Choose numeric columns to visualize:&lt;/li&gt;
&lt;li&gt;Histogram (distribution + KDE curve)&lt;/li&gt;
&lt;li&gt;Scatter plot between two variables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Download the same file or modified data (optional feature)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s an example dataset:&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;Fecha,Producto,Categoria,Precio,Cantidad,Vendedor
2024-01-03,Camiseta,Indumentaria,15.99,3,Ana
2024-01-04,Jeans,Indumentaria,39.99,2,Carlos
2024-01-05,Sombrero,Accesorios,12.50,4,Lucía
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code (Core Logic)&lt;/strong&gt;&lt;br&gt;
Here’s a simplified version of the app (see full code in GitHub):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

st.title("📊 CSV Data Explorer")

uploaded_file = st.file_uploader("Upload a CSV file", type="csv")

if uploaded_file:
    df = pd.read_csv(uploaded_file)
    st.write("### Preview", df.head())
    st.write("### Descriptive Statistics", df.describe())

    st.write("## 📈 Histogram")
    column = st.selectbox("Choose a column", df.select_dtypes(include='number').columns)
    fig, ax = plt.subplots()
    sns.histplot(df[column], kde=True, ax=ax)
    st.pyplot(fig)

    st.write("## 📉 Scatter Plot")
    cols = df.select_dtypes(include='number').columns
    col1 = st.selectbox("X-axis", cols, index=0)
    col2 = st.selectbox("Y-axis", cols, index=1)
    fig2, ax2 = plt.subplots()
    sns.scatterplot(data=df, x=col1, y=col2, ax=ax2)
    st.pyplot(fig2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
This Streamlit app shows how easy it is to transform a simple Python script into an interactive web tool for data exploration. With just a few lines of code, users can upload CSV files, visualize their data, and extract insights—all without needing advanced technical knowledge.&lt;/p&gt;

&lt;p&gt;Streamlit makes data applications accessible, fast to build, and even easier to share. Whether you're a student, analyst, or developer, tools like this help bring data to life for everyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repository&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/DylanTapiaVargas999/Streamlit-" rel="noopener noreferrer"&gt;https://github.com/DylanTapiaVargas999/Streamlit-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live Demo&lt;/strong&gt;&lt;br&gt;
You can see the full project in action here:&lt;br&gt;
&lt;a href="https://hghguua5xkuqc7ypasslea.streamlit.app/" rel="noopener noreferrer"&gt;https://hghguua5xkuqc7ypasslea.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This live version allows you to upload your own CSV file, explore it interactively, and generate visualizations&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%2Fehvt8tt293pe8hfxdzyg.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%2Fehvt8tt293pe8hfxdzyg.png" alt="Image description" width="800" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Repository Pattern in the Context of Enterprise Architecture</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Tue, 29 Apr 2025 02:23:34 +0000</pubDate>
      <link>https://dev.to/dylantv/repository-pattern-in-the-context-of-enterprise-architecture-4eb8</link>
      <guid>https://dev.to/dylantv/repository-pattern-in-the-context-of-enterprise-architecture-4eb8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In the world of enterprise application development, efficient data management is crucial for success. Large-scale and scalable applications require an organized way to interact with databases and other storage systems. In this context, the Repository Pattern plays a critical role by providing an abstraction layer between the business logic and the data access logic.&lt;/p&gt;

&lt;p&gt;In this article, we will explore the Repository Pattern as part of an enterprise architecture, understanding its advantages and demonstrating its implementation in a CRUD API using Python, with tools such as FastAPI and SQLAlchemy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the Repository Pattern?&lt;/strong&gt;&lt;br&gt;
The Repository Pattern is a design pattern used to handle data access in an organized manner by decoupling business logic from the data access details. This pattern is highly popular in enterprise architectures due to its ability to promote modularity, maintainability, and effective unit testing.&lt;/p&gt;

&lt;p&gt;Key Benefits in an Enterprise Context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Abstraction and Encapsulation: Data access is performed through a repository that hides complex details such as SQL queries, making maintenance easier.&lt;/li&gt;
&lt;li&gt;Decoupling: Allows changing the database implementation or type without affecting the business logic.&lt;/li&gt;
&lt;li&gt;Testability: By using repositories, databases can be mocked or simulated in tests, making the testing process more efficient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Implementing the Repository Pattern in Enterprise Architecture&lt;/strong&gt;&lt;br&gt;
Scenario:&lt;br&gt;
Imagine we are developing an API to manage products in an enterprise. The Repository Pattern will allow us to abstract database interactions, making the application easier to scale and maintain in the future.&lt;/p&gt;

&lt;p&gt;Below, we will implement a basic CRUD application to manage products in the database using SQLAlchemy and FastAPI.&lt;/p&gt;

&lt;p&gt;Architecture Diagram:&lt;br&gt;
In an enterprise architecture, this pattern is integrated within a data persistence layer, which can be part of a layered architecture or a hexagonal architecture (also known as "ports and adapters").&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ API / Business Logic ] → [ Repository (Data Access Interface) ] → [ Database ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Code&lt;/strong&gt;&lt;br&gt;
1) Data Model&lt;br&gt;
We begin by creating the product model using SQLAlchemy, which will represent our database table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sqlalchemy import Column, Integer, String, Float
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Product(Base):
    __tablename__ = 'products'

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, index=True)
    price = Column(Float)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product: Represents a product in the database, where each product has an ID, name, and price.&lt;/li&gt;
&lt;li&gt;Base: We create the base for our data models using declarative_base().&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Repository&lt;br&gt;
The next step is to create the repository that will manage CRUD operations for the products. This repository acts as an abstraction layer, allowing the business logic to remain independent of the database queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sqlalchemy.orm import Session
from models import Product

class ProductRepository:
    def __init__(self, db: Session):
        self.db = db

    def create(self, name: str, price: float) -&amp;gt; Product:
        product = Product(name=name, price=price)
        self.db.add(product)
        self.db.commit()
        self.db.refresh(product)
        return product

    def get_by_id(self, product_id: int) -&amp;gt; Product:
        return self.db.query(Product).filter(Product.id == product_id).first()

    def update(self, product_id: int, name: str, price: float) -&amp;gt; Product:
        product = self.get_by_id(product_id)
        if product:
            product.name = name
            product.price = price
            self.db.commit()
            self.db.refresh(product)
        return product

    def delete(self, product_id: int) -&amp;gt; None:
        product = self.get_by_id(product_id)
        if product:
            self.db.delete(product)
            self.db.commit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
CRUD Methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create: Creates a new product in the database.&lt;/li&gt;
&lt;li&gt;get_by_id: Retrieves a product by its ID.&lt;/li&gt;
&lt;li&gt;update: Updates an existing product.&lt;/li&gt;
&lt;li&gt;delete: Deletes a product from the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This repository layer becomes a reusable service that can be easily adapted for different needs in the application.&lt;/p&gt;

&lt;p&gt;3) API - Integration with FastAPI&lt;br&gt;
Finally, we integrate this repository into an API built with FastAPI so we can interact with products via HTTP requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI, Depends
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from repositories.product_repository import ProductRepository
from models import Product, Base

DATABASE_URL = "sqlite:///./test.db"
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

app = FastAPI()

def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()

@app.post("/products/")
def create_product(name: str, price: float, db: Session = Depends(get_db)):
    repo = ProductRepository(db)
    return repo.create(name, price)

@app.get("/products/{product_id}")
def get_product(product_id: int, db: Session = Depends(get_db)):
    repo = ProductRepository(db)
    return repo.get_by_id(product_id)

@app.put("/products/{product_id}")
def update_product(product_id: int, name: str, price: float, db: Session = Depends(get_db)):
    repo = ProductRepository(db)
    return repo.update(product_id, name, price)

@app.delete("/products/{product_id}")
def delete_product(product_id: int, db: Session = Depends(get_db)):
    repo = ProductRepository(db)
    repo.delete(product_id)
    return {"message": "Product deleted successfully"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use FastAPI to create API routes that manage products.&lt;/li&gt;
&lt;li&gt;Each route calls the appropriate method from the repository to perform the corresponding operation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Testing and Validation&lt;/strong&gt;&lt;br&gt;
The Repository Pattern greatly facilitates unit testing in enterprise applications. By mocking or using in-memory databases, we can test the behavior of the API and repository without needing a real environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The Repository Pattern is essential for any enterprise application that seeks a clean, scalable, and maintainable architecture. Its ability to decouple data access from business logic improves flexibility and ease of maintenance for large systems.&lt;/p&gt;

&lt;p&gt;Implementing this pattern not only enhances the structure of the application but also enables more effective testing and reduces long-term complexity.&lt;/p&gt;

&lt;p&gt;You now have an implementation of the Repository Pattern in a CRUD API that adapts well to the needs of modern enterprise architecture&lt;/p&gt;

&lt;p&gt;Repository &lt;br&gt;
&lt;a href="https://github.com/DylanTapiaVargas999/mini_project_repository_pattern" rel="noopener noreferrer"&gt;https://github.com/DylanTapiaVargas999/mini_project_repository_pattern&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Applying Software Design Principles in an Order Management System</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Mon, 28 Apr 2025 14:21:18 +0000</pubDate>
      <link>https://dev.to/dylantv/applying-software-design-principles-in-an-order-management-system-55l8</link>
      <guid>https://dev.to/dylantv/applying-software-design-principles-in-an-order-management-system-55l8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In the world of software development, design principles are essential for creating robust, scalable, and maintainable applications. These principles guide developers in making architectural decisions that not only solve immediate problems but also optimize code quality and efficiency in the long term. In this article, we will explore some of the most important software design principles and how they apply to a real-world case: building an order management system.&lt;/p&gt;

&lt;p&gt;Using a practical example, we will demonstrate how these principles are implemented in Python, showcasing the importance of separation of concerns, modularity, dependency inversion, and code testing throughout the process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Software Design Principles&lt;/strong&gt;&lt;br&gt;
There are several fundamental software design principles, among which the following are most important:&lt;/p&gt;

&lt;p&gt;-Single Responsibility Principle (SRP).&lt;br&gt;
-Open/Closed Principle (OCP).&lt;br&gt;
-Liskov Substitution Principle (LSP).&lt;br&gt;
-Interface Segregation Principle (ISP).&lt;br&gt;
-Dependency Inversion Principle (DIP).&lt;/p&gt;

&lt;p&gt;Throughout this article, we will apply these principles to our order management system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case Study: Order Management System&lt;/strong&gt;&lt;br&gt;
We will develop a simple system to handle customer orders, process payments, and send confirmation emails. As we implement each part, we will apply the design principles mentioned above to demonstrate their effectiveness.&lt;/p&gt;

&lt;p&gt;1) Single Responsibility Principle (SRP)&lt;br&gt;
The Single Responsibility Principle states that each class should have only one reason to change, meaning it should be responsible for a single task. In our system, each class has a clear and unique responsibility:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order: Represents the order, storing customer details, products, and the total amount.&lt;/li&gt;
&lt;li&gt;OrderRepository: Responsible for saving orders to a file.&lt;/li&gt;
&lt;li&gt;PaymentService: Processes payment for the order.&lt;/li&gt;
&lt;li&gt;EmailService: Responsible for sending confirmation emails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each class has a single responsibility, making the code easier to maintain and understand.&lt;/p&gt;

&lt;p&gt;2) Open/Closed Principle (OCP)&lt;br&gt;
The Open/Closed Principle states that a class should be open for extension but closed for modification. This means we should be able to add new functionality without modifying existing classes.&lt;/p&gt;

&lt;p&gt;In our example, if we wanted to add a new payment method, such as cryptocurrency payments, we could extend the PaymentService class by creating a new class like CryptoPaymentService, without modifying the original PaymentService class. This approach allows us to extend functionality without breaking the existing code.&lt;/p&gt;

&lt;p&gt;3) Dependency Inversion Principle (DIP)&lt;br&gt;
The Dependency Inversion Principle states that high-level modules should not depend on low-level modules, but rather on abstractions. Instead of having our OrderRepository class directly depend on a specific file implementation, we could create an interface or base class for order storage, such as OrderStorage. Then, OrderRepository would depend on this interface, making the system more flexible and extensible.&lt;/p&gt;

&lt;p&gt;4) Modularity and Unit Testing&lt;br&gt;
Modularity is a key principle that helps us organize the code so that different parts of the application can evolve independently. Additionally, unit testing ensures that each module behaves as expected.&lt;/p&gt;

&lt;p&gt;In our system, classes are clearly separated, and each one can be independently tested. For example, we can write unit tests to verify that payment processing works correctly without needing to run the entire system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Explanation&lt;/strong&gt;&lt;br&gt;
Let's now see how we've implemented these ideas in the code.&lt;/p&gt;

&lt;p&gt;Class Order (Single Responsibility)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Order:
    def __init__(self, customer_name, customer_email, items, total_amount):
        self.customer_name = customer_name  # Customer's name
        self.customer_email = customer_email  # Customer's email
        self.items = items  # List of products in the order
        self.total_amount = total_amount  # Total order amount
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
The Order class has the sole responsibility of storing order details. It contains attributes like the customer's name, email, list of items, and total amount. In line with the Single Responsibility Principle (SRP), this class does nothing more than store this data.&lt;/p&gt;

&lt;p&gt;Class OrderRepository (Open/Closed)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class OrderRepository:
    def save(self, order):
        with open("orders.txt", "a") as f:
            f.write(f"Customer: {order.customer_name}, Email: {order.customer_email}, Items: {order.items}, Total: ${order.total_amount}\n")
        print(f"Order for {order.customer_name} saved.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
The OrderRepository class is responsible for saving orders to a text file. If we wanted to add another storage method, such as using a database, we would simply create a new class (like DatabaseOrderRepository) that also implements a save() method. This way, our code is open for extension (adding more repositories) but closed for modification.&lt;/p&gt;

&lt;p&gt;Class PaymentService (Single Responsibility)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class PaymentService:
    def process_payment(self, order):
        print(f"Processing payment of ${order.total_amount} for {order.customer_name}. Payment Successful!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
The PaymentService class is solely responsible for processing payments. It doesn't do other tasks like sending emails or saving data to a file, which is consistent with the Single Responsibility Principle (SRP).&lt;/p&gt;

&lt;p&gt;Class EmailService (Single Responsibility)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class EmailService:
    def send_confirmation_email(self, order):
        print(f"Sending confirmation email to {order.customer_email} for the order of {len(order.items)} items.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
The EmailService class is responsible only for sending confirmation emails. This modular approach keeps the code clean and easy to understand, aligning with the Single Responsibility Principle (SRP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit Testing&lt;/strong&gt;&lt;br&gt;
Unit testing allows us to ensure that each component of the system works as expected. Using the unittest module, we write tests that validate the functionality of each class.&lt;/p&gt;

&lt;p&gt;Example Test for OrderRepository Class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import unittest
from unittest.mock import patch, mock_open
from order import Order
from order_repository import OrderRepository

class TestOrderRepository(unittest.TestCase):
    def test_save_order(self):
        order = Order("John Doe", "john@example.com", ["Laptop", "Mouse"], 1500.0)
        repo = OrderRepository()

        with patch("builtins.open", mock_open()) as mocked_file:
            repo.save(order)
            mocked_file.assert_called_once_with("orders.txt", "a")
            handle = mocked_file()
            handle.write.assert_called_once()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
In this test, we verify that the save() method of OrderRepository correctly opens the orders.txt file and saves the order details. We use mocking to simulate file interactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Software design is a critical discipline that guides the creation of scalable, maintainable, and flexible applications. In this article, we applied some of the most important software design principles to an order management system. From single responsibility to dependency inversion, these principles ensure that our system is easy to understand, test, and extend in the future.&lt;/p&gt;

&lt;p&gt;Implementing these principles effectively not only improves code quality but also prepares developers to handle more complex challenges and build robust applications.&lt;/p&gt;

&lt;p&gt;You can find the complete code for this project in my GitHub repository:&lt;br&gt;
&lt;a href="https://github.com/DylanTapiaVargas999/order_management_system" rel="noopener noreferrer"&gt;https://github.com/DylanTapiaVargas999/order_management_system&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Comparison of Testing Management Tools: GitLab Pipelines, GitHub Actions, and Jenkins</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Wed, 11 Dec 2024 22:33:25 +0000</pubDate>
      <link>https://dev.to/dylantv/comparison-of-testing-management-tools-gitlab-pipelines-github-actions-and-jenkins-35f7</link>
      <guid>https://dev.to/dylantv/comparison-of-testing-management-tools-gitlab-pipelines-github-actions-and-jenkins-35f7</guid>
      <description>&lt;p&gt;1) GitLab Pipelines&lt;br&gt;
Description:&lt;br&gt;
GitLab Pipelines is a complete CI/CD solution integrated within GitLab. It allows you to automate the entire software development lifecycle, from code compilation to deployment in production. What makes GitLab interesting is that everything is centralized in one platform, which makes it easier to manage source code, testing, and deployments.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native integration with GitLab repositories.&lt;/li&gt;
&lt;li&gt;Pipeline configuration through a YAML file (.gitlab-ci.yml).&lt;/li&gt;
&lt;li&gt;Scalability and flexibility for both small and large projects.&lt;/li&gt;
&lt;li&gt;Integrated monitoring of pipeline execution.&lt;/li&gt;
&lt;li&gt;Enables automated tests before each deployment.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stages:
  - build
  - test
  - deploy

build-job:
  stage: build
  script:
    - echo "Building the project..."

test-job:
  stage: test
  script:
    - echo "Running tests..."
    - pytest

deploy-job:
  stage: deploy
  script:
    - echo "Deploying to production..."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2) GitHub Actions&lt;/p&gt;

&lt;p&gt;Description:&lt;br&gt;
GitHub Actions is an automation tool integrated within GitHub that allows you to create custom workflows. These workflows can be triggered by events, such as a push or a pull request, and are highly configurable due to their YAML format.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;p&gt;Native integration with GitHub.&lt;br&gt;
Marketplace with predefined actions for various tasks (tests, deployments, code analysis, etc.).&lt;br&gt;
Easy integration with external services like Docker, AWS, Azure, and others.&lt;br&gt;
Support for execution matrices, which allows running tests in different environments and versions.&lt;br&gt;
Code Example (workflow.yml):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: CI Pipeline

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x

      - name: Run tests
        run: |
          python -m unittest discover
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Jenkins&lt;br&gt;
Description:&lt;br&gt;
Jenkins is one of the oldest and most flexible CI/CD tools. It is open-source and offers a wide range of plugins to suit various integration and continuous deployment needs.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;p&gt;Extensive community and plugin ecosystem.&lt;br&gt;
Great flexibility for configuring complex pipelines through its web interface or Groovy files.&lt;br&gt;
Ideal for large projects and teams requiring advanced customization.&lt;br&gt;
Supports multiple programming languages and execution environments.&lt;br&gt;
Code Example (Jenkinsfile):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'echo "Building the project..."'
            }
        }
        stage('Test') {
            steps {
                sh 'echo "Running tests..."'
                sh 'pytest'
            }
        }
        stage('Deploy') {
            steps {
                sh 'echo "Deploying..."'
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quick Comparison:&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%2Fbfgcasls59u015sa5d1z.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%2Fbfgcasls59u015sa5d1z.PNG" alt="Image description" width="617" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitLab Pipelines is ideal for teams already using GitLab as their primary platform, offering an all-in-one solution.&lt;/li&gt;
&lt;li&gt;GitHub Actions stands out due to its native integration with GitHub and flexibility, especially with the large variety of actions available in its marketplace.&lt;/li&gt;
&lt;li&gt;Jenkins is a powerful option for teams with complex or customized needs, but it may be more difficult to configure and maintain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These tools offer similar features, but each has its own focus and advantages depending on your specific needs and the platform you're already using.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring Top API Testing Frameworks: Real-World Examples and Applications</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Thu, 21 Nov 2024 16:12:07 +0000</pubDate>
      <link>https://dev.to/dylantv/exploring-top-api-testing-frameworks-real-world-examples-and-applications-3j9a</link>
      <guid>https://dev.to/dylantv/exploring-top-api-testing-frameworks-real-world-examples-and-applications-3j9a</guid>
      <description>&lt;p&gt;Nowadays, web-based applications are essential for interoperability between systems. APIs (Application Programming Interfaces) have become the bridge connecting different platforms and services, enabling data exchange. However, to ensure that these APIs function efficiently and without errors, thorough testing is crucial. There are various frameworks specifically designed to facilitate API testing, and each offers unique features that can cater to different needs. Today, we will explore some of the most popular API testing frameworks, along with real-world examples.&lt;/p&gt;

&lt;p&gt;1) Katalon Studio&lt;br&gt;
Es una herramienta de prueba integral que soporta tanto pruebas de API como de aplicaciones web y móviles. Ofrece una interfaz fácil de usar, adecuada tanto para testers técnicos como no técnicos. Su integración con CI/CD facilita la automatización.&lt;br&gt;
Ejemplo: Usando Katalon, podemos enviar una solicitud GET a una API y verificar que la respuesta tenga un código de estado 200 y contenga datos específicos.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def response = WS.sendRequest(findTestObject('API/GET_Example'))
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, 'data.id', '1')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) SoapUI&lt;br&gt;
Is known for its robustness, especially in testing SOAP and REST APIs. It allows functional, security, and performance testing. Its graphical interface makes it easy to create tests without coding.&lt;br&gt;
Example: In SoapUI, we configure a GET request to the API and verify the status code and a property of a user in the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;step type="RestRequest" name="GET Request"&amp;gt;
    &amp;lt;properties&amp;gt;
        &amp;lt;property name="RequestType" value="GET"/&amp;gt;
        &amp;lt;property name="Endpoint" value="https://jsonplaceholder.typicode.com/users/1"/&amp;gt;
    &amp;lt;/properties&amp;gt;
&amp;lt;/step&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Postman&lt;br&gt;
Is one of the most popular tools for API testing, thanks to its ease of use and ability to organize requests into collections. It supports automated testing with JavaScript and integrates perfectly into CI/CD pipelines.&lt;br&gt;
Example: In Postman, we can validate both the status code and the response content using test scripts written in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm.test("Check response status", function () {
    pm.response.to.have.status(200);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) Tricentis Tosca&lt;br&gt;
Is a model-based test automation platform designed to accelerate testing in Agile and DevOps environments. It supports a wide range of protocols and can be used for API testing across mobile, web, and packaged apps.&lt;br&gt;
Example: In Tosca, test steps can be defined to send requests to an API and validate responses visually through a no-code approach.&lt;/p&gt;

&lt;p&gt;5) JMeter &lt;br&gt;
Is widely used for performance and load testing, although it also supports basic functional API testing.&lt;br&gt;
Example: In JMeter, we can create a test plan that simulates multiple users making requests to an API, ensuring that the response is as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;HTTPRequest sampler&amp;gt;
    &amp;lt;method&amp;gt;GET&amp;lt;/method&amp;gt;
    &amp;lt;url&amp;gt;https://jsonplaceholder.typicode.com/users&amp;lt;/url&amp;gt;
&amp;lt;/HTTPRequest&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6) Rest-Assured &lt;br&gt;
Is a Java-based framework widely used for REST API testing. With its BDD (Behavior-Driven Development) syntax, it allows tests to be written in a natural and readable way.&lt;br&gt;
Example: Rest-Assured simplifies sending HTTP requests and validating responses.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;given().pathParam("userId", 1)
.when().get("/users/{userId}")
.then().statusCode(200)
      .body("name", equalTo("Leanne Graham"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7) Swagger &lt;br&gt;
Is not only a set of tools for API documentation but also allows testing directly from its interface. Through Swagger Inspector, we can validate the responses of APIs against defined schemas.&lt;br&gt;
Example: We use Swagger Inspector to validate that an API response matches the schema defined in the Swagger JSON file.&lt;/p&gt;

&lt;p&gt;Each framework has its own approach and advantages depending on the specific needs of the project. From tools like Postman and Katalon Studio, which facilitate testing with graphical interfaces, to more robust options like JMeter for performance testing, each of these tools serves a different purpose in the API testing process. The choice will depend on the team’s requirements, the company’s infrastructure, and the type of API that needs to be tested. These tools ensure that APIs are reliable, secure, and scalable.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Applying Bandit: A SAST Tool for Python</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Wed, 02 Oct 2024 15:34:23 +0000</pubDate>
      <link>https://dev.to/dylantv/applying-bandit-a-sast-tool-for-python-4el1</link>
      <guid>https://dev.to/dylantv/applying-bandit-a-sast-tool-for-python-4el1</guid>
      <description>&lt;p&gt;Introduction to Bandit&lt;br&gt;
Bandit is an open-source static application security testing (SAST) tool designed to identify security vulnerabilities in Python code. As part of the OpenStack Security ecosystem, it scans Python projects for common vulnerabilities, helping developers address security issues early in the development process.&lt;/p&gt;

&lt;p&gt;Key Features&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open-source and Free: Bandit is free to use, making it accessible to both individual developers and organizations.&lt;/li&gt;
&lt;li&gt;Thorough Code Scanning: It examines code for vulnerabilities such as code injections, insecure cryptographic use, and improper data handling.&lt;/li&gt;
&lt;li&gt;Ease of Use: Bandit integrates easily into development workflows and CI/CD pipelines.&lt;/li&gt;
&lt;li&gt;Specific Vulnerability Detection: It identifies issues like SQL injection, insecure file handling, and weak cryptographic practices.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How Bandit Works&lt;br&gt;
Bandit scans Python projects using built-in plugins that detect vulnerability patterns. Running Bandit is simple via the command line:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bandit -r project_directory/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Benefits&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Early Vulnerability Prevention: By identifying security issues in the early stages of development, Bandit enables developers to fix vulnerabilities before they reach production, reducing both costs and associated risks.&lt;/li&gt;
&lt;li&gt;Improved Code Quality: Regular use of Bandit encourages secure development practices, educating developers on common vulnerabilities and how to avoid them.&lt;/li&gt;
&lt;li&gt;Seamless Integration: Bandit can easily integrate into CI/CD pipelines, allowing applications to be scanned automatically at each phase of development.&lt;/li&gt;
&lt;li&gt;Cost Efficiency: As an open-source, free tool, Bandit provides an accessible solution for teams of all sizes, avoiding the need for expensive commercial tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limitations&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python-specific Coverage: Bandit is designed exclusively for Python projects, meaning it cannot analyze code written in other programming languages.&lt;/li&gt;
&lt;li&gt;False Positives: Like most SAST tools, Bandit may report vulnerabilities that are not truly exploitable, potentially creating extra work for developers.&lt;/li&gt;
&lt;li&gt;Configuration Adjustments: Some default rules may require tweaking to better suit the specific needs of a project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Bandit is a powerful and easy-to-use tool for improving the security of Python code. Its open-source nature, combined with strong vulnerability detection, makes it an essential tool for any Python developer looking to prevent security issues early in the development lifecycle.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is the Repository Pattern?</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Tue, 01 Oct 2024 18:08:59 +0000</pubDate>
      <link>https://dev.to/dylantv/what-is-the-repository-pattern-2h1b</link>
      <guid>https://dev.to/dylantv/what-is-the-repository-pattern-2h1b</guid>
      <description>&lt;p&gt;The repository pattern aims to decouple the code that handles data persistence from business logic by storing the data access code in a separate layer. This way, application services do not need to know how data is being stored or retrieved. This separation also allows changing the implementation of data access without affecting the upper layers.&lt;/p&gt;

&lt;p&gt;The repository pattern generally involves three main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The repository interface&lt;/li&gt;
&lt;li&gt;The repository implementation&lt;/li&gt;
&lt;li&gt;The entity model&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Defining the Repository Interface
The repository interface specifies the operations that can be performed on the entity. Generally, these operations include the CRUD operations (Create, Read, Update, and Delete).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below is an example of a repository interface for the Product entity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface IProductRepository
{
    IEnumerable&amp;lt;Product&amp;gt; GetAll();
    Product GetById(int id);
    void Add(Product product);
    void Update(Product product);
    void Delete(int id);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The interface defines the basic operations we can perform on the Product entity. For example, GetAll() returns a list of all products, GetById() returns a specific product by its ID, and the Add(), Update(), and Delete() functions handle creating, updating, and deleting products, respectively.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Repository Implementation
The repository implementation is responsible for providing the logic that interacts with the database. In this case, we will use Entity Framework to manage database access efficiently and avoid writing SQL queries manually.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the repository implementation for Product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductRepository : IProductRepository
{
    private readonly ApplicationDbContext _context;

    public ProductRepository(ApplicationDbContext context)
    {
        _context = context;
    }

    public IEnumerable&amp;lt;Product&amp;gt; GetAll()
    {
        return _context.Products.ToList();
    }

    public Product GetById(int id)
    {
        return _context.Products.Find(id);
    }

    public void Add(Product product)
    {
        _context.Products.Add(product);
        _context.SaveChanges();
    }

    public void Update(Product product)
    {
        _context.Products.Update(product);
        _context.SaveChanges();
    }

    public void Delete(int id)
    {
        var product = _context.Products.Find(id);
        if (product != null)
        {
            _context.Products.Remove(product);
            _context.SaveChanges();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the ProductRepository class implements the IProductRepository interface and uses a database context provided by Entity Framework, ApplicationDbContext, to perform CRUD operations. This reduces the need to write SQL queries directly, simplifying the interaction with the database.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Entity Model
The entity model represents the data that will be stored and manipulated. In this case, Product is our entity, corresponding to the Products table in the database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the entity model for Product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    public string Description { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each instance of the Product class represents a record in the Products table. The properties of the class correspond to the columns of the table.&lt;/p&gt;

&lt;p&gt;Using the Repository Pattern&lt;br&gt;
With the repository interface, repository implementation, and entity model in place, we can now use the repository in our services or controllers to perform data access operations without worrying about the database implementation details.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Implementing a Serverless Application with Azure Functions</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Thu, 04 Jul 2024 22:21:26 +0000</pubDate>
      <link>https://dev.to/dylantv/implementing-a-serverless-application-with-azure-functions-9bn</link>
      <guid>https://dev.to/dylantv/implementing-a-serverless-application-with-azure-functions-9bn</guid>
      <description>&lt;p&gt;In this article, we will walk through step-by-step how to create and deploy a serverless function using Azure Functions. We'll use a practical example of an HTTP function that greets users based on the name provided in the request.&lt;/p&gt;

&lt;p&gt;Step 1: Creating the Function in Azure Functions&lt;/p&gt;

&lt;p&gt;1) Access Azure Portal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign in to portal.azure.com using your Azure credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Create a New Resource:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on "+ Create a resource" in the upper left corner.
-Search for and select "Azure Function" in the Azure marketplace.
-Configure basic details like subscription, resource group, function name, and location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3) Function Configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choose the consumption plan to leverage serverless execution.&lt;/li&gt;
&lt;li&gt;Select the "HTTP trigger" template to start with a basic HTTP trigger.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4) Create the Function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on "Review and create" and then "Create" to deploy the function in Azure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 2: Implementing the Function Code&lt;br&gt;
1) Function Development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement the following code in your function. This code will handle GET and POST requests to greet the user based on the provided name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;csharp&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

public static class HttpTriggerExample
{
    [FunctionName("HttpTriggerExample")]
    public static async Task&amp;lt;IActionResult&amp;gt; Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        log.LogInformation("C# HTTP trigger function processed a request.");

        string name = req.Query["name"];

        string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
        dynamic data = JsonConvert.DeserializeObject(requestBody);
        name = name ?? data?.name;

        return name != null
            ? (ActionResult)new OkObjectResult($"Hello, {name}")
            : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
    }
}

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

&lt;/div&gt;



&lt;p&gt;3) Code Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The HttpTriggerExample function handles incoming HTTP requests.&lt;/li&gt;
&lt;li&gt;It retrieves the name from query parameters (req.Query["name"]) or from the request body if provided in JSON format.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 3: Configuring Triggers&lt;br&gt;
1) HTTP Trigger Configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Azure Functions portal, select your function.&lt;/li&gt;
&lt;li&gt;Go to the "Triggers" tab and click on "+ Add trigger".&lt;/li&gt;
&lt;li&gt;Choose "HTTP trigger" and configure details like HTTP method (GET, POST, etc.) and authorization options if needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;br&gt;
In this article, we explored how to create a serverless application using Azure Functions. You learned how to configure an HTTP trigger, implement code to handle requests, and how to test your function using various HTTP request tools. Azure Functions simplifies the development and deployment of serverless applications, offering automatic scalability and a consumption-based pricing model. Experiment with different triggers and functions to build efficient and scalable applications in Azure.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring Different API Architecture Styles: Sockets</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Wed, 12 Jun 2024 15:56:57 +0000</pubDate>
      <link>https://dev.to/dylantv/exploring-different-api-architecture-styles-graphql-grpc-sockets-and-soap-50ho</link>
      <guid>https://dev.to/dylantv/exploring-different-api-architecture-styles-graphql-grpc-sockets-and-soap-50ho</guid>
      <description>&lt;p&gt;Sockets provide a way for bidirectional real-time communication between a client and a server. They are widely used in chat applications, online games, and live data streaming. Here's an example of how to implement a simple chat server using sockets in Node.js:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const net = require('net');

const server = net.createServer(socket =&amp;gt; {
   console.log('Client connected');

   socket.on('data', data =&amp;gt; {
     console.log('Message received:', data.toString());
     socket.write('Message received');
   });

   socket.on('end', () =&amp;gt; {
     console.log('Client disconnected');
   });
});

server.listen(3000, () =&amp;gt; {
   console.log('Chat server running on port 3000');
});

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

&lt;/div&gt;



&lt;p&gt;In this example, we create a socket server that listens on port 3000 and handles client connections. When a client sends a message, the server receives it and responds with a confirmation message.&lt;/p&gt;

&lt;p&gt;Socket Applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real-time applications&lt;/li&gt;
&lt;li&gt;Push notifications&lt;/li&gt;
&lt;li&gt;Remote monitoring&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Functional Programming with Functors, Monads, and Promises</title>
      <dc:creator>Dylan </dc:creator>
      <pubDate>Thu, 18 Apr 2024 21:51:25 +0000</pubDate>
      <link>https://dev.to/dylantv/functional-programming-with-functors-monads-and-promises-4foi</link>
      <guid>https://dev.to/dylantv/functional-programming-with-functors-monads-and-promises-4foi</guid>
      <description>&lt;p&gt;Introduction:&lt;br&gt;
Functional programming is a paradigm that emphasizes the use of immutable data and pure functions. It provides a set of powerful tools and concepts for writing clean, concise, and composable code. In this article, we will explore three fundamental concepts in functional programming: functors, monads, and promises. We will explain what they are and provide code examples for each of them.&lt;/p&gt;

&lt;p&gt;Functors:&lt;br&gt;
Functors are objects or data types on which mapping can be applied. They allow us to apply a function to the values they contain while maintaining the structure. In functional programming, the map function is commonly associated with functors.&lt;br&gt;
Code Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Array Functor
const products = [
  { name: 'T-shirt', price: 20 },
  { name: 'Pants', price: 50 },
  { name: 'Shoes', price: 80 }
];

const prices = products.map((product) =&amp;gt; product.price);
const totalPrice = prices.reduce((total, price) =&amp;gt; total + price, 0);
console.log(totalPrice);
// Output: 150
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use the Array functor and the map function to apply a function that extracts the price of each product in the list. Then, we use the reduce function to sum up all the prices and obtain the total price. The result is 150, which is the sum of the prices of all products in the list.&lt;/p&gt;

&lt;p&gt;Monads:&lt;br&gt;
Monads are a higher-level abstraction that extends the concept of functors. They allow us to chain operations while handling possible side effects. Monads provide methods like flatMap or bind to compose computations sequentially.&lt;br&gt;
Code Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Maybe Monad
const Maybe = (value) =&amp;gt; ({
  map: (fn) =&amp;gt; (value ? Maybe(fn(value)) : Maybe(null)),
  flatMap: (fn) =&amp;gt; (value ? fn(value) : Maybe(null)),
  value,
});

// Function to get a user from the database
const getUser = (id) =&amp;gt; {
  // Simulating user retrieval
  const database = {
    1: { id: 1, name: 'John Doe', age: 30 },
    2: { id: 2, name: 'Jane Smith', age: 25 },
  };

  const user = database[id];
  return Maybe(user);
};

const user = getUser(1);
const uppercasedName = user
  .flatMap((u) =&amp;gt; Maybe(u.name))
  .map((name) =&amp;gt; name.toUpperCase())
  .value;

console.log(uppercasedName);
// Output: "JOHN DOE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use the Maybe monad to handle possible null values when retrieving a user from the database. The getUser function returns a Maybe monad that contains the user if it exists or a null value if it doesn't.&lt;/p&gt;

&lt;p&gt;Then, we chain multiple operations using the flatMap method to get the user's name and the map method to convert it to uppercase. The beauty of using monads is that we can safely chain these operations without worrying about null value cases.&lt;/p&gt;

&lt;p&gt;In the end, we get the user's name in uppercase as a result. If the user doesn't exist in the database, the result would be null.&lt;/p&gt;

&lt;p&gt;Promises:&lt;br&gt;
Promises are a mechanism for handling asynchronous operations in a functional manner. They represent the eventual completion (or failure) of an asynchronous operation and provide a way to chain asynchronous actions.&lt;br&gt;
Code Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function simulating an asynchronous operation
const asyncOperation = () =&amp;gt; {
  return new Promise((resolve, reject) =&amp;gt; {
    setTimeout(() =&amp;gt; {
      const result = Math.random() &amp;gt;= 0.5; // Simulating success or failure
      if (result) {
        resolve('Operation successful');
      } else {
        reject('Error: Operation failed');
      }
    }, 2000);
  });
};

// Calling the asynchronous operation
asyncOperation()
  .then((message) =&amp;gt; {
    console.log(message);
  })
  .catch((error) =&amp;gt; {
    console.error(error);
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the asyncOperation function simulates an operation that completes after 2 seconds. The operation has a random result: a 50% chance of success and a 50% chance of failure.&lt;/p&gt;

&lt;p&gt;We use a promise to wrap the asynchronous operation. Inside the promise, we resolve the promise with a success message if the result is true, or reject it with an error message if the result is false.&lt;/p&gt;

&lt;p&gt;Then, we call the asynchronous operation using the then and catch syntax of promises. If the operation is successful, then will execute and print the success message to the console. If the operation fails, catch will execute and print the error message to the console.&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
Functors, monads, and promises are essential concepts in functional programming. Functors allow us to apply functions to values while maintaining their structure. Monads extend functors by providing a way to chain computations and handle side effects. Promises allow us to handle asynchronous operations in a functional manner. By understanding these concepts and using them in our code, we can write more expressive, modular, and maintainable functional programs.&lt;/p&gt;

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