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
310
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
130
Motivation
jeg2
1
97
Coding in the Classroom
jeg2
0
120
Implementing the LHC on a Whiteboard
jeg2
3
760
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
400
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
910
The M Word
jeg2
3
1k
Other Decks in Technology
See All in Technology
AWSの新機能検証をやる時こそ、Amazon Qでプロンプトエンジニアリングを駆使しよう
duelist2020jp
1
330
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
2
450
読んで学ぶ Amplify Gen2 / Amplify と CDK の関係を紐解く #jawsug_tokyo
tacck
PRO
1
300
Dataverseの検索列について
miyakemito
1
170
ペアーズにおける評価ドリブンな AI Agent 開発のご紹介
fukubaka0825
7
2k
3D生成AIのための画像生成
kosukeito
2
580
AI 코딩 에이전트 더 똑똑하게 쓰기
nacyot
0
460
生成AIによるCloud Native基盤構築の可能性と実践的ガードレールの敷設について
nwiizo
7
1.4k
Web Intelligence and Visual Media Analytics
weblyzard
PRO
1
6k
Новые мапы в Go. Вова Марунин, Clatch, МТС
lamodatech
0
1.6k
SnowflakeとDatabricks両方でRAGを構築してみた
kameitomohiro
1
570
Dynamic Reteaming And Self Organization
miholovesq
3
740
Featured
See All Featured
Faster Mobile Websites
deanohume
306
31k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
How STYLIGHT went responsive
nonsquared
100
5.5k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Designing for humans not robots
tammielis
253
25k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
550
Writing Fast Ruby
sferik
628
61k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
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