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
280
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
74
Coding in the Classroom
jeg2
0
98
Implementing the LHC on a Whiteboard
jeg2
3
690
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
380
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
900
The M Word
jeg2
3
970
Other Decks in Technology
See All in Technology
不動産 x AIことはじめ~データの真価を拓くために
estie
0
110
突撃! 隣のAmazon Bedrockユーザー 〜YouはどうしてAWSで?〜
minorun365
PRO
3
380
Road to Single Activity
yurihondo
1
230
事前準備が肝!AI活用のための業務改革
layerx
PRO
1
370
『GRANBLUE FANTASY Relink』ソフトウェアラスタライザによる実践的なオクルージョンカリング
cygames
0
140
やってやろうじゃないかメカアジャイル! / Let's do it, mechanical agile!
psj59129
1
600
四国クラウドお遍路 2024 in 高知 オープニング
yukataoka
0
200
OCI で始める!! Red Hat OpenShift / Get Started OpenShift on OCI
oracle4engineer
PRO
1
170
DevRelの始め方
moongift
PRO
1
380
自社サービスのための独自リリース版Redmine「RedMica」の取り組み
vividtone
0
1.3k
Tricentisにおけるテスト自動化へのAI活用ご紹介/20240910Shunsuke Katakura
shift_evolve
0
180
AWS SAW を広めたい @四国クラウドお遍路
kazzpapa3
0
230
Featured
See All Featured
Thoughts on Productivity
jonyablonski
66
4.2k
Why Our Code Smells
bkeepers
PRO
334
56k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
19k
What's new in Ruby 2.0
geeforr
340
31k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
Statistics for Hackers
jakevdp
794
220k
Making Projects Easy
brettharned
113
5.8k
How to Ace a Technical Interview
jacobian
274
23k
Testing 201, or: Great Expectations
jmmastey
36
7k
Fantastic passwords and where to find them - at NoRuKo
philnash
48
2.8k
Raft: Consensus for Rubyists
vanstee
135
6.5k
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