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
jeg2
August 04, 2013
Technology
360
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Why Best Practices?
This is JEG2's segment of the Ruby Rogues panel form LSRC 2013.
jeg2
August 04, 2013
More Decks by jeg2
See All by jeg2
How to Level Up in Elixir
jeg2
2
190
Motivation
jeg2
1
150
Coding in the Classroom
jeg2
0
190
Implementing the LHC on a Whiteboard
jeg2
3
860
The Patterns We All Need to Know
jeg2
15
1.3k
Command-line Ruby
jeg2
5
460
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
980
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
Model Studio CLI × Token Plan
maigo999
0
190
Digitization部 紹介資料
sansan33
PRO
2
7.7k
トヨタ⽣産⽅式(TPS)⼊⾨
recruitengineers
PRO
3
930
LLM Internals: 언어 모델의 계보와 알고리즘 진화 (2023~2026)
inureyes
PRO
0
400
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
680
猫付きpingコマンドを自作
uyuki234
0
250
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
300
強化学習「理論」入門
enakai00
3
3.6k
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
150
20260804_Q4AzureUpdateBite_FabricDataAgentの精度を高める設計.pdf
matayuuu
1
140
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
My broken English still works: speaking at global OSS events
naruoga
0
110
Featured
See All Featured
Fireside Chat
paigeccino
42
4k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
350
The Cost Of JavaScript in 2023
addyosmani
55
10k
How to Ace a Technical Interview
jacobian
281
24k
Docker and Python
trallard
47
4.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
270
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
470
sira's awesome portfolio website redesign presentation
elsirapls
0
320
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1.1k
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