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
84
Coding in the Classroom
jeg2
0
110
Implementing the LHC on a Whiteboard
jeg2
3
730
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
990
Other Decks in Technology
See All in Technology
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
200
あなたの知らないクラフトビールの世界
miura55
0
140
RubyでKubernetesプログラミング
sat
PRO
4
160
When Windows Meets Kubernetes…
pichuang
0
310
あなたの人生も変わるかも?AWS認定2つで始まったウソみたいな話
iwamot
3
870
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
250
2025年の挑戦 コーポレートエンジニアの技術広報/techpr5
nishiuma
0
150
デジタルアイデンティティ人材育成推進ワーキンググループ 翻訳サブワーキンググループ 活動報告 / 20250114-OIDF-J-EduWG-TranslationSWG
oidfj
0
560
comilioとCloudflare、そして未来へと向けて
oliver_diary
6
460
【Oracle Cloud ウェビナー】2025年のセキュリティ脅威を読み解く:リスクに備えるためのレジリエンスとデータ保護
oracle4engineer
PRO
1
110
Oracle Exadata Database Service(Dedicated Infrastructure):サービス概要のご紹介
oracle4engineer
PRO
0
12k
Copilotの力を実感!3ヶ月間の生成AI研修の試行錯誤&成功事例をご紹介。果たして得たものとは・・?
ktc_shiori
0
370
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
51
7.3k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Visualization
eitanlees
146
15k
The Cost Of JavaScript in 2023
addyosmani
46
7.2k
GitHub's CSS Performance
jonrohan
1030
460k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
How STYLIGHT went responsive
nonsquared
96
5.3k
Scaling GitHub
holman
459
140k
Agile that works and the tools we love
rasmusluckow
328
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
The Cult of Friendly URLs
andyhume
78
6.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