Singleton Design Pattern In C# – Part Three (Static vs Singleton)


Introduction

In this series on learning singleton pattern, we learned lazy initialization and eager initialization with practical examples. We also learned why it is necessary to make the singleton class sealed with the sealed keyword. In this article, I’ll try to explain the differences between static and singleton class. We will also see where to use static class and where to use singleton classes.

Continue reading “Singleton Design Pattern In C# – Part Three (Static vs Singleton)”

Advertisements

Singleton Design Pattern In C# – Part 2 (Eager and Lazy Initialization in Singleton)


Introduction

In the previous article on learning singleton pattern, we discussed what is singleton design pattern, when is it needed and what problems it solves. We also discussed how to create a basic singleton class step by step and how to enhance that class to be thread-safe with the help of locking and performance effective with the help of double check locking. In this article, we’ll discuss Lazy initialization, the lazy keyword, why to make singleton class a sealed class, and what are the differences between singleton and static class. Before we start, I strongly recommend you go through my last article.

Continue reading “Singleton Design Pattern In C# – Part 2 (Eager and Lazy Initialization in Singleton)”

Singleton Design Pattern in C# – Part 1


Introduction

I always wanted to write on Singleton design pattern in C#. Though there already are many posts available on Singleton design pattern, I’ll try to cover this topic in the most simplistic and easy to understand way.

Continue reading “Singleton Design Pattern in C# – Part 1”

Learning C# (Day 11) – Events In C# (A Practical Approach)


Introduction

This article of the “Diving into OOP” series will explain all about events in C#. The article focuses more on practical implementations and less on theory.

Events (The definition)

Let’s start with the definition taken from MSDN.

“Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.”

Continue reading “Learning C# (Day 11) – Events In C# (A Practical Approach)”

Learning C# (Day 10): Delegates in C# (A Practical Approach)

This article of the series “Diving into OOP” will explain all about delegates in C#. The article focuses more on practical implementations and less on theory. The article explains the concept in-depth.


Introduction

This article of the series “Diving into OOP” will explain all about delegates in C#. The article focuses more on practical implementations and less on theory. The article explains the concept in-depth.

Delegates (The definition)

Let’s start with the definition taken from MSDN

“A delegate declaration defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure.”

Continue reading “Learning C# (Day 10): Delegates in C# (A Practical Approach)”

Understanding Recursion in C# : A Practical Approach


Introduction

In our programming life there are situations where we have to write code to perform some repetitive tasks and in those situations recursion can become our best friend, but the problem with recursion is that it is sometimes complicated to understand.

Recursion is one of the topics that we all are taught in our student life but at that time we do not give much attention to this guy, and when we start our life as a programmer this same guy comes again in our life to irritate us and laugh at us.

So this is my little effort to introduce you to recursion so that you can use it in your code without any doubt and hesitation.

Though many of the problems can be easily solved using iteration and loops, there are some problems like graphs and tree where recursion can come in handy.

In this article I’ll be focusing more on algorithms rather than on programming language —  you can choose programming language of you to own choice. For demonstration purposes, I’ll be using JavaScript & C# because most of the programmers are familiar with the same.
Continue reading “Understanding Recursion in C# : A Practical Approach”

Understanding Events in C# (An Insight)


Introduction

Events are one of the core and important concepts of C# Programming environment and frankly speaking sometimes it’s hard to understand them without proper explanation and example.

So I thought of writing this article to make things easier for learners and beginners.

Continue reading “Understanding Events in C# (An Insight)”