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
290
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
120
Motivation
jeg2
1
87
Coding in the Classroom
jeg2
0
110
Implementing the LHC on a Whiteboard
jeg2
3
740
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
390
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
900
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
Developers Summit 2025 浅野卓也(13-B-7 LegalOn Technologies)
legalontechnologies
PRO
0
660
技術的負債解消の取り組みと専門チームのお話 #技術的負債_Findy
bengo4com
1
1.3k
運用しているアプリケーションのDBのリプレイスをやってみた
miura55
1
700
Larkご案内資料
customercloud
PRO
0
650
Cloud Spanner 導入で実現した快適な開発と運用について
colopl
1
550
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
700
Culture Deck
optfit
0
410
エンジニアのためのドキュメント力基礎講座〜構造化思考から始めよう〜(2025/02/15jbug広島#15発表資料)
yasuoyasuo
16
6.6k
エンジニアの育成を支える爆速フィードバック文化
sansantech
PRO
3
1k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
57k
Data-centric AI入門第6章:Data-centric AIの実践例
x_ttyszk
1
400
ホワイトボードチャレンジ 説明&実行資料
ichimichi
0
130
Featured
See All Featured
KATA
mclloyd
29
14k
Adopting Sorbet at Scale
ufuk
74
9.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
The Language of Interfaces
destraynor
156
24k
GitHub's CSS Performance
jonrohan
1030
460k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
For a Future-Friendly Web
brad_frost
176
9.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Docker and Python
trallard
44
3.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.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