This repository includes an examples of patterns realisation in Apex.
The factory method is just a method, it can be overridden in a subclass, whereas the abstract factory is an object that has multiple factory methods on it.
Examples:
The builder pattern is used to instantiate an object of a complex class using the step-by-step approach and return a constructed object at once. Allows creating different products based on the same process.
Examples:
Interpreter pattern is used to define a grammatical representation for a language and provides an interpreter to deal with this syntax.
- This pattern is used in SOQL parsing, symbol processing engine etc.
- This pattern performs upon a hierarchy of expressions. Each expression here is a terminal or non-terminal.
- The tree contains the expressions to be evaluated and is usually generated by a parser. The parser itself is not a part of the interpreter pattern.
Examples:
The singleton design pattern restricts the instantiation of a class to only one object.
- This pattern is used in SOQL parsing, symbol processing engine etc.
- This pattern performs upon a hierarchy of expressions. Each expression here is a terminal or non-terminal.
- The tree contains the expressions to be evaluated and is usually generated by a parser. The parser itself is not a part of the interpreter pattern.
Examples: