SlideShare a Scribd company logo
1 of 56
Horky
SPD SW
Apr/2011
http://blog.csdn.net/horkychen
1
介绍程序员成长路上的那些小事情!
2
Agenda
 Pragmatic Programmer
 Estimating (提升专业素养)
 DRY rule - Repeat or Reuse (提炼经验)
 Control Structures & Complexity (简洁就是美)
 Table Driven (善于运用算法)
 Design for CHANGE (完善设计、争取主动)
 Refactoring (追求卓越,勇于改进)
 Automation (一切都要自动化)
 Resource
 Who is working for you (找个巨人的肩膀)
 Accessories for you
 Process and Methods
 Process enhances confidence
 Thought Disorder(最容易欺骗的人是自己)
 Conceptual Blockbusting
 Career anchors
 How to define the VALUE (价值不等式)
 Professionalism
 Q&A
3
Pragmatic Programmer
(注重实效)
4
Estimating (估算)
 估算是专业能力的综合表现。
 难点
 需求分析
 行政干预
 精确度
 PI
 美国的议员曾提案要求将PI值定为3。
 而NASA将需要12个小数位。
 建议估算时间以周为单位。
5
 估算是专业能力的体现!
 新的系统
 建立系统架构模型
 分解为组件
 设计组件的功能
 依功能对各个组件进行估算
 展开及细化
 汇总
 修改的系统
 识别需要变更的组件
 定义需变更的组件内容
 依据变更的内容进行逐项估算
 汇总
 追踪估算,逐步修正误差!
 Reference:
 http://www.cnblogs.com/badwps/archive/2009/08/
28/1555485.html
Estimating (估算)
6
DRY rule - Repeat or Reuse
 开发者利器
 Google & Baidu
 Sourceforge & CodeProject
 Ctrl+C & Ctrl+V
 复用不是重复使用,而是如何重复使用!
 思考:
 物以稀为贵,越容易得到的也就越容易失去!
 在如此开放的网络环境下,我们的知识还有多少价值?
 面对变化时,维护成本变大且风险很高
 知识是不稳定的!唯一不变的就是变化!
 BUG可能隐藏在仸何位置,那是噩梦的开始!
 对个人知识积累不利
 常常消化不良
7
Category and Count measure
 类型:
 无意的重复
 无耐性的重复
 对策
 Simplify design
 Cleaning Code
 Coding Rule
 Coding Review
 Reference:
 Refactoring: Improving the Design of existing code
8
Control Structure
 Need a loop that executes a specified number of times
 To use a for loop
 If change the index value of a for loop force it to
terminate, use a while loop instead.
 Else to use a while loop.
 Reference:
 Write Solid Code, Maguire, 1993
9
Controlling the loop
 Major principles
 简化循环体相关连的因素(所引用的变量或数据),判
断或结束条件一定要简单。
 循环也是另类的子程序,可以视其为Black box.
 Entering the Loop
 Put initialization code directly before the loop
 Use while ( true ) for infinite loops
 Don’t use a for loop when a while loop is more
appropriate
10
Sample
Control statements vs. housekeeping statements
11
Processing the middle of the loop
 Use { and } to enclose the statements in a loop
 Avoid empty loops
 Keep loop-housekeeping chores at either the beginning or the
end of the loop
 Make each loop perform only one function
 可以做,但不代表应该做。正确的代码不代表是好的代码!
12
Exiting the loop
 Existing loops early
 According to an article in Software Engineering Notes, the software error that 7
brought down the New York City phone systems for 9 hours on January 15, 8
1990 was due to an extra break statement (SEN 1990)
break的分散代表逻辑上的分散,会带来维护上的风险!大量的return出现在函数
体,多个深层嵌套,变量中途转为它用,多处理重复功能相近的代码,都预示者
开发者的逻辑可能已经出现问题!
13
Checking endpoints
 Willingness to perform this kind of check is a key
difference between efficient and inefficient
programmers.
 How to check
 Hand calculations
 Mental simulations
 Calculate by Excel
 What are benefits?
 You understand how your code works rather than
guessing about it!
14
How long should a loop be
 Make your loops short enough to view all at once.
 Limit nesting to three levels
 Move loop innards of long loops into routines
 Make long loops especially clear.
 Single exit.
15
Creating loop easily
 From the inside out
16
Control Structure and Complexity
 The control flow is at least one of the largest
contributors to complexity, if not the largest.
 HP apply McCabe’s complexity metric, that is helpful
to improve coding quality.
 General guideline for reducing complexity
 Improve your own mental juggling abilities
 You can decrease the complexity of your programs and
