際際滷

際際滷Share a Scribd company logo
So#ware	Cra#smanship	
Workshop	
Bal$more	So+ware	Prac$ces	and	Pa2erns																																				November	29,	2017	
Camille	Bell	
cbell@CamilleBellConsul$ng.com	
Twi2er	@agilecamille	
www.slideshare.net/Camille_Bell
So/ware	Cra/smanship	
cbell@CamilleBellConsul$ng.com																																																																																																																																			2	
≒ Tradi8onally	cra/smen	prac8ced	a	lot	
≒ Tradi8onally	cra/smen	worked	under	masters,	
who	guided	them	in	their	cra/	
≒ Doctors	s8ll	work	as	appren8ces	under	masters	in	
their	internships	and	residencies	
≒ But	so/ware	developers	don't	have	a	tradi8on	of	
prac8ce	mastering	our	cra/	
≒ Code	Dojos	where	we	prac8ce	TDD,	Refactoring	
and	Pairing	can	鍖ll	this	gap
cbell@CamilleBellConsul$ng.com																																																																																																																																			3	
Test	Driven	Development	Ensures	Quality
Develop	in	Baby	Steps	
cbell@CamilleBellConsul$ng.com																																																																																																																																	4	
≒ Write	a	8ny	test	
≒ Watch	it	fail	
≒ Write	only	enough	code	
to	make	it	pass	-	KISS	
≒ Watch	it	pass	
≒ If	the	code	gets	messy,	
refactor	in	baby	steps	
≒ Repeat
3	Rules	of	Test	Driven	Development	
1. You	are	not	allowed	to	write	any	produc8on	code	unless	
it	is	to	make	a	failing	unit	test	pass.	
2. You	are	not	allowed	to	write	any	more	of	a	unit	test	than	
is	su鍖cient	to	fail;	and	compila8on	failures	are	failures.	
3. You	are	not	allowed	to	write	any	more	produc8on	code	
than	is	su鍖cient	to	pass	the	one	failing	unit	test.	
With	tests	you	are	in	control;	without	tests	you	arent!	
Bob	Mar8n	-	The	Three	Rules	of	TDD	
cbell@CamilleBellConsul$ng.com																																																																																																																																			5
Test	Driven	Development	Feedback	Loop	
Write	a	test	for	
new	low	level	
func8onality		
Run	the	test	and	
watch	it	fail		
(no	code	=	test	fails)	
Write	just	enough	
code	to	make	the	
test	pass	
cbell@CamilleBellConsul$ng.com																																																																																																																																			6	
Run	the	test	and	
watch	it	pass	
Clean	up	
complex	or	
messy	code	
Run	test	again		
to	make	sure	it		
s8ll	passes	
Check	in	
Code	&	
Tests	
Check	in	
Code	&	
Tests
Simpli鍖ed	TDD	Flow	
(o/en	called	Red-Green-Refactor	
Write	a	failing	unit	test	
for	new	func8onality	
Write	just	enough	
code	to	pass	test	
Refactored	code	must	
also	pass	tests,		
no	new	func8onality	
cbell@CamilleBellConsul$ng.com																																																																																																																																	7	
TDD	is	Deep	Inside	Code:	Tes8ng	at	Unit	Level
≒ Programmers	restructure	system	by	improving	the	design	of	exis8ng	code	
without	changing	its	behavior		
 to	remove	duplica8on,	improve	communica8on,	simplify,	or	add	鍖exibility	
≒ Refactoring	is	not	random	change,	instead	its	driven	by	learning	from	our	
tests	and	from	iden8fying	and	鍖xing	code	smells	
≒ DRY	(Dont	Repeat	Yourself)	
≒ Refactoring	can	occur	just	prior	or	just	a/er	wri8ng	new	code	
≒ Test,	code,	refactor,	re-test	
 Very	short	cycles		refactor	in	baby	steps	
Refactoring	
When	鍖xing	bugs,	write	a	Red	test,	BEFORE	鍖xing		the	bug.	Test	will	run	Green	when	bug	鍖xed.	
When	working	with	legacy	code	make	sure	to	write	automated	tests	BEFORE	refactoring	code,	
If	tests	didnt	exist.	
cbell@CamilleBellConsul$ng.com																																																																																																																																			8
Ping	Pong	Pairing	
cbell@CamilleBellConsul$ng.com																																																																																																																																	9	
Shared	
Computer	
Mary	 Tom	
Write	a	failing	test	
Make	test	pass	
Write	a	failing	test	
Make	test	pass	
Write	a	failing	test	
Make	test	pass	
								etc.	
Make	test	pass	
Write	a	failing	test	
Make	test	pass	
Write	a	failing	test	
Make	test	pass	
Write	a	failing	test	
								etc.	
Refactor	as	needed
Mob	Programming	
≒ Whole	team	works	together	
≒ On	the	same	thing	
≒ At	the	same	8me	
≒ In	the	same	space	
≒ Using	the	same	computer	
≒ Driver	rotates	
≒ Everyone	par8cipates	
≒ Great	for	training	&	prac8ce	
≒ Great	for	collabora8on	
≒ Everyone	up	to	speed	faster	
≒ Some	teams	mob	always,	others	frequently	
≒ Features	delivered	faster		single	piece	鍖ow	/wo	hando鍖s	
cbell@CamilleBellConsul$ng.com																																																																																																																																	10	
1
Live	FizzBuzz	Code	Kata	
1		2		Fizz		4		Buzz		Fizz		
7			8		Fizz		Buzz		11		
Fizz		13		14		FizzBuzz		
Implement	FizzBuzz	using	TDD	
like	you	really	mean	it	
cbell@CamilleBellConsul$ng.com																																																																																																																																	11
Some	Kata	References	
cbell@CamilleBellConsul$ng.com																																																																																																																																	12	
≒ The	Coding	Dojo	Handbook	
		Available	in	PDF	from	Lean	Pub	
		hmps://leanpub.com/codingdojohandbook	
≒ Search	for	katas	available	online	(such	as):	
≒ Bowling	Game	Kata	(Uncle	Bob's	classic)	
≒ Red	Pencil	Promo8on	Kata	(Messy	Business	Rules)	
≒ Credit	Card	Number	Validator	
≒ Ordered	Jobs	Kata	
≒ and	many	more
Camille	Bell	
Agile	Technical	&	Process	Coaching	
Retrospec8ves	
Agile	Boot	Camps		
Agile	Training	
Updated	際際滷s	
or	just	to	chat	about	things	agile	
cbell@CamilleBellConsul$ng.com

More Related Content

Software Craftsmanship Workshop