In your web
application, if you want to postpone execution of actual class by substituting
another class for it then you can do it using Prototype Pattern. The substituted
class is the prototype class. The actual class will be a cloned copy of
the prototype class. After cloning, you can add more details to your actual
class.
Here is
a code sample to demonstrate it:
abstract class prototypeClass {
private int member;
public prototypeClass(int member) {
this.member = member;
}
public void getMember() {
Console.WriteLine(Member value = {0}, member);
}
public abstract prototypeClass clonePrototype();
}
class actualClass : prototypeClass {
public actualClass(int member):base(member) { }
public override prototypeClass clonePrototype() {
prototypeClass obj = (prototypeClass) this.MemberwiseClone();
return obj;
}
}
class testClass {
actualClass sampleObj = new actualClass(10);
actualClass clonedObj = (actualClass) sampleObj.clonePrototype();
clonedObj.getMember();
}