SlideShare a Scribd company logo
1 of 53
Download to read offline
Tricks for Isolated
Architecture in Ruby
Ruby Meditation #15, May 13 2017
I am Sergiy
And I’ve been searching a silver bullet for a while
BTW, my twitter is @sergey_kukunin
Hello!
I work at , Lviv
The Humble Programmer
“we shall be able to design and implement the
kind of systems that are now straining our
programming ability, at the expense of only a few
percent in man-years of what they cost us now,
and that besides that, these systems will be
virtually free of bugs”
by Edsger W. Dijkstra, 1972, http://bit.ly/2pHGbhF
The Humble Programmer
● intellectually manageable programs
● proof of correctness
● the amount of intellectual effort depends on
the program length
● the influence of the tool we are trying to use
upon our own thinking habits
● hierarchy
The Humble Programmer
“In computer programming our basic building
block has an associated time grain of less than a
microsecond, but our program may take hours of
computation time. I do not know of any other
technology covering a ratio of 1010
or more”
Two values of software
The secondary value of software is its behavior.
1
Defined by Uncle Bob Martin in episode 9 (‘The Single Responsibility
Principle’) of his CleanCoders video series
The primary value of
software is that it’s soft.
The ability of software to tolerate and facilitate such ongoing change is
the primary value of software.
2
Conclusions
● Programming is complicated
● Programming is risky
● Programming is expensive
That’s why we should care about what we write.
Symptoms of Rotting Design
◉ Rigidity - the tendency for software to be difficult to change
◉ Fragility - the tendency of the software to break in many places every
time it is changed
◉ Immobility - the inability to reuse software from other projects or from
parts of the same project
◉ Viscosity - two forms: viscosity of the design, and viscosity of the
environment
http://bit.ly/2rawutr
Other criterias
◉ Deployability
◉ Developability
◉ Comprehensibility
Every technique has own advantages and
overhead. Sometimes, a technique doesn’t fit.
You’re the one who is solely responsible for
the code quality of your project.
Disclaimer:
“
The main enemy of software is
complexity. To remain
maintainable, software should be
simple.
Complexity grows as
application grows1
The biggest impact is made
by solution modularity
Analyze of Sorting algorithms
Bubble sort = O(N2
)
When N = 60, N2
= 3600
If we divide an array into two halves
we’ll have 2 * (N/2)2
= 2 * (302
) = 1800
Divide and Conquer
Divide and Conquer
Single Responsibility Principle
● Definition of responsibility
○ Should have only one reason to change file
● Works on class level as well as on module level
● + Decreases rigidity
● + Necessary step for modularity
Examples of SRP
● Localization
● Thread handling
● HTML/CSS/JS
● Interactors
Rely on interface, not on
implementation
Example of interface
The less a module knows about siblings,
the more independent it is.
Keep encapsulation
Law of Demeter
might indicates that current class knows too
much. Does this look better?
Dependency Inversion Principle
● High-level policy should not be dependent
upon low-level detail
● Main trick for decoupling
● + Decreases rigidity
● + Improves modularity/deployability
● + Better testing
● - Lines of code overhead
How it works: DI
How it works: DI
Dependency Injection
Isn’t this violation of
encapsulation?
Integration of modules
IoC
1 ● Separates the application from the main.
● Fixes dependencies order.
● Decouples modules and classes.
● Decreases rigidity of the application.
Should be iterative, small and often
Constant Refactoring
Boyscout Rule
Functional programming
Because functions are data
First-class functions
Composability
Immutability
First-class tests
● Tests are proof of correctness
● They make you feel safe while refactoring
● Tests drive better design
● Tests should be trustful
● Tests should be fast
Test-driven development
1. You are not allowed to write any production
code unless it is to make a failing unit test pass.
2. You are not allowed to write any more of a
unit test than is sufficient to fail; and
compilation failures are failures.
3. You are not allowed to write any more
production code than is sufficient to pass the
one failing unit test.
“
The only way to keep it simple is
to make composition of
abstractions
Simple software is
readable software2
We read code even when we write code
Micro-level
◉ Small classes
◉ Small methods
◉ Intention-revealing
methods
◉ Consistent indentation
Readability
Macro-level
◉ Ubiquitous language
◉ Unified model
◉ Domain-driven design
DDD separates
domain-related code
from platform-related
2
Domain layer: dry-types
1 ● Prevention of illegal state
● Types algebra
● Immutability
● Blazing fast
Application layer: CQS
1 defines application boundaries: data inside are trusted
Infrastructure layer
1 ● Independent implementations of 3rd-party
services
● The easiest to extract to a gem
● Persistence is here
UI layer
1 ● An interface for interactive for the application
● HTTP delivery mechanism
● Validation is tied to an interface, not to an entity
● dry-validation
Persistence layer: ROM
1 ● Adapters
● Relations
● Mappers
● Repositories
Other advices
◉ Prefer instance methods over class methods
◉ Avoid singletons and global state
◉ Prefer pure functions
Real experience
Any questions ?
You can find me at
◉ @sergey_kukunin
◉ sergiy@maticinsurance.com
Thanks!

