Skip to main content

Posts

Why I Built My Own Data Export Tool

 I work on a team that regularly supports users by providing them with data from our production database. The catch is, I’m the only one on the team who can access that database. Whenever someone needs specific information — say a list of recent orders or the details of a set of customers — they’d come to me with a request. My role, then, was to log into production, run the queries, and hand over an Excel file with the results. At first, I didn’t mind. It was part of my job. But as the requests piled up — often the same few queries repeated, or small variations on existing ones — I realized how much time I was spending just exporting data. I searched for a tool to automate this but found everything too cumbersome: either it had too many features I didn’t need, or it was too complicated to set up. I needed something simpler. That’s when I decided to build my own. All I wanted was a command-line tool that would read a set of queries from a file, run them, and create an Excel file — e...

How I Used a Classic Algorithm to Solve a Real-Life Restaurant Problem

Algorithms and data structures often feel like abstract, academic exercises when you first encounter them. Many of us in university wondered, Will I ever use this in real life? Fast forward to the working world, and the answer is often a resounding yes . Here’s a story of how I used Breadth-First Search (BFS), a classic algorithm, to solve a seemingly impossible problem for a restaurant inventory system. The Restaurant Dilemma Imagine you’re designing a system for a restaurant chain. The system needs to handle recipes, track ingredient usage, and calculate costs for menu items. Sounds straightforward, right? Let’s complicate it. Consider a dish like Lasagna. To make lasagna, you need: Pasta Sheets Bolognese Sauce Cheese But here’s the twist: Bolognese Sauce is itself a recipe that requires: Ground Meat Tomatoes Spices Every ingredient comes from an inventory with details like: Unit of Measurement (UOM) : Grams, Liters, etc. Cost per Unit : Calculated based on the last purchase price...

How to Make API Documentation the Easy Way with Postman

If you’re like me, you probably hate making API documentation. It’s boring, takes a lot of time, and feels like extra work. I used to skip it most of the time. But recently, I had no choice. I was working on a Web API that other software needed to use, and I had to make proper documentation. That’s when I found an easy solution:  Postman . Most of us already use Postman to test APIs, right? The good news is that Postman can now help you create documentation automatically with its AI tool. Here’s how you can do it. Steps to Create API Documentation in Postman Step 1: Add a Collection Description First, open Postman. On the left side, click on the  collection  you want to document. Go to the  Overview  tab and write a short description of your collection. This helps explain what your API is about. Overview page Step 2: Use AI to Write API Descriptions Select one of the API requests in your collection. On the right-hand side, click the  Documentation  ico...

Building a Tic Tac Toe Console Game in C#

When learning a new programming language, a common exercise is to create a classic game, such as Tic Tac Toe. In this post, I'll guide you through creating a simple, console-based Tic Tac Toe game in C#. First, let's start with the challenge we're trying to solve: Tic Tac Toe is a two-player game. We need to handle input from two players and alternate between them. The game is played on a 3x3 grid. We need to keep track of the state of this grid. A player wins by marking three spots in a row, either horizontally, vertically, or diagonally. The game continues until a player has won or all spots on the grid have been marked, in which case the game is a draw. To address these challenges, we need to develop a problem-solving mindset. Let's break down the problem into smaller, manageable pieces and think about how we could solve each one. This process is known as "decomposition" and it's a fundamental skill in programming and problem-solving in general. Step 1:...

Desktop Application Project: Building a Simple Library Management System in C#

 Let's create a simple library management system using the concepts we've covered throughout this series. The system will manage books, users, and borrow records. The project will include classes, inheritance, interfaces, events, delegates, generics, collections, LINQ, and exception handling. using System; using System.Collections.Generic; using System.Linq; // Chapter 2.1: Understanding classes, objects, and inheritance public class User { // Chapter 2.4: Understanding properties and indexers public int Id { get ; set ; } public string Name { get ; set ; } public DateTime JoinDate { get ; set ; } // Chapter 2.2: Understanding constructors and destructors public User( int id, string name) { Id = id; Name = name; JoinDate = DateTime.Now; } // Chapter 2.3: Understanding access modifiers (public, private, protected, internal) protected void PrintUserDetails() { Console.WriteLine( $ "ID: {I...

Chapter 6.4: Working with .NET Classes: Understanding System.Linq

 Introduction: In the previous article , Chapter 6.3, we discussed the System.Collections and System.Collections.Generic namespaces, which provide classes for working with collections of objects in C# applications. In this final article of our series, we'll explore the System.Linq namespace, which offers powerful querying capabilities for collections, allowing you to filter, sort, and transform data with ease. After completing this article, you should have a solid understanding of C# and its core concepts. We encourage you to start a project to implement what you've learned and further strengthen your skills. System.Linq Namespace: The System.Linq namespace provides Language Integrated Query (LINQ) functionality, which allows you to perform complex queries on collections using a concise and expressive syntax. LINQ works with both generic and non-generic collections, as well as with other data sources like XML and relational databases. Some key features of LINQ include: ...

