SlideShare une entreprise Scribd logo
1  sur  74
Télécharger pour lire hors ligne
Yaroslav Voloshchuk && Aleksey Yashchenko
Grammarly
False Simplicity
of Frontend Applications
• Who we are?
• Software Engineers @ Grammarly
• Working on …
• Past
• Browser Extension
• Present
• Web Editor
• Desktop Editor

Our Talk: Overview
• [Done] Who we are
• => Overview (this slide :D)
• Complexity assessment mistake: why it happens?
• How to get it right?
• How to deal with complexity on the code level?

Our Talk
• [Done] Who we are
• [Done] Overview
• => Complexity assessment mistake: why it happens?
• How to get it right?
• How to deal with complexity on the code level?

1. Why and how it happens
• People don’t understand the problem they are solving
• Incomplete requirements
• Edge cases not taken into account
• 3rd party libraries/components are being used
• …
Inherent problems
complexity
2. The process
• Planning and resource allocation
• Choosing approach, architecture, tools
• Coding
• Release :(
• …
2. The process
• …
• Details appear in the process ‘out of the blue’
• It’s a small change!
• Let’s add one `if`
• [Repeat]
• Code => Spaghetti
• Release?
2. The process
• …
• Details appear in the process ‘out of the blue’
• It’s a small change!
• Let’s add one `if`
• [Repeat]
• Code => Spaghetti
• Release… :(
Can you just add this button please?
Shouldn’t be too hard!
2. The process
• …
• Details appear in the process ‘out of the blue’
• It’s a small change!
• Let’s add one `if`
• [Repeat]
• Code => Spaghetti
• Release… :(
Can you just add this button please?
Shouldn’t be too hard!
2. The process
• …
• Details appear in the process ‘out of the blue’
• It’s a small change!
• Let’s add one `if`
• [Repeat]
• Code => Spaghetti
• Eternal release… soon :( Release… :(
3.1. Technical Results
• Unsupportable, write-only code
• Instant legacy in a new product
• Undermining architectural effort; non-optimal solution
completely ruins the architecture



3.1. Product Results
• Bugs
• Unexpected behavior
• A lot of product areas are underdeveloped
• Team’s moral & spirit is affected

Okay, smarty, what to do?
• Get complexity right
• Address it on the code level
Our Talk
• [Done] Who we are
• [Done] Overview
• [Done] Complexity assessment mistake: why it
happens?
• => How to get it right?
• How to deal with complexity on the code level?

Describe the problem in more details
• Talk to colleagues, specialists, 

non-specialists, and to the debug duck
• Run a requirements testing with QA engineers
• Ask how to break a feature before you write it,
brainstorm corner cases
• Ask how a feature will develop in 1-2 years from now
• Look how it’s done by competitors, think why
Describe the problem in more details:Tools
• => Design mockups & prototyping
• Build models
• Plain old multileveled list
• Mind maps
• Draw a state chart (state diagram) with events and
transitions
• User story mapping
Describe the problem in more details:Tools
• Design mockups & prototyping
• => Build models
• Plain old multileveled list
• Mind maps
• Draw a state chart (state diagram) with events and
transitions
• User story mapping
Describe the problem in more details:Tools
• Design mockups & prototyping
• Build models
• => Plain old multileveled list
• Mind maps
• Draw a state chart (state diagram) with events and
transitions
• User story mapping
Describe the problem in more details:Tools
• Design mockups & prototyping
• Build models
• Plain old multileveled list
• => Mind maps
• Draw a state chart (state diagram) with events and
transitions
• User story mapping
Describe the problem in more details:Tools
• Design mockups & prototyping
• Build models
• Plain old multileveled list
• Mind maps
• => Draw a state chart (state diagram) with events and
transitions
• User story mapping
Describe the problem in more details:Tools
• Design mockups & prototyping
• Build models
• Plain old multileveled list
• Mind maps
• Draw a state chart (state diagram) with events and
transitions
• => User story mapping (well, we don’t use it :))
• …
• You name it!







Describe the problem in more details
Complexity Assessment:
But don’t go waterfall!
Okay… 

Houston, we have
a complex problem,
what now?
Deal with it.
Our Talk
• [Done] Who we are
• [Done] Overview
• [Done] Complexity assessment mistake: why it happens?
• [Done] How to get it right?
• => How to deal with complexity on the code level?
–Edsger W. Dijkstra
“The art of programming is 

the art of organizing complexity”
–Anonymous
“Programming is all about composition”
Complexity?
Complexity?
• Wikipedia: In software engineering, programming
complexity is a measure of the interactions of the
various elements of the software.
• Level of entropy
• More: https://en.wikipedia.org/wiki/Complex_system

Where it came from?
• Essential complexity
• Input
• Output
• Accidental complexity
• Everything else we created



- Brooks, Fred (1986).“No Silver Bullet” 

• Coupling 

how tightly a module is related to others
• Cohesion 

how closely all the routines in a module support it’s
central purpose













Characteristics
• Readability
• Maintainability
• Branching (Cyclomatic complexity)
• Size (LOC)
• More buzzwords: 

https://en.wikipedia.org/wiki/Programming_complexity

Characteristics
It occurs at different levels
• Statements
• Methods
• Modules / Classes
• App / Subsystems
• Product / Requirements
Structural
Behavioral
It occurs at different levels
• Statements
• Methods
• Modules / Classes
• App / Subsystems
• Product / Requirements
Structural
Behavioral
Conquering Complexity
1. Statements
• const vs let

Use const everywhere
• for, while, if, break => 

foreach, map, reduce, filter, find, ...
• Try, Option

Idiomatic handling for empty values and errors
• With this you mostly don’t need defensive
programming
Idiomatic handling for empty values and errors
export function parseConfig(
base: AppConfig,
localConfig: Option<string>
): AppConfig {
return localConfig
.flatMap(config =>
Try.of(() => JSON.parse(config)).recover(() => window.atob(config)).toOption()
)
.flatMap(
parsedConfig =>
iots
.validate(parsedConfig, ConfigType)
.map(validConfig => merge(base, validConfig)) // Load app with custom config
)
.getOrElse(base)
}
2. Functions/Methods
• Prefer pure functions
• Prefer polymorphism to if statements
• Single responsibility
• Don’t break invariants
• Use composition with functions. 

They are first class citizens (thus: memoization, strategy,
pipeline, etc)
• Make it understandable without reading the method body
Prefer polymorphism to if statements
////// Don’t
function logMessage(message: string) {
remoteLoggerSink.send(message)
if (Config.printToConsole) {
console.log('LOG: ' + message)
}
}
////// Do
function logToRemote(message: string) {
remoteLoggerSink.send(message)
}
function logWithConsole(message: string) {
logToRemote(message)
console.log('LOG: ' + message)
}
const logMessage = Config.printToConsole ? logWithConsole : logToRemote
2. Functions/Methods
• Prefer pure functions
• Prefer polymorphism to if statements
• Single responsibility
• Don’t break invariants
• Use composition with functions. 

They are first class citizens (thus: memoization, strategy,
pipeline, etc)
• Make it understandable without reading the method body
Don’t break invariants
/// Don’t
const alert = Alerts.createAlert(alertData)
// ...
// then
alert.register(positionManager)
/// Do
const alert = Alerts.createAlert(alertData, positionManager)
2. Functions/Methods
• Prefer pure functions
• Prefer polymorphism to if statements
• Single responsibility
• Don’t break invariants
• Use composition with functions. 

They are first class citizens (thus: memoization, strategy,
pipeline, etc)
• Make it understandable without reading the method body
Make it understandable without reading the
method body
// Don't
function parse(data) {
// 20 LOC body to read
}
// Do
function parseConfig(configJson: string): Try<Config> {
// Whatever
}
3. Modules/Classes #0
• Use Types
• Use Types
• Use Types
• If in doubt => Use Types



3. Modules/Classes #0
• Use Types
• Use Types
• Use Types
• If in doubt => Use Types



Flow
TypeScript
Elm
PureScript
OCaml (BuckleScript)
…
3. Modules/Classes #1
• Liskov substitution principle
3. Modules/Classes #1: SOLID
• Single responsibility principle
• Open/closed principle
• Liskov substitution principle
• Interface segregation principle
• Dependency inversion principle
Single responsibility principle
const alerts: Alert[] = alertsManager.allAlerts()
// Don’t
const scoreString: string = calculateScore(alerts)
// Do
const score: Score = calculateScore(alerts)
const scoreString: string = jsonSerializer(score)
Open/closed principle
class TrackingClient {
// ...
track(event: TrackingEvent) {
fetch(this._endpoing, { /* payload */ })
}
}
class TrackingClient {
// ...
constructor(private _fetch = fetch) {
}
track(logEntry: TrackingEvent) {
this._fetch(this._endpoing, { /* payload */ })
}
}
Liskov substitution principle
interface ImmutablePoint {
readonly x: number
readonly y: number
}
// Wrong, violates contract
interface MutablePoint extends ImmutablePoint {
x: number
y: number
}
3. Modules/Classes #1: SOLID
• Single responsibility principle
• Open/closed principle
• Liskov substitution principle
• Interface segregation principle
• Dependency inversion principle
Dependency inversion principle
namespace Bad {
class A {}
class B {
// Direct dependency creates stronger coupling
constructor(param: A) {}
}
}
namespace Good {
interface A {}
class B {
// Dependency on abstraction, allows any impl here
constructor(param: A) {}
}
class AImpl implements A {}
}
3. Modules/Classes #2
• Data hiding/encapsulation
• Separation of concerns
• Composition over inheritance
• Invariance in types
• Algebraic data types
enum RequestState {
loading,
ready,
error
}
interface Loading {
state: RequestState.loading
}
interface Ready {
state: RequestState.ready
data: string
}
interface Error {
state: RequestState.error
error: any
}
type Request = Loading | Ready | Error
function proccesRequest(request: Request) {
switch (request.state) {
case RequestState.loading: return console.info('request in progress')
case RequestState.ready: return console.log('response', request.data)
case RequestState.error: return console.error('error =(', request.error)
default:
const state: never = request
throw new Error('Unexpected state')
}
}
Algebraic Data Types
buzzwords…
YAGNI
DRY
Stable Dependencies Principle
Stable Abstractions Principle
KISS
MDA
Monoids
GRASP
Code Generation
Currying
Continuations
4. Subsystems/Apps
• Don’t reinvent the wheel:There is an app library for that!
• Grab a good runtime library 

(ramda, immutable.js, lodash-fp, etc, still not clear for TS thou)
• Read more papers, e.g. 

https://github.com/papers-we-love/papers-we-love
• Use existing design patterns which address your problem
• Use suitable data structures instead of arrays/objects
• Use frameworks/libraries that fit your task
Behavioral Complexity
Behavioral Complexity
• Callbacks hell
• PubSub aka Emitter hell
• FRP comes to the rescue!
• Event Streams (Signals/Observables) > Events
• RxJS, Bacon.js, Kefir, Highland
hoveredMarks = this.options.scrollContainer
.map(scroll => scroll.getOrElseL(() => this.quill.root))
.switchMap(container =>
Observable.merge(
Observable.fromEvent(container, 'mouseenter').mapTo(true),
Observable.fromEvent(container, 'mouseleave').mapTo(false)
)
)
.switchMap(
inside =>
inside
? Observable.merge(
this.options.contentUpdated.mapTo(None),
this.options.scrollPositionChanged.mapTo(None),
Observable.fromEvent<MouseEvent>(this.quill.root, 'mousemove')
.auditTime(50)
.map(e => {
const node = document.elementFromPoint(e.clientX, e.clientY)
const blot = Quill.find(node, true) as Blot
return !blot || blot instanceof Quill
? None
: this._getMarksByBlot(blot)
})
)
: Observable.of(None).delay(200)
)
.distinctUntilChanged(this._optionMarksEqual)
.share()
.startWith(None)
Fin.
Questions?
Yaroslav Voloshchuk
@wenqer
LI:yaroslavvoloshchuk
Aleksey Yashchenko
@tuxslayer
FB/LI:tuxslayer
Further Reading
Further reading 

Articles on Requirements & Complexity
• Programming complexity https://en.wikipedia.org/wiki/
Programming_complexity
• Cyclomatic complexity https://en.wikipedia.org/wiki/
Cyclomatic_complexity
• No Silver Bullet http://www.cs.nott.ac.uk/~pszcah/G51ISS/Documents/
NoSilverBullet.html
• SOLID https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
• The Coming Software Apocalypse https://www.theatlantic.com/
technology/archive/2017/09/saving-the-world-from-code/540393
• User story mapping https://www.scrumalliance.org/community/articles/
2013/august/creating-an-agile-roadmap-using-story-mapping
Further reading

Useful papers, articles and tech
• Papers we love 

https://github.com/papers-we-love/papers-we-love
• FP vs OOP 

http://blog.cleancoder.com/uncle-bob/2014/11/24/
FPvsOO.html
• AirBnb Sketch App 

https://github.com/airbnb/react-sketchapp
• FSM 

https://en.wikipedia.org/wiki/Finite-state_machine
Further reading

Books and stuff
• Code Complete
• FRP https://www.manning.com/books/functional-reactive-programming
• Refactoring: Improving the Design of Existing Code
• UML Distilled: A Brief Guide to the Standard Object Modeling Language
• Head First Design Patterns
• Learning JavaScript Design Patterns
• TypeScript Deep Dive https://www.gitbook.com/book/basarat/typescript/details
• Functional JavaScript http://shop.oreilly.com/product/0636920028857.do
• FP in Scala https://www.manning.com/books/functional-programming-in-scala
• PureScript https://leanpub.com/purescript/read
• Learn You a Haskell for Great Good http://learnyouahaskell.com

Contenu connexe

Tendances

Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.comAdvanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
DevOpsDays Tel Aviv
 

Tendances (20)

Gatling
Gatling Gatling
Gatling
 
Sharing the pain using Protractor
Sharing the pain using ProtractorSharing the pain using Protractor
Sharing the pain using Protractor
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
 
Lets cook cucumber !!
Lets cook cucumber !!Lets cook cucumber !!
Lets cook cucumber !!
 
Automated Testing in Angular Slides
Automated Testing in Angular SlidesAutomated Testing in Angular Slides
Automated Testing in Angular Slides
 
"Production Driven Development", Serhii Kalinets
"Production Driven Development", Serhii Kalinets"Production Driven Development", Serhii Kalinets
"Production Driven Development", Serhii Kalinets
 
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
 
Jasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScriptJasmine - A BDD test framework for JavaScript
Jasmine - A BDD test framework for JavaScript
 
BDD from QA side
BDD from QA sideBDD from QA side
BDD from QA side
 
Capybara testing
Capybara testingCapybara testing
Capybara testing
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
Migration from AngularJS to Angular
Migration from AngularJS to AngularMigration from AngularJS to Angular
Migration from AngularJS to Angular
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Meetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React TestingMeetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React Testing
 
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.comAdvanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
Advanced A/B Testing at Wix - Aviran Mordo and Sagy Rozman, Wix.com
 
Load testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew SiemerLoad testing with Visual Studio and Azure - Andrew Siemer
Load testing with Visual Studio and Azure - Andrew Siemer
 
Getting By Without "QA"
Getting By Without "QA"Getting By Without "QA"
Getting By Without "QA"
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with Arquillian
 

Similaire à Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"

Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 

Similaire à Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications" (20)

A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Component-first Applications
Component-first ApplicationsComponent-first Applications
Component-first Applications
 
A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
 
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
 
Mixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting exampleMixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting example
 
BDD Primer
BDD PrimerBDD Primer
BDD Primer
 
Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to use
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
How to crack java script certification
How to crack java script certificationHow to crack java script certification
How to crack java script certification
 
Design Without Types
Design Without TypesDesign Without Types
Design Without Types
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
Introducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsIntroducing systems analysis, design & development Concepts
Introducing systems analysis, design & development Concepts
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 

Plus de Fwdays

Plus de Fwdays (20)

"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
 
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast..."Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
 
"Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others..."Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others...
 
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
 
"Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv..."Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv...
 
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin..."How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"

  • 1. Yaroslav Voloshchuk && Aleksey Yashchenko Grammarly False Simplicity of Frontend Applications
  • 2.
  • 3. • Who we are? • Software Engineers @ Grammarly • Working on … • Past • Browser Extension • Present • Web Editor • Desktop Editor

  • 4.
  • 5. Our Talk: Overview • [Done] Who we are • => Overview (this slide :D) • Complexity assessment mistake: why it happens? • How to get it right? • How to deal with complexity on the code level?

  • 6. Our Talk • [Done] Who we are • [Done] Overview • => Complexity assessment mistake: why it happens? • How to get it right? • How to deal with complexity on the code level?

  • 7. 1. Why and how it happens • People don’t understand the problem they are solving • Incomplete requirements • Edge cases not taken into account • 3rd party libraries/components are being used • …
  • 9. 2. The process • Planning and resource allocation • Choosing approach, architecture, tools • Coding • Release :( • …
  • 10. 2. The process • … • Details appear in the process ‘out of the blue’ • It’s a small change! • Let’s add one `if` • [Repeat] • Code => Spaghetti • Release?
  • 11. 2. The process • … • Details appear in the process ‘out of the blue’ • It’s a small change! • Let’s add one `if` • [Repeat] • Code => Spaghetti • Release… :( Can you just add this button please? Shouldn’t be too hard!
  • 12. 2. The process • … • Details appear in the process ‘out of the blue’ • It’s a small change! • Let’s add one `if` • [Repeat] • Code => Spaghetti • Release… :( Can you just add this button please? Shouldn’t be too hard!
  • 13. 2. The process • … • Details appear in the process ‘out of the blue’ • It’s a small change! • Let’s add one `if` • [Repeat] • Code => Spaghetti • Eternal release… soon :( Release… :(
  • 14. 3.1. Technical Results • Unsupportable, write-only code • Instant legacy in a new product • Undermining architectural effort; non-optimal solution completely ruins the architecture
 

  • 15. 3.1. Product Results • Bugs • Unexpected behavior • A lot of product areas are underdeveloped • Team’s moral & spirit is affected

  • 16. Okay, smarty, what to do? • Get complexity right • Address it on the code level
  • 17. Our Talk • [Done] Who we are • [Done] Overview • [Done] Complexity assessment mistake: why it happens? • => How to get it right? • How to deal with complexity on the code level?

  • 18. Describe the problem in more details • Talk to colleagues, specialists, 
 non-specialists, and to the debug duck • Run a requirements testing with QA engineers • Ask how to break a feature before you write it, brainstorm corner cases • Ask how a feature will develop in 1-2 years from now • Look how it’s done by competitors, think why
  • 19. Describe the problem in more details:Tools • => Design mockups & prototyping • Build models • Plain old multileveled list • Mind maps • Draw a state chart (state diagram) with events and transitions • User story mapping
  • 20. Describe the problem in more details:Tools • Design mockups & prototyping • => Build models • Plain old multileveled list • Mind maps • Draw a state chart (state diagram) with events and transitions • User story mapping
  • 21.
  • 22. Describe the problem in more details:Tools • Design mockups & prototyping • Build models • => Plain old multileveled list • Mind maps • Draw a state chart (state diagram) with events and transitions • User story mapping
  • 23. Describe the problem in more details:Tools • Design mockups & prototyping • Build models • Plain old multileveled list • => Mind maps • Draw a state chart (state diagram) with events and transitions • User story mapping
  • 24.
  • 25. Describe the problem in more details:Tools • Design mockups & prototyping • Build models • Plain old multileveled list • Mind maps • => Draw a state chart (state diagram) with events and transitions • User story mapping
  • 26.
  • 27. Describe the problem in more details:Tools • Design mockups & prototyping • Build models • Plain old multileveled list • Mind maps • Draw a state chart (state diagram) with events and transitions • => User story mapping (well, we don’t use it :))
  • 28.
  • 29. • … • You name it!
 
 
 
 Describe the problem in more details
  • 31. Okay… 
 Houston, we have a complex problem, what now?
  • 33. Our Talk • [Done] Who we are • [Done] Overview • [Done] Complexity assessment mistake: why it happens? • [Done] How to get it right? • => How to deal with complexity on the code level?
  • 34. –Edsger W. Dijkstra “The art of programming is 
 the art of organizing complexity” –Anonymous “Programming is all about composition”
  • 36. Complexity? • Wikipedia: In software engineering, programming complexity is a measure of the interactions of the various elements of the software. • Level of entropy • More: https://en.wikipedia.org/wiki/Complex_system

  • 37. Where it came from? • Essential complexity • Input • Output • Accidental complexity • Everything else we created
 
 - Brooks, Fred (1986).“No Silver Bullet” 

  • 38. • Coupling 
 how tightly a module is related to others • Cohesion 
 how closely all the routines in a module support it’s central purpose
 
 
 
 
 
 
 Characteristics
  • 39. • Readability • Maintainability • Branching (Cyclomatic complexity) • Size (LOC) • More buzzwords: 
 https://en.wikipedia.org/wiki/Programming_complexity
 Characteristics
  • 40. It occurs at different levels • Statements • Methods • Modules / Classes • App / Subsystems • Product / Requirements Structural Behavioral
  • 41. It occurs at different levels • Statements • Methods • Modules / Classes • App / Subsystems • Product / Requirements Structural Behavioral
  • 43.
  • 44. 1. Statements • const vs let
 Use const everywhere • for, while, if, break => 
 foreach, map, reduce, filter, find, ... • Try, Option
 Idiomatic handling for empty values and errors • With this you mostly don’t need defensive programming
  • 45. Idiomatic handling for empty values and errors export function parseConfig( base: AppConfig, localConfig: Option<string> ): AppConfig { return localConfig .flatMap(config => Try.of(() => JSON.parse(config)).recover(() => window.atob(config)).toOption() ) .flatMap( parsedConfig => iots .validate(parsedConfig, ConfigType) .map(validConfig => merge(base, validConfig)) // Load app with custom config ) .getOrElse(base) }
  • 46. 2. Functions/Methods • Prefer pure functions • Prefer polymorphism to if statements • Single responsibility • Don’t break invariants • Use composition with functions. 
 They are first class citizens (thus: memoization, strategy, pipeline, etc) • Make it understandable without reading the method body
  • 47. Prefer polymorphism to if statements ////// Don’t function logMessage(message: string) { remoteLoggerSink.send(message) if (Config.printToConsole) { console.log('LOG: ' + message) } } ////// Do function logToRemote(message: string) { remoteLoggerSink.send(message) } function logWithConsole(message: string) { logToRemote(message) console.log('LOG: ' + message) } const logMessage = Config.printToConsole ? logWithConsole : logToRemote
  • 48. 2. Functions/Methods • Prefer pure functions • Prefer polymorphism to if statements • Single responsibility • Don’t break invariants • Use composition with functions. 
 They are first class citizens (thus: memoization, strategy, pipeline, etc) • Make it understandable without reading the method body
  • 49. Don’t break invariants /// Don’t const alert = Alerts.createAlert(alertData) // ... // then alert.register(positionManager) /// Do const alert = Alerts.createAlert(alertData, positionManager)
  • 50. 2. Functions/Methods • Prefer pure functions • Prefer polymorphism to if statements • Single responsibility • Don’t break invariants • Use composition with functions. 
 They are first class citizens (thus: memoization, strategy, pipeline, etc) • Make it understandable without reading the method body
  • 51. Make it understandable without reading the method body // Don't function parse(data) { // 20 LOC body to read } // Do function parseConfig(configJson: string): Try<Config> { // Whatever }
  • 52. 3. Modules/Classes #0 • Use Types • Use Types • Use Types • If in doubt => Use Types
 

  • 53. 3. Modules/Classes #0 • Use Types • Use Types • Use Types • If in doubt => Use Types
 
 Flow TypeScript Elm PureScript OCaml (BuckleScript) …
  • 54. 3. Modules/Classes #1 • Liskov substitution principle
  • 55. 3. Modules/Classes #1: SOLID • Single responsibility principle • Open/closed principle • Liskov substitution principle • Interface segregation principle • Dependency inversion principle
  • 56. Single responsibility principle const alerts: Alert[] = alertsManager.allAlerts() // Don’t const scoreString: string = calculateScore(alerts) // Do const score: Score = calculateScore(alerts) const scoreString: string = jsonSerializer(score)
  • 57. Open/closed principle class TrackingClient { // ... track(event: TrackingEvent) { fetch(this._endpoing, { /* payload */ }) } } class TrackingClient { // ... constructor(private _fetch = fetch) { } track(logEntry: TrackingEvent) { this._fetch(this._endpoing, { /* payload */ }) } }
  • 58. Liskov substitution principle interface ImmutablePoint { readonly x: number readonly y: number } // Wrong, violates contract interface MutablePoint extends ImmutablePoint { x: number y: number }
  • 59. 3. Modules/Classes #1: SOLID • Single responsibility principle • Open/closed principle • Liskov substitution principle • Interface segregation principle • Dependency inversion principle
  • 60. Dependency inversion principle namespace Bad { class A {} class B { // Direct dependency creates stronger coupling constructor(param: A) {} } } namespace Good { interface A {} class B { // Dependency on abstraction, allows any impl here constructor(param: A) {} } class AImpl implements A {} }
  • 61. 3. Modules/Classes #2 • Data hiding/encapsulation • Separation of concerns • Composition over inheritance • Invariance in types • Algebraic data types
  • 62. enum RequestState { loading, ready, error } interface Loading { state: RequestState.loading } interface Ready { state: RequestState.ready data: string } interface Error { state: RequestState.error error: any } type Request = Loading | Ready | Error function proccesRequest(request: Request) { switch (request.state) { case RequestState.loading: return console.info('request in progress') case RequestState.ready: return console.log('response', request.data) case RequestState.error: return console.error('error =(', request.error) default: const state: never = request throw new Error('Unexpected state') } } Algebraic Data Types
  • 63. buzzwords… YAGNI DRY Stable Dependencies Principle Stable Abstractions Principle KISS MDA Monoids GRASP Code Generation Currying Continuations
  • 64. 4. Subsystems/Apps • Don’t reinvent the wheel:There is an app library for that! • Grab a good runtime library 
 (ramda, immutable.js, lodash-fp, etc, still not clear for TS thou) • Read more papers, e.g. 
 https://github.com/papers-we-love/papers-we-love • Use existing design patterns which address your problem • Use suitable data structures instead of arrays/objects • Use frameworks/libraries that fit your task
  • 66. Behavioral Complexity • Callbacks hell • PubSub aka Emitter hell • FRP comes to the rescue! • Event Streams (Signals/Observables) > Events • RxJS, Bacon.js, Kefir, Highland
  • 67. hoveredMarks = this.options.scrollContainer .map(scroll => scroll.getOrElseL(() => this.quill.root)) .switchMap(container => Observable.merge( Observable.fromEvent(container, 'mouseenter').mapTo(true), Observable.fromEvent(container, 'mouseleave').mapTo(false) ) ) .switchMap( inside => inside ? Observable.merge( this.options.contentUpdated.mapTo(None), this.options.scrollPositionChanged.mapTo(None), Observable.fromEvent<MouseEvent>(this.quill.root, 'mousemove') .auditTime(50) .map(e => { const node = document.elementFromPoint(e.clientX, e.clientY) const blot = Quill.find(node, true) as Blot return !blot || blot instanceof Quill ? None : this._getMarksByBlot(blot) }) ) : Observable.of(None).delay(200) ) .distinctUntilChanged(this._optionMarksEqual) .share() .startWith(None)
  • 68. Fin.
  • 72. Further reading 
 Articles on Requirements & Complexity • Programming complexity https://en.wikipedia.org/wiki/ Programming_complexity • Cyclomatic complexity https://en.wikipedia.org/wiki/ Cyclomatic_complexity • No Silver Bullet http://www.cs.nott.ac.uk/~pszcah/G51ISS/Documents/ NoSilverBullet.html • SOLID https://en.wikipedia.org/wiki/SOLID_(object-oriented_design) • The Coming Software Apocalypse https://www.theatlantic.com/ technology/archive/2017/09/saving-the-world-from-code/540393 • User story mapping https://www.scrumalliance.org/community/articles/ 2013/august/creating-an-agile-roadmap-using-story-mapping
  • 73. Further reading
 Useful papers, articles and tech • Papers we love 
 https://github.com/papers-we-love/papers-we-love • FP vs OOP 
 http://blog.cleancoder.com/uncle-bob/2014/11/24/ FPvsOO.html • AirBnb Sketch App 
 https://github.com/airbnb/react-sketchapp • FSM 
 https://en.wikipedia.org/wiki/Finite-state_machine
  • 74. Further reading
 Books and stuff • Code Complete • FRP https://www.manning.com/books/functional-reactive-programming • Refactoring: Improving the Design of Existing Code • UML Distilled: A Brief Guide to the Standard Object Modeling Language • Head First Design Patterns • Learning JavaScript Design Patterns • TypeScript Deep Dive https://www.gitbook.com/book/basarat/typescript/details • Functional JavaScript http://shop.oreilly.com/product/0636920028857.do • FP in Scala https://www.manning.com/books/functional-programming-in-scala • PureScript https://leanpub.com/purescript/read • Learn You a Haskell for Great Good http://learnyouahaskell.com