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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
jeg2
August 04, 2013
Technology
350
3
Share
Why Best Practices?
This is JEG2's segment of the Ruby Rogues panel form LSRC 2013.
jeg2
August 04, 2013
More Decks by jeg2
See All by jeg2
How to Level Up in Elixir
jeg2
2
170
Motivation
jeg2
1
140
Coding in the Classroom
jeg2
0
170
Implementing the LHC on a Whiteboard
jeg2
3
830
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
460
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
960
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
Data Enabling Team立ち上げました
sansantech
PRO
0
290
ZOZOTOWNリプレイスでのSkills導入までの流れとこれから
zozotech
PRO
4
3.2k
今年60歳のおっさんCBになる
kentapapa
1
330
推し活エージェント
yuntan_t
1
890
Podcast配信で広がったアウトプットの輪~70人と音声発信してきた7年間~/outputconf_01
fortegp05
0
240
建設的な現実逃避のしかた / How to practice constructive escapism
pauli
4
300
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
5
1.3k
DIPS2.0データに基づく森林管理における無人航空機の利用状況
naokimuroki
0
150
AIドリブン開発の実践知 ― AI-DLC Unicorn Gym実施から見えた可能性と課題
mixi_engineers
PRO
0
120
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
4
14k
I ran an automated simulation of fake news spread using OpenClaw.
zzzzico
1
1k
40代からのアウトプット ― 経験は価値ある学びに変わる / 20260404 Naoki Takahashi
shift_evolve
PRO
5
910
Featured
See All Featured
Abbi's Birthday
coloredviolet
2
6.4k
Thoughts on Productivity
jonyablonski
76
5.1k
Producing Creativity
orderedlist
PRO
348
40k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Mobile First: as difficult as doing things right
swwweet
225
10k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
96
Evolving SEO for Evolving Search Engines
ryanjones
0
170
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
430
We Have a Design System, Now What?
morganepeng
55
8.1k
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