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
340
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
160
Motivation
jeg2
1
130
Coding in the Classroom
jeg2
0
160
Implementing the LHC on a Whiteboard
jeg2
3
820
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
440
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
950
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
AI開発の落とし穴 〜馬には乗ってみよAIには添うてみよ〜
sansantech
PRO
8
3.5k
ファシリテーション勉強中 その場に何が求められるかを考えるようになるまで / 20260123 Naoki Takahashi
shift_evolve
PRO
3
370
AWS監視を「もっと楽する」ために
uechishingo
0
390
書籍執筆での生成AIの活用
sat
PRO
1
210
AI アクセラレータチップ AWS Trainium/Inferentia に 今こそ入門
yoshimi0227
1
320
Regional_NAT_Gatewayについて_basicとの違い_試した内容スケールアウト_インについて_IPv6_dual_networkでの使い分けなど.pdf
cloudevcode
1
130
【NGK2026S】日本株のシステムトレードに入門してみた
kazuhitotakahashi
0
130
さくらのクラウドでのシークレット管理を考える/tamachi.sre#2
fujiwara3
1
220
20260120 Amazon VPC のパブリックサブネットを無くしたい!
masaruogura
2
160
CodeRabbit CLI + Claude Codeの連携について
oikon48
1
640
会社紹介資料 / Sansan Company Profile
sansan33
PRO
13
400k
EventBridge API Destination × AgentCore Runtimeで実現するLambdaレスなイベント駆動エージェント
har1101
7
250
Featured
See All Featured
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Agile that works and the tools we love
rasmusluckow
331
21k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
72
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Designing Experiences People Love
moore
143
24k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
Unsuck your backbone
ammeep
671
58k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
How to build a perfect <img>
jonoalderson
1
4.9k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
46
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