Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Managing Success: We made it, now we're screwed

Managing Success: We made it, now we're screwed

Life as a startup, whether a bootstrapped company or an experimental project within an enterprise, is hard. You have to struggle to earn success. Lean, pivots, minimal viable products, and other buzzwords all steps along this journey. The struggle makes the eventual success that much sweeter. But it can also lead to suboptimal code, confusing logic, and general friction to getting things done.

In this talk I'll discuss ways to identify areas of your Rails app improve and strategies for improving the quality over time. I'll share insights on managing several large Rails applications, the dangers of the single, monolithic, ball of mud Rails app, and what changes make the biggest impact.

blowmage

July 01, 2012
Tweet

More Decks by blowmage

Other Decks in Programming

Transcript

  1. Managing Success
    We made it, now we're screwed

    View full-size slide

  2. (NIH)
    Not Invented Here

    View full-size slide

  3. Conway's Law

    View full-size slide

  4. Organizations which design
    systems are constrained to
    produce designs which are
    copies of the communication
    structures of these
    organizations.
    - Melvin Conway

    View full-size slide

  5. "Ruby is designed to make
    programmers happy."
    - Matz

    View full-size slide

  6. Cost
    Time
    Cost per change
    (bugs, new features, etc)
    Non-TDD TDD

    View full-size slide

  7. Models
    Controllers/Routes
    Views/Helpers
    Application
    In Browser
    Cost per test

    View full-size slide

  8. Models
    Controllers/Routes
    Views/Helpers
    Application
    In Browser
    ROI per test

    View full-size slide

  9. Monolithic
    Models

    View full-size slide

  10. 1) Delarative

    View full-size slide

  11. 2) Level of
    Abstraction

    View full-size slide


  12. <% @article.tags.each do |tag| -%>
    <%= link_to "#{tag.name} (#{tag.articles.length})",
    tag_path(tag) %>
    <% end %>

    View full-size slide


  13. <% @article.tags.each do |tag| -%>
    <%= link_to "#{tag.name} (#{tag.article_count})",
    tag_path(tag) %>
    <% end %>

    View full-size slide


  14. <% @article.tags.each do |tag| -%>
    <%= link_to "#{tag.name} (#{tag.article_count})",
    tag_path(tag) %>
    <% end %>

    View full-size slide

  15. class Tag < ActiveRecord::Base
    belongs_to :article
    def article_count
    self.articles.count
    end
    end

    View full-size slide

  16. class Tag < ActiveRecord::Base
    belongs_to :article
    def article_count
    # Performance hack
    # faster than SELECT COUNT(*)
    self.articles.select(:id).count
    end
    end

    View full-size slide

  17. Monolithic Views

    View full-size slide

  18. <% if @course.available? &&
    @course.self_enrollment &&
    @course.open_enrollment &&
    (!@course_enrollment || !@course_enrollment.active?) &&
    !session["role_course_#{@course.id}"] %>
    <%= render :partial => "join_course", :object => @course %>
    <% elsif @course_enrollment &&
    @course_enrollment.self_enrolled &&
    @course_enrollment.active? &&
    (!session["role_course_#{@course.id}"]) %>
    <%= render :partial => "drop_course",
    :locals => { :course => @course,
    :enrollment => @course_enrollment } %>
    <% elsif temp_type = session["role_course_#{@course.id}"] %>
    ...
    <% end %>

    View full-size slide

  19. <% if can_join_course?(@course, @enrollment) %>
    <%= render :partial => "join_course", :object => @course %>
    <% elsif can_drop_course?(@course, @enrollment) %>
    <%= render :partial => "drop_course",
    :locals => { :course => @course,
    :enrollment => @course_enrollment } %>
    <% elsif temp_type = temp_permissions_to(@course) %>
    ...
    <% end %>

    View full-size slide

  20. module CourseHelper
    def can_join_course? course, enrollment
    course.available? &&
    course.self_enrollment &&
    course.open_enrollment &&
    (!enrollment || !enrollment.active?) &&
    !temp_permissions_to(course)
    end
    def can_drop_course? course, enrollment
    enrollment &&
    enrollment.self_enrolled &&
    enrollment.active? &&
    !temp_permissions_to(course)
    end
    def temp_permissions_to course
    session["role_course_#{course.id}"]
    end
    end

    View full-size slide

  21. <% if @presenter.can_join_course? %>
    <%= render :partial => "join_course", :object => @presenter.course %>
    <% elsif @presenter.can_drop_course? %>
    <%= render :partial => "drop_course",
    :locals => { :course => @presenter.course,
    :enrollment => @presenter.enrollment } %>
    <% elsif @presenter.temp_permissions %>
    ...
    <% end %>

    View full-size slide

  22. class CourseShowPresenter # this is a ViewModel, really
    attr_accessor :course, :enrollment, :current_user, :session
    def can_join_course?
    @course.available? &&
    @course.self_enrollment &&
    @course.open_enrollment &&
    (!@enrollment || [email protected]?) &&
    !temp_permissions
    end
    def can_drop_course?
    @enrollment &&
    @enrollment.self_enrolled &&
    @enrollment.active? &&
    !temp_permissions
    end
    def temp_permissions
    @session["role_course_#{@course.id}"]
    end
    end

    View full-size slide

  23. 1) Delarative

    View full-size slide

  24. 2) Level of
    Abstraction

    View full-size slide

  25. Monolithic Apps

    View full-size slide

  26. Monolithic Apps

    View full-size slide

  27. What is code?

    View full-size slide

  28. “Underlying our approach to this
    subject is our conviction that
    “computer science” is not a science
    and that its significance has little to
    do with computers.
    ... The computer revolution is a
    revolution in the way we think and in
    the way we express what we think.

    View full-size slide

  29. ... we want to establish the idea that
    a computer language is not just a
    way of getting a computer to
    perform operations but rather that it
    is a novel formal medium for
    expressing ideas about methodology.
    Thus, programs must be written for
    people to read, and only incidentally
    for machines to execute.

    View full-size slide

  30. ... we believe that the essential
    material to be addressed by a subject
    at this level is not the syntax of
    particular programming-language
    constructs, nor clever algorithms for
    computing particular functions
    efficiently, nor even the mathematical
    analysis of algorithms and the
    foundations of computing, ...

    View full-size slide

  31. but rather the techniques
    used to control the
    intellectual complexity of
    large software systems.”

    View full-size slide

  32. but rather the techniques
    used to control the
    intellectual complexity of
    large software systems.”

    View full-size slide

  33. Intellectual
    Complexity

    View full-size slide

  34. Human
    Activity

    View full-size slide

  35. “Often people, especially computer
    engineers, focus on the machines.
    They think, “By doing this, the
    machine will run faster. By doing this,
    the machine will run more
    effectively. By doing this, the machine
    will something something
    something.” They are focusing on
    machines...

    View full-size slide

  36. But in fact we need to focus on
    humans, on how humans care about
    doing programming or operating the
    application of the machines. We are
    the masters. They are the slaves.”
    -Matz

    View full-size slide

  37. HIRE ME!!!
    humanecode.com

    View full-size slide

  38. HIRE ME!!!
    humanecode.com
    Questions?

    View full-size slide