Slide 1

Slide 1 text

Speed-dating Your Rails Application Dana Jones @danabrit Software Developer Collective Idea collectiveidea.com

Slide 2

Slide 2 text

Who Am I? @danabrit @danabrit

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

• deadmanssnitch • harmony • hourglass • inchworm • Downside

Slide 5

Slide 5 text

6 years 8 years

Slide 6

Slide 6 text

HatTip: thejohnsonletters.com

Slide 7

Slide 7 text

1. New job

Slide 8

Slide 8 text

1. New job 2. Change project at job

Slide 9

Slide 9 text

1. New job 2. Change project at job 3. New client

Slide 10

Slide 10 text

1. New job 2. Change project at job 3. New client 4. Review a gem for possible use

Slide 11

Slide 11 text

1. New job 2. Change project at job 3. New client 4. Review a gem for possible use 5. Open source contributor

Slide 12

Slide 12 text

HatTip: huffpost.com

Slide 13

Slide 13 text

HatTip: myitalia.me

Slide 14

Slide 14 text

Goals

Slide 15

Slide 15 text

Goals Values

Slide 16

Slide 16 text

Goals Values Lifestyles

Slide 17

Slide 17 text

Goals Values Lifestyles Tastes

Slide 18

Slide 18 text

Goals Values Lifestyles Attraction Tastes

Slide 19

Slide 19 text

HatTip: phermalabs.com

Slide 20

Slide 20 text

HatTip: positiveproductive.com

Slide 21

Slide 21 text

Key Concepts

Slide 22

Slide 22 text

1.Classes

Slide 23

Slide 23 text

1.Classes 2.Documentation

Slide 24

Slide 24 text

1.Classes 2.Documentation 3.Dependencies

Slide 25

Slide 25 text

1.Classes 2.Documentation 3.Dependencies 4.Data Storage

Slide 26

Slide 26 text

Classes Getting to Know Your

Slide 27

Slide 27 text

Relationship Graphs help you visualize the relationships between the classes in your application.

Slide 28

Slide 28 text

Post Relationship Graph: 
 Simple Blog

Slide 29

Slide 29 text

Post Author 1 Relationship Graph: 
 Simple Blog

Slide 30

Slide 30 text

Post Author 1 ∞ Relationship Graph: 
 Simple Blog

Slide 31

Slide 31 text

Post Author Comment Tag 1 ∞ Relationship Graph: 
 Simple Blog

Slide 32

Slide 32 text

Post Author Comment Tag 1 ∞ ∞ ∞ Relationship Graph: 
 Simple Blog

Slide 33

Slide 33 text

Post Author Comment Tag 1 1 1 ∞ ∞ ∞ Relationship Graph: 
 Simple Blog

Slide 34

Slide 34 text

Lobsters - Link Aggregator
 github.com/jcs/lobsters
 May 2015

Slide 35

Slide 35 text

Redmine - CMS github.com/edavis10/redmine
 circa 2009

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Computer-Generated Relationship Graphs github.com/voormedia/rails-erd gem "rails-erd" $ brew install graphviz $ bundle install $ bundle exec rake erd rails-erd github.com/preston/railroady gem "railroady" $ brew install graphviz $ bundle install $ bundle exec rake diagram:all railroady

Slide 38

Slide 38 text

$ bundle exec rake erd rails-erd: default github.com/fxn/rails-contributors contributors.rubyonrails.org

Slide 39

Slide 39 text

$ bundle exec rake erd attributes=false rails-erd: simple

Slide 40

Slide 40 text

$ bundle exec rake diagram:all railroady: complete

Slide 41

Slide 41 text

$ bundle exec rake diagram:all railroady: brief

Slide 42

Slide 42 text

Customizing Diagrams rails-erd railroady Diagram title Output file name/type Diagram orientation Show/hide inheritance Show/hide timestamp fields Include orphaned models Transitive associations Generate controller diagrams Include plugin/engine models Diagram info label Limit models by name (only/exclude)

Slide 43

Slide 43 text

Documentation Getting to Know Your

Slide 44

Slide 44 text

Documentation is the secret, underused weapon in the developer’s arsenal.

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Sources of Documentation • README - general overview of the application, 
 install instructions, caveats, dependencies,
 historical data

Slide 47

Slide 47 text

Sources of Documentation • README - general overview of the application, 
 install instructions, caveats, dependencies,
 historical data
 • /doc - RubyDoc documentation (native to Rails),
 as well as anything that you or other gems may
 add to this dir (eg. railroady schemas, rdoc, yardoc)

Slide 48

Slide 48 text

Sources of Documentation • README - general overview of the application, 
 install instructions, caveats, dependencies,
 historical data
 • /doc - RubyDoc documentation (native to Rails),
 as well as anything that you or other gems may
 add to this dir (eg. railroady schemas, rdoc, yardoc)
 • Tests - especially feature tests. Well-named, well-
 structured tests are excellent documentation.

Slide 49

Slide 49 text

Dependencies Getting to Know Your

Slide 50

Slide 50 text

• Gemfile Dependencies

Slide 51

Slide 51 text

