By admin on Jan 9, 2008 in .NET, Programming, Structural | Comments Off on Design Pattern in .NET 101 – Decorator Pattern (Structural Pattern)
Download Sample Code Decorator Pattern attaches additional responsibilities to an object dynamically and provides a flexible alternative to subclassing for extending functionality. E.g. BaseMessage is defined using System; using System.Collections.Generic; using System.Text; namespace DecoratorPattern { abstract class BaseMessage { private string sender; private string recipient; public string Sender { get { return this.sender; } set […]
By admin on Jan 8, 2008 in .NET, Programming, Structural | Comments Off on Design Pattern in .NET 101 – Proxy Pattern (Structural Pattern)
Download Sample Code Proxy Pattern provides a surrogate or placeholder for another object to control access to it. E.g. I defined a IGreeting interface using System; using System.Collections.Generic; using System.Text; namespace ProxyPattern { interface IGreeting { void SayHello(); } } Greeting implements IGreeting using System; using System.Collections.Generic; using System.Text; namespace ProxyPattern { class Greeting: IGreeting […]
By admin on Dec 31, 2007 in Creational, Java, Programming | 1 Comment
Download Source Code Builder pattern is used to construct a complex object from simple objects step by step. E.g., I have a Message class public class Message { private String sender; private String recipient; private String header; private String body; public String getSender() { return sender; } public void setSender(String sender) { this.sender = sender; […]
By admin on Dec 28, 2007 in Behavioral, Java, Programming | 1 Comment
Download Source Code NOTE: This is written for me to recap and relearn what I learnt before…. This article is written in order for me to recap what I have learnt and used before, though I know there are already many sites which talked about all these. Visitor Pattern defines a new operation to deal […]
By admin on Dec 10, 2007 in Java, Others, Programming | 2 Comments
Normally we create a class with the constructor, set/get methods as below public class Person { private String name; private Integer age; private String email; public Person() { } public Person(String name, Integer age, String email) { this.name = name; this.age = age; this.email = email; } public String getName() { return name; } public […]