Kata2: The Decorator Pattern

by geoffrey 26. January 2010 18:26

 

This the second part of the series of Coding Kata’s. Here we’ll explore the Decorator pattern.

This is the user story:

You need to send alerts to your customers when a new product is available. 
An Alert is represented by the Alert Class:

public class Alert
{
      public String DestinationAddress { get; set; }
      public String SenderAddress { get; set; }
      public String Content { get; set; }
      public string Log { get; set; }
}

Classes used to send the Alerts implement the following interface:

public interface ISender
{
        void Send(Alert alert);
}

 

  • Create an Alerter class that send the appropriate alerts.  
  • Alerts are always send by e-mail.
  • Customers can also subscribe to receive alerts via sms and/or through messenger. 
  • Use the Decorator pattern to configure the Alerter

    You do not need to use real infrastructure code to send the alert, just append a string that contains the Sender through which the message was send.
    ->Append the following text to the Alert.Log when the message is send by:
  • e-mail      : “Message was send by e-mail”
  • sms         : “Message was send by sms”
  • messenger: “Message was send by messenger”

 

Show Solution

 

Tags:

Coding Kata on design patterns: Kata1, The Abstract Factory Pattern

by geoffrey 25. January 2010 20:19

 

This post is the first in a series dedicated to Coding Kata’s and design patterns.  

Because I’m not always able to remember all the patterns I decided to learn by practice.  

Every week I will try to create a Kata with a simple problem that has to be resolved with one of the Gov’s design patterns.  

Because I want to start smoothly we’ll start with one of the simplest pattern -> the Abstract Factory.

Kata1 ->

- A product has a property Name.  

- Because the Name is used as an identifier it can’t be changed.  

- We need to be able to construct 2 products with following names: Product1, Product2.

- Use the abstract factory pattern so that you’re able to create Products.

 

This is my solution for Kata1.

 

 

Tags:

Sharepoint 2007 Certification Guide

by geoffrey 25. January 2010 16:54

Here under you can find two usefull ressources to prepare for the exam:

 

-       The Wrox book: Professional Sharepoint 2007 Development

 

-       The Blog of: Adam Roderick

 

By focusing primarily on these two resources I managed to pass the Sharepoint Certification with what could be considered a ‘high score’. 

Tags:

About the author

Geoffrey Vandiest

contact

View Geoffrey Vandiest's profile on LinkedIn

Follow me on twitter

Geoffrey Vandiest is a technical fellow who learned the art of programming at the age of 10 on a Philips MSX computer. He's skilled in the architecture and development on the Microsoft platform and started experimenting with the Microsoft .Net framework as from the Beta 1 in 2001. Since nearly a decade Geoffrey coaches development teams and base his management style on Agile principles.

 

Month List