June 30, 2012

Singleton pattern

I'm sorry for pause in writing new posts about design patterns.  
Unfortunately, I had no free time, but now I'm really ready to do it.

So, today I'm going to write a post about the most popular and well-known design pattern - Singleton.

The essence of Singleton is to provide :
  • exactly one instance of class across the system;
  • simple access to it.
The implementation of Singleton based on creation a class with a method(or property in .NET) that creates an instance of this class if one doesn't exists yet. The constructor of class must be private to prevent other ways of initialization. Also Singleton must be carefully used in multi-threaded applications because in one point of time, the two threads may create two different instances (which violates singleton pattern).

Below I'll explore the most frequent implementations of pattern. As always, I'll show structural code and real-world code.

June 15, 2012

.NET Parameter passing

Recently, I had a dispute with co-worker about .NET passing parameter. So, I decide to write post about it and clarify some aspects. This post will show you how parameter passing is handled in memory.
Also this post expects that readers knew what's the difference between a value-type and a reference-type in .NET. By the way, I'm going to dive deeper into this question. Thus, wait for another post :)

In .NET we may passing parameter by value or by reference.
I break out a post into four parts :
  • Passing value-type variables by value;
  • Passing value-type variables by reference;
  • Passing reference-type by value;
  • Passing reference-type by reference.

June 9, 2012

Facade pattern

First pattern which I'll try to explore is a structural pattern - Facade.

Before we go to the pattern I think we must understand a concept of subsystem.

Subsystem is a part of large system that consists of a set of elements and relations.
Let's look for simple example for better understanding.

Here you can see a system which consists of four subsystems : UserInterface, OrderManagement, SeatingManagement and Database. Each subsystem has own logic as well as relations to another subsystem(s).

June 7, 2012

Structure of design patterns

From wikipedia :
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.

I always wanted to write all well-known design patterns into one repository with details and own examples. I think that my blog and github (all sources will be avaible on github) is comfortable for it.
So, every Saturday I'll be write a post about exactly one design pattern.

In this post, I want to group the design patterns into the categories.
Historically, design patterns were grouped into : creational patterns, structural patterns, and behavioral patterns.

From each group I chose only most popular and well-known patterns.

June 6, 2012

How To Solve “Not Enough Time”

It's would be a very small post.

I just wanna to share with you really cool article about pessimistic statement - “Not Enough Time”.

Have a nice day !