SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
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!

Más contenido relacionado

Similar a Tricks for Isolated Architecture in Ruby - Sergey Kukunin

Software Development in 21st Century
Software Development in 21st CenturySoftware Development in 21st Century
Software Development in 21st Century
Henry Jacob
 
Software Engineering Methodologies
Software Engineering MethodologiesSoftware Engineering Methodologies
Software Engineering Methodologies
Nesrine Shokry
 

Similar a 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
 

Más de Ruby Meditation

Más de 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
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

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!