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

Your First Legacy Codebase

Your First Legacy Codebase

So you've just graduated from a bootcamp and you're starting your first real job in software development. You've got several Rails apps under your belt and you're excited to get started. But few jobs offer the opportunity to build new apps; it's much more likely that you will be part of a team charged with maintaining and growing a legacy application. How can you get started working on an aging codebase when the sum of your experience so far was with greenfield apps?

4900754dfff6786e747438a703e0d791?s=128

Coraline Ada Ehmke

May 04, 2016
Tweet

More Decks by Coraline Ada Ehmke

Other Decks in Technology

Transcript

  1. Your First Legacy Codebase Coraline Ada Ehmke @CoralineAda

  2. Congratulations!

  3. Green fields lay behind you.

  4. A twisted legacy awaits.

  5. Who am I?

  6. Code Witch

  7. Long-Time Rubyist

  8. where.coraline.codes

  9. @CoralineAda

  10. Contributor Covenant

  11. Senior Engineer

  12. Notorious SJW

  13. Legacy Codebases

  14. A large, unwieldy,
 pre-existing code base.

  15. A code base so large 
 that it’s difficult to

    hold
 in your head all at once.
  16. Code whose creators have moved on to other things.

  17. Code that represents a 
 significant investment.

  18. Code that is essential to 
 the company making money.

  19. Code that can’t just be
 “burned down”.

  20. The Ultimate Legacy Application

  21. World’s Largest Rails App?

  22. Canvas LMS

  23. $ find . -type f | wc -l 11687

  24. None
  25. None
  26. None
  27. Legacy Architecture

  28. 1990’s: The Age of the Architect

  29. Detailed Requirements

  30. Architecture Diagrams

  31. Object Models

  32. Very Thorough

  33. Painfully Slow…

  34. 2010’s: The Age of the Cowboy Coder

  35. Evolutionary

  36. Fluid

  37. Undocumented

  38. Easily Influenced

  39. Opinionated

  40. Major Obstacles to Understanding

  41. Older Frameworks

  42. Complexity

  43. Lack of Cohesion

  44. Inconsistency

  45. God Models

  46. Custom Gems

  47. Monkey Patches

  48. A Strategy for Understanding

  49. The OODA Loop

  50. Observe

  51. Orient

  52. Decide

  53. Act

  54. Observation

  55. #{Rails.root}/docs/

  56. # comments

  57. Wiki

  58. Architecture 
 decision records

  59. Pull requests

  60. Tests

  61. $ rspec spec/ --format documentation Membership determines its upgradeability calculates

    its expiration in days detects when it has expired detects when it is expiring soon Finished in 0.01401 seconds 12 examples, 0 failures
  62. Read the Code

  63. Orientation

  64. The Problem

  65. Terms of Art

  66. Patterns

  67. People

  68. Read Routes In

  69. None
  70. Decision

  71. Plan a Refactor

  72. Explore Inheritance

  73. Uncover Modules

  74. Untangle Gems

  75. Understand Relationships

  76. None
  77. None
  78. None
  79. Go Exploring

  80. None
  81. Seek the Truth

  82. None
  83. def hours_occupied(date) if availability = get_work_hours(date) focus = "work" elsif

    availability = get_family_hours(date) focus = "family" elsif availability = get_friend_hours(date) focus = "friends" end end
  84. def hours_occupied(date) if availability = get_work_hours(date) focus = "work" elsif

    availability = get_family_hours(date) focus = "family" elsif availability = get_friend_hours(date) focus = "friends" end end
  85. None
  86. def hours_occupied(date) if availability = get_work_hours(date) focus = "work" elsif

    availability = get_family_hours(date) focus = "family" elsif availability = get_friend_hours(date) focus = "friends" end end
  87. None
  88. def hours_occupied(date) if availability = get_work_hours(date) focus = "work" elsif

    availability = get_family_hours(date) focus = "family" elsif availability = get_friend_hours(date) focus = "friends" end end
  89. None
  90. Action

  91. Branch

  92. $ git branch -b refactor_user

  93. Be Godzilla

  94. Pry

  95. 36: def self.create_or_update(opts={}) 37: opts = opts.with_indifferent_access 38: content =

    opts.delete(:content) 39: user = opts.delete(:user) 40: return nil unless user && content 41: => 42: require ‘pry’; binding.pry 43: pry> user => #<User:0x007fdcd9008828 @first_name=“Coraline">
  96. Repeat the Cycle

  97. None
  98. Remember the goal.

  99. Keep at it.

  100. Pair up.

  101. Believe in yourself.

  102. Go write some code!

  103. Thanks! Coraline Ada Ehmke @CoralineAda