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
Introduce go-mnd
Search
Tommy Mühle
February 06, 2020
Programming
0
130
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
78
Enums - An introduction
tommymuehle
0
220
Defensive programming
tommymuehle
10
1.3k
Why setters are bad
tommymuehle
2
710
Keep yourself up to date
tommymuehle
0
230
Exception handling - classic and fancy
tommymuehle
3
600
Other Decks in Programming
See All in Programming
無関心の谷
kanayannet
0
160
複数アプリケーションを育てていくための共通化戦略
irof
10
3.8k
GoのGenericsによるslice操作との付き合い方
syumai
2
540
「兵法」から見る質とスピード
ickx
0
260
技術懸念に立ち向かい 法改正を穏便に乗り切った話
pop_cashew
0
1.4k
赤裸々に公開。 TSKaigiのオフシーズン
takezoux2
0
130
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.3k
社内での開発コミュニティ活動とモジュラーモノリス標準化事例のご紹介/xPalette and Introduction of Modular monolith standardization
m4maruyama
1
120
単体テストの始め方/作り方
toms74209200
0
430
2度もゼロから書き直して、やっとブラウザでぬるぬる動くAIに辿り着いた話
tomoino
0
160
実践ArchUnit ~実例による検証パターンの紹介~
ogiwarat
2
250
事業戦略を理解してソフトウェアを設計する
masuda220
PRO
22
6k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.3k
Building Applications with DynamoDB
mza
95
6.4k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Embracing the Ebb and Flow
colly
86
4.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
What's in a price? How to price your products and services
michaelherold
245
12k
Gamification - CAS2011
davidbonilla
81
5.3k
Rails Girls Zürich Keynote
gr2m
94
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
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