$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Why Best Practices?
Search
jeg2
August 04, 2013
Technology
3
330
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
160
Motivation
jeg2
1
120
Coding in the Classroom
jeg2
0
150
Implementing the LHC on a Whiteboard
jeg2
3
810
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
430
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
940
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
Kiro Autonomous AgentとKiro Powers の紹介 / kiro-autonomous-agent-and-powers
tomoki10
0
430
Sansanが実践する Platform EngineeringとSREの協創
sansantech
PRO
2
810
乗りこなせAI駆動開発の波
eltociear
1
1.1k
「Managed Instances」と「durable functions」で広がるAWS Lambdaのユースケース
lamaglama39
0
300
RAG/Agent開発のアップデートまとめ
taka0709
0
160
AI 駆動開発勉強会 フロントエンド支部 #1 w/あずもば
1ftseabass
PRO
0
340
MapKitとオープンデータで実現する地図情報の拡張と可視化
zozotech
PRO
1
140
ChatGPTで論⽂は読めるのか
spatial_ai_network
7
25k
最近のLinux普段づかいWaylandデスクトップ元年
penguin2716
1
690
Debugging Edge AI on Zephyr and Lessons Learned
iotengineer22
0
180
Gemini でコードレビュー知見を見える化
zozotech
PRO
1
250
日本Rubyの会の構造と実行とあと何か / hokurikurk01
takahashim
4
1k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Bash Introduction
62gerente
615
210k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Practical Orchestrator
shlominoach
190
11k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
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