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
110
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
Agentic DevOps時代の生存戦略
kkamegawa
1
1.2k
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
29
9.6k
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
160
MySQL5.6から8.4へ 戦いの記録
kyoshidaxx
1
150
Claude Code Actionを使ったコード品質改善の取り組み
potix2
PRO
6
1.9k
GeminiとNotebookLMによる金融実務の業務革新
abenben
0
210
rubygem開発で鍛える設計力
joker1007
1
170
変化する開発、進化する体系時代に適応するソフトウェアエンジニアの知識と考え方(JaSST'25 Kansai)
mizunori
0
170
Microsoft Build 2025 技術/製品動向 for Microsoft Startup Tech Community
torumakabe
2
240
Navigation3でViewModelにデータを渡す方法
mikanichinose
0
220
より良いプロダクトの開発を目指して - 情報を中心としたプロダクト開発 #phpcon #phpcon2025
bengo4com
1
3.1k
ローカルLLMでファインチューニング
knishioka
0
140
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
35
6.7k
Balancing Empowerment & Direction
lara
1
350
Done Done
chrislema
184
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
The World Runs on Bad Software
bkeepers
PRO
69
11k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
How to Ace a Technical Interview
jacobian
277
23k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Site-Speed That Sticks
csswizardry
10
650
RailsConf 2023
tenderlove
30
1.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
124
52k
Music & Morning Musume
bryan
46
6.6k
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