Popular Posts

Aug 11, 2026

What 7+ Years in Software Development Has Taught Me

 

When I started my software development career, I was mostly focused on one thing:

Learning how to write code.

After several years of experience, my focus has changed.

Now I think more about:

Why am I writing this code?

Will this solution scale?

Will another developer understand it?

What happens when something goes wrong in production?

Does this actually solve the user's problem?

Technology changes constantly. Frameworks change. Libraries change. Programming languages evolve.

But some things remain important:

🔹 Problem-solving
🔹 Communication
🔹 Understanding business requirements
🔹 Writing maintainable code
🔹 Learning continuously
🔹 Taking responsibility for the solution

I have worked with technologies such as C#, ASP.NET Core, Angular, Blazor, SQL Server, EF Core, REST APIs, and enterprise applications.

But the biggest lesson I've learned is:

Being a good developer isn't just about knowing more technologies. It's about becoming better at solving problems.

And I'm still learning.

Every project brings a new problem.
Every problem brings a new lesson.

That's what makes software development interesting.

#SoftwareDeveloper #CareerGrowth #DotNet #Angular #Learning #SoftwareEngineering #DeveloperLife

Aug 9, 2026

Clean Code Is Not About Writing More Code

 [Clean Code Is Not About Writing More Code]

As developers, we often think clean code means writing more abstractions, more interfaces, more design patterns, and more layers.
But over the years, I've learned something important:
Clean code is about making code easy to understand, change, and maintain.
A few practices that have helped me:
🔹 Give variables and methods meaningful names.
🔹 Keep methods focused on one responsibility.
🔹 Avoid unnecessary complexity.
🔹 Don't introduce a design pattern just because you can.
🔹 Keep business logic separate from infrastructure concerns.
🔹 Write code that another developer can understand six months later.
A simple solution that is easy to maintain is often better than a complicated "perfect" architecture.
The best code isn't necessarily the most sophisticated code. It's the code that solves the problem clearly and remains maintainable as the system grows.
After years of working with technologies like C#, ASP.NET Core, Angular, SQL Server, and Blazor, I continue to believe that simplicity is one of the most valuable engineering skills.
What does clean code mean to you?
#SoftwareDevelopment #CleanCode #DotNet #Angular #Programming #SoftwareEngineering #Coding

May 16, 2024

Logging in ASP.NET Core using Serilog

 Serilog is a popular logging library for .NET applications. It provides a flexible and efficient logging framework that allows developers to log structured data in a variety of formats and sinks (destinations where log data is stored), such as text files, databases, and cloud-based services like Seq.

Serilog stands out for its structured logging capabilities, which allow developers to log data in a structured format (e.g., JSON) rather than plain text. This structured data can then be easily parsed and analyzed by log management systems, making it particularly useful for troubleshooting and monitoring applications in production environments.

Serilog supports a wide range of logging features, including log levels, message templates, contextual logging with property enrichment, and support for custom sinks and enrichers. It's widely used in the .NET ecosystem and is known for its simplicity, flexibility, and performance.


Create a asp.net core project. You can name a project anything but you can’t named serilog. Because it is a package name and you will get error.

 

Download package from nuget

dotnet add package Serilog.AspNetCore

 

 

Create a folder Services.

Create interface named it IMathService.

Write the following code

public interface IMathService

{

    decimal Divide(decimal a, decimal b);

}

 

Create a class MathService:

public class MathService : IMathService

{

    private readonly ILogger<MathService> _logger;

 

    public MathService(ILogger<MathService> logger)

    {

        _logger = logger;

    }

 

    public decimal Divide(decimal a, decimal b)

    {

        _logger.LogInformation("Parameter 1: " + a);

        _logger.LogInformation("Parameter 2: " + b);

 

        decimal result = 0;

 

        try

        {

            result = a / b;

        }

        catch (DivideByZeroException ex)

        {

            _logger.LogWarning(ex, "You cannot divide by zero.");

            throw ex;

        }

 

        return result;

    }

}

 

In program.cs file add the following code:

builder.Services.AddTransient<IMathService, MathService>();

////Add support to logging with SERILOG

builder.Host.UseSerilog((context, configuration) =>

    configuration.ReadFrom.Configuration(context.Configuration));

 

 

 

app.UseStaticFiles();

 

//Add support to logging request with SERILOG

