RSS Feed for design patternCategory: design pattern

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 […]

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 […]

Design Pattern in Java 101 – Builder Pattern (Creational Pattern) »

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; […]

Design Pattern in Java 101 – Visitor Pattern (Behavioral Pattern) »

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 […]

Java Fluent Interface – Return Instance from Set Method »

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 […]