the amount of concentration required to understand
them.
17
How to measure complexity
 Techniques for counting the decision points in a routine
 Start with 1 for the straight pat through the routine
 Add 1 for each of the following keywords, or their equivalents: if
while repeat for and or
 Add 1 for each case in a case statement
 Exercise
 if ( ( (status = Success ) and done) or
( not done and ( numLines >= maxLines ) ) )
then …
*Cyclomatic Complexity 18
Table Driven
 Advantage:
 Simplify codes and enhance the performance
 Enhance the system customization capability.
 Weakness:
 Not everyone know it well, it may bring extra efforts.
 Virtually anything you can select with logic
statements, you can select with tables instead.
19
Indexed Access Tables
20
Stair-Step Access Tables
21
Example
static unsigned int chooseDPI(unsigned int
original_dpi, int datatype)
{
int i, d, diff, k;
static Support_Mode support_mode[] = {
{4, 0}, //support two modes
{150, 2},
{300, 3}, //300DPI with color and gray
{600, 3}, //600DPI with color and gray
{1200, 2}
};
diff = -1;
k = 1;
for (i = 1; i <= support_mode[0].dpi; ++i)
{
if (support_mode[i].support_mode & datatype)
{
d = abs(support_mode[i].dpi - original_dpi);
if (diff == -1)
{
diff = d;
k = i;
}
else
{
if (d <= diff)
{
diff = d;
k = i;
}
else
break;
}
}
}
return support_mode[k].dpi;
}
22
Design for Change
• 应对变化:
– 解耦:得墨忒尔法则
– 元数据与动态配置
– 并发与次序
– 划分模块、分而治之
23
The law of Demeter
 某个对象的任何方法都应该只能调用:
 它自身
 传入该方法的任何参数
 它创建的任何对象
 任何直接持有的组件对象
24
Meta data and Dynamic Configuration
 将变化封装起来,使用元数据进行配置。
 什么是变化的?
 什么是不变化的?
 抽象、抽象
 Example:
 Linux – Build your own Linux distribution
25
并发与时序
 时间耦合(temporal coupling)
 定义好你的工作流
 用服务为并发进行设计
26
分而治之
 观察者模式
27
Refactoring
重构最困难之处在于情感上,而不是技术上!
目的: 不改变“软件之可察行为”前提下,
提高其可理解性,降低其维护成本.
权威著作:
Author:
Martin Fowler
28
Example 1
 分析switch(nBits)
 以下两种为常用运算
+3)>>2)<<2
 ConvertToMultipleOfFour
+7)>>3)+3)>>2)<<2
 GetRowBytesForMonoImage
29
Example 2
if/else两个分支中有部分重复代码
if(nDestResolution <= nFromSourceResX)
{
FlatTypeCfg.bitsPerPixel=1;
nScaleBitsPerPixel=1;
FlatTypeCfg.composition=scLineArt;
nDestWidth=nScanRight-nScanLeft+1;
nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1;
nSourceRowBytes=GetRowBytesForMonoImage(nSourceWidth);
scImage.rowBytes=nSourceRowBytes;
nDestRowBytes=GetRowBytesForMonoImage(nDestWidth);
}
else
{ // Use scan gray mode to simulate BW
FlatTypeCfg.bitsPerPixel=8;
FlatTypeCfg.composition=scGrayScale;
nScaleBitsPerPixel=1;
nDestWidth=nScanRight-nScanLeft+1;
nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1;
nSourceRowBytes=ConvertToMultipleOfFour(nSourceWidth);
scImage.rowBytes=nSourceRowBytes;
nDestRowBytes=GetRowBytesForMonoImage(nDestWidth);
}
30
Example 2. New codes
nDestWidth=nScanRight-nScanLeft+1;
nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1;
if(nDestResolution <= nFromSourceResX)
{
FlatTypeCfg.bitsPerPixel=1;
FlatTypeCfg.composition=scLineArt;
nSourceRowBytes=GetRowBytesForMonoImage(nSourceWidth);
}
else
{ // Use scan gray mode to simulate BW
FlatTypeCfg.bitsPerPixel=8;
FlatTypeCfg.composition=scGrayScale;
nSourceRowBytes=ConvertToMultipleOfFour(nSourceWidth);
}
nDestRowBytes=GetRowBytesForMonoImage(nDestWidth);
nScaleBitsPerPixel=1;
scImage.rowBytes=nSourceRowBytes;
31
Automation
 Release
 Localization & Wording
 Regression testing
 Coding
32
Release
 Dynamic Languages
 Perl
 Python
 Ruby
33
Regression testing
 Windows:
 Python + Pywinauto
 Mac OS (No full solution)
 AppleScript
 Sikuli
