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
3
310
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
150
Motivation
jeg2
1
110
Coding in the Classroom
jeg2
0
130
Implementing the LHC on a Whiteboard
jeg2
3
780
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
410
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
920
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
13k
振り返りTransit Gateway ~VPCをいい感じでつなげるために~
masakiokuda
3
210
第64回コンピュータビジョン勉強会「The PanAf-FGBG Dataset: Understanding the Impact of Backgrounds in Wildlife Behaviour Recognition」
x_ttyszk
0
240
LIXIL基幹システム刷新に立ち向かう技術的アプローチについて
tsukuha
1
380
今だから言えるセキュリティLT_Wordpress5.7.2未満を一斉アップデートせよ
cuebic9bic
2
170
Autify Company Deck
autifyhq
2
44k
CDKコード品質UP!ナイスな自作コンストラクタを作るための便利インターフェース
harukasakihara
2
230
QuickSight SPICE の効果的な運用戦略~S3 + Athena 構成での実践ノウハウ~/quicksight-spice-s3-athena-best-practices
emiki
0
290
ABEMAの本番環境負荷試験への挑戦
mk2taiga
5
1.3k
An introduction to Claude Code SDK
choplin
2
1k
「現場で活躍するAIエージェント」を実現するチームと開発プロセス
tkikuchi1002
3
300
cdk initで生成されるあのファイル達は何なのか/cdk-init-generated-files
tomoki10
1
670
Featured
See All Featured
Music & Morning Musume
bryan
46
6.7k
Documentation Writing (for coders)
carmenintech
72
4.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
A designer walks into a library…
pauljervisheath
207
24k
Designing Experiences People Love
moore
142
24k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
108
19k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
340
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
990
Building Flexible Design Systems
yeseniaperezcruz
328
39k
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