Scala from the Trenches - Java One 2016

16
@kfirondev Scala from the Trenches @kfirondev Introduction to TDD and clean code Kfir Bloch Head of Backend Engineering

Transcript of Scala from the Trenches - Java One 2016

Page 1: Scala from the Trenches - Java One 2016

@kfirondev

Scala from the Trenches

@kfirondev

Introduction to TDD and clean code

Kfir BlochHead of Backend Engineering

Page 2: Scala from the Trenches - Java One 2016

@kfirondev

KFIR BLOCH● Head of backend engineering @ Wix● Hands-on developer above 17 years● Joined Wix 5 years ago

linkedin/in/blochkfir github.com/kfiron@[email protected]

Page 3: Scala from the Trenches - Java One 2016

@kfirondev

BASICS

Page 4: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

THE ESSENCE OF TDD

REFACTORMAKE THE TEST PASS

WRITE A FAILING TEST

Page 5: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

Great software is something to marvel at: powerful, elegant, functional, a pleasure to work with as both a developer and as a user.

Great software isn’t written by machines. It is written by professionals with an unshakable commitment to craftsmanship.

“ “

Page 6: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

TDD is based on a simple idea: Write tests for your code before you write the code itself. However, this "simple" idea takes skill and judgment to do well.

Now there's a practical guide to TDD that takes you beyond the basic concepts.

“ “

Page 7: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

Unit Test FakesCollaborators

StubsMatchers

IntegrationTests

Mocks Contract tests

www.maplecityrubber.com

TDD & CLEAN CODE “BUZZWORDS”

Refactoring

Page 8: Scala from the Trenches - Java One 2016

@kfirondev

USE CASE

Page 9: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

Get - prize Get - prize

OK OK

Get - prize Get - prize

Already wonAlready played

Get - prizeGet - prizeGet - prizeGet - prizeGet - prize

Get - prizeGet - prizeGet - prizeGet - prizeGet - prize

Already wonAlready wonAlready wonAlready wonAlready won

Already wonAlready wonAlready wonAlready wonAlready won

USER QUIZ PRIZE SERVER

DATABASE

Page 10: Scala from the Trenches - Java One 2016

@kfirondev@kfirondev

Get - prize Get - prize

OK OK

Get - prize

Already played

Get - prizeGet - prizeGet - prizeGet - prizeGet - prize

Already wonAlready wonAlready wonAlready wonAlready won

USER QUIZ PRIZE SERVER

DATABASE

FAIL FAST PATTERN

THROTTLER

ROLLING WINDOW KEY (user-id) THROTTLER

Page 11: Scala from the Trenches - Java One 2016

@kfirondev

LET’S CODE

Page 12: Scala from the Trenches - Java One 2016

@kfirondev

• TDD & Clean code definitions• DOS attack use case• Developed rolling window throttler• Wire the throttler to pre-baked

service

Summary of what we did

Page 13: Scala from the Trenches - Java One 2016

@kfirondev

• ~120 backend developers• Zero QA engineers• ~100 deployments per day

It works for us

projectlifemastery.com

Page 15: Scala from the Trenches - Java One 2016

@kfirondev

linkedin/in/blochkfir github.com/kfiron@[email protected]

Kfir BlochHead of Backend Engineering

Q&A

Page 16: Scala from the Trenches - Java One 2016

@kfirondev

Thank You Wix Engineering Blog

http://engineering.wix.com/

We are hiring http://jobs.wix.com

[email protected]

@kfirondev

Kfir BlochHead of Backend Engineering