Please enable JavaScript.
Coggle requires JavaScript to display documents.
javascript patterns - Coggle Diagram
javascript patterns
-
-
-
-
factory pattern
a way of creating an interface for creating objects → we can let subclasses define which classes to instantiate
often used to manage and maintain and manipulate collections of objects that are different, at the same time have many common characteristics
-
factory
-
-
-
create members
members.push(factory.createMember('John Doe', 'simple'));
observer pattern
allows us to subscribe and unsubscribe to certain events, functionality → gives us a nice subscription model
-
-
-
mediator
a mediator, an interface for communicating with collogues (mediated objects)
-
chatroom example
class User { ... }
methods
send (message, to) { ... }
receive(message, from) { ... }
-
class Chatroom { ... }
-
methods
-
send(message, from, to) { ... }
single → to.receive(message, from);
mass → this.users[key].receive(message, from);
start
-
-
-
brad.send("hello jeff", sara);