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
290
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
82
Coding in the Classroom
jeg2
0
110
Implementing the LHC on a Whiteboard
jeg2
3
730
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
390
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
900
The M Word
jeg2
3
990
Other Decks in Technology
See All in Technology
.NET 9 のパフォーマンス改善
nenonaninu
0
940
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
2
370
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
230
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
310
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
20241220_S3 tablesの使い方を検証してみた
handy
4
550
podman_update_2024-12
orimanabu
1
270
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
460
C++26 エラー性動作
faithandbrave
2
740
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Side Projects
sachag
452
42k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Practical Orchestrator
shlominoach
186
10k
Site-Speed That Sticks
csswizardry
2
190
Navigating Team Friction
lara
183
15k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.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