Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Why Best Practices?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
jeg2
August 04, 2013
Technology
3
340
Why Best Practices?
This is JEG2's segment of the Ruby Rogues panel form LSRC 2013.
jeg2
August 04, 2013
Tweet
Share
More Decks by jeg2
See All by jeg2
How to Level Up in Elixir
jeg2
2
170
Motivation
jeg2
1
140
Coding in the Classroom
jeg2
0
170
Implementing the LHC on a Whiteboard
jeg2
3
820
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
450
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
960
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
TypeScript 7.0の現在地と備え方
uhyo
7
2k
Phase11_戦略的AI経営
overflowinc
0
580
20260323_データ分析基盤でGeminiを使う話
1210yuichi0
0
160
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
2
110
CyberAgentの生成AI戦略 〜変わるものと変わらないもの〜
katayan
0
280
ReactのdangerouslySetInnerHTMLは“dangerously”だから危険 / Security.any #09 卒業したいセキュリティLT
flatt_security
0
420
DDD×仕様駆動で回す高品質開発のプロセス設計
littlehands
4
1.6k
めちゃくちゃ開発するQAエンジニアになって感じたメリットとこれからの課題感
ryuhei0000yamamoto
0
230
FastMCP OAuth Proxy with Cognito
hironobuiga
3
110
Tebiki Engineering Team Deck
tebiki
0
27k
1GB RAMのラズピッピで何ができるのか試してみよう / 20260319-rpijam-1gb-rpi-whats-possible
akkiesoft
0
700
「通るまでRe-run」から卒業!落ちないテストを書く勘所
asumikam
2
440
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
690
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
92
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.9k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
410
The browser strikes back
jonoalderson
0
820
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
RailsConf 2023
tenderlove
30
1.4k
A Tale of Four Properties
chriscoyier
163
24k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
140
Building Adaptive Systems
keathley
44
3k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
340
Transcript
I Only Have Time to Make One Point The others
made me include this slide!
.
Thanks!
Why Best Practices?
How Should We Use Struct? class Specialized < Struct.new(:whatever) #
... define custom methods here... end Specialized = Struct.new(:whatever) do # ... define custom methods here... end
I Prefer the Block Form But that’s not the point!
Code Similarity and Malleability Specialized = Struct.new(:whatever) do # ...
define custom methods here... end Trivial = Struct.new(:whatever)
An Extra Class • The anonymous class doesn’t tell us
much • Code reloading may cause “TypeError: superclass mismatch…” [Specialized, #<Class:0x007f8ba7389d18>, Struct, Enumerable, Object, PP::ObjectMixin, Kernel, BasicObject] class Specialized < Struct.new(:whatever) # ... define custom methods here... end
The “super” Problem class Specialized < Struct.new(:whatever) def whatever super
|| :default end include SomeMixin end Specialized = Struct.new(:whatever) do def whatever self[:whatever] || :default end prepend SomeMixin end
The Point • It’s not about the one right way
to code • It’s about what we learn in the discussion • This trivial example alone includes: • Code malleability • The ancestor class chain • The value of prepend