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
360
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Why Best Practices?
This is JEG2's segment of the Ruby Rogues panel form LSRC 2013.
jeg2
August 04, 2013
More Decks by jeg2
See All by jeg2
How to Level Up in Elixir
jeg2
2
190
Motivation
jeg2
1
150
Coding in the Classroom
jeg2
0
190
Implementing the LHC on a Whiteboard
jeg2
3
850
The Patterns We All Need to Know
jeg2
15
1.3k
Command-line Ruby
jeg2
5
460
10 Things You Didn't Know Ruby Could do
jeg2
200
54k
The Aspects of Programming
jeg2
12
980
The M Word
jeg2
3
1.1k
Other Decks in Technology
See All in Technology
Vポイント分析基盤におけるデータモデリング20年史
taromatsui_cccmkhd
4
780
現場との対話から始める “作る前に問い直す”業務改善
mochico50
2
330
セキュリティ研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
20
18k
データベース研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
1
500
それでも、技術なブログを書く理由 #kichijojipm / Why I Still Write Tech Blogs Even Now
shinkufencer
0
1.1k
変更し続けられるシステムをどう保つか — AI時代のSSoTという設計原則
kawauso
1
1.4k
『モンスターストライク』 の運営に伴走する! データ民主化への 解析グループの3つのアプローチ
mixi_engineers
PRO
0
130
VPCセキュリティ対応の最新事情
nagisa53
1
340
AI工学特論: MLOps・継続的評価
asei
11
2.9k
QAと開発の両側から進める AI活用 -QAプロセスAI支援ツールキットと Inner Loop / Outer Loopの取り組み-
legalontechnologies
PRO
2
170
「休む」重要さ
smt7174
7
1.7k
数値で見る Microsoft MVP 〜Spec Kit と GitHub Copilot Agent で作るデータ可視化ダッシュボード〜
yutakaosada
0
150
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
420
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
570
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
320
Balancing Empowerment & Direction
lara
6
1.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
270
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
RailsConf 2023
tenderlove
30
1.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
430
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