Friday, March 13, 2009

Design Patterns

We software professionals owe design patterns to an architect – Christopher Alexander. In 1970s, Christopher Alexander developed a pattern language with the purpose of letting individuals express their innate sense of design through a sort of informal grammar.

So what is a pattern? A design pattern is a known well-established core solution applicable to a family of concrete problems that might show up during implementation.  A design pattern is a core solution and, as such, it might need adaption to a specific context.

Using design patterns does not make your solution more valuable because at the end of the day the only thing that matters is that the application works and meet the requirements.

Patterns might be an end when you refactor according to them, and they might be a means when you face a problem that is clearly resolved by a particular pattern. Patterns are not an added value for your solution, but they are valuable for you as an architect or a developer looking for a solution.

Patterns vs. Idioms

Software patterns indicates well established solutions to recurring design problems. Sometimes specific features of a given programming language can help significantly in quickly and elegantly solving recurring problem. When a solution is hard coded on the language or implemented our of the box it is called an idiom.  

As far as the .NET is concerned, a set of idiomatic design rules exists under the name of Framework Design Guidelines. you access them online: you can also find useful information at

Here are some examples:

  • Idiomatic Design: Strucutres or Classes? – The guidelione suggests that you always use a class unless the footprint of the type is below 16 bytes and the type is immutable.
  • Idiomatic Design: Do not use List<T> in public signatures? One of the reasons for this guideline is that List<T> is a rather bloated type with many members that are not relevant in many scenarios. This means that List<T> has low cohesion and to some extent violates the Single Responsibility Principle. Another reason is that the class is unsealed but not specifically designed to be extended. It is therefore recommended the you use IList<T> instead, or derived interfaces, in public signatures. Alternatively, use custom classes the directly implement IList<T>.

Dependency Injection

DIP has been the buzzword lately in my group as has been widely used as a pattern. DIP states that higher level modules should depend on abstractions rather than on concrete implementation of functionalities. Inversion of Control is an application of DIP that refers to situations where generic code controls the execution of more specific code and external components.

IOC resemble the template method pattern ( where you have a method whose code is filled with one or more stubs. The functionality of each stub is provided by external components invoked through an abstract interface. Replacing any external components does not affect the high-level method. Of course IOC is not applied to an specific method but throughout the code.

Today IOC/DI is often associated with special frameworks that offers a number of rather advanced features.

Here are some examples

Framework More Information
Castle Windsor
Spring .NET

Those are very interesting frameworks to take a look at it and get some ideas. I am personally familiar with Unity and Spring.

All IOC frameworks are built around container object that, bould to some configuration information resolve dependencies. The caller code instantiates the container and passes the desired interface as an argument. In response, the IOC/DI framework returns a concrete object that implements that interface.

I will spend some time on the next post talking about Unity and back to our pattern discussion.


Anonymous said...

Hello everyone! Who knows where to upload the film Avatar?
I even bought the film Avatar for a SMS to , the link was, but download fails, the system will boot quite strange cocoa something.
Men, advise where to normal as quickly download film avatar?

Anonymous said...

I sell a boat-program which will help you to outwit auction and to win, initially the boat was created for the Scandinavian auction but now the program can work with similar auctions: gagen ru, vezetmne ru and with ten.
The program-boat stakes for you, i.e. for this purpose it is not necessary to sit constantly at the monitor. The boat can set time when it is necessary to stake, thus you as much as possible will lower expenses for rates, and as much as possible increase the chances of a victory.

The price of the program a boat for the Scandinavian auctions 20$

For the first 10 clients the price 15$

To all clients free updating and support.

Behind purchases I ask in icq: 588889590 Max.

Anonymous said...

[b]Set software LoveBots v 5.2[/b]

All for a mass mailing dating

The script is written in php5


[i]registration, account activation
manual input captures, or the solution through antikapchu
filling data accounts:
- Gulf desired photo
- Инфы about yourself
- Diary
- Sexual preference[/i]

gulyalka on questionnaires spammer on lichku
- Randomization Posts: replacement of Russian letters in Latin analogues

optimized to work in a continuous loop
check-activation-filling-spam check ..

Updates and support free of charge.

Price per set 100 wmz

For the first 10 buyers price 70 wmz (your feedback on the software).

For shopping I ask in icq: 588889590 Max.

Scrin program:




Flooding in the subject no! Write to feedback after the purchase.