SlideShare a Scribd company logo
1 of 55
Download to read offline
Node.js
for Enterprise
Chief Technology Architect at Metarhia
CTO at Salucyber, Lecturer at KPI & KSE
github.com/tshemsedinov
Timur Shemsedinov
Is Node.js ready for Enterprise?
Is Node.js ready for Enterprise?
Yes, sure
Is Node.js ready for Enterprise?
Yes, sure
Node.js is ready
Is Node.js ready for Enterprise?
Yes, sure
Node.js is ready
But JavaScript developers...
Is Node.js ready for Enterprise?
Yes, sure
Node.js is ready
But JavaScript developers are not
New features
● Multithreading for calculations and scale
(added in v10, stable in v12)
● WASI, Node-API 8, V8 v9 for Node.js v16, npm 7
● API: diagnostic API, perf_hooks, timer promises,
AbortController, vm, v8, scrypt, Web crypto api,
async_hooks, AsyncLocalStorage, etc.
● QUIC or HTTP/3 especially for mobile and 5G
Monkey job
Everything repeats every time we start a project
● Let’s discuss scaling, we expect highload
● We need microservices, REST and ORM
● People, vision and setup processes
● Application architecture and structure
● Select tools, libraries, frameworks
● Code conventions, repository maintenance
Node.js challenges
● Enterprise requirements: Reliability,
Maintainability, High Availability, Security,
Isolation, Compatibility
● Community culture: meetups, conferences,
fundamental SC knowledge, consensus
● Reputation and trust: education, certification,
success stories
Your code
With the code of your colleagues
With node_modules
Application in Node.js runtime
libuv
V8
openssl
zlib
c-ares
llhttp
Node.js in infrastructure
node
cron
postgres
autovacuum
logger
writer
statistics
statistics
checkpointer
redis systemd
journald
networkd
docker
How to think about you code
It’s glue and business-logic code
Semantically and syntactically flexible
Very expressive (you can create DSL)
Simple for maintenance and changes
Simple and readable for everyone
Works everywhere
Easy to integrate
Engineering culture
● Architecture: DDD and clean code, layered
architecture, domain in the middle
● Principles and patterns: GRASP, SOLID, GoF,
IoC, DI, coupling и cohesion, Law of Demeter
● Project structure: framework-agnostic
● Techniques: error handling, asynchronous and
parallel programming, metaprogramming...
Important aspects
● Application is the place for applied code
● Declarative code is better than imperative
● State: reliability, performance, interactivity
● Configuration and infrastructure in the code
● Getting rid of dependencies
● We use layered architecture
Related to Node.js
● Context isolation and v8 sandboxes
● Don’t block event-loop
● Avoiding race conditions and leaks
● Avoid reference pollution and mixins
● Don’t use middlewares
● Implement graceful shutdown
● Limit concurrency (async queue or semaphore)
Important for Enterprise
● Business needs quick prototyping (TTM)
● We need security audit and certifications,
so get rid of dependencies
● Enterprise prefers low-code
● Modeling visualisation
(BPMN, ERD, state diagram, process flow)
Layered (onion) Architecture
Domain
model
Domain services
Application services
Presentation
Infrastructure
Persistence
Postgres
Redis
External API
Logger
Configs
Scheduler
Health mon
Validation
Cryptography
Sessions
App firewall
AAA
Web UI
Mobile UI
API gateway
Middleware: big ball of mud
models
controllers
logger
configs
AAA
validation
cryptography
sessions
routing
middlewares
db
configs
rendering
ORM antipattern
models
controllers
logger
configs
AAA
validation
cryptography
sessions
routing
middlewares
ORM
db
configs
rendering
Express architecture
models
controllers
logger
configs
AAA
validation
cryptography
sessions
routing
middlewares
ORM
db
configs
rendering
High coupling
● References are passed to other parts of the
application (examples: req, res, socket, person,
payment, logger, session, scheduler...)
● Passed objects mutations due to mixins will
breaks our expectations
● Remaining references are visible from contexts
so memory leaks and we need restarts
“Talk is cheap.
Show me the code.”
What we get
● Framework-agnostic application
● Transport-agnostic communications
● No race conditions in asynchronous code
● No memory leaks and resource leaks
● Errors are handled properly
● Code reuse, no code duplication
● A few and reliable dependencies
What we get
● DI (dependency-injection)
● Automatic routing (directory based)
● Context isolation
● Parse cookie without middlewares
● Sessions without middlewares
● Authentication without middlewares
● Concurrency control with semaphores
graceful shutdown
metawatch
semaphore
contract checking
metaschema
Schema-centric approach
Domain model
Schema
Domain services External interfaces
DB structure
API specs
Data structs
Validation
Use cases
BL Scenarios
User interfaces
Web UI
Mobile UI
Reporting
Schemas example
Schemas/SystemUser.js
({
login: { type: 'string', unique: true, length: 30 },
password: { type: 'string', length: 10 },
fullName: { 'string' required: false },
});
SystemUser
SystemGroup SystemSession
Schemas example
Schemas/SystemGroup.js
({
name: { type: 'string', unique: true },
users: { many: 'SystemUser' },
});
SystemUser
SystemGroup SystemSession
Schemas example
Schemas/SystemSession.js
({
user: 'SystemUser',
token: { type: 'string', unique: true },
ip: 'string',
data: 'json',
});
SystemUser
SystemGroup SystemSession
Autogenerated SQL DDL
CREATE TABLE "SystemUser" (
"systemUserId" bigint generated always as identity,
"login" varchar(30) NOT NULL,
"password" varchar(10) NOT NULL,
"fullName" varchar
);
ALTER TABLE "SystemUser"
ADD CONSTRAINT "pkSystemUser"
PRIMARY KEY ("systemUser");
Autogenerated SQL DDL
CREATE TABLE "SystemGroup" (
"systemGroupId" bigint generated always as identity,
"name" varchar NOT NULL
);
ALTER TABLE "SystemGroup"
ADD CONSTRAINT "pkSystemGroup"
PRIMARY KEY ("systemGroup");
Autogenerated SQL DDL
CREATE TABLE "SystemGroupSystemUser" (
"systemGroupId" bigint NOT NULL,
"systemUserId" bigint NOT NULL
);
ALTER TABLE "SystemGroupSystemUser"
ADD CONSTRAINT "pkSystemGroupSystemUser"
PRIMARY KEY ("systemGroupId", "systemUserId");
Autogenerated SQL DDL
ALTER TABLE "SystemGroupSystemUser"
ADD CONSTRAINT "fkSystemGroupSystemUserSystemGroup"
FOREIGN KEY ("systemGroupId")
REFERENCES "SystemGroup" ("systemGroupId");
ALTER TABLE "SystemGroupSystemUser"
ADD CONSTRAINT "fkSystemGroupSystemUserSystemUser"
FOREIGN KEY ("systemUserId")
REFERENCES "SystemUser" ("systemUserId");
Autogenerated SQL DDL
CREATE TABLE "SystemSession" (
"systemSessionId" bigint generated always as identity,
"userId" bigint NOT NULL,
"token" varchar NOT NULL,
"ip" varchar NOT NULL,
"data" jsonb NOT NULL
);
ALTER TABLE "SystemSession"
ADD CONSTRAINT "pkSystemSession"
PRIMARY KEY ("systemSession");
Autogenerated SQL DDL
ALTER TABLE "SystemSession"
ADD CONSTRAINT "fkSystemSessionUser"
FOREIGN KEY ("userId")
REFERENCES "SystemUser" ("systemUserId");
Autogenerated typings
interface SystemUser {
systemUserId: number;
login: string;
password: string;
fullName: string;
}
interface SystemGroup {
systemGroupId: number;
name: string;
}
Autogenerated typings
interface SystemSession {
systemSessionId: number;
userId: number;
token: string;
ip: string;
data: string;
}
Powered by schemas
● Contracts and data-structures validation
● Autogenerated .d.ts typings
● SQL DDL (database structure)
● Automated-migrations and structure versioning
● Scaffolding for DB access
● UI (web and mobile)
● Declarative data projections and aggregations
GRASP
General responsibility assignment software
patterns
“Applying UML and Patterns: An Introduction to
Object-Oriented Analysis and Design and Iterative
Development” // Craig Larman
GRASP
General responsibility assignment software
patterns
• Low Coupling • High Cohesion
• Information Expert • Creator
• Controller • Polymorphism
• Pure Fabrication • Indirection
• Protected Variations
GRASP: Information Expert
Problem: What is a basic principle by which to
assign responsibilities to objects?
Solution: Assign responsibility to the class that has
the information needed to fulfill it.
Benefits: Low Coupling, High Cohesion, Code
simplicity, Better encapsulation, Code reuse.
GRASP: Cohesion & Coupling
Cohesion (связность)
inside class, module,
component. etc.
Coupling (зацепление)
between classes
and other components
GRASP: Creator
Problem: Who creates object instance?
(who holds reference or destroy it)
Solution: composition containers (who aggregate
instances), who works with it and closely use it,
who have initializing information for instances.
Benefits: Low Coupling
Examples: constructor, factory, object pool.
GRASP: Controller
Problem: Who should be responsible for handling
an input system event?
Solution: Controller - communication entry point,
all system operations; delegates BL.
Benefits: protection, handle concurrency,
asynchronity, and parallel programming issues.
Examples: command, facade, layer isolation.
GRASP: Polymorphism
Polymorphism - alternative behaviour based on
type (see SOLID: LSP, OCP).
Problem: how to handle behavioral alternatives
based on type (or class)?
Solution: assign responsibility to the classes,
select one of type/class instead of if-statements,
access by interface or abstract class.
GRASP: Indirection
Indirection - intermediate object will decrease
coupling between two abstractions.
Benefits: Low Coupling, Code reuse.
Examples: GoF Mediator pattern (посредник),
MVC, С - controller.
GRASP: Pure fabrication
Pure fabrication - an abstraction that does not
exist in the subject area. It often reduces the
overlapping of domain classes.
Examples: Socket, DB Query, EventEmitter,
Promise, Asynchronous queue.
GRASP: Protected variations
Problem: How to design objects, subsystems, and
systems so that the variations or instability in
these elements does not have an undesirable
impact on other elements?
Solution: Identify points of predicted variation or
instability; assign responsibilities to create a stable
interface around them.
Summarize the approach
● Architecture: DDD and clean code, layered
architecture, domain in the middle
● Principles and patterns: GRASP, SOLID, GoF,
IoC, DI, coupling и cohesion, Law of Demeter
● Project structure: framework-agnostic
● Techniques: error handling, asynchronous and
parallel programming, metaprogramming...
LoD (Law of Demeter)
● Module should “knows” less about others
(low coupling), access through interfaces (ISP)
● All components communicates only with
neighbors and talks explicitly
● A class method works with its arguments,
other methods and properties of the instance
and its first-level structural parts
What we get
● Code reuse, no boilerplate
● A few and reliable dependencies
(pg 803 kb, ws 118 kb = 921 kb)
● System code 6 kb, applied code: 837 b
● Metarhia (5 June): 286 kb (JavaScript: 155 kb)
● Characteristics: Portability, Reliability, Security,
Isolation, Maintainability, High Availability
timur.shemsedinov@gmail.com
github.com/tshemsedinov
youtube.com/TimurShemsedinov
Largest Node.js and JavaScript course
github.com/HowProgrammingWorks/Index
t.me/HowProgrammingWorks
t.me/NodeUA
github.com/metarhia