34
Code Generator
 用模具来提高工作效率!
 M4 -> Generate Info.plist
 -> Generate HTML/XML file
 flex -> Parser
35
Reference
36
Authors
Kent Beck Steve McConnell Andrew Hunt Dave Thomas Martin Fowler
37
Resource
38
Who is working for you
 More than 1,441,209 engineers are working for you:
 SourceForge
 Google Code
 Code Project
 Linux Community
39
Accessories
 Unit Test: CPPUnit, Google Test, PyUnit
 Static Code Checking: CPPTest, splint,
 Cyclomatic Complexity counting: cyclo
 LOC counting: Beyond Compare,Cloc in perl
 UML tools:Bouml, ArgoUML
 Drawing tool: yEd
 Mind mapping tool:Freemind
 VNC:TightVNC
 Editor: Notepad++
 Python/Perl Editor: TextWrangler
 Schedule Utility on Linux/Mac OS: Taskjuggler
 Installation utility: Inno Setup
 MD5 Checksum on Windows: WinMD5
 MD5 Checksum on Unix/Linux/Mac OS:md5sum
 Team Work : GForge, FusionForge
 Version Management: Subversion,Git,Bazaar
40
Process and Methodology
41
Process enhances confidence
 Follow the existing process well.
 To reduce development risk.
42
Two critical issues
 DLL building failed
 Customer get corrupted release package
 Side-effect for function parameter with default value
43
Enhance the process with tool
 DLL building failed
 Create one script to check version number for each DLL
 Customer get corrupted release package while testing
 Provides the MD5 Checksum
 Side-effect for function parameter with default value
 Define in coding rule
44
Thought Disorder
45
Conceptual Blockbusting
Reference: 突破思维的障碍
46
Methodology
大M: 公司定义的工作方法
(BMS, VM, CMMI, Agile Dev.)
小m: 个人的工作方法
(SVN, Coding style)
47
Key Problem in Project
 Schedule & Quality
 No enough time to build best deliverables.
 压缩开发时间,必须做好承担风险的准备!
 加班或加人都不是面对风险的最佳途径!
48
Career anchors
49
Career anchors
 充分认识自我,准确地“抛锚”于你钟情的职业,实现人生价值的最大
化。
 我们不得不面对这样一个事实:知识经济时代要求从业者具备终身学
习能力,从业者能力的提高必然带来择业机会的增多,而从者直接导
致从业者在面对职业选择机会时困惑的加剧!职业困惑部分源于外在
因素对个人价值观的影响,更有一部分是因为困惑者对自身需求的不
了解。
50
Eight anchors
 技术/职能型职业锚
 管理型职业锚
 创造/创业型职业锚
 自主/独立型职业锚
 安全/稳定型职业锚
 服务型职业锚
 挑战型职业锚
 生活型职业锚 Edgar H. Schein
51
Your Knowledge Portfolio
 经营你的资产
 定期投资
 多元化是长期成功的关键
 周期性地重新评估和平衡资产
 批判地评判你所看到的和听到的!
52
Study Plan for Programmer
Level 10
Code Complete 2nd Edition, Steve McConnell
Programming Pearls 2nd Edition, Jon Bentley
Refactoring, Martin Fowler
UML Distilled, Martin Fowler
Applying UML & Patterns 2nd Ed, Craig Larman
Testing Computer Software, Cem Kaner et all
Conceptual Blockbusting, James Adams
Software Creativity, Robert Glass
Software Project Survival Guide, Steve McConnell
Level 11
Mastering the Requirements Process, Robertson and Robertson
Software Requirements, Karl Wiegers
"Manager's Handbook for Software Development", NASA Goddard Space Flight Center
Writing Efficient Programs, John Bentley
Writing Solid Code, Steve Maquire
Software Implementation, Michael Marcotty
More Programming Pearls, John Bentley
A Practitioner's Guide to Software Testing Design, Lee Copeland
Rapid Development, Steve McConnell
Level 12
Design Patterns, Erich Gamma et all
Object Oriented Software Construction, Bertrand Meyer
Object Oriented Analysis and Design, Grady Booch
Software Architecture in Practice, Bass et all
"Manager's Handbook for Software Development", NASA Goddard Space Flight Center
"Software Measurement Guidebook", NASA Goddard Space Flight Center
53
Level 10
Rapid Development, Steve McConnell
"Manager's Handbook for Software Development", NASA Goddard Space Flight Center
Mastering the Requirements Process, Robertson and Robertson
Software Requirements, Karl Wiegers
Level 11
Agile and Iterative Development: A Managers Guide, Craig Larman
Balancing Agility with Discipline, Barry Boehm and Richard Turner
Creating a Software Engineering Culture, Karl Wiegers
Peopleware, DeMarco and Lister
A Practitioner's Guide to Software Test Design, Lee Copeland
"Recommended Approach to Software Development, NASA Goddard Space Flight Center
"Software Measurement Guidebook", NASA Goddard Space Flight Center
Level 12
Agile Modeling, Scott Adams
Requirements by Collaboration: Workshops for Defining Needs, Ellen Gottesdiener
Scenarios, Stories, Use Cases, Ian Alexander
Writing Effective Use Cases, Alistair Cockburn
Peer Reviews, Karl Wiegers
The Logic of Failure: Recognizing and Avoiding Error in Complex Situations, Domer Dietrich
Customer Oriented Software Quality Assurance, Frank Ginac
Code Complete 2nd Edition, Steve McConnell
Applying UML & Patterns 2nd Ed, Craig Larman
Study Plan for Manager
54
正當的力量,才是人生的王道!
人生不只是一場戰鬥,更是一趟有夢相隨的旅
程。
為你的夢想追根究柢,一切就從基本功開始!
◎每一個工作,都可以有計畫的幫自己尋找磨練的機會。
◎所有的成就都來自於基本功;而基本功來自於既深且廣
的歷練。
◎從事每一行都需要寬廣的視野,才能出類拔萃。
◎先求有,再求好。
55
THANKS
56

