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
110
Motivation
jeg2
1
68
Coding in the Classroom
jeg2
0
84
Implementing the LHC on a Whiteboard
jeg2
3
650
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
890
The M Word
jeg2
3
950
Other Decks in Technology
See All in Technology
今日からできる!簡単 .NET 高速化 Tips -2024 edition-
xin9le
7
4k
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
330
いいたいことちゃんという
tkengo
0
230
Babylon.js JAPAN活動紹介 (2024/4)
limes2018
1
120
Cloud Service Mesh に触れ合う
phaya72
1
230
生成AIの変革の時代に、直近1年で直面した課題とその解決策
ktc_wada
0
680
今年のRubyKaigiはProfiler Year🤘
osyoyu
0
390
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
37k
[新卒向け研修資料] テスト文字列に「うんこ」と入れるな(2024年版)
infiniteloop_inc
5
18k
【SORACOM UG 東海】あらゆるモノがつながる社会へ、IoT と SORACOM
soracom
PRO
1
140
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
1.6k
Cypress or Playwright?
rainerhahnekamp
0
170
Featured
See All Featured
Side Projects
sachag
451
41k
What's new in Ruby 2.0
geeforr
337
31k
Why Our Code Smells
bkeepers
PRO
331
56k
Automating Front-end Workflow
addyosmani
1357
200k
Documentation Writing (for coders)
carmenintech
60
4k
Rebuilding a faster, lazier Slack
samanthasiow
74
8.2k
Product Roadmaps are Hard
iamctodd
45
9.7k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
Six Lessons from altMBA
skipperchong
22
3k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
RailsConf 2023
tenderlove
8
550
Music & Morning Musume
bryan
41
5.6k
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