Building Better Packages
by
Jeremy Saenz
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
BUILDING BETTER PACKAGES
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
WE ALL HAVE WRITTEN SHITTY CODE
Slide 4
Slide 4 text
Code Quality Design Effort
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
IMPLEMENTATION
Slide 8
Slide 8 text
IMPLEMENTATION INTERFACE
Slide 9
Slide 9 text
SIMPLICITY FLEXIBILITY CONTINUITY
Slide 10
Slide 10 text
SIMPLICITY FLEXIBILITY CONTINUITY
Slide 11
Slide 11 text
SIMPLICITY FLEXIBILITY CONTINUITY
Slide 12
Slide 12 text
SIMPLICITY FLEXIBILITY CONTINUITY
Slide 13
Slide 13 text
SIMPLICITY
Slide 14
Slide 14 text
SIMPLICITY IS PREREQUISITE FOR RELIABILITY EDSGER DIJKSTRA
Slide 15
Slide 15 text
SIMPLE MADE EASY RICH HICKEY
Slide 16
Slide 16 text
SINGULARITY
Slide 17
Slide 17 text
ONE ROLE
Slide 18
Slide 18 text
ONE TASK
Slide 19
Slide 19 text
ONE CONCEPT
Slide 20
Slide 20 text
ONE DIMENSION
Slide 21
Slide 21 text
DISCOVERY
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
LETTER OPENERS AND NOT SWISS ARMY KNIFES
Slide 24
Slide 24 text
WHAT DOES IT MEAN?
Slide 25
Slide 25 text
WHAT DOES IT ACCOMPLISH?
Slide 26
Slide 26 text
WHAT DOES IT OFFER?
Slide 27
Slide 27 text
EXAMPLE: negroni
Slide 28
Slide 28 text
EXAMPLE: Run(addr string) ServeHTTP(rw http.ResponseWriter, r *http.Request) Use(h Handler) UseHandler(h http.Handler)
Slide 29
Slide 29 text
FLEXIBILITY
Slide 30
Slide 30 text
COMPLIMENTS GROWTH
Slide 31
Slide 31 text
INTERFACES
Slide 32
Slide 32 text
INTERFACES: type Writer interface { Write(p []byte) (n int, err error) }
Slide 33
Slide 33 text
INTERFACES: type Writer interface { Write(p []byte) (n int, err error) }
Slide 34
Slide 34 text
INTERFACES: type FileSystem interface { Open(name string) (File, error) }
Slide 35
Slide 35 text
INTERFACES: type FileSystem interface { Open(name string) (File, error) }
Slide 36
Slide 36 text
ALWAYS USE INTERFACES
Slide 37
Slide 37 text
ALWAYS USE INTERFACES
Slide 38
Slide 38 text
MOSTLY USE INTERFACES
Slide 39
Slide 39 text
INTERFACES COMMUNICATE CONCRETENESS
Slide 40
Slide 40 text
INTERFACES COMMUNICATE STABILITY
Slide 41
Slide 41 text
INTERFACES COMMUNICATE COMMITMENT
Slide 42
Slide 42 text
RETURN VALUE?
Slide 43
Slide 43 text
RETURN VALUE? STRUCT
Slide 44
Slide 44 text
ARGUMENT VALUE?
Slide 45
Slide 45 text
ARGUMENT VALUE? INTERFACE
Slide 46
Slide 46 text
EXAMPLE: pkg/bufio
Slide 47
Slide 47 text
EXAMPLE: NewWriter(w io.Writer) *Writer
Slide 48
Slide 48 text
EXAMPLE: NewWriter(w io.Writer) *Writer
Slide 49
Slide 49 text
EXAMPLE: NewWriter(w io.Writer) *Writer
Slide 50
Slide 50 text
DISCOVERING INTERFACES
Slide 51
Slide 51 text
No content
Slide 52
Slide 52 text
OS.FILE
Slide 53
Slide 53 text
IO.WRITER VS OS.FILE
Slide 54
Slide 54 text
CONTINUITY
Slide 55
Slide 55 text
No content
Slide 56
Slide 56 text
No content
Slide 57
Slide 57 text
FICTIONAL CONTINUITY
Slide 58
Slide 58 text
THE CONSISTENCY OF THE CHARACTERISTICS OF PERSONS, PLOT, OBJECTS, PLACES AND EVENTS SEEN BY THE READER OR VIEWER
Slide 59
Slide 59 text
THE CONSISTENCY OF THE CHARACTERISTICS OF PERSONS, PLOT, OBJECTS, PLACES AND EVENTS SEEN BY THE READER OR VIEWER
Slide 60
Slide 60 text
HOW?
Slide 61
Slide 61 text
WRITE CODE LIKE… A MORON
Slide 62
Slide 62 text
WRITE CODE LIKE… IT ALREADY EXISTS
Slide 63
Slide 63 text
WRITE CODE LIKE… IT’S A PART OF THE GO STDLIB
Slide 64
Slide 64 text
EXAMPLE: gorilla/mux
Slide 65
Slide 65 text
EXAMPLE: func main() { r := mux.NewRouter() r.HandleFunc("/", Home) r.HandleFunc("/products", Products) http.Handle("/", r) }
Slide 66
Slide 66 text
EXAMPLE: func main() { r := mux.NewRouter() r.HandleFunc("/", Home) r.HandleFunc("/products", Products) http.Handle("/", r) }
Slide 67
Slide 67 text
NEED EXAMPLES?
Slide 68
Slide 68 text
DIG INTO THE STDLIB
Slide 69
Slide 69 text
EXTEND IT!
Slide 70
Slide 70 text
WE MADE IT
Slide 71
Slide 71 text
SIMPLICITY FLEXIBILITY CONTINUITY
Slide 72
Slide 72 text
- A WORLD THAT SEEMS TO HAVE BEEN GOING ON BEFORE WE STUMBLED INTO IT BUT WHICH, ONCE FOUND BY THE RIGHT READER, BECOMES INDISPENSABLE TO HIM. CS LEWIS
Slide 73
Slide 73 text
@CODEGANGSTA