qcon beijing 2010
DESCRIPTION
Slide I made last year after attended the Qcon Beijing 2010. Wish you like it.TRANSCRIPT
QCon Beijing架构, TDD, Python, twitter, facebook, agile, js ...
#QCon分享10年6月7日星期一
QCon Beijing
• 4.23~4.25 业界分享
10年6月7日星期一
QCon Beijing
http://www.qconbeijing.com/agenda.html
10年6月7日星期一
• 架构,设计类
• 系统架构与最佳实践及创新的关系
• 设计可扩展的架构
• Facebook的扩展Memcached实战
• Twitter的可伸缩性数据架构
• 构建可扩展的微博系统
• 敏捷类 (Agile)
• 如何在团队中有效实施TDD
• Agile and Scrum in China
• 让测试也敏捷起来
• 语言类
• Python
• F#,Scala,Erlang,Rebol
• JavaScript
QCon Beijing
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
python
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
python
twitter,微博
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
python
twitter,微博
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
OVERVIEW
架构与最佳实践创新的关系
10年6月7日星期一
• 有干货• 有水货• 有广告 人人网的技术架构的演进
OVERVIEW
架构与最佳实践创新的关系
10年6月7日星期一
• 有干货• 有水货• 有广告
Oracle,Micros囧ft
OVERVIEW
10年6月7日星期一
• 有干货• 有水货• 有广告
Oracle,Micros囧ft
有图有真相
OVERVIEW
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
Agile《Agile and Scrum in China : Can it work?》4.24
10年6月7日星期一
Agile
10年6月7日星期一
What is Agile ?
10年6月7日星期一
What is Agile ?
• 2001年2月,17位志愿者聚集在美国犹他州雪鸟度假胜地,讨论一个新的软件开发趋势,这个趋势被不严格地称为“轻量型软件开发过程”
• 我们都见过了因为开发过程的冗余,笨重,繁杂而失败的项目。世上应该有一种更好的软件开发方法---只关注真正重要的事情,少关注那些占用大量时间而不重要的事情。
• 这些志愿者们给这个方法取名为敏捷。
10年6月7日星期一
17位志愿者捣鼓了半天 ...
.........
10年6月7日星期一
Agile Manifesto
• Individuals and interactions over processes and tools
• Working software over comprehensive documentation
• Customer collaboration over contract negotiation
• Responding to change over following a plan
10年6月7日星期一
What is Agile ?• 敏捷方法可以快速地响应变化,它强调团队合作,人们专注于具体可行的目标(实现真正可以工作的软件),这就是敏捷的精神。
• 要求团队中的每一个人(包括与团队合作的人)都具备职业精神,并积极地期望项目能够获得成功。它并不要求所有人都是有经验的专业人员,但必须具有专业的工作态度,每个人都希望尽最大可能做好自己的工作。
• 敏捷开发就是在一个高度协作的环境中,不断地使用反馈进行自我调整和完善。
10年6月7日星期一
12 Principles of Agile• 我们的最高目标是,通过尽早和持续地交付有价值的软件来满足客户。
• 欢迎对需求提出变更——哪怕是在项目开发后期。要善于利用需求变更,帮助客户获得竞争优势。
• 要经常性地交付可用的软件,周期从几周到几个月不等,交付时间越短越好。
• 项目过程中,业务人员与开发人员必须在天天一起工作。
• 要善于激励项目人员,给他们以所需要的环境和支持,并相信他们能够完成任务。
• 无论是团队内还是团队间,最有效的沟通方法是面对面的交谈。
• 可用的软件是衡量进度的主要指标。
• 敏捷过程提倡可持续的开发。项目方、开发人员和用户应该能够保持长期稳定的进展速度。
• 对技术的精益求精以及对设计的不断完善将提升敏捷性。
• 要做到简洁,即尽最大可能减少不必要的工作。这是一门艺术。
• 最佳的架构、需求和设计出自于自组织的团队。
• 团队要定期反省如何能够做到更有效,并相应地调整团队的行为。
10年6月7日星期一
What is Scrum?• 软件开发模型是敏捷开发的一种
• backlog: 可以预知的所有任务, 包括功能性的和非功能性的所有任务。
• sprint:一次跌代开发的时间周期,一般最多以30天为一个周期.在这段时间内,开发团队需要完成一个制定的backlog,并且最终成果是一个增量的,可以交付的产品。
• sprint backlog:一个sprint周期内所需要完成的任务。
• scrumMaster: 负责监督整个Scrum进程,修订计划的一个团队成员。
• time-box: 一个用于开会时间段。比如每个daily scrum meeting的time-box为15分钟。
• sprint planning meeting: 在启动每个sprint前召开。一般为一天时间(8小时)。该会议需要制定的任务是:产品Owner和团队成员将backlog分解成小的功能模块, 决定在即将进行的sprint里需要完成多少小功能模块,确定好这个Product Backlog的任务优先级。另外,该会议还需详细地讨论如何能够按照需求完成这些小功能模块。制定的这些模块的工作量以小时计算。
• Daily Scrum meeting:开发团队成员召开,一般为15分钟。每个开发成员需要向ScrumMaster汇报三个项目:今天完成了什么? 是否遇到了障碍? 即将要做什么?通过该会议,团队成员可以相互了解项目进度。
• Sprint review meeting:在每个Sprint结束后,这个Team将这个Sprint的工作成果演示给Product Owner和其他相关的人员。一般该会议为4小时。
• Sprint retrospective meeting:对刚结束的Sprint进行总结。会议的参与人员为团队开发的内部人员。一般该会议为3小时。
10年6月7日星期一
Some tips from 《Practices of an Agile Developer》
• 一个学习型的团队才是较好的团队。每周,要求团队中的一个人主持讲座。他会给大家介绍一些概念,演示工具,或者做团队感兴趣的任何一件事情,你可以挑一本书,给大家说说其中一些特别内容,项目或者实践。无论什么主题都可以。读书小组逐章一起阅读以本书,会非常有用,但是要选好书;坚持有计划有规律的举行讲座。
• 在许多不成功的项目中,基本上都是随意安排工作计划,没有任何的规律。敏捷项目会有一个节奏和循环。最大的节拍就是迭代时间,一般是1-4周的时间。当时间到的时候,迭代就完成了,那部分是固定不变的,但是在一个具体的迭代中完成哪些功能是灵活的。换句话说,你不会改变时间,但是你可以改变功能。
• 白板,草图,便利贴都是非常好的设计工具。复杂的建模工具只会让你分散精力,而不是启发你的工作。
• 敏捷的一个主要特点就是持续开发。
• 依赖于单元测试。
• 代码被阅读的次数要远远超过被编写的次数,所以在编程时多付出一点努力来做好文档,会让你将来受益匪浅。
• 保持简单。
• 维护一个问题及其解决方案的日志。保留解决方案时修复问题过程的一部分,以后发生相同或类似问题时,就可以很快找到并使用了。要记录团队做出一个重要决策的原因。
• 如果不及时跟进讨论中给出的建议,代码复查是没有实际价值的。要确保参与人员得到每次复查活动的反馈。作为结果,要让每个人指导复查完成后所采取的行动。
• 及时通报进展与问题。发布进展状况,新的想法和目前正在关注的主题,不要等别人来问项目状态如何。
10年6月7日星期一
结论道理都知道,只是 ...
10年6月7日星期一
结论道理都知道,只是 ...
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
Twitter《Twitter 的可伸缩性数据架构》4.24
10年6月7日星期一
有图有真相
欢迎系统工程师- 大胡子@nk
10年6月7日星期一
有图有真相
欢迎系统工程师- 大胡子@nk
10年6月7日星期一
有图有真相
欢迎系统工程师- 大胡子@nk
• 敏捷的开发:快速实现,随着应用和用户量需求调整架构(exp:single table => partition table)
10年6月7日星期一
有图有真相
欢迎系统工程师- 大胡子@nk
• 敏捷的开发:快速实现,随着应用和用户量需求调整架构(exp:single table => partition table)• 没有高深复杂的架构,够用即可
10年6月7日星期一
有图有真相
欢迎系统工程师- 大胡子@nk
• 敏捷的开发:快速实现,随着应用和用户量需求调整架构(exp:single table => partition table)• 没有高深复杂的架构,够用即可• 不管黑猫白猫,能捉住老鼠就是好猫
10年6月7日星期一
有图有真相
有推有真相
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
Douglas Crockford《javascript的现状与未来》4.25
10年6月7日星期一
有图有真相
• Yahoo! 资深js工程师•《JavaScript:The Good
Parts》(《JavaScript语言精粹》)作者• JavaScript的发明人Brendan Eich
说他是“lambda编程和JavaScript
的精神领袖”。• json之父
Douglas Crockford
Crockford
10年6月7日星期一
有图有真相
大师观点
• IE6
• JavaScript
• HTML5
Douglas Crockford
Crockford
10年6月7日星期一
有图有真相
IE6
Crockford
10年6月7日星期一
有图有真相
大师观点 - IE6
Crockford
10年6月7日星期一
有图有真相
大师观点 - IE6
Crockford
10年6月7日星期一
有图有真相
微软在2010年3月1日宣布结束对IE6的主流支持,来自世界各地的IE6粉丝们昨天在美国科罗拉多州为IE6举办了葬礼
国外,IE6 ...
Crockford
10年6月7日星期一
有图有真相
但是在天朝,IE6 ...
OVER 70% !!!
数据来源:网易市场部网站组浏览器统计
Crockford
10年6月7日星期一
有图有真相
大师观点 - IE6
Crockford
10年6月7日星期一
有图有真相
大师观点 - IE6 again
Crockford
10年6月7日星期一
有图有真相
大师观点 - JavaScript
Crockford
10年6月7日星期一
有图有真相
大师观点 - JavaScript
Crockford
Macros
Threads
Tail Calls
10年6月7日星期一
有图有真相
大师观点 - JavaScript
Crockford
10年6月7日星期一
有图有真相
大师观点 - JavaScript
Crockford
10年6月7日星期一
有图有真相
大师观点 - JavaScript
Crockford
10年6月7日星期一
有图有真相
HTML5
Crockford
10年6月7日星期一
有图有真相
HTML5
HTML5 ~= HTML +CSS + JSAPI
Crockford
10年6月7日星期一
有图有真相
HTML5
Crockford
• Semantics (New tags, Link Relations, Microdata)
• Web Forms 2.0 (Input Fields)
• Multimedia (Audio Tag, Video Tag)
• 2D and 3D drawing (Canvas, WebGL, SVG)
HTML
10年6月7日星期一
有图有真相
HTML5
Crockford
• Typography
• Visuals
• Transitions, transforms and
animations
CSS
10年6月7日星期一
有图有真相
HTML5
Crockford
• Client Side Storage (Web SQL Database, App
Cache, Web Storage)
• Communication (Web Sockets)
• Desktop experience (Notifications, Drag and
Drop API)
• Geolocation
JSAPI
10年6月7日星期一
有图有真相
HTML5
拥抱HTML5 ?
Crockford
10年6月7日星期一
有图有真相
大师观点 - HTML5
Crockford
10年6月7日星期一
有图有真相
大师观点 - HTML5
Crockford
10年6月7日星期一
有图有真相
大师观点 - HTML5
Crockford
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
Python《Python于web2.0网站的应用》4.23
10年6月7日星期一
Python
洪强宁北京豆瓣互动科技有限公司首席架构师
• Python语言的特点、文化及优势•结合豆瓣开发过程中的多个实际案例,阐述Python这门语言是如何简化一些常见场景的开发
twitter: @hongqn
10年6月7日星期一
Pythonic
10年6月7日星期一
Pythonic
10年6月7日星期一
Pythonic
10年6月7日星期一
Server
python -m SimpleHTTPServer
10年6月7日星期一
web.pyhttp://webpy.org/
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
web框架
the answer is often that it is way too easy to put together one in Python. That certainly seems plausible since there are so many libraries that implement the components of a web framework and if it's easy to plug those pieces together then maybe that lowers the bar of entry for new frameworks.
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating : kid
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating : kid
SQL : SQLAlchemy
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating : kid
SQL : SQLAlchemy
Routing : Selector
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating : kid
SQL : SQLAlchemy
Routing : Selector
WSGI
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating : kid
SQL : SQLAlchemy
Routing : Selector
WSGI
Robaccia(3 hours, 60
lines)
web框架
10年6月7日星期一
• Other frameworks: Quixote, django,leazy ...
• http://bitworking.org/news/
Why_so_many_Python_web_frameworks
Templating :jinja2
SQL :dbop.py + model.py
Routing :dispatcher.py + url.py
WSGI
Leazy
web框架
10年6月7日星期一
测试doctest - testmod
10年6月7日星期一
测试doctest - testmod
10年6月7日星期一
测试doctest - testfile
file name : example
10年6月7日星期一
测试doctest - unittest
As your collection of doctest’ed modules grows, you’ll want a way to run all their
doctests systematically.
10年6月7日星期一
测试doctest - unittest
utest1.py utest2.py
10年6月7日星期一
测试doctest - unittest
10年6月7日星期一
测试doctest - unittest
10年6月7日星期一
测试doctest - unittest
>>> python utest_driver.py ..---------------------------------------------Ran 2 tests in 0.043s
OK
10年6月7日星期一
测试nose extends unittest to make testing easier. http://somethingaboutorange.com/mrl/projects/nose/
easy_install nose
10年6月7日星期一
测试nose extends unittest to make testing easier. http://somethingaboutorange.com/mrl/projects/nose/
bash-3.2$ nosetests --with-doctest..------------------------------------Ran 2 tests in 0.038s
OKbash-3.2$
在前一个包含utest1.py和utest2.py的目录下运行nosetests
easy_install nose
10年6月7日星期一
测试nose extends unittest to make testing easier. http://somethingaboutorange.com/mrl/projects/nose/
Write your nose test file:
nose_test_case.py
easy_install nose
10年6月7日星期一
测试nose extends unittest to make testing easier. http://somethingaboutorange.com/mrl/projects/nose/
nose_test_case.py
base$ nosetests nose_test_case.py.----------------------------------------Ran 1 test in 0.001s
OKbase$
Write your nose test file:
easy_install nose
10年6月7日星期一
测试nose extends unittest to make testing easier. http://somethingaboutorange.com/mrl/projects/nose/
nose_test_case.py
base$ nosetests nose_test_case.py.----------------------------------------Ran 1 test in 0.001s
OKbase$
Write your nose test file:
Any function or class that matches the configured testMatch regular expression ((?:^|[\\b_\\.-])[Tt]est)
easy_install nose
10年6月7日星期一
科学运算numpy
>>> numpy.arange(0, 10, 1)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> numpy.linspace(0, 10, 10) # 0~10, 10 numbers
>>> numpy.logspace(0, 2, 10) #1~100,10 numbers
>>> a = numpy.arange(4).reshape(2,2)
>>> a
array([[0, 1],
[2, 3]])
>>> numpy.dot(a, a.T)
array([[ 1, 3],
[ 3, 13]])
10年6月7日星期一
ipython
iPython http://ipython.scipy.org/doc/stable/html/
bash$ ipythonPython 2.5 (r25:51918, Sep 19 2006, 08:49:13) Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.? -> Introduction and overview of IPython's features.%quickref -> Quick reference.help -> Python's own help system.object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: lsFlask-0.3.1/ memcached-1.4.5/ objc-json/ web.py-0.34/einstall.py* numpy/ scipy/
In [2]: print "hello world"hello world
10年6月7日星期一
virtualenvvirtualenv 创建一个干净的、隔离的python环境
$ virtualenv --no-site-packages vetest$ cd vetest$ source bin/activate(vetest)fbmac:vetest fengbo$ lsbin include lib(vetest)fbmac:vetest fengbo$ python>>> import BeautifulSoupTraceback (most recent call last): File "<stdin>", line 1, in <module>ImportError: No module named BeautifulSoup>>> exit()$ sudo easy_install BeautifulSoup$ python>>> import BeautifulSoup>>>
10年6月7日星期一
C扩展(1)
Cython
def say_hello(name): print "hello, %s" % name
easy_install cython
cython_test.pyx
pythonPython 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import pyximport>>> pyximport.install()>>> import cython_test>>> cython_test.say_hello("world")hello, world>>> exit()
10年6月7日星期一
C扩展(2)
Cython
def say_hello(name): print "hello, %s" % name
easy_install cython
cython_test.pyx
compile to .so file
from distutils.core import setupfrom distutils.extension import Extensionfrom Cython.Distutils import build_ext
ext_modules = [Extension("hello", ["cython_test.pyx"])]
setup( name = 'Hello world app', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules)
setup.py
10年6月7日星期一
C扩展(3)
Cython easy_install cython
$ python setup.py build_ext --inplace
$ ls
build cython_test.c cython_test.pyx hello.so setup.py
$ python
>>> import hello
>>> hello.say_hello(“world”)
>>> hello, world
10年6月7日星期一
配置文件svn线上版本配置与个人测试环境配置不同
10年6月7日星期一
配置文件svn线上版本配置与个人测试环境配置不同
我们的做法:
config.py.sample config.py
svn线上版本
cp 后修改
个人测试环境
10年6月7日星期一
配置文件svn线上版本配置与个人测试环境配置不同
config.py
project_path = “/home/project/xx”try:
from local_config import *except ImportError, ex:
pass
local_config.py
project_path = “/home/user/aaa/project/xx”
10年6月7日星期一
decorator - 消息队列使用消息队列发送email
10年6月7日星期一
decorator - 消息队列使用decorator
async_func.py
10年6月7日星期一
decorator - 消息队列使用decorator
async_func.py
10年6月7日星期一
decorator - 消息队列使用decorator
async_func.py
10年6月7日星期一
decorator - cached
10年6月7日星期一
decorator - cached
使用decorator
10年6月7日星期一
decorator - cached
10年6月7日星期一
decorator - cachedimport inspect
10年6月7日星期一
import inspect
get params dict
decorator - cached
10年6月7日星期一
import inspect
get params dict
get from mmecache / db
decorator - cached
10年6月7日星期一
decorator - cached
使用decorator
“uinfo_{uid}”
python2.6
“uinfo_{uid}”.format(uid=2)
10年6月7日星期一
开发工具/环境
•编辑器:Vim / Emacs / Ulipad
•版本管理: subversion /mercurial / git
• wiki/错误跟踪/代码浏览:Trac
•持续集成: Bitten
10年6月7日星期一
Agenda
• Overview
• Agile
• Douglas Crockford
• Python
10年6月7日星期一
总结
•敏捷开发•用适合自己的技术和架构• IE6 MUST DIE
• HTML5? web安全性是需要关注的首要问题• python的工具包,写测试用例(TDD?)•使用decorator简化代码
10年6月7日星期一
More ...
• Visit : http://www.qconbeijing.com/
10年6月7日星期一
END
follow me on twitter: @vonboon 网易微博: @vonbo
10年6月7日星期一