Skip to content

Commit c6d6dd1

Browse files
author
Badacadabra
committed
Do minor modifications
1 parent 37425af commit c6d6dd1

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# PatternifyJS: JavaScript Design Patterns
1+
# PatternifyJS - JavaScript Design Patterns
22

33
## About
44

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:
66

77
* ECMAScript (Vanilla)
88
* ES5
@@ -12,9 +12,9 @@ PatternifyJS is a reference of the main design patterns in the JavaScript world.
1212

1313
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)".
1414

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.
1616

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.
1818

1919
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!
2020

@@ -52,15 +52,17 @@ Apart from the GoF patterns, there are also miscellaneous (functional and more)
5252
## Miscellaneous patterns
5353

5454
* [Currying](misc/Currying)
55+
* [Method Chaining](misc/MethodChaining)
5556
* [Module](misc/Module)
5657
* [Object Specifier](misc/ObjectSpecifier)
5758
* [Revealing Module](misc/RevealingModule)
5859

5960
## Inspiring resources
6061

61-
* *JavaScript: The Definitive Guide*, **David Flanagan**
62-
* *JavaScript: The Good Parts*, **Douglas Crockford**
63-
* *Learning JavaScript Design Patterns*, **Addy Osmani**
64-
* *Exploring ES6*, **Axel Rauschmayer**
65-
* *The Little Book on CoffeeScript*, **Alex MacCaw**
66-
* *TypeScript Deep Dive*, **Basarat Ali Syed**
62+
* *JavaScript: The Definitive Guide* by **David Flanagan**
63+
* *JavaScript: The Good Parts* by **Douglas Crockford**
64+
* *Learning JavaScript Design Patterns* by **Addy Osmani**
65+
* *Exploring ES6* by **Axel Rauschmayer**
66+
* *The Little Book on CoffeeScript* by **Alex MacCaw**
67+
* *TypeScript Deep Dive* by **Basarat Ali Syed**
68+
* *Design Patterns: Elements of Reusable Object-Oriented Software* by **Erich Gamma**, **Richard Helm**, **Ralph Johnson** and **John Vlissides**

misc/Module/CoffeeScript/index.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Person = do ->
99
secretNickname = nickname
1010

1111
sayHello: ->
12-
"Hello, #{this.firstName} #{this.lastName}!"
12+
"Hello, #{@firstName} #{@lastName}!"
1313

1414
getSecretNickname: ->
1515
secretNickname

misc/Module/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ JavaScript is not very strict when it comes to encapsulation and each script ten
66

77
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.
88

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

Comments
 (0)