The archetype pattern is a software design pattern that separates logic from implementation. The separation is accomplished through the creation of two abstract classes: a decorator (for logic), and a delegate (for implementation). The Factory handles the mapping of decorator and delegate classes and returns the pair associated with a parameter or parameters passed. The interface is the contract between a decorator, a delegate, and the calling class, creating an Inversion of Responsibility.[1] This example use two branches; however, you can have 'N' branches as required. The pattern means that one branch from the interface does not have to worry about how another branch operators as long it implements the interface.
Decorator
The descendants of the decorator class handle the logic, for example performing a calculation. The descendants of the decorator can then call the descendants of the delegated when or if they wish to pass responsibility for example storage or communication.
Delegate
The descendants of the delegate flow class handle the implementation for call a sub-system, storage, or communication. Different children can use completely different sub-systems storage, or communications than each other.
public class RequestFactory
public class App
public abstract class DecoratorRequest implements Request
public abstract class DelegateRequest implements Request
public class ADecoratorRequest extends DecoratorRequest
public class BDecoratorRequest extends DecoratorRequest
public class YDelegateRequest extends DelegateRequest
public class ZDelegateRequest extends DelegateRequest
Delegation pattern - calls the specific implementation
Decorator pattern - performs the generalised logic
Factory method pattern - creates the archetype combination