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
120
Coding in the Classroom
jeg2
0
150
Implementing the LHC on a Whiteboard
jeg2
3
810
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
430
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
940
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
Microsoft Agent Frameworkの可観測性
tomokusaba
1
120
松尾研LLM講座2025 応用編Day3「軽量化」 講義資料
aratako
14
4.7k
Next.js 16の新機能 Cache Components について
sutetotanuki
0
200
LayerX QA Night#1
koyaman2
0
290
[Neurogica] 採用ポジション/ Recruitment Position
neurogica
1
140
202512_AIoT.pdf
iotcomjpadmin
0
160
技術選定、下から見るか?横から見るか?
masakiokuda
0
170
Entity Framework Core におけるIN句クエリ最適化について
htkym
0
140
AI with TiDD
shiraji
1
330
_第4回__AIxIoTビジネス共創ラボ紹介資料_20251203.pdf
iotcomjpadmin
0
160
『君の名は』と聞く君の名は。 / Your name, you who asks for mine.
nttcom
1
130
Introduce marp-ai-slide-generator
itarutomy
0
150
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Un-Boring Meetings
codingconduct
0
170
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
270
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.2k
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
WCS-LA-2024
lcolladotor
0
390
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
37
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
It's Worth the Effort
3n
187
29k
My Coaching Mixtape
mlcsv
0
15
The browser strikes back
jonoalderson
0
240
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