Design Pattern

Usefull examples of design patterns, with code samples.

TypeMock tutorial #03. Control behaviors.

01 July 2011 |

Note for purists: In this tutorial I am showing you a simplified example of a Unit of Work and a Repository, please do not care about the complexity or simplicity of these objects but look at the TypeMock implementations. We are now at the third post of this series and I found out that there are a lot of readers interested in learning TypeMock, which means that series will have to continue! Last time, we have created some object’s mocks using TypeMock but they were simple Value Objects with nothing or very few business logic in it....

TypeMock tutorial #02. Object creation.

25 June 2011 |

In this new  part of the TypeMock series I am going to show you how to deal with objects and classes in general, how you can create them and what are (honestly aren’t) the limit of TypeMock on dealing with objects. First of all I have just drawn down a little domain that I have added to the demo application. I am planning to upload this demo the next week on Codeplex.com so that every geek reading this blog can just go there and download the source code. The Demo domain The domain is a very simple...

New content for my Microsoft book

15 June 2011 |

The Microsoft’s book I have published few months ago: “Building Enterprise Applications with WPF and MVVM” has been a success but I still got some negative feedbacks that me and my editor we want to get rid off. This book is my first real book and of course it was my first experience on writing a book (for this reason we kept the price of the book very low). Anyway .. I got some bad feedbacks about missing parts, parts not explained as expected and a misunderstanding of the book audience and target. I personally believe that the...

Unity and injection with factories.

14 June 2011 |

Last week in the office I just found a bug on how I was implementing a series of Inversion of Control chain using Microsoft Unity. To be precise, the bug has been found by one of the new guy in the team, Gary McLean Hall, the author of the book “APRESS - Pro WPF and Silverlight MVVM”. Before starting with the explanation of the problem, let’s see what I am talking about. I believe that anyone of you know already concepts like “Inversion of Control” and ‘Dependency Injection”; if you don’t, just follow the links. A classic...

Updates for April/May 2011

12 April 2011 |

Note: Starting from the 15th of April 2011 until the 6th of May 2011 I will be off-island. During this period I will not have access to the internet so I will not able to approve you comments or either to read and answer them. You can try to send me an e-mail using the...

Updates for my Microsoft Book

03 April 2011 |

After one week that my book about LOB applications has been published I started to receive some additional questions that I am trying to address in this post. First of all I want to thank all the guys and girls that are buying the book and all the people that are providing feedbacks for the book. I really appreciate. I want also to specify that the Microsoft book has not been released as a “Book about MVVM” but more as a “book to discover LOB and layered applications”. I believe that part of the misunderstanding as been caused by...

My book for Model View ViewModel (MVVM) and n-tier applications is out

22 March 2011 |

(a.k.a. Buy one copy!) Finally I am excited and glad to let you know that my first book: “Building Enterprise Applications with Windows® Presentation Foundation and the Model View ViewModel Pattern” is out and available through the major IT books distributors like: www.amazon.com, kindle, www.oReilly.com and more. Distributors Please forgive me if I am missing some of my distributors but I do not have yet the full list. The book is available through the oReilly website at this address: http://oreilly.com/catalog/0790145309686/ in the following formats: PDF, EBOOK, KINDLE and PAPERBACK (hard copy); of course the hard...

State pattern using C#. Part 02.

20 February 2011 |

In the previous post we saw how we can implement the state pattern (I know, I didn’t show you the purist way of using the State pattern …) and include in the state execution the flow logic. This technique is fine but … it requires a lot of effort in the implementation and requires a lot of maintenance, plus it has the GAP of forcing us to re-run the CanExecute delegate every time we want to execute a specific action. On the web I have found some solutions that personally didn’t satisfy me at all. I personally believe...

State pattern using C#. Part 01

13 February 2011 |

I have been busy for a while writing my two books about MVVM and WPF but I am almost done so be ready to get more posts in the next months. This one is the first of a series that I will write to solve the state pattern issue. Today I want to start to talk about the state pattern, a design pattern used to represent the state of an object and how we can apply this pattern in a normal WPF application. The problem we have is that based on the state of an Order we can...

News for MVVM lovers and MVVM Books.

07 December 2010 |

A lot of things are going here, on my side I am publishing two books about WPF and more in general about MVVM and Prism; on another side someone pretty cool (Karl Shifflett) has just released a new way of delivering tutorials and lessons within the Visual Studio 2010 UI, the tool is called InTheBox. Finally, the team of Patterns and Practices is making progress on Prism and a new drop has been released on Codeplex. In The Box and Feature Builder InTheBox is a new way of delivering mentoring through the UI of Visual Studio 2010. The...

Symposium 2010 – Redmond

24 October 2010 |

