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
270
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
100
Motivation
jeg2
1
68
Coding in the Classroom
jeg2
0
81
Implementing the LHC on a Whiteboard
jeg2
3
640
The Patterns We All Need to Know
jeg2
15
1.2k
Command-line Ruby
jeg2
5
370
10 Things You Didn't Know Ruby Could do
jeg2
200
53k
The Aspects of Programming
jeg2
12
890
The M Word
jeg2
3
940
Other Decks in Technology
See All in Technology
Beginner's Guide to Partitioning vs. Sharding in Postgres | Claire Giordano | Nordic PGDay 2024
clairegiordano
0
210
The Disturbing Truth: Why Do Most Software Projects Suck?
lemiorhan
0
110
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
0
1.1k
OpenStack再入門「アーキテクチャ編」
kajinamit
0
240
マルチテナントの実現におけるDB設計とRLS / Utilizing RSL in multi-tenancy
soudai
20
5k
Command-line interface tool design / PHPerKaigi 2024
k1low
4
1k
Feature Flag Deep Dive
biwashi
20
5k
皆がすなるカオスエンジアリングといふものを、ネットワークオペレーションでもしてみむとてするなり
tjmtrhs
0
120
Automate your changelogs! Release Drafter
onenashev
PRO
2
410
5分で理解するWebAssemblyのWebの外の話 PHPはマイコンの夢を見るか?
usuyuki
3
200
AIエージェントが変えるソフトウェアのパラダイム
masahiro_nishimi
0
200
履歴データテーブルとの向き合い方_PHPerKaigi2024
gennei
25
6.7k
Featured
See All Featured
Happy Clients
brianwarren
91
6.3k
Why Our Code Smells
bkeepers
PRO
330
56k
Side Projects
sachag
451
41k
The Cult of Friendly URLs
andyhume
72
5.6k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
Pencils Down: Stop Designing & Start Developing
hursman
115
11k
10 Git Anti Patterns You Should be Aware of
lemiorhan
644
57k
A Tale of Four Properties
chriscoyier
150
22k
The World Runs on Bad Software
bkeepers
PRO
60
6.6k
Music & Morning Musume
bryan
39
5.4k
No one is an island. Learnings from fostering a developers community.
thoeni
14
2k
jQuery: Nuts, Bolts and Bling
dougneiner
57
7.1k
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