app.UseSerilogRequestLogging();





Github: https://github.com/itsjubayer/Serilog.git




May 14, 2024

In-Memory Caching in ASP.NET Core

 


 

In ASP.NET Core, in-memory caching is a technique used to store data within the application's memory. This cached data is readily accessible to subsequent requests, which can significantly improve the performance of the application by avoiding expensive operations such as repeated database queries or complex calculations.

 

Create an webapi project named it InMemoryCaching. We will use database first approach.

In appsetting set database configutation:

,

  "ConnectionStrings": {

    "DBConnectionString": "Server=DESKTOP-M80VO7A;Database=EmployeeDB;Trusted_Connection=True;MultipleActiveResultSets=true; TrustServerCertificate=True;Integrated Security=SSPI; TrustServerCertificate=True; MultipleActiveResultSets=true;"

  }

 

 

Create context file: EmployeeDbContext

public partial class EmployeeDbContext : DbContext

{

   

    public EmployeeDbContext(DbContextOptions<EmployeeDbContext> options)

        : base(options)

    {

    }

}

In Program.cs file:

builder.Services.AddDbContext<EmployeeDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DBConnectionString")));

 

builder.Services.AddMemoryCache();

 

we need to download some nuget packages like SqlServer, Tools, Design etc.


 

Open package manager console and run the command:

Scaffold-DbContext -Connection Name=DBConnectionString Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models –force

 

Create controller named it EmployeeController

Write the code below in the controller:

 

private readonly EmployeeDbContext _context;

private readonly IMemoryCache _cache;

 

 

public EmployeeController(EmployeeDbContext context, IMemoryCache cache)

{

    _context = context;

    _cache = cache;

}

 

[HttpGet]

public async Task<IActionResult> GetAll()

{

    var products = await _context.Employees.ToListAsync();

 

    return Ok(products);

}

 

[HttpGet]

[Route("GetAllCache")]

public async Task<IActionResult> GetAllCache()

{

    var cacheKey = "GET_ALL_EMPLOYEES";

 

    // If data found in cache, return cached data

    if (_cache.TryGetValue(cacheKey, out List<Employee> Employees))

    {

        return Ok(Employees);

    }

 

    // If not found, then fetch data from database

    Employees = await _context.Employees.ToListAsync();

 

    // Add data in cache

    _cache.Set(cacheKey, Employees);

 

    return Ok(Employees);

}

 

 

Open post man and test the controller, when we run get all we get the result below:


 

 

 

When we run get all cache:


 

To cache data for the exact time, we can use the AbsoluteExpiration setting. In the following code snippet, the AbsoluteExpiration is set to 5 minutes, which means no matter how frequently our cached data is accessed, it will flush after 5 minutes.

            var cacheOptions = new MemoryCacheEntryOptions()

            {

                AbsoluteExpiration = DateTime.Now.AddMinutes(5)

            };

 

            _cache.Set(cacheKey, Employees, cacheOptions);

 

We can also use the SlidingExpiration setting which allows us to remove cached items which are not frequently accessed. In the example below, I set it to 5 minutes which means that data will remove from the cache only if it is not accessed in the last 5 minutes.

            var cacheOptions = new MemoryCacheEntryOptions()

            {

                SlidingExpiration = TimeSpan.FromMinutes(5)

            };

 

            _cache.Set(cacheKey, Employees, cacheOptions);

 

If our data is accessed more frequently than our sliding expiration time, then we will end up in a situation where our data will never expire. We can resolve this problem by following code:

            var cacheOptions = new MemoryCacheEntryOptions()

            {

                SlidingExpiration = TimeSpan.FromMinutes(5),

                AbsoluteExpiration = DateTime.Now.AddMinutes(60)

            };

 

            _cache.Set(cacheKey, Employees, cacheOptions);

 

 

 

We can also set the priority of the cached items to keep high priority items in cache during a memory pressure triggered cleanup. By default, all items in the cache have Normal priority but we are allowed to set Low, Normal, High, and NeverRemove options as well.

 

var cacheOptions = new MemoryCacheEntryOptions()

{

    AbsoluteExpiration = DateTime.Now.AddMinutes(60),

    Priority = CacheItemPriority.High

};

 

_cache.Set(cacheKey, Employees, cacheOptions);




Github: https://github.com/itsjubayer/InMemoryCaching.git