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
300
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
130
Motivation
jeg2
1
93
Coding in the Classroom
jeg2
0
120
Implementing the LHC on a Whiteboard
jeg2
3
750
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
400
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
910
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
AIエージェントキャッチアップと論文リサーチ
os1ma
6
1.4k
FinOps_Demo
tkhresk
0
120
データベースで見る『家族アルバム みてね』の変遷 / The Evolution of Family Album Through the Lens of Databases
kohbis
4
1.1k
Road to SRE NEXT@仙台 IVRyの組織の形とSLO運用の現状
abnoumaru
1
460
”知のインストール”戦略:テキスト資産をAIの文脈理解に活かす
kworkdev
PRO
8
3.6k
All You Need Is Kusa 〜Slackデータで始めるデータドリブン〜
jonnojun
0
110
Amebaにおける Platform Engineeringの実践
kumorn5s
5
850
古き良き Laravel のシステムは関数型スタイルでリファクタできるのか
leveragestech
1
310
出前館を支えるJavaとKotlin
demaecan
0
150
デザインシステムのレガシーコンポーネントを刷新した話/Design System Legacy Renewal
kaonavi
0
140
10分でわかるfreeeのQA
freee
1
11k
バックエンド留学した話/Backend study abroad story
kaonavi
0
140
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
7
630
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
How STYLIGHT went responsive
nonsquared
99
5.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
Thoughts on Productivity
jonyablonski
69
4.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.6k
The Cost Of JavaScript in 2023
addyosmani
48
7.6k
Become a Pro
speakerdeck
PRO
27
5.2k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.7k
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