More Related Content

What's hot

Flavours of agile software engineering
Flavours of agile software engineeringFlavours of agile software engineering
Flavours of agile software engineering
Zeeshan Masood S
 
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.
Sanjith Ml
 
Chapter 1 ASE Slides ppt
Chapter 1 ASE Slides pptChapter 1 ASE Slides ppt
Chapter 1 ASE Slides ppt
Mr SMAK
 
Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010
Joseph Yoder
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
AgileSparks
 
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-BrockPragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
Joseph Yoder
 
Shirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defectShirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defect
AgileSparks
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-as
AgileSparks
 

What's hot (20)

Database Refactoring
Database RefactoringDatabase Refactoring
Database Refactoring
 
Flavours of agile software engineering
Flavours of agile software engineeringFlavours of agile software engineering
Flavours of agile software engineering
 
Software testing ari force institute of tech.
Software testing ari force institute of tech.Software testing ari force institute of tech.
Software testing ari force institute of tech.
 
Chapter 1 ASE Slides ppt
Chapter 1 ASE Slides pptChapter 1 ASE Slides ppt
Chapter 1 ASE Slides ppt
 
5 sins of all hands ppt
5 sins of all hands ppt5 sins of all hands ppt
5 sins of all hands ppt
 
Engine Terminology 1
Engine Terminology 1Engine Terminology 1
Engine Terminology 1
 
Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010
 
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
Dynamic Resolution Techniques for Intel® Processor Graphics | SIGGRAPH 2018 T...
 
Naavinya Version 4 1
Naavinya Version 4 1Naavinya Version 4 1
Naavinya Version 4 1
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
 
Exploring MobileXPRT 2015
Exploring MobileXPRT 2015Exploring MobileXPRT 2015
Exploring MobileXPRT 2015
 
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-BrockPragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-Brock
 
The Design Process - FRC
The Design Process - FRCThe Design Process - FRC
The Design Process - FRC
 
Performance and durability comparison: Dell Latitude 14 5000 Series vs. Lenov...
Performance and durability comparison: Dell Latitude 14 5000 Series vs. Lenov...Performance and durability comparison: Dell Latitude 14 5000 Series vs. Lenov...
Performance and durability comparison: Dell Latitude 14 5000 Series vs. Lenov...
 
Shirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defectShirly Ronen - Documenting an agile defect
Shirly Ronen - Documenting an agile defect
 
Chiranjeevi_QA Engg.
Chiranjeevi_QA Engg.Chiranjeevi_QA Engg.
Chiranjeevi_QA Engg.
 
Pragmatic notdogmatictdd
Pragmatic notdogmatictddPragmatic notdogmatictdd
Pragmatic notdogmatictdd
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
Lean agile pt
Lean  agile ptLean  agile pt
Lean agile pt
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-as
 

Viewers also liked

程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
Horky Chen
 
Rm 1 Intro Types Research Process
Rm   1   Intro Types   Research ProcessRm   1   Intro Types   Research Process
Rm 1 Intro Types Research Process
itsvineeth209
 

Viewers also liked (19)

