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
360
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Why Best Practices?
This is JEG2's segment of the Ruby Rogues panel form LSRC 2013.
jeg2
August 04, 2013
More Decks by jeg2
See All by jeg2
How to Level Up in Elixir
jeg2
2
190
Motivation
jeg2
1
150
Coding in the Classroom
jeg2
0
190
Implementing the LHC on a Whiteboard
jeg2
3
860
The Patterns We All Need to Know
jeg2
15
1.3k
Command-line Ruby
jeg2
5
460
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
980
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
AIエージェントを前提としたプラットフォーム エンジニアリング:GKEで作るAgent-Ready Golden Path
legalontechnologies
PRO
2
210
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
620
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
200
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
140
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.6k
事業価値と Engineering 2026年度版
recruitengineers
PRO
41
21k
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
ラジオの科学
frievea
0
270
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
270
Cursor Meetup Sapporo - Cursor物語 続編
cocacola917
0
140
바이브풀 라이프
arawn
0
100
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
140
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
480
Into the Great Unknown - MozCon
thekraken
41
2.7k
Darren the Foodie - Storyboard
khoart
PRO
3
3.5k
ラッコキーワード サービス紹介資料
rakko
1
4.3M
Ethics towards AI in product and experience design
skipperchong
2
340
Done Done
chrislema
186
16k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
240
Building Applications with DynamoDB
mza
96
7.2k
KATA
mclloyd
PRO
35
15k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
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