# By placing all of Spree's shared dependencies in this file and then loading # it for each component's Gemfile, we can be sure that we're only testing just # the one component of Spree. source 'https://rubygems.org' gem 'coffee-rails', '~> 4.0.0' gem 'sass-rails', '~> 5.0.0' gem 'sqlite3', platforms: [:ruby, :mingw, :mswin, :x64_mingw] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] platforms :jruby do gem 'jruby-openssl' gem 'activerecord-jdbcsqlite3-adapter' end platforms :ruby do gem 'mysql2' gem 'pg' end group :test do gem 'capybara', '~> 2.4' gem 'database_cleaner', '~> 1.3' gem 'email_spec' gem 'factory_girl_rails', '~> 4.5.0' gem 'launchy' gem 'rspec-activemodel-mocks' gem 'rspec-collection_matchers' gem 'rspec-its' gem 'rspec-rails', '~> 3.1.0' gem 'simplecov' gem 'webmock', '1.8.11' gem 'poltergeist', '1.6.0' gem 'timecop' gem 'with_model' end group :test, :development do gem 'rubocop', require: false gem 'pry-byebug' end

Slide 52

Slide 52 text

source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.6' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' gem 'bootstrap-sass', '~> 3.3.1' gem 'autoprefixer-rails' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', group: :development # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Use debugger # gem 'debugger', group: [:development, :test]

Slide 53

Slide 53 text

• Gemfile • /lib Dependencies

Slide 54

Slide 54 text

• Gemfile • /lib • /config Dependencies

Slide 55

Slide 55 text

• Gemfile • /lib • /config ๏ environments ๏ initializers ๏ routes Dependencies

Slide 56

Slide 56 text

Data Storage Getting to Know Your

Slide 57

Slide 57 text

HatTip: thedreamingwizard.com

Slide 58

Slide 58 text

1. Number of tables Data Storage - Red Flags

Slide 59

Slide 59 text

1. Number of tables 2. Redundancy Data Storage - Red Flags

Slide 60

Slide 60 text

1. Number of tables 2. Redundancy 3. Unused tables Data Storage - Red Flags

Slide 61

Slide 61 text

1. Number of tables 2. Redundancy 3. Unused tables 4. Missing indices Data Storage - Red Flags

Slide 62

Slide 62 text

1. Number of tables 2. Redundancy 3. Unused tables 4. Missing indices 5. Cleverness smells Data Storage - Red Flags

Slide 63

Slide 63 text

1. Number of tables 2. Redundancy 3. Unused tables 4. Missing indices 5. Cleverness smells 6. Meaningless attribute names Data Storage - Red Flags

Slide 64

Slide 64 text

1. Number of tables 2. Redundancy 3. Unused tables 4. Missing indices 5. Cleverness smells 6. Meaningless attribute names • data • type • key, value • a, b, c • first_option, second_option Data Storage - Red Flags

Slide 65

Slide 65 text

Just Enough Getting to Know

Slide 66

Slide 66 text

HatTip: travelingtopher.com

Slide 67

Slide 67 text

Thank You! Dana Jones @danabrit

Slide 68

Slide 68 text

Bonus Slides

Slide 69

Slide 69 text

HatTip: essence.com

Slide 70

Slide 70 text

1. Logic allocation Second Date

Slide 71

Slide 71 text

1. Logic allocation 2. Code redundancy Second Date

Slide 72

Slide 72 text

1. Logic allocation 2. Code redundancy 3. Simplicity Second Date

Slide 73

Slide 73 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) Second Date

Slide 74

Slide 74 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage Second Date

Slide 75

Slide 75 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage 6. Responsiveness (design) Second Date

Slide 76

Slide 76 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage 6. Responsiveness (design) 7. Responsiveness (speed) Second Date

Slide 77

Slide 77 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage 6. Responsiveness (design) 7. Responsiveness (speed) 8. Authentication/authorization Second Date

Slide 78

Slide 78 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage 6. Responsiveness (design) 7. Responsiveness (speed) 8. Authentication/authorization 9. Markup language/views Second Date

Slide 79

Slide 79 text

1. Logic allocation 2. Code redundancy 3. Simplicity 4. Hackishness (count the TODOs) 5. Javascript library usage 6. Responsiveness (design) 7. Responsiveness (speed) 8. Authentication/authorization 9. Markup language/views 10.Feedback (metrics and human) Second Date

Slide 80

Slide 80 text

Ruby on Rails Speed-dating Checklist Do I know what each class represents? Do the tests pass? Do the associations between classes make sense? Am I familiar/comfortable with the testing stack? Are there redundant or unnecessary classes or tables? Are there signs of organization or disorganization? Do the classes’ attributes make sense? How much monkey-patching is evident? Is the same data being stored in multiple places, without cause? Are there obvious lapses in security? Are my primary and foreign keys sensical? Does it follow common Rails and Ruby conventions? Will the application be difficult to install or configure? Are the data types used sensical, performant, and efficient? What versions of Ruby and Rails does it rely on? Does indexing appear to be used sanely? Are there dependencies I have struggled with in the past? Am I familiar with the database this project uses? Are there gems I’ve never used or heard of before? Does the database used match the requirements of this project, and/or my use of it? Is the project in active development? What external APIs does this project depend on? Do I know how to contact the maintainer? Does this project offer a robust community for support and/or guidance? How thoroughly-tested is the project? Is this a project I am welcomed to contribute to? How much do I trust the tests? Is this a project I feel inclined to contribute to?