Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
MapKitとオープンデータで実現する地図情報の拡張と可視化
zozotech
PRO
1
140
OCI Oracle Database Services新機能アップデート(2025/09-2025/11)
oracle4engineer
PRO
1
130
生成AIでテスト設計はどこまでできる? 「テスト粒度」を操るテーラリング術
shota_kusaba
0
710
Database イノベーショントークを振り返る/reinvent-2025-database-innovation-talk-recap
emiki
0
110
GitHub Copilotを使いこなす 実例に学ぶAIコーディング活用術
74th
3
2.9k
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
570
非CUDAの悲哀 〜Claude Code と挑んだ image to 3D “Hunyuan3D”を EVO-X2(Ryzen AI Max+395)で動作させるチャレンジ〜
hawkymisc
2
170
AWS CLIの新しい認証情報設定方法aws loginコマンドの実態
wkm2
6
720
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
1
170
エンジニアリングをやめたくないので問い続ける
estie
2
1.2k
MLflowで始めるプロンプト管理、評価、最適化
databricksjapan
1
190
打 造 A I 驅 動 的 G i t H u b ⾃ 動 化 ⼯ 作 流 程
appleboy
0
290
Featured
See All Featured
Unsuck your backbone
ammeep
671
58k
A better future with KSS
kneath
240
18k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Building an army of robots
kneath
306
46k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Producing Creativity
orderedlist
PRO
348
40k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
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