Chapter 6.3: Working with .NET Classes: Understanding System.Collections and System.Collections.Generic

 Introduction: In the previous article , Chapter 6.2, we explored the System.Text and System.Text.Encoding namespaces, which are important for working with text and character encodings in C# applications. In this article, we'll discuss the System.Collections and System.Collections.Generic namespaces, which provide classes for working with collections of objects. In the next article, we'll dive into the System.Linq namespace, which offers powerful querying capabilities for collections. System.Collections Namespace: The System.Collections namespace provides non-generic collection classes, such as ArrayList, Hashtable, and Queue. These classes store objects, but they don't enforce type safety: ArrayList list = new ArrayList(); list.Add(42); list.Add( "Hello, world!" ); foreach ( object item in list) { // Process item } System.Collections.Generic Namespace: The System.Collections.Generic namespace offers type-safe, generic collection classe...

Chapter 6.2: Working with .NET Classes: Understanding System.Text and System.Text.Encoding

 Introduction: In the previous article , Chapter 6.1, we discussed the System.IO namespace, which provides classes for working with files, directories, and streams. In this article, we'll explore the System.Text and System.Text.Encoding namespaces, which are important for working with text and character encodings in C# applications. In the next article, we'll discuss the System.Collections and System.Collections.Generic namespaces, which are essential for working with collections of objects. System.Text Namespace: The System.Text namespace contains classes and interfaces for working with text and character encodings. Some key classes include: StringBuilder: Provides a mutable string buffer for efficient string manipulation. Encoding: Represents a character encoding, such as UTF-8, UTF-16, or UTF-32. Decoder/Encoder: Convert between different character encodings and byte arrays. StringBuilder: The StringBuilder class is useful for efficient string manipula...

Chapter 6.1: Working with .NET Classes: Understanding the System.IO Namespace

 Introduction: In this new chapter, we'll explore working with .NET classes, which are essential for developing robust and efficient C# applications. In this first article, we'll discuss the System.IO namespace, which provides classes for working with files, directories, and streams. In the next article, we'll delve into the System.Text and System.Text.Encoding namespaces, which are important for working with text and character encodings. System.IO Namespace: The System.IO namespace contains classes for performing various operations on files, directories, and streams. Some key classes include: File: Provides static methods for creating, copying, deleting, and moving files, as well as opening files for reading and writing. Directory: Provides static methods for creating, deleting, and moving directories, and enumerating files and directories. FileStream: Represents a file stream, allowing you to read and write data to a file. StreamReader/StreamWriter:...

Chapter 5.2: File I/O and Serialization: Understanding Serialization and Deserialization of Objects

 Introduction: In the previous article , Chapter 5.1, we discussed reading and writing text and binary files, essential skills for working with data in C#. In this article, we'll explore serialization and deserialization of objects, which are important for persisting and restoring object states. In the next article, we'll discuss working with .NET classes, an important aspect of developing C# applications. Serialization: Serialization is the process of converting an object's state into a format that can be stored or transmitted. In C#, the .NET framework provides several serialization mechanisms, such as binary, XML, and JSON serialization: // Binary Serialization BinaryFormatter formatter = new BinaryFormatter(); using (FileStream stream = new FileStream( "data.bin" , FileMode.Create)) { formatter.Serialize(stream, myObject); } Deserialization: Deserialization is the process of reconstructing an object's state from a serialized forma...

Chapter 5.1: File I/O and Serialization: Understanding Reading and Writing Text and Binary Files

 Introduction: In this new chapter, we'll explore File I/O and Serialization, essential concepts for working with data in C#. In this first article, we'll discuss reading and writing text and binary files. In the next article, we'll delve into serialization and deserialization of objects, which are important for persisting and restoring object states. Reading and Writing Text Files: C# provides several classes for reading and writing text files, such as StreamReader, StreamWriter, and File: // Writing a text file using (StreamWriter writer = new StreamWriter( "example.txt" )) { writer.WriteLine( "Hello, world!" ); } // Reading a text file using (StreamReader reader = new StreamReader( "example.txt" )) { string line; while ((line = reader.ReadLine()) != null ) { Console.WriteLine(line); } } Reading and Writing Binary Files: For working with binary files, C# provides the BinaryReader and Bina...