Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
Snowflakeでデータ基盤を もう一度作り直すなら / rebuilding-data-platform-with-snowflake
pei0804
6
1.6k
SREには開発組織全体で向き合う
koh_naga
0
370
コンテキスト情報を活用し個社最適化されたAI Agentを実現する4つのポイント
kworkdev
PRO
1
1.5k
Haskell を武器にして挑む競技プログラミング ─ 操作的思考から意味モデル思考へ
naoya
6
1.6k
シニアソフトウェアエンジニアになるためには
kworkdev
PRO
3
180
AI-DLCを現場にインストールしてみた:プロトタイプ開発で分かったこと・やめたこと
recruitengineers
PRO
2
160
初めてのDatabricks AI/BI Genie
taka_aki
0
200
モダンデータスタック (MDS) の話とデータ分析が起こすビジネス変革
sutotakeshi
0
510
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
190
MLflowで始めるプロンプト管理、評価、最適化
databricksjapan
1
260
[デモです] NotebookLM で作ったスライドの例
kongmingstrap
0
160
1人1サービス開発しているチームでのClaudeCodeの使い方
noayaoshiro
1
300
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Rails Girls Zürich Keynote
gr2m
95
14k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
The Pragmatic Product Professional
lauravandoore
37
7.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
980
Why Our Code Smells
bkeepers
PRO
340
57k
A Tale of Four Properties
chriscoyier
162
23k
Building Adaptive Systems
keathley
44
2.9k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.3k
What's in a price? How to price your products and services
michaelherold
246
13k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
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