More Related Content

What's hot

Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture corehard_by
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & ExpressChristian Joudrey
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6장현 한
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Expressjguerrero999
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS ExpressDavid Boyer
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming Tom Croucher
 
Using Grails to power your electric car
Using Grails to power your electric carUsing Grails to power your electric car
Using Grails to power your electric carMarco Pas
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.jsConFoo
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 

What's hot (20)

NodeJS
NodeJSNodeJS
NodeJS
 
NodeJS
NodeJSNodeJS
NodeJS
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Choosing the right parallel compute architecture
Choosing the right parallel compute architecture Choosing the right parallel compute architecture
Choosing the right parallel compute architecture
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS Express
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
 
Using Grails to power your electric car
Using Grails to power your electric carUsing Grails to power your electric car
Using Grails to power your electric car
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.js
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 

Similar to Node.js for enterprise - JS Conference

Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014Máté Nádasdi
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinSigma Software
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkLuciano Mammino
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?João Pedro Martins
 
Java on Windows Azure
Java on Windows AzureJava on Windows Azure
Java on Windows AzureDavid Chou
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop OverviewShubhra Kar
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsSebastian Springer
 
Why NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasWhy NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasDatavail
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureCloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureDavid Chou
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextPrateek Maheshwari
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with RailsPaul Gallagher
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Matthew McCullough
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsChris Bailey
 
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~Brocade
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DMithun Hunsur
 