MOST_OpenFoundry_version control system_Git
MOST_OpenFoundry_version control system_GitMOST_OpenFoundry_version control system_Git
MOST_OpenFoundry_version control system_Git
 
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 + 102 for NUU
 
A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer Testing
 
Defencive programming
Defencive programmingDefencive programming
Defencive programming
 
Code tuning techniques
Code tuning techniquesCode tuning techniques
Code tuning techniques
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
 
Variables
VariablesVariables
Variables
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introduction
 
Coding Style
Coding StyleCoding Style
Coding Style
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
 
Integration
IntegrationIntegration
Integration
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Code tuning strategies
Code tuning strategiesCode tuning strategies
Code tuning strategies
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU
 
Code Tuning
Code TuningCode Tuning
Code Tuning
 
Code Complete
Code CompleteCode Complete
Code Complete
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 
Rm 1 Intro Types Research Process
Rm   1   Intro Types   Research ProcessRm   1   Intro Types   Research Process
Rm 1 Intro Types Research Process
 

Similar to 程序员实践之路

miniprojectreport
miniprojectreportminiprojectreport
miniprojectreport
silpa mohan
 
hari_duche_updated
hari_duche_updatedhari_duche_updated
hari_duche_updated
Hari Duche
 
Ecd302 unit 02(evaluate software packages)
Ecd302 unit 02(evaluate software packages)Ecd302 unit 02(evaluate software packages)
Ecd302 unit 02(evaluate software packages)
Xi Qiu
 
Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it
Prakashchand Suthar
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
Enkitec
 

Similar to 程序员实践之路 (20)

Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
Machine programming
Machine programmingMachine programming
Machine programming
 
Making Observability Actionable At Scale - DBS DevConnect 2019
Making Observability Actionable At Scale - DBS DevConnect 2019Making Observability Actionable At Scale - DBS DevConnect 2019
Making Observability Actionable At Scale - DBS DevConnect 2019
 
RAGHUNATH_GORLA_RESUME
RAGHUNATH_GORLA_RESUMERAGHUNATH_GORLA_RESUME
RAGHUNATH_GORLA_RESUME
 
Chega de receita de bolo: gerenciando infraestrutura como código
Chega de receita de bolo: gerenciando infraestrutura como códigoChega de receita de bolo: gerenciando infraestrutura como código
Chega de receita de bolo: gerenciando infraestrutura como código
 
Resume
ResumeResume
Resume
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
 
miniprojectreport
miniprojectreportminiprojectreport
miniprojectreport
 
hari_duche_updated
hari_duche_updatedhari_duche_updated
hari_duche_updated
 
System Benchmarking
System BenchmarkingSystem Benchmarking
System Benchmarking
 
Ecd302 unit 02(evaluate software packages)
Ecd302 unit 02(evaluate software packages)Ecd302 unit 02(evaluate software packages)
Ecd302 unit 02(evaluate software packages)
 
Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it
 
Ci tips and_tricks_linards_liepins
Ci tips and_tricks_linards_liepinsCi tips and_tricks_linards_liepins
Ci tips and_tricks_linards_liepins
 
Resume
ResumeResume
Resume
 
Periodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and PracticesPeriodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and Practices
 
