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
280
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
110
Motivation
jeg2
1
69
Coding in the Classroom
jeg2
0
93
Implementing the LHC on a Whiteboard
jeg2
3
680
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
380
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
890
The M Word
jeg2
3
970
Other Decks in Technology
See All in Technology
スレットハンティングについて知っておきたいこと
hacket
0
130
クラウド利用者の「責任」をどう果たす?AWSセキュリティ対策のススメ #AWSSummit
hiashisan
0
280
LLMアプリケーションの評価の実践と課題 ~PharmaXにおける今後の展望~
pharma_x_tech
2
170
ACRiルーム最新情報とAMD GPUサーバーのご紹介
anjn
0
160
スタートアップにおける組織設計とスクラムの長期戦略 / Scrum Fest Kanazawa 2024
yoshikiiida
13
3.6k
MySQLのロックの種類とその競合
yoku0825
6
1.6k
テストケースの自動生成に生成AIの導入を試みた話と生成AIによる今後の期待
shift_evolve
0
190
DDDにおける認可の扱いとKotlinにおける実装パターン / authorization-for-ddd-and-kotlin-implement-pattern
urmot
4
390
AOAI Dev Day - Opening Session
yoshidashingo
2
470
JBUG岡山 #6 WordCamp男木島の チームビルディング
takeshifurusato
0
150
dxd2024-生成AIに振り回された3か月間の成功と失敗/dxd2024-link-and-motivation
lmi
2
260
AIアシスタントの活用で品質の向上と開発ワークフローのスピードアップ
nagix
1
210
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
17
2.8k
Adopting Sorbet at Scale
ufuk
71
8.8k
Ruby is Unlike a Banana
tanoku
96
10k
How To Stay Up To Date on Web Technology
chriscoyier
784
250k
Rebuilding a faster, lazier Slack
samanthasiow
78
8.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
17
8.7k
Building Adaptive Systems
keathley
34
2k
Pencils Down: Stop Designing & Start Developing
hursman
118
11k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
502
140k
Faster Mobile Websites
deanohume
303
30k
Designing for humans not robots
tammielis
247
25k
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