Similar to Node.js for enterprise - JS Conference (20)

Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Java on Windows Azure
Java on Windows AzureJava on Windows Azure
Java on Windows Azure
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Why NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB AtlasWhy NBC Universal Migrated to MongoDB Atlas
Why NBC Universal Migrated to MongoDB Atlas
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows AzureCloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
CloudConnect 2011 - Building Highly Scalable Java Applications on Windows Azure
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
NodeJS
NodeJSNodeJS
NodeJS
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs Nodejs
 
Intro to Databases
Intro to DatabasesIntro to Databases
Intro to Databases
 
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~
Event-driven automation, DevOps way ~IoT時代の自動化、そのリアリティとは?~
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 

More from Timur Shemsedinov

How to use Chat GPT in JavaScript optimizations for Node.js
How to use Chat GPT in JavaScript optimizations for Node.jsHow to use Chat GPT in JavaScript optimizations for Node.js
How to use Chat GPT in JavaScript optimizations for Node.jsTimur Shemsedinov
 
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...Timur Shemsedinov
 
Multithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScriptMultithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScriptTimur Shemsedinov
 
Node.js threads for I/O-bound tasks
Node.js threads for I/O-bound tasksNode.js threads for I/O-bound tasks
Node.js threads for I/O-bound tasksTimur Shemsedinov
 
Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021Timur Shemsedinov
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsTimur Shemsedinov
 
