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
270
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
100
Motivation
jeg2
1
68
Coding in the Classroom
jeg2
0
81
Implementing the LHC on a Whiteboard
jeg2
3
640
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
370
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
890
The M Word
jeg2
3
940
Other Decks in Technology
See All in Technology
HoneycombとOpenTelemetryでオブザーバビリティに入門してみる
sumiren
2
150
#51 “Empowering Azure Storage with RDMA”
cafenero_777
3
210
これまでのキャリアとこれからMLエンジニアとしてどう動くか
masatakashiwagi
0
300
サービスメッシュ環境における OpenTelemetry 活用 / OpenTelemetry in Service Mesh
k6s4i53rx
2
830
任意コード実行の原理
ffri
0
170
「XX試験の環境作ってよ」と言われた時によく使うAWSのソリューションについて
bun913
0
120
技術イベントはなんとかひねり出す 日経の技術広報の取り組み/techpr3
nishiuma
0
220
やっていきテスト
k6s4i53rx
0
160
GraphQLに入門してみた
chiroruxx
2
120
オブジェクトのおしゃべり大失敗 メッセージングアンチパターン集 / messaging anti-pattern collection
ytake
0
330
暗黙知を集積するプラットフォーム : 「健常者エミュレータ事例集」の取り組み
sora32127
1
160
Vos logs méritent mieux que la config par défaut
lyrixx
2
310
Featured
See All Featured
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.6k
Optimizing for Happiness
mojombo
369
69k
Designing Experiences People Love
moore
135
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
257
12k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
19
1.6k
Web Components: a chance to create the future
zenorocha
304
41k
Being A Developer After 40
akosma
56
580k
Designing for Performance
lara
601
67k
Atom: Resistance is Futile
akmur
258
25k
Building an army of robots
kneath
300
41k
Creatively Recalculating Your Daily Design Routine
revolveconf
209
11k
How To Stay Up To Date on Web Technology
chriscoyier
781
250k
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