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
310
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
140
Motivation
jeg2
1
100
Coding in the Classroom
jeg2
0
130
Implementing the LHC on a Whiteboard
jeg2
3
770
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
410
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
920
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
コードの考古学 〜労務システムから発掘した成長の糧〜
kenta_smarthr
1
1.3k
Generational ZGCのメモリ運用改善 - その物理メモリ使用量、本当に正しい?
tabatad
0
170
toittaにOpenTelemetryを導入した話 / Mackerel APM リリースパーティ
cohalz
1
500
積み上げられた技術資産と向き合いながら、プロダクトの信頼性をどう守るか
plaidtech
PRO
0
1k
エンジニアが組織に馴染むために勉強会を主催してチームの壁を越える
ohmori_yusuke
2
130
GitHub Copilot Use Cases at ZOZO
horie1024
1
210
AIに実況させる / AI Streamer
motemen
3
1.4k
Java 30周年記念! Javaの30年をふりかえる
skrb
4
2.3k
組織とセキュリティ文化と、自分の一歩
maimyyym
3
1.3k
CSS polyfill とその未来
ken7253
0
150
キャッシュレス決済のプロダクトから決済基盤への進化
b1a9id
0
120
ソフトウェアテストのAI活用_ver1.10
fumisuke
0
240
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
BBQ
matthewcrist
88
9.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Building an army of robots
kneath
306
45k
Balancing Empowerment & Direction
lara
1
93
Automating Front-end Workflow
addyosmani
1370
200k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Designing for Performance
lara
608
69k
What's in a price? How to price your products and services
michaelherold
245
12k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Practical Orchestrator
shlominoach
188
11k
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