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
320
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
160
Motivation
jeg2
1
110
Coding in the Classroom
jeg2
0
140
Implementing the LHC on a Whiteboard
jeg2
3
790
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
420
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
930
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
会社を支える Pythonという言語戦略 ~なぜPythonを主要言語にしているのか?~
curekoshimizu
3
770
AI時代の開発を加速する組織づくり - ブログでは書けなかったリアル
hiro8ma
1
320
Kubernetes self-healing of your workload
hwchiu
0
550
ヘンリー会社紹介資料(エンジニア向け) / company deck for engineer
henryofficial
0
390
Building a cloud native business on open source
lizrice
0
180
混合雲環境整合異質工作流程工具運行關鍵業務 Job 的經驗分享
yaosiang
0
190
デザインとエンジニアリングの架け橋を目指す OPTiMのデザインシステム「nucleus」の軌跡と広げ方
optim
0
120
「最速」で Gemini CLI を使いこなそう! 〜Cloud Shell/Cloud Run の活用〜 / The Fastest Way to Master the Gemini CLI — with Cloud Shell and Cloud Run
aoto
PRO
1
180
Behind Postgres 18: The People, the Code, & the Invisible Work | Claire Giordano | PGConfEU 2025
clairegiordano
0
140
マルチエージェントのチームビルディング_2025-10-25
shinoyamada
0
180
AI-Readyを目指した非構造化データのメダリオンアーキテクチャ
r_miura
1
330
NLPコロキウム20251022_超効率化への挑戦: LLM 1bit量子化のロードマップ
yumaichikawa
3
500
Featured
See All Featured
The Language of Interfaces
destraynor
162
25k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
190
55k
Rails Girls Zürich Keynote
gr2m
95
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
KATA
mclloyd
PRO
32
15k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Documentation Writing (for coders)
carmenintech
75
5.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
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