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
Postman と API セキュリティ / Postman and API Security
yokawasa
0
200
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
540
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
190
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
23
11k
ハイテク休憩
sat
PRO
2
120
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
160
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
180
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
260
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
kargoの魅力について伝える
magisystem0408
0
200
podman_update_2024-12
orimanabu
1
260
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
How STYLIGHT went responsive
nonsquared
95
5.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building Adaptive Systems
keathley
38
2.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
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