Test Failed, Then...

Optimizing communication between people	
Toru Furukawa"
@torufurukawa"
Agenda	
•  Introduction

Web app syncing with live TV show"
•  Loose coupling"
•  Testable components"
•  Efficient communi...
Agile App Development 

on Concrete Backend Services	
HTML App"
App Server	
Backend Service(s)"
Project	
  dependent	
Comm...
Because...	
•  Requirements keep changing"
•  Not only Web, but also TV"
•  Not only TV, but also Web"
•  Spiky access tra...
Ended up with…	
HTML App"
App Server	
Counter" Messenger"
High Communication Cost	
"Communication overheads increase as the
number of people increases." F. Brooks"
Minimal and Effective Communication
Optimize Communication	
•  Between Components"
•  Between People
How to Simplify Dependency?	
HTML App"
App Server	
 Counter" Messenger"
PHP	
•  IMPORTANT: PHP is fine"
•  Cannot be combined with Python
component in language layer easily
Loose Coupling	
"Write small services that speak HTTP and
bridge them together with another
application.""
Armin Ronacher ...
Loose Coupling	
HTML App"
(JavaScript)	
App Server"
(whatever)	
Counter"
(Python)	
Messenger"
(Node.js)	
HTTP
Assign Engineer for Component	
HTML App"
(JavaScript)	
App Server"
(whatever)	
Counter"
(Python)	
Messenger"
(Node.js)	
HT...
Communication Paths
2 Projects Running
Wrap Engineers' Communication	
•  New layers to simplify inter-component
communication"
•  Assign new roles to simplify in...
HTML App"
(JavaScript)	
App Server"
(whatever)	
Counter"
(Python)	
Messenger"
(Node.js)	
Server/Server Communication"
(Pyt...
If a servicewise feature does not
work, how to identify the cause?"
•  Ask developer to check logs?"
•  Ask developer to c...
Log with fluentd	
App Server"
(whatever)	
Counter"
(Python)	
Messenger"
(Node.js)	
fluentd	
Mongo	
  DB	
 Web App
Define CRUD APIs	
•  Make DB accessible from test and admin	
•  REST /objects/:id"
•  /get_objects

/get_object, /set_objec...
"requests" package 

for Web API Access	
>>>	
  r	
  =	
  requests.get(url,	
  auth=(...),	
  ...)	
  
>>>	
  r	
  =	
  re...
Library for Productivity	
•  Use testing libraries to increase
productivity 

i.e. how many test you write per hour"
•  se...
Translate Test Report	
Traceback	
  (most	
  recent	
  call	
  last):	
  
	
  	
  File	
  "mytest.py",	
  line	
  7,	
  in...
Library for Readability	
class	
  MyTest(unittest.TestCase):	
  
	
  	
  	
  	
  def	
  test(self):	
  
	
  	
  	
  	
  	
...
Traceback	
  (most	
  recent	
  call	
  last):	
  
	
  	
  File	
  "mytest.py",	
  line	
  7,	
  in	
  test	
  
	
  	
  	
...
Python vs HTTP	
Python	
HTTP	
Test Fast	
Loosely
Couple	
Develop
Fast
If I stick to Python too much,

my communication is

tightly coupled
Convert requests function to curl	
>>>	
  import	
  curledrequests	
  as	
  requests	
  
>>>	
  requests.debug	
  =	
  Tru...
Loosely Couple

Components and Engineers
Share Your Practice	
@torufurukawa or grab me"
Test Failed, Then...
Test Failed, Then...
Test Failed, Then...
Test Failed, Then...
Test Failed, Then...
Test Failed, Then...
Upcoming SlideShare
Loading in …5
×

Test Failed, Then...

1,671 views
1,639 views

Published on

Pycon APAC presentation on optimizing inter-component communication and inter-engineer communication.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,671
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
4
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Test Failed, Then...

  1. 1. Test Failed, Then...
 Optimizing communication between people Toru Furukawa" @torufurukawa"
  2. 2. Agenda •  Introduction
 Web app syncing with live TV show" •  Loose coupling" •  Testable components" •  Efficient communication"
  3. 3. Agile App Development 
 on Concrete Backend Services HTML App" App Server Backend Service(s)" Project  dependent Common
  4. 4. Because... •  Requirements keep changing" •  Not only Web, but also TV" •  Not only TV, but also Web" •  Spiky access traffic" •  Common fundamental features" ▼" •  Easy to change application" •  Well tested platform"
  5. 5. Ended up with… HTML App" App Server Counter" Messenger"
  6. 6. High Communication Cost "Communication overheads increase as the number of people increases." F. Brooks"
  7. 7. Minimal and Effective Communication
  8. 8. Optimize Communication •  Between Components" •  Between People
  9. 9. How to Simplify Dependency? HTML App" App Server Counter" Messenger"
  10. 10. PHP •  IMPORTANT: PHP is fine" •  Cannot be combined with Python component in language layer easily
  11. 11. Loose Coupling "Write small services that speak HTTP and bridge them together with another application."" Armin Ronacher (@mitsuhiko)" http://lucumr.pocoo.org/2010/12/24/common-mistakes-as-web-developer/
  12. 12. Loose Coupling HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) HTTP
  13. 13. Assign Engineer for Component HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) HTTP
  14. 14. Communication Paths
  15. 15. 2 Projects Running
  16. 16. Wrap Engineers' Communication •  New layers to simplify inter-component communication" •  Assign new roles to simplify inter-people communication
  17. 17. HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) Server/Server Communication" (Python) Client/Server Communication
  18. 18. If a servicewise feature does not work, how to identify the cause?" •  Ask developer to check logs?" •  Ask developer to check DB?" ▼" Make component diagnosable" Instrument Components
  19. 19. Log with fluentd App Server" (whatever) Counter" (Python) Messenger" (Node.js) fluentd Mongo  DB Web App
  20. 20. Define CRUD APIs •  Make DB accessible from test and admin •  REST /objects/:id" •  /get_objects
 /get_object, /set_object, /delete_object" ▼" •  Diagnose 1-layer deeper from outside"
  21. 21. "requests" package 
 for Web API Access >>>  r  =  requests.get(url,  auth=(...),  ...)   >>>  r  =  requests.post(url,  data={...},  ...)   >>>  r.status_code   200   >>>  r.content   u'{"foo":"bar","x":true}'   >>>  r.json()   {u'foo':  u'bar',  'x':  True}  
  22. 22. Library for Productivity •  Use testing libraries to increase productivity 
 i.e. how many test you write per hour" •  setup and teardown" – unittest" – nose" – py.test" – testfixtures" – etc.
  23. 23. Translate Test Report Traceback  (most  recent  call  last):      File  "mytest.py",  line  7,  in  test          assert  result  ==  expected   AssertionError   ▼" •  How do YOU determine what is wrong?" •  How do you tell OTHERS what is wrong?" ▼" •  Need better way to communicate
  24. 24. Library for Readability class  MyTest(unittest.TestCase):          def  test(self):                  expected  =  {...}                  result  =  {...}                  self.assertEqual(x,  y)   " "
  25. 25. Traceback  (most  recent  call  last):      File  "mytest.py",  line  7,  in  test          self.assertEqual(x,  y)   AssertionError:  {'items':  ['spam',  'spam'],   'foo':  'bar'}  !=  {'items':  ['spam',  'ham'],   'foo':  'bar'}   -­‐  {'foo':  'bar',  'items':  ['spam',  'spam']}   ?                                                                      ^^     +  {'foo':  'bar',  'items':  ['spam',  'ham']}   ?                                                                      ^
  26. 26. Python vs HTTP Python HTTP Test Fast Loosely Couple Develop Fast
  27. 27. If I stick to Python too much,
 my communication is
 tightly coupled
  28. 28. Convert requests function to curl >>>  import  curledrequests  as  requests   >>>  requests.debug  =  True   >>>  r  =  requests.get(   ...      'http://www.google.com/',   ...      params={'q':'python'})   ...   $  curl  “http://www.google.com/?q=python”  -­‐w   'n%{http_code}n'   <!doctype  html><html  itemscope=""   itemtype="http://schema.org/WebPage"><head><me   ...   200   h5p://goo.gl/hO579O  
  29. 29. Loosely Couple
 Components and Engineers
  30. 30. Share Your Practice @torufurukawa or grab me"

×