RubyConf 2018 Day Three

Ruby Conf 2018 Day Three


Key note - UNLEARNING - THE CHALLENGE OF CHANGE by Jessie Shternshus

Your brain on unlearning

Adapt

How do you motivate your team to change?

How do we make it better?

Case study

Books

Branch in Time by Tekin Suleyman

Case study

Commands for revising commits

git commit --amend --no-edit # this is useful rather than `git commit` then `git rebase -i`
git push --force-with-lease # in case someone else has published revisions

Resources

Recommendations

  1. Configure your git environment
    git config --global core.editor # (the editor of your choice)
    git config --global commit.verbose true
    
  2. In your commit message, capture the why and not the what
  3. Think carefully about the shape of your commit
    • create small atmoic commits, if your commit message has an “and”
    • shape as you go and not at the end
      git add --patch / -p
      
  4. Treat your local commits as mutable
    git commit --amend
    # --fixup / --autosquash
    git rebase -i # --interactive
    

Building Generic Software by Chris Salzberg

common patterns in translation libraries

  1. The translated attribute

  2. Storage patterns - tables in postgres

  3. Fallbacks - if a locale is not found return the english translation rather than nil

  4. Dirty tracking
    talk.changes
    
  5. control flows
    read_from_storage(:title)
    write_to_storage(:title, value)
    
module InstanceMethods
  def read_from_storage(attirbute)
    fallback_locales.each do |locale|
      value = column_value(attribute, locale)
      return value if value.present?
    end
  end

  def column_value(attribute, locale)
    ...
  end
end
 talk               application-code
  |
 \|/
translates          high-level-interface
  |
 \|/
read_from_storage   low-level-implementaion

Inversion of control

talk
 |    /|\
\|/    |
translates

Designing Reusable Classes - Ralph E. Johnson. Brian Foote

The hollywood principle


class Talk
  define_accessor(:title)

  def title
    title_backend.read(I18n.locale)
  end

  def title(:value)
    title_backend.write(I18n.locale, value)
  end


  def title_backend
    @backends[:title] ||=
      ColumnBackend.new(self, :title)
    end
  end
end
  1. plugins.each include plugin
  2. attributes.each define_accessor, define_backend
  3. backend.setup_model
  4. pass fallback class as an argument to the initializer

Mobility is a Pluggable Ruby translation framework

Other pluggable libraries

Complexity of protocol vs. reusability of software