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
87
Coding in the Classroom
jeg2
0
110
Implementing the LHC on a Whiteboard
jeg2
3
740
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
1k
Other Decks in Technology
See All in Technology
アジャイル開発とスクラム
araihara
0
170
PHPカンファレンス名古屋-テックリードの経験から学んだ設計の教訓
hayatokudou
2
260
プロセス改善による品質向上事例
tomasagi
2
2.5k
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
1
710
自動テストの世界に、この5年間で起きたこと
autifyhq
10
8.5k
技術負債の「予兆検知」と「状況異変」のススメ / Technology Dept
i35_267
1
1.1k
Moved to https://speakerdeck.com/toshihue/presales-engineer-career-bridging-tech-biz-ja
toshihue
2
740
室長と気ままに学ぶマイクロソフトのビジネスアプリケーションとビジネスプロセス
ryoheig0405
0
360
転生CISOサバイバル・ガイド / CISO Career Transition Survival Guide
kanny
3
980
2025-02-21 ゆるSRE勉強会 Enhancing SRE Using AI
yoshiiryo1
1
320
抽象化をするということ - 具体と抽象の往復を身につける / Abstraction and concretization
soudai
16
3.6k
目の前の仕事と向き合うことで成長できる - 仕事とスキルを広げる / Every little bit counts
soudai
24
7.1k
Featured
See All Featured
Being A Developer After 40
akosma
89
590k
Speed Design
sergeychernyshev
27
790
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Raft: Consensus for Rubyists
vanstee
137
6.8k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Building an army of robots
kneath
303
45k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
It's Worth the Effort
3n
184
28k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
330
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
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