Solving architectural
problems with
OOP in pictures
Ivan Nemytchenko, railshurts.com, @inem
RubyRussia 2019
Slide 2
Slide 2 text
What’s the problem?
Abstractions on top of abstractions on top of other abstractions!
Slide 3
Slide 3 text
What’s the problem?
Very hard to see the big picture in real projects
Slide 4
Slide 4 text
What’s the problem?
Very hard to see the big picture in real projects
UML :(
Slide 5
Slide 5 text
What’s the problem?
Very hard to SEE the big picture in real projects
CRC Cards
Slide 6
Slide 6 text
What’s the problem?
Code quality metrics are non-actionable
So what?
Slide 7
Slide 7 text
What to expect here?
1. It is gonna be fun!
2. You’ll become better at:
• Learning, teaching, explaining, understanding
• Visualizing big picture, architecture flaws, code quality
Slide 8
Slide 8 text
How to illustrate
Dependency Injection
* with one picture
** so that everyone understands
?
Slide 9
Slide 9 text
About me
• Speaking
• Teaching (GoodProgramer.ru)
• Learning (RailsHurts.com)
• Freelancing
• GitLab Fan
• Omsk → Belgrade, Serbia
Slide 10
Slide 10 text
OOP in pictures
Foundation
Advanced concepts
Using in practice
Slide 11
Slide 11 text
“Smart kettle” task
Boil water correctly and safely!
1. No code
2. Just classes
3. And their methods
Slide 12
Slide 12 text
Kettle components (objects)
small dudes == objects
Slide 13
Slide 13 text
Kettle components (objects)
small dudes == objects
Slide 14
Slide 14 text
Objects with methods!
hands == methods
Slide 15
Slide 15 text
A method
number of fingers == number of arguments
Slide 16
Slide 16 text
Instance variables
Stored inside the brain
Slide 17
Slide 17 text
Instance variables
Can be reused later
Slide 18
Slide 18 text
А как тогда будет выглядеть…
Slide 19
Slide 19 text
Returning results
Slide 20
Slide 20 text
Private methods
Slide 21
Slide 21 text
Exception
Slide 22
Slide 22 text
Anti-patterns
Slide 23
Slide 23 text
Too many arguments
Slide 24
Slide 24 text
Too many methods
Slide 25
Slide 25 text
Too long methods
Slide 26
Slide 26 text
Too many instance variables
Slide 27
Slide 27 text
Too much conditional logic in methods
Руки-базуки
Slide 28
Slide 28 text
Too much of everything!!!
Slide 29
Slide 29 text
OOP in pictures
Foundation
Advanced concepts
Using in practice
Slide 30
Slide 30 text
Polymorphism
same number of hands with same number of fingers
Slide 31
Slide 31 text
No content
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
Classes
A spawning platform
Slide 36
Slide 36 text
Classes
A spawning platform
Slide 37
Slide 37 text
same topology
Object & classes have the
Slide 38
Slide 38 text
Topology
Кружка и бублик имеют
одинаковую топологию
Slide 39
Slide 39 text
same topology
Object & classes have the
Slide 40
Slide 40 text
Execution flow
Slide 41
Slide 41 text
Execution flow
Slide 42
Slide 42 text
Execution flow
Slide 43
Slide 43 text
Execution flow
Slide 44
Slide 44 text
Execution flow
Slide 45
Slide 45 text
Execution flow
Slide 46
Slide 46 text
Execution flow
Slide 47
Slide 47 text
Execution flow
Slide 48
Slide 48 text
Dependencies
have to remember about classes to use them
Slide 49
Slide 49 text
Dependencies
Slide 50
Slide 50 text
Side effects
Slide 51
Slide 51 text
Dependency Injection
Instead of remembering thing we pass them as arguments
Slide 52
Slide 52 text
No content
Slide 53
Slide 53 text
OOP in pictures
Foundation
Advanced concepts
Using in practice
Slide 54
Slide 54 text
Visual language!
Slide 55
Slide 55 text
No content
Slide 56
Slide 56 text
No content
Slide 57
Slide 57 text
No content
Slide 58
Slide 58 text
No content
Slide 59
Slide 59 text
No content
Slide 60
Slide 60 text
No content
Slide 61
Slide 61 text
No content
Slide 62
Slide 62 text
No content
Slide 63
Slide 63 text
No content
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
No content
Slide 66
Slide 66 text
Big picture
Slide 67
Slide 67 text
Big picture in dynamics
Slide 68
Slide 68 text
Big picture in dynamics
Slide 69
Slide 69 text
Big picture in dynamics
Slide 70
Slide 70 text
Big picture in dynamics
Slide 71
Slide 71 text
No content
Slide 72
Slide 72 text
No content
Slide 73
Slide 73 text
No content
Slide 74
Slide 74 text
No content
Slide 75
Slide 75 text
No content
Slide 76
Slide 76 text
No content
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
OOP in pictures
Foundation
Advanced concepts
Using in practice
Slide 79
Slide 79 text
No content
Slide 80
Slide 80 text
• Big picture
• Modelling
• Documenting
• Sharing knowledge
• Explaining
What can you use it for
Slide 81
Slide 81 text
• ТРИЗ
• Максвел
• Курпатов
It is a big deal!
Slide 82
Slide 82 text
Ivan Nemytchenko, railshurts.com, @inem
RubyRussia 2019
Questions