Recover 30% of your day with IBM Development Tools (Smarter Mainframe Develop...
Recover 30% of your day with IBM Development Tools (Smarter Mainframe Develop...Recover 30% of your day with IBM Development Tools (Smarter Mainframe Develop...
Recover 30% of your day with IBM Development Tools (Smarter Mainframe Develop...
 
Agile Secure Development
Agile Secure DevelopmentAgile Secure Development
Agile Secure Development
 
Reverse code engineering
Reverse code engineeringReverse code engineering
Reverse code engineering
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
 

More from Horky Chen (7)

编程语言与自然语言
编程语言与自然语言编程语言与自然语言
编程语言与自然语言
 
Tow points of WebKit in design
Tow points of WebKit in designTow points of WebKit in design
Tow points of WebKit in design
 
第五项修炼 (学习型组织的艺术与实践)
第五项修炼 (学习型组织的艺术与实践)第五项修炼 (学习型组织的艺术与实践)
第五项修炼 (学习型组织的艺术与实践)
 
注重实效的编程(3)
注重实效的编程(3)注重实效的编程(3)
注重实效的编程(3)
 
注重实效的编程(2)
注重实效的编程(2)注重实效的编程(2)
注重实效的编程(2)
 
注重实效的编程(1)
注重实效的编程(1)注重实效的编程(1)
注重实效的编程(1)
 
JavaScript closures
JavaScript closuresJavaScript closures
JavaScript closures
 

Recently uploaded

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

程序员实践之路

  • 3. Agenda  Pragmatic Programmer  Estimating (提升专业素养)  DRY rule - Repeat or Reuse (提炼经验)  Control Structures & Complexity (简洁就是美)  Table Driven (善于运用算法)  Design for CHANGE (完善设计、争取主动)  Refactoring (追求卓越,勇于改进)  Automation (一切都要自动化)  Resource  Who is working for you (找个巨人的肩膀)  Accessories for you  Process and Methods  Process enhances confidence  Thought Disorder(最容易欺骗的人是自己)  Conceptual Blockbusting  Career anchors  How to define the VALUE (价值不等式)  Professionalism  Q&A 3
  • 5. Estimating (估算)  估算是专业能力的综合表现。  难点  需求分析  行政干预  精确度  PI  美国的议员曾提案要求将PI值定为3。  而NASA将需要12个小数位。  建议估算时间以周为单位。 5
  • 6.  估算是专业能力的体现!  新的系统  建立系统架构模型  分解为组件  设计组件的功能  依功能对各个组件进行估算  展开及细化  汇总  修改的系统  识别需要变更的组件  定义需变更的组件内容  依据变更的内容进行逐项估算  汇总  追踪估算,逐步修正误差!  Reference:  http://www.cnblogs.com/badwps/archive/2009/08/ 28/1555485.html Estimating (估算) 6
  • 7. DRY rule - Repeat or Reuse  开发者利器  Google & Baidu  Sourceforge & CodeProject  Ctrl+C & Ctrl+V  复用不是重复使用,而是如何重复使用!  思考:  物以稀为贵,越容易得到的也就越容易失去!  在如此开放的网络环境下,我们的知识还有多少价值?  面对变化时,维护成本变大且风险很高  知识是不稳定的!唯一不变的就是变化!  BUG可能隐藏在仸何位置,那是噩梦的开始!  对个人知识积累不利  常常消化不良 7
  • 8. Category and Count measure  类型:  无意的重复  无耐性的重复  对策  Simplify design  Cleaning Code  Coding Rule  Coding Review  Reference:  Refactoring: Improving the Design of existing code 8
  • 9. Control Structure  Need a loop that executes a specified number of times  To use a for loop  If change the index value of a for loop force it to terminate, use a while loop instead.  Else to use a while loop.  Reference:  Write Solid Code, Maguire, 1993 9
  • 10. Controlling the loop  Major principles  简化循环体相关连的因素(所引用的变量或数据),判 断或结束条件一定要简单。  循环也是另类的子程序,可以视其为Black box.  Entering the Loop  Put initialization code directly before the loop  Use while ( true ) for infinite loops  Don’t use a for loop when a while loop is more appropriate 10
  • 11. Sample Control statements vs. housekeeping statements 11
  • 12. Processing the middle of the loop  Use { and } to enclose the statements in a loop  Avoid empty loops  Keep loop-housekeeping chores at either the beginning or the end of the loop  Make each loop perform only one function  可以做,但不代表应该做。正确的代码不代表是好的代码! 12
  • 13. Exiting the loop  Existing loops early  According to an article in Software Engineering Notes, the software error that 7 brought down the New York City phone systems for 9 hours on January 15, 8 1990 was due to an extra break statement (SEN 1990) break的分散代表逻辑上的分散,会带来维护上的风险!大量的return出现在函数 体,多个深层嵌套,变量中途转为它用,多处理重复功能相近的代码,都预示者 开发者的逻辑可能已经出现问题! 13
  • 14. Checking endpoints  Willingness to perform this kind of check is a key difference between efficient and inefficient programmers.  How to check  Hand calculations  Mental simulations  Calculate by Excel  What are benefits?  You understand how your code works rather than guessing about it! 14
  • 15. How long should a loop be  Make your loops short enough to view all at once.  Limit nesting to three levels  Move loop innards of long loops into routines  Make long loops especially clear.  Single exit. 15
  • 16. Creating loop easily  From the inside out 16
  • 17. Control Structure and Complexity  The control flow is at least one of the largest contributors to complexity, if not the largest.  HP apply McCabe’s complexity metric, that is helpful to improve coding quality.  General guideline for reducing complexity  Improve your own mental juggling abilities  You can decrease the complexity of your programs and the amount of concentration required to understand them. 17
  • 18. How to measure complexity  Techniques for counting the decision points in a routine  Start with 1 for the straight pat through the routine  Add 1 for each of the following keywords, or their equivalents: if while repeat for and or  Add 1 for each case in a case statement  Exercise  if ( ( (status = Success ) and done) or ( not done and ( numLines >= maxLines ) ) ) then … *Cyclomatic Complexity 18
  • 19. Table Driven  Advantage:  Simplify codes and enhance the performance  Enhance the system customization capability.  Weakness:  Not everyone know it well, it may bring extra efforts.  Virtually anything you can select with logic statements, you can select with tables instead. 19
  • 22. Example static unsigned int chooseDPI(unsigned int original_dpi, int datatype) { int i, d, diff, k; static Support_Mode support_mode[] = { {4, 0}, //support two modes {150, 2}, {300, 3}, //300DPI with color and gray {600, 3}, //600DPI with color and gray {1200, 2} }; diff = -1; k = 1; for (i = 1; i <= support_mode[0].dpi; ++i) { if (support_mode[i].support_mode & datatype) { d = abs(support_mode[i].dpi - original_dpi); if (diff == -1) { diff = d; k = i; } else { if (d <= diff) { diff = d; k = i; } else break; } } } return support_mode[k].dpi; } 22
  • 23. Design for Change • 应对变化: – 解耦:得墨忒尔法则 – 元数据与动态配置 – 并发与次序 – 划分模块、分而治之 23
  • 24. The law of Demeter  某个对象的任何方法都应该只能调用:  它自身  传入该方法的任何参数  它创建的任何对象  任何直接持有的组件对象 24
  • 25. Meta data and Dynamic Configuration  将变化封装起来,使用元数据进行配置。  什么是变化的?  什么是不变化的?  抽象、抽象  Example:  Linux – Build your own Linux distribution 25
  • 26. 并发与时序  时间耦合(temporal coupling)  定义好你的工作流  用服务为并发进行设计 26
  • 29. Example 1  分析switch(nBits)  以下两种为常用运算 +3)>>2)<<2  ConvertToMultipleOfFour +7)>>3)+3)>>2)<<2  GetRowBytesForMonoImage 29
  • 30. Example 2 if/else两个分支中有部分重复代码 if(nDestResolution <= nFromSourceResX) { FlatTypeCfg.bitsPerPixel=1; nScaleBitsPerPixel=1; FlatTypeCfg.composition=scLineArt; nDestWidth=nScanRight-nScanLeft+1; nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1; nSourceRowBytes=GetRowBytesForMonoImage(nSourceWidth); scImage.rowBytes=nSourceRowBytes; nDestRowBytes=GetRowBytesForMonoImage(nDestWidth); } else { // Use scan gray mode to simulate BW FlatTypeCfg.bitsPerPixel=8; FlatTypeCfg.composition=scGrayScale; nScaleBitsPerPixel=1; nDestWidth=nScanRight-nScanLeft+1; nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1; nSourceRowBytes=ConvertToMultipleOfFour(nSourceWidth); scImage.rowBytes=nSourceRowBytes; nDestRowBytes=GetRowBytesForMonoImage(nDestWidth); } 30
  • 31. Example 2. New codes nDestWidth=nScanRight-nScanLeft+1; nSourceWidth=FlatTypeCfg.bounds.right-FlatTypeCfg.bounds.left+1; if(nDestResolution <= nFromSourceResX) { FlatTypeCfg.bitsPerPixel=1; FlatTypeCfg.composition=scLineArt; nSourceRowBytes=GetRowBytesForMonoImage(nSourceWidth); } else { // Use scan gray mode to simulate BW FlatTypeCfg.bitsPerPixel=8; FlatTypeCfg.composition=scGrayScale; nSourceRowBytes=ConvertToMultipleOfFour(nSourceWidth); } nDestRowBytes=GetRowBytesForMonoImage(nDestWidth); nScaleBitsPerPixel=1; scImage.rowBytes=nSourceRowBytes; 31
  • 32. Automation  Release  Localization & Wording  Regression testing  Coding 32
  • 33. Release  Dynamic Languages  Perl  Python  Ruby 33
  • 34. Regression testing  Windows:  Python + Pywinauto  Mac OS (No full solution)  AppleScript  Sikuli 34
  • 35. Code Generator  用模具来提高工作效率!  M4 -> Generate Info.plist  -> Generate HTML/XML file  flex -> Parser 35
  • 37. Authors Kent Beck Steve McConnell Andrew Hunt Dave Thomas Martin Fowler 37
  • 39. Who is working for you  More than 1,441,209 engineers are working for you:  SourceForge  Google Code  Code Project  Linux Community 39
  • 40. Accessories  Unit Test: CPPUnit, Google Test, PyUnit  Static Code Checking: CPPTest, splint,  Cyclomatic Complexity counting: cyclo  LOC counting: Beyond Compare,Cloc in perl  UML tools:Bouml, ArgoUML  Drawing tool: yEd  Mind mapping tool:Freemind  VNC:TightVNC  Editor: Notepad++  Python/Perl Editor: TextWrangler  Schedule Utility on Linux/Mac OS: Taskjuggler  Installation utility: Inno Setup  MD5 Checksum on Windows: WinMD5  MD5 Checksum on Unix/Linux/Mac OS:md5sum  Team Work : GForge, FusionForge  Version Management: Subversion,Git,Bazaar 40
  • 42. Process enhances confidence  Follow the existing process well.  To reduce development risk. 42
  • 43. Two critical issues  DLL building failed  Customer get corrupted release package  Side-effect for function parameter with default value 43
  • 44. Enhance the process with tool  DLL building failed  Create one script to check version number for each DLL  Customer get corrupted release package while testing  Provides the MD5 Checksum  Side-effect for function parameter with default value  Define in coding rule 44
  • 47. Methodology 大M: 公司定义的工作方法 (BMS, VM, CMMI, Agile Dev.) 小m: 个人的工作方法 (SVN, Coding style) 47
  • 48. Key Problem in Project  Schedule & Quality  No enough time to build best deliverables.  压缩开发时间,必须做好承担风险的准备!  加班或加人都不是面对风险的最佳途径! 48
  • 50. Career anchors  充分认识自我,准确地“抛锚”于你钟情的职业,实现人生价值的最大 化。  我们不得不面对这样一个事实:知识经济时代要求从业者具备终身学 习能力,从业者能力的提高必然带来择业机会的增多,而从者直接导 致从业者在面对职业选择机会时困惑的加剧!职业困惑部分源于外在 因素对个人价值观的影响,更有一部分是因为困惑者对自身需求的不 了解。 50
  • 51. Eight anchors  技术/职能型职业锚  管理型职业锚  创造/创业型职业锚  自主/独立型职业锚  安全/稳定型职业锚  服务型职业锚  挑战型职业锚  生活型职业锚 Edgar H. Schein 51
  • 52. Your Knowledge Portfolio  经营你的资产  定期投资  多元化是长期成功的关键  周期性地重新评估和平衡资产  批判地评判你所看到的和听到的! 52
  • 53. Study Plan for Programmer Level 10 Code Complete 2nd Edition, Steve McConnell Programming Pearls 2nd Edition, Jon Bentley Refactoring, Martin Fowler UML Distilled, Martin Fowler Applying UML & Patterns 2nd Ed, Craig Larman Testing Computer Software, Cem Kaner et all Conceptual Blockbusting, James Adams Software Creativity, Robert Glass Software Project Survival Guide, Steve McConnell Level 11 Mastering the Requirements Process, Robertson and Robertson Software Requirements, Karl Wiegers "Manager's Handbook for Software Development", NASA Goddard Space Flight Center Writing Efficient Programs, John Bentley Writing Solid Code, Steve Maquire Software Implementation, Michael Marcotty More Programming Pearls, John Bentley A Practitioner's Guide to Software Testing Design, Lee Copeland Rapid Development, Steve McConnell Level 12 Design Patterns, Erich Gamma et all Object Oriented Software Construction, Bertrand Meyer Object Oriented Analysis and Design, Grady Booch Software Architecture in Practice, Bass et all "Manager's Handbook for Software Development", NASA Goddard Space Flight Center "Software Measurement Guidebook", NASA Goddard Space Flight Center 53
  • 54. Level 10 Rapid Development, Steve McConnell "Manager's Handbook for Software Development", NASA Goddard Space Flight Center Mastering the Requirements Process, Robertson and Robertson Software Requirements, Karl Wiegers Level 11 Agile and Iterative Development: A Managers Guide, Craig Larman Balancing Agility with Discipline, Barry Boehm and Richard Turner Creating a Software Engineering Culture, Karl Wiegers Peopleware, DeMarco and Lister A Practitioner's Guide to Software Test Design, Lee Copeland "Recommended Approach to Software Development, NASA Goddard Space Flight Center "Software Measurement Guidebook", NASA Goddard Space Flight Center Level 12 Agile Modeling, Scott Adams Requirements by Collaboration: Workshops for Defining Needs, Ellen Gottesdiener Scenarios, Stories, Use Cases, Ian Alexander Writing Effective Use Cases, Alistair Cockburn Peer Reviews, Karl Wiegers The Logic of Failure: Recognizing and Avoiding Error in Complex Situations, Domer Dietrich Customer Oriented Software Quality Assurance, Frank Ginac Code Complete 2nd Edition, Steve McConnell Applying UML & Patterns 2nd Ed, Craig Larman Study Plan for Manager 54