SlideShare a Scribd company logo
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

NodeJS
NodeJSNodeJS
NodeJS
LinkMe Srl
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
Erik van Appeldoorn
 
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 & Express
Christian Joudrey
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
Sébastien Pertus
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
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
jguerrero999
 
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 Express
David 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 js
Akshay Mathur
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 

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 2014
Má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 Galkin
Sigma 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 framework
Luciano 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 Azure
David Chou
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
Yevgeniy Brikman
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
Shubhra 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.js
Sebastian 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 Atlas
Datavail
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
YoungSu 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 Azure
David 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 Next
Prateek Maheshwari
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
Paul Gallagher
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
DevOpsDays Austin 2014
 
NodeJS
NodeJSNodeJS
NodeJS
Alok Guha
 
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
Matthew McCullough
 
JAX London 2015: Java vs Nodejs
JAX London 2015: Java vs NodejsJAX London 2015: Java vs Nodejs
JAX London 2015: Java vs Nodejs
Chris Bailey
 
Intro to Databases
Intro to DatabasesIntro to Databases
Intro to Databases
Sargun Dhillon
 
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 D
Mithun 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.js
Timur 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 JavaScript
Timur 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 tasks
Timur Shemsedinov
 
Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021Node.js Меньше сложности, больше надежности Holy.js 2021
Node.js Меньше сложности, больше надежности Holy.js 2021
Timur Shemsedinov
 
Rethinking low-code
Rethinking low-codeRethinking low-code
Rethinking low-code
Timur Shemsedinov
 
Hat full of developers
Hat full of developersHat full of developers
Hat full of developers
Timur 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.js
Timur 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 3
Timur Shemsedinov
 
Node.js in 2021
Node.js in 2021Node.js in 2021
Node.js in 2021
Timur Shemsedinov
 
Node.js middleware: Never again!
Node.js middleware: Never again!Node.js middleware: Never again!
Node.js middleware: Never again!
Timur Shemsedinov
 
Patterns and antipatterns
Patterns and antipatternsPatterns and antipatterns
Patterns and antipatterns
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-memory
Timur Shemsedinov
 
Asynchronous programming and mutlithreading
Asynchronous programming and mutlithreadingAsynchronous programming and mutlithreading
Asynchronous programming and mutlithreading
Timur Shemsedinov
 
Node.js in 2020 - part 3
Node.js in 2020 - part 3Node.js in 2020 - part 3
Node.js in 2020 - part 3
Timur Shemsedinov
 
Node.js in 2020 - part 2
Node.js in 2020 - part 2Node.js in 2020 - part 2
Node.js in 2020 - part 2
Timur Shemsedinov
 
Information system structure and architecture
Information system structure and architectureInformation system structure and architecture
Information system structure and architecture
Timur Shemsedinov
 
Node.js in 2020 - part 1
Node.js in 2020 - part 1Node.js in 2020 - part 1
Node.js in 2020 - part 1
Timur Shemsedinov
 
Web Locks API
Web Locks APIWeb Locks API
Web Locks API
Timur Shemsedinov
 
Node.js in 2020
Node.js in 2020Node.js in 2020
Node.js in 2020
Timur 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

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
Nettur Technical Training Foundation
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 

Recently uploaded (20)

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 

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