summary
- went to https://github.com/rails/rails
- clicked activesupport
- read #blank? & #present?
Slide 29
Slide 29 text
then I gave up reading Rails
Slide 30
Slide 30 text
but I learned a ton
Slide 31
Slide 31 text
what stuck with me
Slide 32
Slide 32 text
it's not about getting it
100%
Slide 33
Slide 33 text
Open Source isn't a
blackbox
(literally)
Slide 34
Slide 34 text
read the parts you can
come back and read more
Slide 35
Slide 35 text
reading
principles
1. just click things
2. remain neutral
3. keep coming back
Slide 36
Slide 36 text
just click things
Slide 37
Slide 37 text
"Oh, that's an interesting
name!"
Slide 38
Slide 38 text
"What does this method
do? Is this a Ruby thing?"
Slide 39
Slide 39 text
"What the hell is this?"
Slide 40
Slide 40 text
remain neutral
Slide 41
Slide 41 text
Do you say things like…
Slide 42
Slide 42 text
"I should know this
already"
evens, odds = integers.partition(&:even?)
Slide 43
Slide 43 text
"I shouldn't need to do this,
right?"
Slide 44
Slide 44 text
"I'm not smart enough to
get this"
Slide 45
Slide 45 text
"there's too much magic"
Slide 46
Slide 46 text
judging yourself
stops you
Slide 47
Slide 47 text
like listening to
new music
Slide 48
Slide 48 text
with music, we'll
just try listening
Slide 49
Slide 49 text
it's not smarts
it's context
Slide 50
Slide 50 text
reading helps you build
that context
Slide 51
Slide 51 text
set anger & frustration
aside
Slide 52
Slide 52 text
try to have an open mind
Slide 53
Slide 53 text
keep coming back
Slide 54
Slide 54 text
with practice
you'll be quicker
Slide 55
Slide 55 text
you'll be
quicker
- parsing brand new code
- splitting it into chunks
- picking up new names & concepts
- spotting styles & patterns
Slide 56
Slide 56 text
it's a process,
not a task
Slide 57
Slide 57 text
1. just click things
2. remain neutral
3. keep coming back
Slide 58
Slide 58 text
it's much better
just to look
Slide 59
Slide 59 text
before the next part
Slide 60
Slide 60 text
when you're learning
something
Slide 61
Slide 61 text
follow a laid out path
Slide 62
Slide 62 text
WAY HARDER
Slide 63
Slide 63 text
part 2
a concept from minitest's
source
Slide 64
Slide 64 text
minitest
Ruby's default test framework
1200 lines
Slide 65
Slide 65 text
Running 1 tests in a single process
(parallelization threshold is 50)
Run options: --seed 56269
# Running:
.
Finished in 0.018606s, 53.7461 runs/s, 53.7461
assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
Slide 66
Slide 66 text
class Reporter < AbstractReporter
def record result
end
end
class SummaryReporter < Reporter; end # .
class StatisticsReporter < Reporter; end
# 1 assertions…
Slide 67
Slide 67 text
class CompositeReporter <
AbstractReporter
def << reporter
end
def record result
end
end
Slide 68
Slide 68 text
self.reporter = CompositeReporter.new
self.reporter << SummaryReporter.new
self.reporter << StatisticsReporter.new
# in tests, minitest calls:
self.reporter.record result
Slide 69
Slide 69 text
class CompositeReporter
def record result
self.reporters.each do |reporter|
reporter.record result
end
end
end
Slide 70
Slide 70 text
this is polymorphism
Slide 71
Slide 71 text
JIT from last week
Slide 72
Slide 72 text
audited + actiontext
gem "audited"
class Post < ApplicationRecord
has_rich_text :content
end
ActionText::RichText.audited
associated_with: :record
Slide 73
Slide 73 text
let's do a little ahead-of-
time reading
Slide 74
Slide 74 text
YAML
(not official docs, just looks nice)
https://rubyapi.org/3.3/o/yaml
Slide 75
Slide 75 text
JIT Demo
Slide 76
Slide 76 text
summary
we read a bit of YAML ahead-of-time
–
we used that knowledge to debug an issue
–
we looked at the source of audited and
actiontext
–
we saw that ActionText::Content doesn't
support YAML serialization
–
Slide 77
Slide 77 text
wrap up
Slide 78
Slide 78 text
what the hell did we just do
we learned about AOT and JIT reading
–
we nibbled some rails reading
–
we became experts at polymorphism from
minitest
–
we used AOT to debug while also doing JIT
–
Slide 79
Slide 79 text
reading
principles
1. just click things
2. remain neutral
3. keep coming back