2. Agenda
• Introduction
Web app syncing with live TV show"
• Loose coupling"
• Testable components"
• Efficient communication"
3.
4. Agile App Development
on Concrete Backend Services
HTML App"
App Server
Backend Service(s)"
Project
dependent
Common
5. 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"
11. How to Simplify Dependency?
HTML App"
App Server
Counter" Messenger"
12. PHP
• IMPORTANT: PHP is fine"
• Cannot be combined with Python
component in language layer easily
13. 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/
22. 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
23. Log with fluentd
App Server"
(whatever)
Counter"
(Python)
Messenger"
(Node.js)
fluentd
Mongo
DB
Web App
24. 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"
25. "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}
26. 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.
27.
28. 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
29. Library for Readability
class
MyTest(unittest.TestCase):
def
test(self):
expected
=
{...}
result
=
{...}
self.assertEqual(x,
y)
"
"