More Related Content

Similar to Tricks for Isolated Architecture in Ruby - Sergey Kukunin

Lecture1 cst205 cst281-oop
Lecture1 cst205 cst281-oopLecture1 cst205 cst281-oop
Lecture1 cst205 cst281-oopktuonlinenotes
 
No silver bullet summary (paper)
No silver bullet summary (paper)No silver bullet summary (paper)
No silver bullet summary (paper)shakeel khan
 
Software Development in 21st Century
Software Development in 21st CenturySoftware Development in 21st Century
Software Development in 21st CenturyHenry Jacob
 
Path dependent-development (PyCon India)
Path dependent-development (PyCon India)Path dependent-development (PyCon India)
Path dependent-development (PyCon India)ncoghlan_dev
 
1605162990-week56.pptx
1605162990-week56.pptx1605162990-week56.pptx
1605162990-week56.pptxSumbalIlyas1
 
STM-UNIT-1.pptx
STM-UNIT-1.pptxSTM-UNIT-1.pptx
STM-UNIT-1.pptxnischal55
 
Software Engineering Methodologies
Software Engineering MethodologiesSoftware Engineering Methodologies
Software Engineering MethodologiesNesrine Shokry
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Kuwait10
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the WebIcinetic
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code cleanBrett Child
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeAnsviaLab
 

Similar to Tricks for Isolated Architecture in Ruby - Sergey Kukunin (20)

Lecture1 cst205 cst281-oop
Lecture1 cst205 cst281-oopLecture1 cst205 cst281-oop
Lecture1 cst205 cst281-oop
 
No silver bullet summary (paper)
No silver bullet summary (paper)No silver bullet summary (paper)
No silver bullet summary (paper)
 
Software Development in 21st Century
Software Development in 21st CenturySoftware Development in 21st Century
Software Development in 21st Century
 
Path dependent-development (PyCon India)
Path dependent-development (PyCon India)Path dependent-development (PyCon India)
Path dependent-development (PyCon India)
 
What is xp
What is xpWhat is xp
What is xp
 
Sepm t1
Sepm t1Sepm t1
Sepm t1
 
1605162990-week56.pptx
1605162990-week56.pptx1605162990-week56.pptx
1605162990-week56.pptx
 
STM-UNIT-1.pptx
STM-UNIT-1.pptxSTM-UNIT-1.pptx
STM-UNIT-1.pptx
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
01_IT4557.pptx
01_IT4557.pptx01_IT4557.pptx
01_IT4557.pptx
 
Software Engineering Methodologies
Software Engineering MethodologiesSoftware Engineering Methodologies
Software Engineering Methodologies
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10
 
PROGRAMMING LANGUAGE AND TYPES
PROGRAMMING LANGUAGE AND TYPESPROGRAMMING LANGUAGE AND TYPES
PROGRAMMING LANGUAGE AND TYPES
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the Web
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the Web
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Answers
AnswersAnswers
Answers
 
Lecture1422914635
Lecture1422914635Lecture1422914635
Lecture1422914635
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
 

More from Ruby Meditation

Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30Ruby Meditation
 
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...Ruby Meditation
 
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29Ruby Meditation
 
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Ruby Meditation
 
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28 How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28 Ruby Meditation
 
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28Ruby Meditation
 
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...Ruby Meditation
 
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...Ruby Meditation
 
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...Ruby Meditation
 
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...Ruby Meditation
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27Ruby Meditation
 
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26Ruby Meditation
 
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26Ruby Meditation
 
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...Ruby Meditation
 
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26Ruby Meditation
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Ruby Meditation
 
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...Ruby Meditation
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Ruby Meditation
 
Rails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan GusievRails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan GusievRuby Meditation
 
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23Ruby Meditation
 

More from Ruby Meditation (20)

Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
 
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
 
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
 
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
 
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28 How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
 
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
 
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
 
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
 
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
 
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
 
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
 
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
 
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
 
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
 
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
 
