Skip to content

amturian/design-patterns

Repository files navigation

design patterns

Design Patterns in JavaScript and TypeScript
See attached presentations in PPT Presentations folder

Singleton

Run cd nodejs-singleton folder & node index in terminal

Builder

Example on how builder pattern is adopted by jQuery's API Open index.html from jquery-builder folder

Protoype

Run script.js content in browser console or any online JavaScript editor https://repl.it/@alexandraturian/Prototype#index.js
Typescript example https://replit.com/@alexandraturian/PrototypePattern#index.ts

Factory

Example on how to create an http or https server in nodejs, using factory pattern
Run cd nodejs-factory & node index http://localhost:3000
Send a request to http://localhost:8082 and watch server logs

Abstract factory

TypeScript example on how to work with a group of factories
Try this online editor to run TypeScript (example is included) https://repl.it/@alexandraturian/AbstractFactory-1#index.ts

Adapter

Example on how to deal with data from two external sources that use different formats using adapter
Run index.js content in browser console or any online JavaScript editor

Composite

Example on how to render a file explorer, using npm package dree strucuture to represent a folder with subfolders and files.
Run script.js content in browser console or any online JavaScript editor

Mediator

Small chatroom example
Try this online editor to run: https://replit.com/@alexandraturian/ChatWithMediator#index.ts

Observer

Subject/Observable: Small user form with one text input
Subscribers/Observers: Display number of users + users list components
Open index.html in any browser or any online HTML, CSS, JS editor
Find the example here: https://codesandbox.io/s/observerpatternexample-z01ps

State

Try this online editor to run: https://replit.com/@alexandraturian/StatePattern#index.ts

Visitor

Example on how to add shipping cost logic for car parts order.
Try any online editor that supports TypeScript. \ How to run locally using WebStorm: https://www.jetbrains.com/help/webstorm/running-and-debugging-typescript.html#ws_ts_run_debug_server_side
Entry point (main): typescript-visitor/VisitorDemo.ts \

added online

About

Design Patterns in JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published