Node.js for enterprise 2021 - JavaScript Fwdays 3
Node.js for enterprise 2021 - JavaScript Fwdays 3Node.js for enterprise 2021 - JavaScript Fwdays 3
Node.js for enterprise 2021 - JavaScript Fwdays 3Timur Shemsedinov
 
Node.js middleware: Never again!
Node.js middleware: Never again!Node.js middleware: Never again!
Node.js middleware: Never again!Timur Shemsedinov
 
Race-conditions-web-locks-and-shared-memory
Race-conditions-web-locks-and-shared-memoryRace-conditions-web-locks-and-shared-memory
Race-conditions-web-locks-and-shared-memoryTimur Shemsedinov
 
Asynchronous programming and mutlithreading
Asynchronous programming and mutlithreadingAsynchronous programming and mutlithreading
Asynchronous programming and mutlithreadingTimur Shemsedinov
 
Information system structure and architecture
Information system structure and architectureInformation system structure and architecture
Information system structure and architectureTimur Shemsedinov
 

More from Timur Shemsedinov (20)

How to use Chat GPT in JavaScript optimizations for Node.js
How to use Chat GPT in JavaScript optimizations for Node.jsHow to use Chat GPT in JavaScript optimizations for Node.js
How to use Chat GPT in JavaScript optimizations for Node.js
 
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
 
Multithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScriptMultithreading in Node.js and JavaScript
Multithreading in Node.js and JavaScript
 
Node.js threads for I/O-bound tasks
Node.js threads for I/O-bound tasksNode.js threads for I/O-bound tasks
Node.js threads for I/O-bound tasks
 
Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021
 
Rethinking low-code
Rethinking low-codeRethinking low-code
Rethinking low-code
 
Hat full of developers
Hat full of developersHat full of developers
Hat full of developers
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
 
Node.js for enterprise 2021 - JavaScript Fwdays 3
Node.js for enterprise 2021 - JavaScript Fwdays 3Node.js for enterprise 2021 - JavaScript Fwdays 3
Node.js for enterprise 2021 - JavaScript Fwdays 3
 
