<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shubham Dhumal on Medium]]></title>
        <description><![CDATA[Stories by Shubham Dhumal on Medium]]></description>
        <link>https://medium.com/@dhumalshubham436?source=rss-6eaa783edecc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TLFuEMyeCXesoVsov3zXbA.png</url>
            <title>Stories by Shubham Dhumal on Medium</title>
            <link>https://medium.com/@dhumalshubham436?source=rss-6eaa783edecc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:59:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dhumalshubham436/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Repository Pattern [.Net Recipe Part-2]]]></title>
            <link>https://medium.com/@dhumalshubham436/repository-pattern-net-recipe-part-2-0e5836c79262?source=rss-6eaa783edecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e5836c79262</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[repository-pattern]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Shubham Dhumal]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 19:41:07 GMT</pubDate>
            <atom:updated>2024-07-10T19:42:01.416Z</atom:updated>
            <content:encoded><![CDATA[<p>This continuation of my first blog for <a href="https://medium.com/@dhumalshubham436/net-recipe-part-1-ffa78778939d">.Net Core Recipe Part-1</a> getting an understanding of the Repository Pattern.</p><p>A design pattern called the repository pattern divides the business logic from the data access logic by offering a single point of access to data.</p><h3>Key Concepts</h3><p><strong>Repository Interface:</strong></p><ol><li>Definition: A contract or blueprint that defines the operations that can be performed on a specific type of data (entity).</li><li>Purpose: It standardizes how your application interacts with the data, abstracting away the details of how the data is stored and retrieved.</li><li>Example: For a User entity, the repository interface would typically include methods like findById, findAll, save, update, and delete.</li></ol><p><strong>Repository Implementation:</strong></p><ol><li>Definition: The concrete implementation of the repository interface, which contains the actual logic for interacting with the data source (e.g., database, file system).</li><li>Purpose: It encapsulates the data access logic, including CRUD operations and any additional queries specific to the entity.</li><li>Example: In a relational database scenario, the “UserRepository“ implementation would include methods that translate to SQL queries or ORM (Object-Relational Mapping) operations to fetch, update, delete, and save user records.</li></ol><p><strong>Unit of Work (Optional):</strong></p><ol><li>Definition: A pattern that manages transactions involving multiple repositories, ensuring consistency and integrity across operations.</li><li>Purpose: It coordinates the actions of multiple repositories that need to work together within a single transaction context.</li><li>Example: If your application needs to create a new user record and update related records (like roles or permissions), the unit of work pattern ensures that these operations either succeed or fail together, maintaining database consistency.</li></ol><h3>Models</h3><pre>public class Product<br>    {<br>        public int Id { get; set; }<br>        public string Name { get; set; }<br>        public decimal Price { get; set; }<br>    }</pre><h3>Repository Interface</h3><pre>public interface IProductRepository<br>    {<br>        Task&lt;IEnumerable&lt;Product&gt;&gt; GetAllAsync();<br>        Task AddAsync(Product product);<br>    }</pre><h3>Repository Implementation</h3><pre>public class ProductRepository : IProductRepository<br>    {<br>        private readonly AppDbContext _context;<br>        public ProductRepository(AppDbContext context) =&gt; _context = context;<br>        public async Task&lt;IEnumerable&lt;Product&gt;&gt; GetAllAsync() =&gt; await _context.Products.ToListAsync();<br>        public async Task AddAsync(Product product) { _context.Products.Add(product); await _context.SaveChangesAsync(); }<br>    }</pre><h3>Database Context and Program. cs</h3><pre>// Database Context<br>    public class AppDbContext : DbContext<br>    {<br>        public DbSet&lt;Product&gt; Products { get; set; }<br>        public AppDbContext(DbContextOptions&lt;AppDbContext&gt; options) : base(options) { }<br>    }</pre><pre> // Main Program<br>    class Program<br>    {<br>        static async Task Main(string[] args)<br>        {<br>            var serviceProvider = new ServiceCollection()<br>                .AddDbContext&lt;AppDbContext&gt;(opt =&gt; opt.UseInMemoryDatabase(&quot;ProductsDb&quot;))<br>                .AddScoped&lt;IProductRepository, ProductRepository&gt;()<br>                .BuildServiceProvider();</pre><pre>            var productRepository = serviceProvider.GetService&lt;IProductRepository&gt;();</pre><pre>            var product = new Product { Name = &quot;Laptop&quot;, Price = 999.99m };<br>            await productRepository.AddAsync(product);<br>            Console.WriteLine(&quot;Product added.&quot;);</pre><pre>            var products = await productRepository.GetAllAsync();<br>            foreach (var p in products) Console.WriteLine($&quot;Product: {p.Name}, Price: {p.Price}&quot;);<br>        }<br>    }</pre><p><strong>Common Pitfalls and How to Avoid Them</strong></p><ul><li>Overloading the Repository Avoid making your repository methods do too many things. Keep it focused on data access concerns.</li><li>For complex operations, consider using services or domain logic to handle these concerns, while keeping the repository clean and straightforward.</li><li>Ignoring Asynchronous Programming Ensure that all data access methods that perform I/O operations are asynchronous.</li><li>This will help maintain application performance, especially under load.</li></ul><h3>Conclusion</h3><p>In conclusion, the Repository Pattern in .Net Core offers a robust way to manage data access by separating it from business logic, thereby promoting cleaner and more maintainable code. By adhering to standardized interfaces and leveraging asynchronous programming, developers can ensure efficient and scalable data operations. However, it’s crucial to avoid common pitfalls such as overloading repositories and neglecting the importance of asynchronous methods. When implemented correctly, the Repository Pattern not only simplifies data management but also enhances the overall architecture and performance of your application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e5836c79262" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.Net Recipe Part-1]]></title>
            <link>https://medium.com/@dhumalshubham436/net-recipe-part-1-ffa78778939d?source=rss-6eaa783edecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffa78778939d</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Shubham Dhumal]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 18:19:42 GMT</pubDate>
            <atom:updated>2024-07-08T18:22:41.686Z</atom:updated>
            <content:encoded><![CDATA[<p>.Net Core is renamed to .Net 5 we currently using .Net 8</p><p>The latest version of .NET Core is .NET 8, which is a Long-Term Support (LTS) release. The most recent update, .NET 8.0.6, was released in June 2024. This version includes improvements to performance, garbage collection, and core libraries. Additionally, .NET 8 introduces new features in <a href="http://asp.net/">ASP.NET</a> Core, Entity Framework Core.</p><p>To help you learn .NET Core through a practical approach using CRUD operations, here’s an adjusted plan that leverages your familiarity with C# Web API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vBD_kg1PGj0b3CBhbt1LFg.jpeg" /></figure><h3>Week 1: Setup and Basics</h3><ol><li><strong>Environment Setup</strong></li></ol><ul><li>Install the latest .NET SDK.</li><li>Set up an IDE like Visual Studio or VS Code.</li></ul><p><strong>2. Basic Concepts</strong></p><ul><li>Review the fundamentals of .NET Core and .NET 8.</li><li>Understand project structure and basic commands (dotnet new, dotnet run, etc.).</li></ul><p><strong>3. Hello World API</strong></p><ul><li>Create a simple Web API project.</li><li>Understand the MVC pattern and how it applies to .NET Core.</li></ul><h3>Week 2: Building the API</h3><ol><li><strong>Models, Controllers, and Actions</strong></li></ol><ul><li>Define models for your application (e.g., Product, Customer).</li><li>Create controllers with basic CRUD actions (Create, Read, Update, Delete).</li></ul><p>2. <strong>Entity Framework Core</strong></p><ul><li>Set up a database using EF Core.</li><li>Implement CRUD operations with EF Core.</li></ul><h3>Week 3: Advanced Features</h3><ol><li><strong>Data Validation and Error Handling</strong></li></ol><ul><li>Implement data validation using Data Annotations.</li><li>Add global error handling and custom error responses.</li></ul><p>2. <strong>Authentication and Authorization</strong></p><ul><li>Add authentication to your API using JWT.</li><li>Implement role-based authorization.</li></ul><h3>Week 4: Testing and Deployment</h3><ol><li><strong>Unit Testing</strong></li></ol><ul><li>Write unit tests for your controllers and services using xUnit.</li><li>Mock dependencies using Moq.</li></ul><p>2. <strong>Integration and Deployment</strong></p><ul><li>Test the full API using tools like Postman.</li><li>Deploy your API to a cloud service like Azure.</li></ul><h3>Week 5: Continuous Learning</h3><ol><li><strong>Explore Advanced Topics</strong></li></ol><ul><li>Look into advanced features in .NET 8 like minimal APIs, Blazor integration, and performance tuning.</li></ul><p>2. <strong>Build a Complete Project</strong></p><ul><li>Start a more complex project that integrates all the concepts you’ve learned.</li><li>Regularly update your knowledge with the latest features and best practices.</li></ul><p>For comprehensive details on what’s new in .NET 8, refer to the <a href="https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8/overview">official Microsoft documentation</a>.</p><h3>launchSettings.json Overview</h3><ul><li><strong>Purpose:</strong> Contains configuration settings for launching the application.</li><li><strong>Settings Included:</strong></li><li>Environment variables</li><li>Application URLs</li><li><strong>Usage:</strong> Utilized by .NET Core Framework when running the application from Visual Studio or .NET Core CLI.</li><li><strong>Note:</strong> This file is used only on the local development machine.</li></ul><h3>appsettings.json Overview</h3><ul><li><strong>Purpose:</strong> Acts as the application configuration file in <a href="http://asp.net/">ASP.NET</a> Core Web Applications.</li><li><strong>Equivalent:</strong> Similar to web.config or app.config in traditional .NET Framework applications.</li><li><strong>Contents:</strong> Stores various configuration settings, including:</li><li>Database connection strings</li><li>API keys</li><li>Logging settings</li><li><strong>Usage:</strong> Utilized by the application to retrieve configuration settings during runtime.</li></ul><p>In a .NET 8 project, the Program.cs file serves as the entry point of the application. This is where the execution begins for a .NET application. Starting with .NET 6 and continuing with .NET 8, the default template for <a href="http://asp.net/">ASP.NET</a> Core projects adopts a minimal hosting model with a simplified structure. The key points of the Program.cs file are:</p><ul><li><strong>Entry Point:</strong> The application execution begins in this file.</li><li><strong>Simplified Structure:</strong> Uses a minimal hosting model for a cleaner setup.</li><li><strong>Default Template:</strong> The template includes essential components to set up and run the application.</li><li><strong>Configuration:</strong> Contains configuration and setup code for the application.</li><li><strong>Hosting:</strong> Sets up the web host and specifies the startup configuration.</li></ul><p>Example code structure:</p><pre>var builder = WebApplication.CreateBuilder(args);</pre><pre>// Add services to the container.<br>builder.Services.AddEndpointsApiExplorer();<br>builder.Services.AddSwaggerGen();</pre><pre>var app = builder.Build();</pre><pre>// Configure the HTTP request pipeline.<br>if (app.Environment.IsDevelopment())<br>{<br>    app.UseSwagger();<br>    app.UseSwaggerUI();<br>}</pre><pre>app.UseHttpsRedirection();</pre><pre>var summaries = new[]<br>{<br>    &quot;Freezing&quot;, &quot;Bracing&quot;, &quot;Chilly&quot;, &quot;Cool&quot;, &quot;Mild&quot;, &quot;Warm&quot;, &quot;Balmy&quot;, &quot;Hot&quot;, &quot;Sweltering&quot;, &quot;Scorching&quot;<br>};</pre><pre>app.MapGet(&quot;/weatherforecast&quot;, () =&gt;<br>{<br>    var forecast =  Enumerable.Range(1, 5).Select(index =&gt;<br>        new WeatherForecast<br>        (<br>            DateOnly.FromDateTime(DateTime.Now.AddDays(index)),<br>            Random.Shared.Next(-20, 55),<br>            summaries[Random.Shared.Next(summaries.Length)]<br>        ))<br>        .ToArray();<br>    return forecast;<br>})<br>.WithName(&quot;GetWeatherForecast&quot;)<br>.WithOpenApi();</pre><pre>app.Run();</pre><pre>record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)<br>{<br>    public int TemperatureF =&gt; 32 + (int)(TemperatureC / 0.5556);<br>}</pre><h3>WebApplicationBuilder</h3><p>WebApplicationBuilder is a tool in <a href="http://asp.net/">ASP.NET</a> Core that helps you set up your web application. It configures services, middleware, settings, and endpoints in an organized way.</p><h3>WebApplication</h3><p>Once you’ve set up everything with WebApplicationBuilder, you use .Build() to create a WebApplication. This final product runs your web app and handles incoming requests.</p><h3>AddEndpointsApiExplorer</h3><p>The AddEndpointsApiExplorer() method is used to enable API Explorer services required for generating the OpenAPI specification. This method adds services necessary for discovering endpoint metadata. This metadata is essential for tools like Swagger to generate accurate and useful documentation for your Web API.</p><h3>AddSwaggerGen</h3><p>The AddSwaggerGen() method adds Swagger generator services to the project. These services are responsible for generating Swagger documents, which describe the structure and capabilities of your Web API. This method allows for customization of the Swagger documentation, such as setting the title and version and even adding custom descriptions and schemas.</p><h3>What is DTO’s?</h3><ul><li><strong>Definition:</strong> DTO stands for Data Transfer Object, a design pattern used to transfer data.</li><li><strong>Purpose:</strong> Primarily used to pass data in a structure convenient for consumers.</li><li><strong>Usage in API Development:</strong></li><li>Send responses</li><li>Receive requests</li><li><strong>Decoupling:</strong> Helps decouple the internal database/entity model from the external interface.</li><li>Changes to the database model don’t necessarily affect the API contracts.</li><li><strong>Characteristics:</strong> Typically a simple object with no business logic.</li></ul><pre>namespace SaaSKit.Contracts.Api;</pre><pre>public record class Users (int id, string firstName, string lastName, string email);</pre><h3>With….</h3><ul><li>.WithName(&quot;GetBooks&quot;): Assigns a name to the endpoint for clarity.</li><li>.WithOpenApi(...): Adds descriptive information for the Swagger UI, enhancing API documentation.</li></ul><h3>Architecture</h3><p>The Domain-Driven Design (DDD) architecture typically involves organizing a software system into distinct layers or modules, each with its own responsibilities and dependencies. Here’s an explanation of the key layers in DDD: API, Application, Domain, and Infrastructure.</p><ol><li><strong>Domain Layer</strong>:</li></ol><ul><li><strong>Responsibility</strong>: This layer represents the core business logic and rules of the application. It encapsulates entities, value objects, aggregates, domain services, and repositories.</li><li><strong>Components</strong>:</li><li><strong>Entities</strong>: Objects that have a distinct identity and lifecycle within the domain. They encapsulate behavior and data related to a specific business concept.</li><li><strong>Value Objects</strong>: Immutable objects without a distinct identity. They are used to describe attributes or characteristics of entities.</li><li><strong>Aggregates</strong>: Consist of entities and value objects that are treated as a single unit of consistency. They enforce business rules and transaction boundaries.</li><li><strong>Domain Services</strong>: Encapsulate domain-specific operations that don’t naturally belong to any entity or value object.</li><li><strong>Repositories</strong>: Provide an abstraction for storing and retrieving aggregates.</li></ul><p>2. <strong>Application Layer</strong>:</p><ul><li><strong>Responsibility</strong>: Coordinates the application’s behavior and interacts with external clients (such as APIs or UIs). It orchestrates domain objects to fulfill use cases or application workflows.</li><li><strong>Components</strong>:</li><li><strong>Application Services</strong>: Define the application’s use cases. They coordinate the domain layer and interact with infrastructure services.</li><li><strong>DTOs (Data Transfer Objects)</strong>: Objects used to exchange data between layers or with external systems. They encapsulate data that is passed to or from the application layer.</li></ul><p>3.<strong> API (Presentation) Layer</strong>:</p><ul><li><strong>Responsibility</strong>: Exposes the application’s functionality to external systems or users. It handles requests, validates input, and formats responses.</li><li><strong>Components</strong>:</li><li><strong>Controllers or Handlers</strong>: Receive incoming requests, invoke application services or domain objects, and return responses.</li><li><strong>Models</strong>: Represent data structures used within the API layer.</li></ul><p>4. <strong>Infrastructure Layer</strong>:</p><ul><li><strong>Responsibility</strong>: Provides supporting services and utilities required by the application. This includes data access, external integrations, logging, and configuration management.</li><li><strong>Components</strong>:</li><li><strong>Persistence</strong>: Implements repositories and data access mechanisms (e.g., using ORM frameworks like Entity Framework or raw SQL).</li><li><strong>External Services</strong>: Integration with external APIs or systems (e.g., payment gateways, email services).</li><li><strong>Logging and Monitoring</strong>: Captures and analyzes application logs, performance metrics, and error reporting.</li><li><strong>Configuration Management</strong>: Handles application settings and environment-specific configurations.</li></ul><p><strong>Interaction between Layers</strong>:</p><ul><li>The API layer receives requests from external clients and invokes corresponding controllers or handlers.</li><li>Controllers in turn invoke application services in the application layer to perform use cases.</li><li>Application services coordinate with domain entities and services in the domain layer to enforce business rules and perform operations.</li><li>Domain entities interact with repositories in the infrastructure layer to persist data.</li><li>Infrastructure services (like logging or external services) support the entire application stack.</li></ul><h3>Conclusion</h3><p>The document provides a comprehensive guide to learning .NET 8, covering setup, building APIs, advanced features, testing, deployment, and continuous learning. It includes detailed explanations of key components like launchSettings.json, appsettings.json, Program.cs, WebApplicationBuilder, and WebApplication. It also explains DTOs and their usage in API development and outlines the Domain-Driven Design (DDD) architecture, detailing the responsibilities and components of the Domain, Application, API, and Infrastructure layers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffa78778939d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concept-based understanding of ANN]]></title>
            <link>https://medium.com/@dhumalshubham436/concept-based-understanding-of-ann-355d67f12e97?source=rss-6eaa783edecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/355d67f12e97</guid>
            <category><![CDATA[gate]]></category>
            <category><![CDATA[logic]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shubham Dhumal]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 14:09:03 GMT</pubDate>
            <atom:updated>2024-03-15T14:09:03.455Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered how computers can learn and make decisions that seem almost intelligent?</p><p>At the heart of this revolution lies the concept of Artificial Neural Networks (ANNs), complex structures inspired by the human brain. But what if I told you that you could build a basic ANN using something familiar — logic gates?</p><p>Logic gates are like small switches in digital circuits. They work with 0s and 1s to give a certain result based on their rules. There are different types like AND, OR, NOT, NAND, NOR, and XOR, each following its own set of rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BDLsMSxrCQh0DJ0xIbWykA.png" /></figure><p>Imagine your brain as a big web made up of tiny worker units called neurons. These neurons chat with each other (just like you talk with your friends), process what they hear (like deciding what to do next), and then send messages out (like telling your muscles to move).</p><p>Now, think of logic gates as simple versions of these worker neurons. They take in information (like yes or no), follow their own set of rules (like AND or OR), and then give out a response (like yes or no). It’s a basic way of making choices, but it helps us understand how more complicated stuff, like brains and neural networks, do their job.</p><p>Suppose we have a single neuron that takes two-bit inputs ‘a’ and ‘b’, and its activation function is defined as ‘a*b’. This configuration would result in an output equivalent to that of an AND Gate.</p><h3>Building a Simple ANN with a Perceptron (Single Neuron):</h3><h4>Input Layer:</h4><p>Start with the input layer, which receives the binary data you want the ANN to process. In our case, the input layer might have one or two inputs, representing the binary values we want to feed into the logic gate-based ANN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cy1iVIkAfUqr0kbfmL4UPw.png" /></figure><h4>Weighted Summation:</h4><p>Each input is then connected to a single neuron (perceptron) with a corresponding weight. These weights determine the influence of each input on the neuron’s output.</p><h4>Activation Function:</h4><p>The weighted sum of the inputs is then passed through an activation function. In a logic gate-based ANN, a simple step function (threshold activation) can be used. If the weighted sum is greater than or equal to a certain threshold (bias), the output becomes 1 (representing true); otherwise, it becomes 0 (representing false).</p><h4>Output Layer:</h4><p>The final output layer simply delivers the result computed by the activation function, mimicking the behaviour of a logic gate.</p><h3>Examples of Logic Gate-Based ANNs:</h3><p>For an AND gate in an Artificial Neural Network (ANN), if we want the output to be 1 only when both inputs are 1, we set the values of both inputs to be positive and set the threshold to 1. This means both inputs need to contribute positively for the output to exceed the threshold and be 1.</p><p>On the other hand, for an OR gate in an ANN, if we want the output to be 1 whenever either or both inputs are 1, we can set one input weight to be high and the other to be lower (or even 0). Setting the threshold to 0 ensures that the output becomes 1 whenever at least one input contributes positively.</p><p>While these basic ANNs offer a glimpse into the connection between logic and neural networks, they are limited in their capabilities. Real-world ANNs often have multiple layers of interconnected neurons, enabling them to learn and solve more intricate problems.</p><h4>Conclusion</h4><p>By learning how to make simple artificial neural networks using logic gates, you’ve gained a strong starting point in understanding how these networks are built from basic parts. As you continue to explore AI, keep in mind that even advanced technologies usually have simple beginnings that anyone can grasp.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=355d67f12e97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>