Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Why Best Practices?
jeg2
August 04, 2013
Technology
3
250
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
66
Motivation
jeg2
1
55
Coding in the Classroom
jeg2
0
44
Implementing the LHC on a Whiteboard
jeg2
3
450
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
350
10 Things You Didn't Know Ruby Could do
jeg2
200
52k
The Aspects of Programming
jeg2
12
870
The M Word
jeg2
3
890
Other Decks in Technology
See All in Technology
技術広報の役割を定義してみた 2022年春
afroscript
3
2.3k
キャッチアップ Android 13 / Catch up Android 13
yanzm
2
870
実験!カオスエンジニアリング / How to Chaos Engineering
oracle4engineer
PRO
0
130
完全に理解した incremetal 〜そして、何もわからないへ〜
mashiike
0
210
開発者のための GitHub Organization の安全な運用と 継続的なモニタリング
flatt_security
2
2.9k
失敗しない条件付きアクセス Season 3
sophiakunii
0
1.3k
Puny to Powerful PostgreSQL Rails Apps
andyatkinson
PRO
0
140
LINEスタンプの実例紹介 小さく始める障害検知・対応・振り返りの 改善プラクティス
line_developers
PRO
3
1.3k
數據的多重宇宙 @ LINE Taiwan
line_developers_tw
PRO
0
360
Motto Go Forward スライドトップと Goを支える文化とコミュニティ してご利用ください 〜なぜ我々はコミュニティにコントリ ビュートするのか〜
luccafort
0
180
SRE_チーム立ち上げから1年_気づいたら_SRE_っぽくない仕事まで貢献しちゃってる説
bitkey
PRO
0
1.9k
Who owns the Service Level?
chaspy
5
710
Featured
See All Featured
Building Adaptive Systems
keathley
25
1.1k
The Language of Interfaces
destraynor
148
20k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1M
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
12
890
Happy Clients
brianwarren
89
5.5k
Git: the NoSQL Database
bkeepers
PRO
415
59k
BBQ
matthewcrist
74
7.9k
Documentation Writing (for coders)
carmenhchung
48
2.5k
Six Lessons from altMBA
skipperchong
14
1.3k
We Have a Design System, Now What?
morganepeng
35
2.9k
Side Projects
sachag
449
37k
What’s in a name? Adding method to the madness
productmarketing
11
1.5k
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