Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Introduce go-mnd
Tommy Mühle
February 06, 2020
Programming
0
48
Introduce go-mnd
Short introduction of go-mnd, the magic number detector for Go.
Tommy Mühle
February 06, 2020
Tweet
Share
More Decks by Tommy Mühle
See All by Tommy Mühle
Useful daily business packages
tommymuehle
1
43
Enums - An introduction
tommymuehle
0
130
Defensive programming
tommymuehle
10
1.2k
Why setters are bad
tommymuehle
2
550
Keep yourself up to date
tommymuehle
0
170
Exception handling - classic and fancy
tommymuehle
3
410
Other Decks in Programming
See All in Programming
T3 Stack and TypeScript ecosystem
quramy
3
810
The State of Kotlin | FOSDEM 2023
prof18
1
110
CDKでValidationする本当の方法 / cdk-validation
gotok365
1
260
エンジニア向け会社紹介資料/engineer-recruiting-pitch
xmile
PRO
0
120
社会人 20 年目エンジニア、発信で技術学びなおしてる話
e99h2121
1
150
フロントエンドで 良いコードを書くために
t_keshi
3
1.7k
42tokyo-born2beroot-review
love42
0
130
Milestoner
bkuhlmann
1
250
存在しないアセットへの参照と 未公開アセットでのネタバレに どう立ち向かうか / How to prevent missing assets and spoilers by assets
orgachem
0
200
Writing Greener Java Applications
hollycummins
0
370
Showkase、Paparazziを用いたビジュアルリグレッションテストの導入にチャレンジした話 / MoT TechTalk #15
mot_techtalk
0
150
PHPアプリケーションにおけるアーキテクチャメトリクスについて / Architecture Metrics in PHP Applications
isanasan
1
300
Featured
See All Featured
Facilitating Awesome Meetings
lara
33
4.6k
Support Driven Design
roundedbygravity
88
8.9k
The Pragmatic Product Professional
lauravandoore
21
3.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1.1M
The Invisible Customer
myddelton
113
12k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
2
410
VelocityConf: Rendering Performance Case Studies
addyosmani
317
22k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
24
4.6k
Mobile First: as difficult as doing things right
swwweet
213
7.8k
4 Signs Your Business is Dying
shpigford
171
20k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
29
8k
Learning to Love Humans: Emotional Interface Design
aarron
263
38k
Transcript
Tommy Mühle | tommy-muehle.io Tommy Mühle Software Engineer and Author
1
Tommy Mühle | tommy-muehle.io Introduce go-mnd 2
Tommy Mühle | tommy-muehle.io A vet analyzer to detect magic
numbers 3
Tommy Mühle | tommy-muehle.io Magic number? 4
Tommy Mühle | tommy-muehle.io Tommy Mühle | tommy-muehle.io A magic
number is a numeric literal that is not defined as a constant, but which may change, and therefore can be hard to update. 5
Tommy Mühle | tommy-muehle.io Hide intention 6
Tommy Mühle | tommy-muehle.io Hard to change 7
package main import `github.com/google/go-github/github` func main() { var repo github.Repository
// ... if repo.GetTeamID() == 12 { // ... } } Tommy Mühle | tommy-muehle.io 8
package main import `github.com/google/go-github/github` const TeamEngineering = 12 func main()
{ var repo github.Repository // ... if repo.GetTeamID() == TeamEngineering { // ... } } Tommy Mühle | tommy-muehle.io 9
Tommy Mühle | tommy-muehle.io How it works 10
Tommy Mühle | tommy-muehle.io 11 >= 1.12
Tommy Mühle | tommy-muehle.io Supported checks 12
package main import ( "net/http" "time" ) func main() {
client := &http.Client{ Timeout: 5 * time.Second, } // ... } Tommy Mühle | tommy-muehle.io 13 Assignment
Tommy Mühle | tommy-muehle.io 14 package main import ( "fmt"
"time" ) func main() { t := time.Now() switch { case t.Hour() < 12: fmt.Println("Good morning!") default: fmt.Println("Good evening.") } } Case
package main import "net/http" func handler(w http.ResponseWriter, r *http.Request) {
// ... http.Error(w, http.StatusText(404), 404) } Tommy Mühle | tommy-muehle.io 15 Argument
package main type queue struct { // ... } //
... func (q *queue) MaxLength() int { return 500 } Tommy Mühle | tommy-muehle.io 16 Return
package main func main() { var y int // ...
x := y * 100 // ... } Tommy Mühle | tommy-muehle.io 17 Operator
Tommy Mühle | tommy-muehle.io 18 package main func main() {
var x int // ... if x > 100 { // ... } } Condition
Tommy Mühle | tommy-muehle.io Demo 19
Tommy Mühle | tommy-muehle.io 20
Tommy Mühle | tommy-muehle.io 21
Tommy Mühle | tommy-muehle.io 22
Tommy Mühle | tommy-muehle.io 22
Questions?
Thank you! Slides http:/ /bit.ly/2pTywBB @tommy_muehle