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
Optimizing Code for Humans
Search
Felipe Ribeiro
May 11, 2017
Programming
6
390
Optimizing Code for Humans
Felipe Ribeiro
May 11, 2017
Tweet
Share
More Decks by Felipe Ribeiro
See All by Felipe Ribeiro
[Draft] My tech career abroad
felipernb
0
24
JavaScript @ Spotify - JSConf Iceland 2016
felipernb
4
390
Other Decks in Programming
See All in Programming
SpringBoot3.4の構造化ログ #kanjava
irof
1
490
令和7年版 あなたが使ってよいフロントエンド機能とは
mugi_uno
12
5.9k
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
18
3.1k
Package Traits
ikesyo
2
220
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
3
970
Vue.jsでiOSアプリを作る方法
hal_spidernight
0
120
最近のVS Codeで気になるニュース 2025/01
74th
1
230
Оптимизируем производительность блока Казначейство
lamodatech
0
980
自分ひとりから始められる生産性向上の取り組み #でぃーぷらすオオサカ
irof
8
2.1k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
800
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
140
AWS re:Invent 2024個人的まとめ
satoshi256kbyte
0
140
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
137
6.7k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Designing for humans not robots
tammielis
250
25k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Typedesign – Prime Four
hannesfritz
40
2.5k
What's in a price? How to price your products and services
michaelherold
244
12k
GraphQLとの向き合い方2022年版
quramy
44
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Optimizing for Happiness
mojombo
376
70k
RailsConf 2023
tenderlove
29
980
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
Why Our Code Smells
bkeepers
PRO
335
57k
Transcript
Optimizing code for humans @felipernb !
“Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.” Martin Fowler - @martinfowler @felipernb !
Simplicity is subjective (?) ! @felipernb !
“The purpose of software engineering is to control complexity, not
to create it.” Pamela Zave @felipernb !
“A C program with six 32-bit integers can have more
states than the number of atoms on the planet” Joe Armstrong - @joeerl @felipernb !
Programming is hard ! @felipernb !
Where does complexity creep in? ! @felipernb !
Algorithms ! @felipernb !
“Fancy algorithms are buggier than simple ones, and they're much
harder to implement.” Rob Pike's Rule #4 - @rob_pike @felipernb !
Searching // O(n) function linearSearch(arr, x) { for (let i
= 0; i < arr.length; i++) { if (arr[i] === x) return true; } return false; } @felipernb !
“Oh! But my array is always sorted, so I can
make this faster. Let's get fancy!” Developer ! @felipernb !
Fancy search // Sorted arrays only, O(lg n) function binarySearch(arr,
x) { let low = 0; let high = arr.length - 1; while (low <= high) { const mid = ((high - low) >> 1) + low; if (arr[mid] === x) return true; if (a[mid] < element) low = mid + 1; else high = mid - 1; } return false; } @felipernb !
“Fancy algorithms are slow when n is small, and n
is usually small.” Rob Pike’s Rule #3 - @rob_pike @felipernb !
Don't get fancy! ! @felipernb !
“Data structures, not algorithms, are central to programming.” Rob Pike’s
Rule #5 - @rob_pike @felipernb !
Performance ! @felipernb !
“Premature optimization is the root of all evil” Donald Knuth
@felipernb !
“If it doesn’t work, it doesn’t matter how fast it
doesn’t work.” Mich Ravera @felipernb !
“The cleaner and nicer the program, the faster it's going
to run. And if it doesn't, it'll be easy to make it fast.” Joshua Bloch - @joshbloch @felipernb !
“Measure. Don't tune for speed until you've measured, and even
then don't unless one part of the code overwhelms the rest.” Rob Pike’s Rule #2 - @rob_pike @felipernb !
Novelty ✨ @felipernb !
“Surprise is one of the most expensive things you can
put into a software architecture.” Adam Tornhill - @adamtornhill @felipernb !
Boring is fine ! @felipernb !
“Are you quite sure that all those bells and whistles,
all those wonderful facilities of your so called powerful programming languages, belong to the solution set rather than the problem set?” Edsger W. Dijkstra @felipernb !
Naming things ! @felipernb !
“There are two hard things in Computer Science: cache invalidation,
naming things, and off-by- one errors.” Phil Karlton + the internet @felipernb !
Descriptive names can replace //comments @felipernb !
doThisAndThatAndReturnThisOtherThing(); If it's hard to name it, it's probably doing
too much @felipernb !
// Double negation is confusing ! if (!disabledFeature) { //
it's enabled! } Avoid flag names with negative meanings such as disable and disallow @felipernb !
Personal taste ❤ @felipernb !
“I do not like semicolons.” Some guy closing a perfectly
valid pull request ! @felipernb !
“You can't always get what you want.” The Rolling Stones
@felipernb !
Strict style guides are good ! @felipernb !
The code should be consistent regardless of who wrote it.
@felipernb !
Automation can put an end to lengthy and pointless discussions*
. * Specially when we all know that tabs make much more sense than spaces. @felipernb !
When consistency is a given, you can focus on what
really matters. @felipernb !
The ! Enterprise @felipernb !
“Any organization that designs a system will produce a design
whose structure is a copy of the organization's communication structure.” Conway's law @felipernb !
Cargo Cult ✈ @felipernb !
“A significant amount of programming is done by superstition” Chris
Siebenmann @felipernb !
Be ! skeptical @felipernb !
Tech Debt ! @felipernb !
“If you want to go fast you take some debt.
But the misunderstanding was that people thought that you never have to pay it back.” Ward Cunningham - @wardcunningham @felipernb !
“Technical debt is hard to explain, but a picture is
worth a thousand words” Jedd Ahyoung - @Jedd_Ahyoung @felipernb !
How to keep things sane? ! @felipernb !
KISS ! Keep it simple, stupid @felipernb !
“Everyone knows that debugging is twice as hard as writing
a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” Brian Kernighan @felipernb !
Design patterns ⛩ @felipernb !
Design patterns are not about pigeonholing problems, but a tool
to efficiently communicate solutions with a common vocabulary. @felipernb !
Refactoring ! @felipernb !
“Software is messy because it reflects our evolving understanding of
the problem as we wrote it.” Sarah Mei - @sarahmei @felipernb !
Unlike the messed up Tetris game, you should be able
to take the time to rearrange the pieces in your code. @felipernb !
Code reviews ! @felipernb !
“My code isn't done until I've gone over it with
a fellow developer.” Jeff Atwood - @codinghorror @felipernb !
Peer review ≠ Pair programming @felipernb !
@felipernb !
Pragmatism ! @felipernb !
“Engineers are hired to say no.” Uncle Bob Martin -
@unclebobmartin @felipernb !
@felipernb !
Sometimes you have to say no to fun @felipernb !
Thank you! @felipernb !