Slide 1

Slide 1 text

Lotus For Rails Developers @jodosha / #lotusrb

Slide 2

Slide 2 text

Indie OSS dev & Freelancer

Slide 3

Slide 3 text

Why Lotus?

Slide 4

Slide 4 text

Lotus Philosophy

Slide 5

Slide 5 text

Lightweight

Slide 6

Slide 6 text

Features • Thread-safety • Full featured HTTP router • RESTful resources • Actions and views as objects • Actions callbacks • Code sharing • Exception handling • Sessions • Secure Cookies • HTTP Caching • Automatic MIME Types • 20+ Template engines • Partials and layouts • Presenters • Routing helpers • Form helpers • HTML helpers • Automatic markup escape • CSRF and XSS prevention • Force SSL • Entities • Repositories • Data Mapper • SQL and Memory adapters • Dirty Tracking • Reusable validations • Mailers • Multiple environments • Static assets • JSON body parser • Params whitelisting and validation • Code generators • Rack servers support • Application console • Database console • Powerful CLI • Migrations • RSpec, Minitest and Capybara support • Several architectures • And more..

Slide 7

Slide 7 text

0 17,5 35 52,5 70 Ruby Rack Sinatra Lotus Rails Dependencies Memory

Slide 8

Slide 8 text

On average, we use only a fraction of the features that a gem provides.

Slide 9

Slide 9 text

Lotus depends on a few gems. You can be sure that all the loaded code is useful for your application.

Slide 10

Slide 10 text

Lotus Foo Bar Baz Runtime dependency Transitive dependency

Slide 11

Slide 11 text

For each gem that we require, we’re adding overhead to Ruby and Bundler.

Slide 12

Slide 12 text

There is no faster code than no code at all.

Slide 13

Slide 13 text

Less convenient

Slide 14

Slide 14 text

Example: Constant Autoloading • Differences across environments • ActiveSupport’s dependencies.rb is ~800LOCs • lotus-controller gem is ~800LOCs • It took years to become stable • It modifies how Ruby VM loads code and features • It requires to “monkey-patch” Ruby Core

Slide 15

Slide 15 text

Solution: Eager loading • Same behaviour across environments • It’s just 26LOCs • It isn’t a perfect solution • “Easy fix” via require

Slide 16

Slide 16 text

No monkey-patching

Slide 17

Slide 17 text

Don’t monkey-patch classes that you don’t own.

Slide 18

Slide 18 text

Testability

Slide 19

Slide 19 text

All the application components can be unit tested.

Slide 20

Slide 20 text

No need to maintain lotus-rspec or lotus- minitest gems.

Slide 21

Slide 21 text

A complete framework

Slide 22

Slide 22 text

Lotus goes beyond “Flat-MVC” by providing a set of collaborators for “Full-MVC”.

Slide 23

Slide 23 text

Lotus toolkit

Slide 24

Slide 24 text

Full stack web apps

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Lotus has a “Modular First” approach that helps you to scale your code.

Slide 28

Slide 28 text

The Monolith is good for the first 5 years, but then a framework should make your life easy.

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Example #1

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

This is the name of the application under apps/

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Web::Controllers::Home::Index For the app named Web we have Web::Action

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

For the app named Web we have Web::View Web::Controllers::Home::Index Web::Views::Home::Index

Slide 39

Slide 39 text

All the “exposures” and view’s public methods are available to the template.

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Exposure from the action

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

Example #2

Slide 44

Slide 44 text

One big ERb block

Slide 45

Slide 45 text

In order to avoid coupling with any ORM, it just accepts symbols.

Slide 46

Slide 46 text

We have the routes factory to not overload the view context with too many methods.

Slide 47

Slide 47 text

No need to concat these two div blocks.

Slide 48

Slide 48 text

Params validation is optional

Slide 49

Slide 49 text

This is the same name that we have set to form_for.

Slide 50

Slide 50 text

Separation between entities and repositories.

Slide 51

Slide 51 text

No coupling with the routing system and the ORM

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Useful resources

Slide 57

Slide 57 text

http://lotusrb.org Guides and API docs

Slide 58

Slide 58 text

http://lotusrb.org/mailing-list Subscribe to the mailing list at:

Slide 59

Slide 59 text

http://lucaguidi.com

Slide 60

Slide 60 text

http://lotusrb.org/hackday

Slide 61

Slide 61 text

Q&A

Slide 62

Slide 62 text

https://speakerdeck.com/jodosha/ lotus-for-rails-developers Slides available at:

Slide 63

Slide 63 text

Thank you