For this article / tutorial I will demonstrate a quick and easy way on how to use data access objects (DAO’s) with the Entity Framework.

These data access objects form a layer between the business logic and the database access technology. The idea is that the business logic should remain ignorant of the technology used to access the database. Using this “DAO pattern” you can more easily interchange this backing technology.

In the text to come this will be demonstrated by setting up a simple domain model which will be modelled using the Entity Framework. Next a layer of DAO’s will be created on top of this domain model.

The business logic will only use these DAO’s to request or send back data from or to the underlying data store. How these CRUD operations are handled is entirely up to the implementation of the DAO’s and should be of no concert to the business logic.

By decoupling the business objects from the backing data store you can more easily switch to another database access technology such as for say Linq To Sql.

Read the rest of this entry »


MVP: Model View Presenter

December 14, 2008


Last week I was reading some articles about using WCF, the Entity Framework and how to transport entities across the service boundary. One of the articles I encountered included a demo project that made use of the Model View Presenter (MVP) pattern.

Having explored the demo project I thought it might be interesting to write an article about this pattern. Your favorite search engine will happily supply you with a plethora of links to other articles that explain this pattern thoroughly.

For this article I’ve decided to supply a concrete implemention and to focus less on the theory behind the pattern.

Let’s roll…

Read the rest of this entry »

Strategy Pattern

August 24, 2008


This week I was at last able to find some spare time to write a new article. It’s been three months already since the last one. I’ve been preoccupied with studying for .NET exams (MCTS) among other things hence the delay.

To get back on track I thought I’d finish an article for which I’ve had the code lying around for quite some time. This article is the second one in the Sudoku series. This series explains a couple of design patterns using a Sudoku game as an example. You can find the first article, which details the Flyweight pattern here. Be sure to take a look at it and download its source code.

Let’s get started with the design pattern at the heart of this article, namely the Strategy pattern…

Read the rest of this entry »

Flyweight Pattern

March 8, 2008


Last weekend I found an article which discusses how to design a Sudoku Game using several design patterns. The article itself did not contain a concrete implementation of the design. I thought it would be fun to create a Sudoku game myself based on this guy’s analysis. This would be a fun way to use several design patterns.

In total four design patterns are used to create the Sudoku game, namely:

  1. Flyweight (Structural Pattern)
  2. Composite (Structural Pattern)
  3. Strategy (Behavioural Pattern)
  4. Builder (Creational Pattern)

Rather than create one large article I will split this up into four parts. Each part focussing on one of the design patterns. In this first part a concrete implementation of the Flyweight pattern will be presented.

Let’s get started…

Read the rest of this entry »