-
Notifications
You must be signed in to change notification settings - Fork 1
/
PatternDoc.txt
69 lines (54 loc) · 2.16 KB
/
PatternDoc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Contents
========
--------
General
=======
Abstract Class
--------------
A class that cannot be instantiated itself, it provides a blueprint or contract that inheriting classes must fulfill before the code will run. A class that 'extends' the abstract can only extend one class
abstract class defined by :- abstract Class <className> {
inheriting class extends abstract with :- Class <className> extends <AbstractClassName>{
Interface
---------
An interface is a class that also provides a blueprint or contract an inheriting class must fulfill before it will instantiate, a class that implements the interface can implement as many interfaces as it likes
interface class defined by :- interface <className> {
inheriting class implements interface with :- class <className> implements <interfaceOneClassName>,<interfaceTwoClassName>... {
Patterns
========
Strategy
--------
Strategy pattern used when many classes that inherit from a a parent class will often share algorithms within the same method eg cats and horses both canter so would share the method for canter. Can decide at runtime which algorithm to use.
Observer
--------
A pattern where an instance notifies a watching class if it changes, classes can attach and detach themselves from being observed at any point. Useful for reporting auditing type systems.
Decorator
--------
A decorator is a way of adding non core functionality to a class without affecting the base class, critical pattern for the OO aim "open to extension, closed to modification" allows classes to be 'decorated' with new functionality. Care is needed to ensure the principle is not employed everywhere as it tends to produce overly complex unreadable code.
Factory
-------
Singleton
---------
A singleton is a pattern where only one instance of the class can ever exist, useful for services and similar.
multiton
--------
The multiton pattern is an extension of the singleton pattern such that only one instance of each type can be instantiated.
Command
Adapter
Facade
Template Method
Iterator
Composite
State
Proxy
Compound Patterns
Extra Patterns
--------------
Bridge
Builder
Chain of Reposnsibility
Flyweight
Interpreter
Mediator
Memento
Prototype
Visitor