Last week, or better this week that just ended I have been to the Microsoft Patterns and Practices Symposium summit which is a very cool 7 days Summit for Software architects, Microsoft and non. Redmond and Seattle It was the first time for me also to be in Redmond, or better to visit Seattle and the suburbs like Redmond, Bellevue and Seattle city. What can I say? It’s really a cool and nice place, it remembers me home ( I am from the north of Italy) with all these trees and mountains but in the same way...

WPf and Prism Tab Region Adapter, Part 02.

04 July 2010 |

As we saw in the previous post, it’s pretty complicate to create a custom design in WPF to override the default style of the TabControl, but it’s pretty simple to extend the behavior of it. As a senior dev, I usually don’t like to: 1) touch what is already working, 2) reinvent the wheel just to write the same code twice. For that there is the refactoring process, at most! So, let’s start by the requirement we had in the previous post, we need to emulate the VS IDE in our applications, that’s it! We also saw...

Prism and WPF. Custom Tab region adapter. Part 01.

04 July 2010 |

The second part of this tutorial is here. Enjoy! One thing that I really hate when I started working on Prism was the fact that the developers didn’t provide a nice tab region adapter. Well, the items adapter provided in Prism fits perfectly with the tab control, but if you use it “as is” it pretty sucks. I am pretty sure that as soon as you will release your first Prism “Visual Studio style” Prism application your manager will ask you for a cook tab like the one below: This is an add-in...

How to write fluent interface with C# and Lambda.

26 June 2010 |

Last week I had a nice discussion in the office about “how to write fluent interface” and I have found a couple of articles over the internet about that. As usual I disagree with some of them and, as usual, my friend Mauro Servienti (MVP C#) has a nice article about it, unfortunately in Italian. He just gave me the startup input. If you think about the Fluent Interface, it is just a trick that you use with C# in order to cheat the intellisense of Visual Studio and in order to create a nice style for your code....

Build enterprise applications with WPF, WCF, EF and Prism. Tutorial 09.

13 February 2010 |

Today we will see the modularity concept of Prism. Probably the best part of it, as it will allow us to build a real plug-and-play application where the main Shell won’t know anything about the modules. Discover and load the module. What does it mean? As we saw in the previous article, we have declared a reference in our Shell for the hello world module. In this way we force the Shell to be compiled including in the shell project a reference to the Hello World module. Fine, but what happen if we want to replace this module...

Build enterprise application with WPF, WCF, Prism and Entity Framework. Tutorial 08.

07 February 2010 |

Update: source code and documentation are now available on CodePlex at this address: http://prismtutorial.codeplex.com/ Today we will build the skeleton of our application using the latest version of Prism, available in this section of MSDN: Prism February 2009. One of the reasons that I didn't write anything concrete until now is the fact that I knew that the new version of Prism was coming this month. The classic Hello World application. As for every tutorial, is always better to start with the classic Hello World in order to understand, step by step, how...

UI Patterns tutorials. MVP, MVVM and Composite app with WPF.

31 January 2010 |

I got a lot of e-mails from my readers (I am very happy for that) where they claim the fact that It’s pretty hard to follow my tutorials because the actual version of SubText (my blog engine) doesn’t allow any search. Unfortunately until the new version of SubText will be released, and I know it will include a search engine, there is no way to help you. For this reason I am writing this post, that I will keep up to date constantly, with a list of available tutorials regarding the UI patterns. Please forgive me if...

Build enterprise application with WPF, Prism and WCF. Tutorial 07.

02 January 2010 |

Update: source code and documentation are now available on CodePlex at this address: http://prismtutorial.codeplex.com/ Design of a Rich Interface using WPF. WPF is a very powerful language and allows you to do everything you want. The only problem is that Microsoft didn’t release yet a rich toolkit with all the controls we need and the XAML is not easy to learn. Before starting to build a UI, usually, I follow these 3 fundamental steps. 1. Main layout of my application (MDI, Tab, Ribbon …) 2. Style of my application (Custom,...

The Model View Presenter pattern with .NET.

30 December 2009 |

I had a request from one of my blog’s reader (Bastien) that I can’t skip. Last week he asked me to write a short article on how to implement the Model View Presenter with Windows form. So let’s skip for a while my series of articles about Prism and let’s see what is the MVP and how it should be implemented. The Model View Presenter pattern. The definition of the model view presenter pattern can be found in many web site, let’s use the classic definition provided by MSDN. (This is an interesting article that explains the MVP)....

Book Review: Architecting application for the enterprise.

30 December 2009 |

Good morning everybody, first of all I want to apologize for my absence in December. I am really sorry but I was ‘trying’ to deliver a component in my office and I was so busy and tired that I didn’t have time for the blog. Let’s start this ‘holiday’ posts with an interesting review of a software architecture book written by two friends of mine: Andrea Salatarello and Dino Esposito. The title is: Microsoft .NET: Architecting Applications for the Enterprise (PRO-Developer) (Paperback) available at Amazon.com for 29.69 USD. Chapters and sections. The book...