Scala from the Trenches - Java One 2016

Post on 07-Jan-2017

97 views 0 download

Transcript of Scala from the Trenches - Java One 2016

@kfirondev

Scala from the Trenches

@kfirondev

Introduction to TDD and clean code

Kfir BlochHead of Backend Engineering

@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@kfirondevkfirb@wix.com

@kfirondev

BASICS

@kfirondev@kfirondev

THE ESSENCE OF TDD

REFACTORMAKE THE TEST PASS

WRITE A FAILING TEST

@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.

“ “

@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.

“ “

@kfirondev@kfirondev

Unit Test FakesCollaborators

StubsMatchers

IntegrationTests

Mocks Contract tests

www.maplecityrubber.com

TDD & CLEAN CODE “BUZZWORDS”

Refactoring

@kfirondev

USE CASE

@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

@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

@kfirondev

LET’S CODE

@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

@kfirondev

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

It works for us

projectlifemastery.com

@kfirondev

linkedin/in/blochkfir github.com/kfiron@kfirondevkfirb@wix.com

Kfir BlochHead of Backend Engineering

Q&A

@kfirondev

Thank You Wix Engineering Blog

http://engineering.wix.com/

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

emailjobs@wix.com

@kfirondev

Kfir BlochHead of Backend Engineering