Rails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan GusievRails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan Gusiev
 
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
[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.pdfhans926745
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 AutomationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
[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
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Tricks for Isolated Architecture in Ruby - Sergey Kukunin

  • 1. Tricks for Isolated Architecture in Ruby Ruby Meditation #15, May 13 2017
  • 2. I am Sergiy And I’ve been searching a silver bullet for a while BTW, my twitter is @sergey_kukunin Hello!
  • 3. I work at , Lviv
  • 4.
  • 5. The Humble Programmer “we shall be able to design and implement the kind of systems that are now straining our programming ability, at the expense of only a few percent in man-years of what they cost us now, and that besides that, these systems will be virtually free of bugs” by Edsger W. Dijkstra, 1972, http://bit.ly/2pHGbhF
  • 6. The Humble Programmer ● intellectually manageable programs ● proof of correctness ● the amount of intellectual effort depends on the program length ● the influence of the tool we are trying to use upon our own thinking habits ● hierarchy
  • 7. The Humble Programmer “In computer programming our basic building block has an associated time grain of less than a microsecond, but our program may take hours of computation time. I do not know of any other technology covering a ratio of 1010 or more”
  • 8. Two values of software The secondary value of software is its behavior. 1 Defined by Uncle Bob Martin in episode 9 (‘The Single Responsibility Principle’) of his CleanCoders video series
  • 9. The primary value of software is that it’s soft. The ability of software to tolerate and facilitate such ongoing change is the primary value of software. 2
  • 10. Conclusions ● Programming is complicated ● Programming is risky ● Programming is expensive That’s why we should care about what we write.
  • 11. Symptoms of Rotting Design ◉ Rigidity - the tendency for software to be difficult to change ◉ Fragility - the tendency of the software to break in many places every time it is changed ◉ Immobility - the inability to reuse software from other projects or from parts of the same project ◉ Viscosity - two forms: viscosity of the design, and viscosity of the environment http://bit.ly/2rawutr
  • 12. Other criterias ◉ Deployability ◉ Developability ◉ Comprehensibility
  • 13. Every technique has own advantages and overhead. Sometimes, a technique doesn’t fit. You’re the one who is solely responsible for the code quality of your project. Disclaimer:
  • 14. “ The main enemy of software is complexity. To remain maintainable, software should be simple.
  • 16. The biggest impact is made by solution modularity
  • 17. Analyze of Sorting algorithms Bubble sort = O(N2 ) When N = 60, N2 = 3600 If we divide an array into two halves we’ll have 2 * (N/2)2 = 2 * (302 ) = 1800
  • 20. Single Responsibility Principle ● Definition of responsibility ○ Should have only one reason to change file ● Works on class level as well as on module level ● + Decreases rigidity ● + Necessary step for modularity
  • 21. Examples of SRP ● Localization ● Thread handling ● HTML/CSS/JS ● Interactors
  • 22. Rely on interface, not on implementation
  • 24. The less a module knows about siblings, the more independent it is. Keep encapsulation
  • 25. Law of Demeter might indicates that current class knows too much. Does this look better?
  • 26. Dependency Inversion Principle ● High-level policy should not be dependent upon low-level detail ● Main trick for decoupling ● + Decreases rigidity ● + Improves modularity/deployability ● + Better testing ● - Lines of code overhead
  • 30. Isn’t this violation of encapsulation?
  • 32. IoC 1 ● Separates the application from the main. ● Fixes dependencies order. ● Decouples modules and classes. ● Decreases rigidity of the application.
  • 33. Should be iterative, small and often Constant Refactoring
  • 36. Because functions are data First-class functions
  • 39. First-class tests ● Tests are proof of correctness ● They make you feel safe while refactoring ● Tests drive better design ● Tests should be trustful ● Tests should be fast
  • 40. Test-driven development 1. You are not allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
  • 41.
  • 42. “ The only way to keep it simple is to make composition of abstractions
  • 43. Simple software is readable software2 We read code even when we write code
  • 44. Micro-level ◉ Small classes ◉ Small methods ◉ Intention-revealing methods ◉ Consistent indentation Readability Macro-level ◉ Ubiquitous language ◉ Unified model ◉ Domain-driven design
  • 46. Domain layer: dry-types 1 ● Prevention of illegal state ● Types algebra ● Immutability ● Blazing fast
  • 47. Application layer: CQS 1 defines application boundaries: data inside are trusted
  • 48. Infrastructure layer 1 ● Independent implementations of 3rd-party services ● The easiest to extract to a gem ● Persistence is here
  • 49. UI layer 1 ● An interface for interactive for the application ● HTTP delivery mechanism ● Validation is tied to an interface, not to an entity ● dry-validation
  • 50. Persistence layer: ROM 1 ● Adapters ● Relations ● Mappers ● Repositories
  • 51. Other advices ◉ Prefer instance methods over class methods ◉ Avoid singletons and global state ◉ Prefer pure functions
  • 53. Any questions ? You can find me at ◉ @sergey_kukunin ◉ sergiy@maticinsurance.com Thanks!