Node.js in 2021
Node.js in 2021Node.js in 2021
Node.js in 2021
 
Node.js middleware: Never again!
Node.js middleware: Never again!Node.js middleware: Never again!
Node.js middleware: Never again!
 
Patterns and antipatterns
Patterns and antipatternsPatterns and antipatterns
Patterns and antipatterns
 
Race-conditions-web-locks-and-shared-memory
Race-conditions-web-locks-and-shared-memoryRace-conditions-web-locks-and-shared-memory
Race-conditions-web-locks-and-shared-memory
 
Asynchronous programming and mutlithreading
Asynchronous programming and mutlithreadingAsynchronous programming and mutlithreading
Asynchronous programming and mutlithreading
 
Node.js in 2020 - part 3
Node.js in 2020 - part 3Node.js in 2020 - part 3
Node.js in 2020 - part 3
 
Node.js in 2020 - part 2
Node.js in 2020 - part 2Node.js in 2020 - part 2
Node.js in 2020 - part 2
 
Information system structure and architecture
Information system structure and architectureInformation system structure and architecture
Information system structure and architecture
 
Node.js in 2020 - part 1
Node.js in 2020 - part 1Node.js in 2020 - part 1
Node.js in 2020 - part 1
 
Web Locks API
Web Locks APIWeb Locks API
Web Locks API
 
Node.js in 2020
Node.js in 2020Node.js in 2020
Node.js in 2020
 

