You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# PatternifyJS: JavaScript Design Patterns
1
+
# PatternifyJS - JavaScript Design Patterns
2
2
3
3
## About
4
4
5
-
PatternifyJS is a reference of the main design patterns in the JavaScript world. External libraries are not covered, only the core languages are. Here is the list of all available languages:
5
+
PatternifyJS is a reference of the main design patterns in JavaScript. JS libraries are not covered, but the core scripting languages around JavaScript are there. Here is the list of all available languages:
6
6
7
7
* ECMAScript (Vanilla)
8
8
* ES5
@@ -12,9 +12,9 @@ PatternifyJS is a reference of the main design patterns in the JavaScript world.
12
12
13
13
The Gang of Four (GoF) patterns are based on original synopses inspired from the real life and are available in two distinct flavors: "[classic](GoF/classic)" & "[idiomatic](GoF/idiomatic)".
14
14
15
-
The classic style emulates the principles of traditional class-based object-oriented languages like Java. Therefore, this style makes heavy use of abstraction, interfaces, classes, inheritance, composition, encapsulation and polymorphism. As a prototype-based language, JavaScript does not have all these functionalities natively (despite all the syntactic sugar introduced by ES6). But it is still possible to use and reproduce each of these concepts... For obvious reasons, constructor functions are the rule in the classic style. Moreover, each design pattern has its own class diagram in UML.
15
+
The classic style emulates the principles of traditional class-based object-oriented languages like Java. Therefore, this style makes heavy use of packages, abstraction, interfaces, classes, inheritance, composition, encapsulation and polymorphism. As a prototype-based language, JavaScript does not have all these functionalities natively (despite all the syntactic sugar introduced by ES6). But it is still possible to use and reproduce most of these concepts... For obvious reasons, constructor functions are the rule in the classic style and each design pattern of this category has its own UML class diagram.
16
16
17
-
The idiomatic style reveals the true nature of JavaScript. Constructor functions and classes are replaced by factory functions and object literals, there is no abstraction anymore, encapsulation is reduced to the minimum and flexibility raised to the maximum. With this style, the GoF patterns are a bit difficult to recognize because their overall structure is blurred. But here it is more reasonable to think about objects directly, not about classes (see object diagrams in UML).
17
+
The idiomatic style reveals the true nature of JavaScript. Constructor functions and classes are replaced by factory functions and object literals, there is no abstraction anymore, encapsulation is reduced to the minimum and flexibility raised to the maximum. With this style, the GoF patterns are a bit difficult to recognize because their overall structure is blurred. But here it is more reasonable to think about objects directly, not about classes. This is the reason why class diagrams have been replaced by UML object diagrams in the idiomatic style.
18
18
19
19
Apart from the GoF patterns, there are also miscellaneous (functional and more) patterns in JavaScript that make life easier. They can be of a great help!
20
20
@@ -52,15 +52,17 @@ Apart from the GoF patterns, there are also miscellaneous (functional and more)
52
52
## Miscellaneous patterns
53
53
54
54
*[Currying](misc/Currying)
55
+
*[Method Chaining](misc/MethodChaining)
55
56
*[Module](misc/Module)
56
57
*[Object Specifier](misc/ObjectSpecifier)
57
58
*[Revealing Module](misc/RevealingModule)
58
59
59
60
## Inspiring resources
60
61
61
-
**JavaScript: The Definitive Guide*, **David Flanagan**
62
-
**JavaScript: The Good Parts*, **Douglas Crockford**
Copy file name to clipboardExpand all lines: misc/Module/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,4 @@ JavaScript is not very strict when it comes to encapsulation and each script ten
6
6
7
7
The Module pattern is a great solution to encapsulate some code. The idea is to store in a variable the returned expression of an IIFE (Immediately-Invoked Function Expression), which can be for instance another function declared inside the module. Within the IIFE, the scope is private. We can then declare private variables and functions that will be invisible from the outside. Conceptually, a module is a bit like a class.
8
8
9
-
N.B. In practice, the module pattern is not often used anymore. CommonJS, AMD, or built-in ES6 modules are much better solutions nowadays...
9
+
N.B. In practice, this pattern is not often used anymore. CommonJS, AMD, or built-in ES6 modules are much better solutions nowadays...
0 commit comments