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
140
Motivation
jeg2
1
100
Coding in the Classroom
jeg2
0
130
Implementing the LHC on a Whiteboard
jeg2
3
770
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
S3 Tables を図解でやさしくおさらい~基本から QuickSight 連携まで/s3-tables-illustrated-basics-quicksight
emiki
1
330
AIエージェントデザインパターンの選び方
almondo_event
0
140
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
12k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
8
65k
Streamline Cloud-Native App Development Using CDEs
saeedzf
0
850
データプレーンプログラミングとは? DPU&スイッチASICの開発経験から語る
ebiken
PRO
1
260
What's Next in OpenShift Q2 CY2025
redhatlivestreaming
1
780
令和トラベルQAのAI活用
seigaitakahiro
0
520
エンジニア幼年期の終わり
rebase_engineering
1
110
JNation 2025 - Quarkus for Spring Developers
edeandrea
PRO
0
110
MCP で繋ぐ Figma とデザインシステム〜LLM を使った UI 実装のリアル〜
kimuson
2
1.3k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
6
360k
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
620
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
The World Runs on Bad Software
bkeepers
PRO
68
11k
GitHub's CSS Performance
jonrohan
1031
460k
Optimizing for Happiness
mojombo
378
70k
Thoughts on Productivity
jonyablonski
69
4.7k
Practical Orchestrator
shlominoach
188
11k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
106
19k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Bash Introduction
62gerente
614
210k
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