Recently uploaded

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Node.js for enterprise - JS Conference

  • 1. Node.js for Enterprise Chief Technology Architect at Metarhia CTO at Salucyber, Lecturer at KPI & KSE github.com/tshemsedinov Timur Shemsedinov
  • 2. Is Node.js ready for Enterprise?
  • 3. Is Node.js ready for Enterprise? Yes, sure
  • 4. Is Node.js ready for Enterprise? Yes, sure Node.js is ready
  • 5. Is Node.js ready for Enterprise? Yes, sure Node.js is ready But JavaScript developers...
  • 6. Is Node.js ready for Enterprise? Yes, sure Node.js is ready But JavaScript developers are not
  • 7. New features ● Multithreading for calculations and scale (added in v10, stable in v12) ● WASI, Node-API 8, V8 v9 for Node.js v16, npm 7 ● API: diagnostic API, perf_hooks, timer promises, AbortController, vm, v8, scrypt, Web crypto api, async_hooks, AsyncLocalStorage, etc. ● QUIC or HTTP/3 especially for mobile and 5G
  • 8. Monkey job Everything repeats every time we start a project ● Let’s discuss scaling, we expect highload ● We need microservices, REST and ORM ● People, vision and setup processes ● Application architecture and structure ● Select tools, libraries, frameworks ● Code conventions, repository maintenance
  • 9. Node.js challenges ● Enterprise requirements: Reliability, Maintainability, High Availability, Security, Isolation, Compatibility ● Community culture: meetups, conferences, fundamental SC knowledge, consensus ● Reputation and trust: education, certification, success stories
  • 11. With the code of your colleagues
  • 13. Application in Node.js runtime libuv V8 openssl zlib c-ares llhttp
  • 15. How to think about you code It’s glue and business-logic code Semantically and syntactically flexible Very expressive (you can create DSL) Simple for maintenance and changes Simple and readable for everyone Works everywhere Easy to integrate
  • 16. Engineering culture ● Architecture: DDD and clean code, layered architecture, domain in the middle ● Principles and patterns: GRASP, SOLID, GoF, IoC, DI, coupling и cohesion, Law of Demeter ● Project structure: framework-agnostic ● Techniques: error handling, asynchronous and parallel programming, metaprogramming...
  • 17. Important aspects ● Application is the place for applied code ● Declarative code is better than imperative ● State: reliability, performance, interactivity ● Configuration and infrastructure in the code ● Getting rid of dependencies ● We use layered architecture
  • 18. Related to Node.js ● Context isolation and v8 sandboxes ● Don’t block event-loop ● Avoiding race conditions and leaks ● Avoid reference pollution and mixins ● Don’t use middlewares ● Implement graceful shutdown ● Limit concurrency (async queue or semaphore)
  • 19. Important for Enterprise ● Business needs quick prototyping (TTM) ● We need security audit and certifications, so get rid of dependencies ● Enterprise prefers low-code ● Modeling visualisation (BPMN, ERD, state diagram, process flow)
  • 20. Layered (onion) Architecture Domain model Domain services Application services Presentation Infrastructure Persistence Postgres Redis External API Logger Configs Scheduler Health mon Validation Cryptography Sessions App firewall AAA Web UI Mobile UI API gateway
  • 21. Middleware: big ball of mud models controllers logger configs AAA validation cryptography sessions routing middlewares db configs rendering
  • 24. High coupling ● References are passed to other parts of the application (examples: req, res, socket, person, payment, logger, session, scheduler...) ● Passed objects mutations due to mixins will breaks our expectations ● Remaining references are visible from contexts so memory leaks and we need restarts
  • 25. “Talk is cheap. Show me the code.”
  • 26. What we get ● Framework-agnostic application ● Transport-agnostic communications ● No race conditions in asynchronous code ● No memory leaks and resource leaks ● Errors are handled properly ● Code reuse, no code duplication ● A few and reliable dependencies
  • 27. What we get ● DI (dependency-injection) ● Automatic routing (directory based) ● Context isolation ● Parse cookie without middlewares ● Sessions without middlewares ● Authentication without middlewares ● Concurrency control with semaphores
  • 29. Schema-centric approach Domain model Schema Domain services External interfaces DB structure API specs Data structs Validation Use cases BL Scenarios User interfaces Web UI Mobile UI Reporting
  • 30. Schemas example Schemas/SystemUser.js ({ login: { type: 'string', unique: true, length: 30 }, password: { type: 'string', length: 10 }, fullName: { 'string' required: false }, }); SystemUser SystemGroup SystemSession
  • 31. Schemas example Schemas/SystemGroup.js ({ name: { type: 'string', unique: true }, users: { many: 'SystemUser' }, }); SystemUser SystemGroup SystemSession
  • 32. Schemas example Schemas/SystemSession.js ({ user: 'SystemUser', token: { type: 'string', unique: true }, ip: 'string', data: 'json', }); SystemUser SystemGroup SystemSession
  • 33. Autogenerated SQL DDL CREATE TABLE "SystemUser" ( "systemUserId" bigint generated always as identity, "login" varchar(30) NOT NULL, "password" varchar(10) NOT NULL, "fullName" varchar ); ALTER TABLE "SystemUser" ADD CONSTRAINT "pkSystemUser" PRIMARY KEY ("systemUser");
  • 34. Autogenerated SQL DDL CREATE TABLE "SystemGroup" ( "systemGroupId" bigint generated always as identity, "name" varchar NOT NULL ); ALTER TABLE "SystemGroup" ADD CONSTRAINT "pkSystemGroup" PRIMARY KEY ("systemGroup");
  • 35. Autogenerated SQL DDL CREATE TABLE "SystemGroupSystemUser" ( "systemGroupId" bigint NOT NULL, "systemUserId" bigint NOT NULL ); ALTER TABLE "SystemGroupSystemUser" ADD CONSTRAINT "pkSystemGroupSystemUser" PRIMARY KEY ("systemGroupId", "systemUserId");
  • 36. Autogenerated SQL DDL ALTER TABLE "SystemGroupSystemUser" ADD CONSTRAINT "fkSystemGroupSystemUserSystemGroup" FOREIGN KEY ("systemGroupId") REFERENCES "SystemGroup" ("systemGroupId"); ALTER TABLE "SystemGroupSystemUser" ADD CONSTRAINT "fkSystemGroupSystemUserSystemUser" FOREIGN KEY ("systemUserId") REFERENCES "SystemUser" ("systemUserId");
  • 37. Autogenerated SQL DDL CREATE TABLE "SystemSession" ( "systemSessionId" bigint generated always as identity, "userId" bigint NOT NULL, "token" varchar NOT NULL, "ip" varchar NOT NULL, "data" jsonb NOT NULL ); ALTER TABLE "SystemSession" ADD CONSTRAINT "pkSystemSession" PRIMARY KEY ("systemSession");
  • 38. Autogenerated SQL DDL ALTER TABLE "SystemSession" ADD CONSTRAINT "fkSystemSessionUser" FOREIGN KEY ("userId") REFERENCES "SystemUser" ("systemUserId");
  • 39. Autogenerated typings interface SystemUser { systemUserId: number; login: string; password: string; fullName: string; } interface SystemGroup { systemGroupId: number; name: string; }
  • 40. Autogenerated typings interface SystemSession { systemSessionId: number; userId: number; token: string; ip: string; data: string; }
  • 41. Powered by schemas ● Contracts and data-structures validation ● Autogenerated .d.ts typings ● SQL DDL (database structure) ● Automated-migrations and structure versioning ● Scaffolding for DB access ● UI (web and mobile) ● Declarative data projections and aggregations
  • 42. GRASP General responsibility assignment software patterns “Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development” // Craig Larman
  • 43. GRASP General responsibility assignment software patterns • Low Coupling • High Cohesion • Information Expert • Creator • Controller • Polymorphism • Pure Fabrication • Indirection • Protected Variations
  • 44. GRASP: Information Expert Problem: What is a basic principle by which to assign responsibilities to objects? Solution: Assign responsibility to the class that has the information needed to fulfill it. Benefits: Low Coupling, High Cohesion, Code simplicity, Better encapsulation, Code reuse.
  • 45. GRASP: Cohesion & Coupling Cohesion (связность) inside class, module, component. etc. Coupling (зацепление) between classes and other components
  • 46. GRASP: Creator Problem: Who creates object instance? (who holds reference or destroy it) Solution: composition containers (who aggregate instances), who works with it and closely use it, who have initializing information for instances. Benefits: Low Coupling Examples: constructor, factory, object pool.
  • 47. GRASP: Controller Problem: Who should be responsible for handling an input system event? Solution: Controller - communication entry point, all system operations; delegates BL. Benefits: protection, handle concurrency, asynchronity, and parallel programming issues. Examples: command, facade, layer isolation.
  • 48. GRASP: Polymorphism Polymorphism - alternative behaviour based on type (see SOLID: LSP, OCP). Problem: how to handle behavioral alternatives based on type (or class)? Solution: assign responsibility to the classes, select one of type/class instead of if-statements, access by interface or abstract class.
  • 49. GRASP: Indirection Indirection - intermediate object will decrease coupling between two abstractions. Benefits: Low Coupling, Code reuse. Examples: GoF Mediator pattern (посредник), MVC, С - controller.
  • 50. GRASP: Pure fabrication Pure fabrication - an abstraction that does not exist in the subject area. It often reduces the overlapping of domain classes. Examples: Socket, DB Query, EventEmitter, Promise, Asynchronous queue.
  • 51. GRASP: Protected variations Problem: How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Solution: Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them.
  • 52. Summarize the approach ● Architecture: DDD and clean code, layered architecture, domain in the middle ● Principles and patterns: GRASP, SOLID, GoF, IoC, DI, coupling и cohesion, Law of Demeter ● Project structure: framework-agnostic ● Techniques: error handling, asynchronous and parallel programming, metaprogramming...
  • 53. LoD (Law of Demeter) ● Module should “knows” less about others (low coupling), access through interfaces (ISP) ● All components communicates only with neighbors and talks explicitly ● A class method works with its arguments, other methods and properties of the instance and its first-level structural parts
  • 54. What we get ● Code reuse, no boilerplate ● A few and reliable dependencies (pg 803 kb, ws 118 kb = 921 kb) ● System code 6 kb, applied code: 837 b ● Metarhia (5 June): 286 kb (JavaScript: 155 kb) ● Characteristics: Portability, Reliability, Security, Isolation, Maintainability, High Availability
  • 55. timur.shemsedinov@gmail.com github.com/tshemsedinov youtube.com/TimurShemsedinov Largest Node.js and JavaScript course github.com/HowProgrammingWorks/Index t.me/HowProgrammingWorks t.me/NodeUA github.com/metarhia