Slide 1

Slide 1 text

advanced design patterns implementing with Ruby

Slide 2

Slide 2 text

@igbanam Rubyist — been cheating on Ruby with Java, Crystal, Scala, and Python RubyConf-NG/openemrs 2 poet. person. programmer.

Slide 3

Slide 3 text

contents 3 design patterns Advanced design patterns. Benefits of code structure. Decoupling. the bridge and the visitor The whens and when-nots. The rumours; the pit-falls. Storytelling with design patterns. demo 1 2 3

Slide 4

Slide 4 text

design patterns a glorified copy-and-paste

Slide 5

Slide 5 text

from concept to distribution automation, optimization… brains are naturally lazy why? What are the groupings? What purpose do they serve? categories? Repeatable solutions to recurring problems what? the language has some barriers ruby? code patterns, application, infrastructure, application domains? 5

Slide 6

Slide 6 text

Repeatable solutions to recurring problems ● started by architects ● adopted into software ○ “software architects” what are design patterns?

Slide 7

Slide 7 text

categories of design patterns 7 creational The most efficient way to create objects for certain use cases: singleton, factory, abstract factory, prototype, etc structural Ways to layout code for the least pain when maintaining it: composite, adapter, façade, bridge, etc behavioural Organizing dynamic interactions: null object, observer, iterator, command, blackboard, visitor, etc.

Slide 8

Slide 8 text

how does Ruby fare? The good… ● flexibility with constructs ● robust standard library ● no interfaces (fixed in Sorbet) The bad… ● no interfaces …currently The ugly… ● modules as interfaces 8

Slide 9

Slide 9 text

Application Patterns Event Sourcing, CQRS, Saga, Shared Database/Schema, and so on Architecture Monolith, MVC, HMVC, Microservices, Blackboard, and so on Infrastructure Serverless (lambdas), VMs, CI/CD Patterns, and so on. Communication Service Registry, RPC, and so on 9 patterns could span multiple development domains

Slide 10

Slide 10 text

the visitor a proper way to practise consent

Slide 11

Slide 11 text

concepts behind the visitor pattern ● Inheritance ○ Basic OO ● Composition ○ A Ruby way to feign interfaces ● Double Dispatch ○ Allowing objects define their interaction on other objects at runtime 11

Slide 12

Slide 12 text

Visitor Pattern Source: sourcemaking.com

Slide 13

Slide 13 text

Visitor Demo 13 Say a prayer to the demo gods

Slide 14

Slide 14 text

the bridge a tale of two cities

Slide 15

Slide 15 text

Source: sourcemaking.com Bridge Pattern

Slide 16

Slide 16 text

Bridge Demo 16 Say a prayer to the demo gods

Slide 17

Slide 17 text

Play with it. Learning is a fun process. Design is a Creative Process 17

Slide 18

Slide 18 text

Thank you for your time @yaasky @igbanam 18 Questions?