an introduction to computer programming

55
An Introduction to An Introduction to Computer Programming Computer Programming 童 童 童 E-mail: [email protected] 中中中中中中中中 中中中 http://math.ustc.edu.cn/ A tutor on coding A tutor on coding , , Sep 9 Sep 9 , 20 , 20 11 11

Upload: monita

Post on 13-Jan-2016

96 views

Category:

Documents


0 download

DESCRIPTION

A tutor on coding , Sep 9 , 20 11. An Introduction to Computer Programming. 童 伟 华 E-mail: [email protected]. 中国科学技术大学 数学系 http://math.ustc.edu.cn/. 内容提纲. 编程概要 编程模型 编程语言 编程环境 软件库介绍 编程进阶. 编程概要. 什么是编程? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: An Introduction to  Computer Programming

An Introduction to An Introduction to Computer ProgrammingComputer Programming

童 伟 华 E-mail: [email protected]

中国科学技术大学 数学系http://math.ustc.edu.cn/

A tutor on codingA tutor on coding, , Sep 9Sep 9, 20, 201111

Page 2: An Introduction to  Computer Programming

2A tutor on coding , Sep 9, 2011

内容提纲内容提纲 编程概要 编程模型 编程语言 编程环境 软件库介绍 编程进阶

Page 3: An Introduction to  Computer Programming

3A tutor on coding , Sep 9, 2011

编程概要编程概要 什么是编程?

From Wikipedia : Computer programming (often shortened to programming or coding) is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language. The code may be a modification of an existing source or something completely new. The purpose of programming is to create a program that exhibits a certain desired behaviour (customization). The process of writing source code often requires expertise in many different subjects, including knowledge of the application domain, specialized algorithms and formal logic.

编程:编写,测试,调试,维护 核心:应用领域知识+算法+数据结构

Page 4: An Introduction to  Computer Programming

4A tutor on coding , Sep 9, 2011

编程概要编程概要 历史简述

编程的概念出现: The concept of devices that operate following a pre-defined set of instructions traces back to Greek Mythology, notably Hephaestus and his mechanical servants. The Antikythera mechanism was a calculator utilizing gears of various sizes and configuration to determine its operation.

可编程机械出现: 1206 年,伊斯兰数学家 Al-Jazari's programmable Automata

现代计算机逻辑模型的发明: 1936 年, Alan Turing 在伦敦数学进展中发表题为“ On Computable Numbers, with an Application to the Entscheidungsproblem ”,提出通用图灵机的概念(计算机的逻辑模型), 1944 年, Von Neumann 在美国 Los Alamos National Laboratory 的 Manhattan Project 中提出该体系结构,后被ENIAC project 使用

Page 5: An Introduction to  Computer Programming

5A tutor on coding , Sep 9, 2011

编程概要编程概要 图灵机 (Turing machine)

Logical Computing Machine : an infinite memory capacity obtained in the form of an infinite tape marked out into squares on each of which a symbol could be printed. At any moment there is one symbol in the machine; it is called the scanned symbol. The machine can alter the scanned symbol and its behavior is in part determined by that symbol, but the symbols on the tape elsewhere do not affect the behavior of the machine. However, the tape can be moved back and forth through the machine, this being one of the elementary operations of the machine. Any symbol on the tape may therefore eventually have an innings

Page 6: An Introduction to  Computer Programming

6A tutor on coding , Sep 9, 2011

编程概要编程概要 图灵机

Page 7: An Introduction to  Computer Programming

7A tutor on coding , Sep 9, 2011

编程概要编程概要 图灵机

真实的计算机:图灵机的实现 (the random access stored program machine)

Page 8: An Introduction to  Computer Programming

8A tutor on coding , Sep 9, 2011

编程概要编程概要 Von Neumann 结构

is a design model for a stored-program digital computer that uses a processing unit and a single separate storage structure to hold both instructions and data. It is named after the mathematician and early computer scientist John von Neumann. Such computers implement a universal Turing machine and have a sequential architecture.

Page 9: An Introduction to  Computer Programming

9A tutor on coding , Sep 9, 2011

编程概要编程概要 Personal computer 的组成(包括 IBM-PC,

Notebook or Laptop, Tablet PC, Pocket PC 等 ) CPU :中央处理器 Motherboard :主板 Main memory :内存 Hard disk :硬盘 Video card :视频卡 辅助设备:网卡、声卡等(现在一般集成在主板上) 输入设备:键盘,鼠标等 输出设备:显示器,音响等

Page 10: An Introduction to  Computer Programming

10A tutor on coding , Sep 9, 2011

编程概要编程概要GPU 编程

Graphics processing unit: is a specialized processor that offloads 3D graphics rendering from the microprocessor

Modern GPUs are very efficient at manipulating computer graphics, and their highly parallel structure makes them more effective than general-purpose CPUs for a range of complex algorithms

特点: Stream processing ( SIMD or MIMD ,单指令多数据 或多指令多数

据),适合并行计算模型 具有强大的浮点运算能力,尤其适合数值并行计算 具有独立的内存资源+高速的总线 编程语言: CUDA (“Compute Unified Device Architecture”), NVidia

公司 行业标准: OpenCL ( GPU 通用计算的统一 标准)

Page 11: An Introduction to  Computer Programming

11A tutor on coding , Sep 9, 2011

编程模型编程模型 Kernighan and Ritchie: C Programming language

ASCII code ( text characters)

Page 12: An Introduction to  Computer Programming

12A tutor on coding , Sep 9, 2011

编程模型编程模型 代码编译

为什么需要了解编译系统 代码优化:例如 switch 语句是否总是比 if-then-else 有效?函数调用的

代价是多高? While 循环是否总比 do 循环有效?等等问题,涉及编译器,机器语言

理解链接错误信息: link-time errors ,例如静态库与动态库的区别?库的次序对链接的影响?

避免安全漏洞:例如缓冲区溢出,堆、栈的管理,参数传递及返回等

Page 13: An Introduction to  Computer Programming

13A tutor on coding , Sep 9, 2011

编程模型编程模型 程序的执行

Page 14: An Introduction to  Computer Programming

14A tutor on coding , Sep 9, 2011

编程模型编程模型 程序的执行

Page 15: An Introduction to  Computer Programming

15A tutor on coding , Sep 9, 2011

编程模型编程模型 程序的执行

Page 16: An Introduction to  Computer Programming

16A tutor on coding , Sep 9, 2011

编程模型编程模型CPU 的 Caches

L1 caches: as fast as the register fileL2 caches: 5 times longer than L1

caches, but faster than 5-10 times than accessing the main memory

Page 17: An Introduction to  Computer Programming

17A tutor on coding , Sep 9, 2011

编程模型编程模型 内存的层次结构

Page 18: An Introduction to  Computer Programming

18A tutor on coding , Sep 9, 2011

编程模型编程模型 操作系统:管理硬件

Page 19: An Introduction to  Computer Programming

19A tutor on coding , Sep 9, 2011

编程模型编程模型 Process: A process is the operating system’s

abstraction for a running program Context switching: The operating system

performs this interleaving with a mechanism known as context switching

多进程操作系统: Windows XP/Vista 等, Unix/Lunix, OS2 等

Page 20: An Introduction to  Computer Programming

20A tutor on coding , Sep 9, 2011

编程模型编程模型 Thread: a process can actually consist of multiple

execution units, called threads, each running in the context of the process and sharing the same code and global data

Virtual Memory: Virtual memory is an abstraction that provides each process with the illusion that it has exclusive use of the main memory. Each process has the same uniform view of memory, which is known as its virtual address space Program code and data Heap Shared libraries Stack Kernel virtual memory

Page 21: An Introduction to  Computer Programming

21A tutor on coding , Sep 9, 2011

编程模型编程模型 虚拟内存空间

Page 22: An Introduction to  Computer Programming

22A tutor on coding , Sep 9, 2011

编程模型编程模型 网络编程

网络模型: ISO 七层模型, TCP/IP 四层模型等 网络协议:例如 TCP/IP 协议 编程模型:例如 Server/Client, P2P 等 套接口: TCP/IP Sockets, Windows Sockets 等

分布式计算 并行程序设计

MPI OpenMP

Page 23: An Introduction to  Computer Programming

23A tutor on coding , Sep 9, 2011

编程模型编程模型 信息的表示

输出的结果是什么?

Page 24: An Introduction to  Computer Programming

24A tutor on coding , Sep 9, 2011

编程模型编程模型 整数在计算机中的表示

Char : 1 Bytes Short int: 2 Bytes Int: 4 Bytes Long int: 4 Bytes

多字节数据的顺序 0x01234567

Page 25: An Introduction to  Computer Programming

25A tutor on coding , Sep 9, 2011

编程模型编程模型 如何处理负号?

Two’s Complement Encodings

Page 26: An Introduction to  Computer Programming

26A tutor on coding , Sep 9, 2011

编程模型编程模型 实数在计算机中的表示

Float: 4 Bytes Double: 4 Bytes

国际标准: IEEE Standard 754 非精确表示 舍入误差(不满足结合律)

Page 27: An Introduction to  Computer Programming

27A tutor on coding , Sep 9, 2011

编程语言编程语言 什么是编程语言?

From Wikipedia : A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human communication.

编程语言分类 目前大概有 2500 多种编程语言 按演化情况(第一代、第二代…第五代) 按实际用途(系统编程语言、网络编程语言、数据库语言等等) 按语言层次(机器语言,汇编语言,高级语言 ) 按执行情况(编译型、解释型、虚拟机)

Page 28: An Introduction to  Computer Programming

28A tutor on coding , Sep 9, 2011

编程语言编程语言TIOBE 世界编程语言排行榜( 2009 年 8 月)

Page 29: An Introduction to  Computer Programming

29A tutor on coding , Sep 9, 2011

编程语言编程语言 系统编程语言

C C++ 汇编语言

网络编程语言 Java C# XML/AJAX /PHP/PERL/Javascript/ Ruby Python

数据库编程语言 SQL (国际标准)

人工智能编程语言 Lisp Prolog

Page 30: An Introduction to  Computer Programming

30A tutor on coding , Sep 9, 2011

编程语言编程语言 脚本编程语言

通常为解释执行,有专门的解释器 Unix/Linux shell: bsh/csh 等 其他如 PHP/PERL/RUBY/PYTHON 等( 通用动态语言 )

文本处理编程语言 Tex/Latex 等

科学计算编程语言 Fortran Matlab

符号计算编程语言 Maple Mathematica

Page 31: An Introduction to  Computer Programming

31A tutor on coding , Sep 9, 2011

编程语言编程语言 计算机图形学、辅助几何设计、几何建模等编程

推荐语言: C/C++ (原因:效率+通用性+可移值性 + 软件库)或者Java

推荐平台: windows 操作系统(原因:广泛性+图形硬件的支持)或者 Xwindows ( Unix/Linux 系统的图形操作界面,缺点:图形硬件的支持不够)

图形接口: OpenGL 或 DirectX 3D 数值线性代数软件库: CLAPACK , LASPACK , TACUS 等 计 算几何软 件 库 : CGAL , Wild Magic , OpenMesh , Open

Geometry 等 通用数值算法库: Numerical Recipes in C/C++ 可视化软件库: VTK , Tecplot 等 真实感渲染软件: PovRay , BMRT , PBRT 等

Page 32: An Introduction to  Computer Programming

32A tutor on coding , Sep 9, 2011

编程语言编程语言 重点学习 C/C++ C 语言推荐书籍

《 The C Programming language》, Brian W.Kernighan,Dennis M.Ritchie ,机械工业出版社(有中译本)

《 C 程序设计》,谭浩强,清华大学出版社C++ 语言推荐书籍

《 The C++ programming language》, Bjarne Stroustrup ,高等教育出版社 (有中译本)

《 Thinking in C++》, Bruce Eckel , Chuck Alison ,机械工业出版社(有中译本)

《 C++ Primmer》, Stanley B. Lippman , Josee Lajoie, Barbara E. Moo ,人民邮电出版社(有中译本)

Page 33: An Introduction to  Computer Programming

33A tutor on coding , Sep 9, 2011

编程语言编程语言 C++ 语言推荐书籍

《 The Design and Evolution of C++》, Bjarne Stroustrup ,机械工业出版社(有中译本)

《 Effective C++ 》 , Scott Meyers ,电子工业出版社 (有中译本) 《 More Effective C++ 》 , Scott Meyers ,电子工业出版社 (有中译本) 《 Inside the C++ Object Model》, Stanley B. Lippman ,中国电力出版社(有中译本)

STL 编程推荐书籍 《 The C++ Standard Library: A Tutorial and Reference 》 , Nicolai M.

Josuttis ,华中科技大学出版社(有中译本) 《 Effective STL》, Scott Meyers , 机械工业出版社(有中译本) 《 STL 源码剖析》,侯捷 ,华中科技大学出版社 《 The C++ Standard Template Library 》, P.J. Plauger, Alexander

Stepanov, Meng Lee , David R. Musser, Pearson Eduction Press 《 Generic Programming and the STL: Using and Extending the C++

Standard Template Library》, Matthew H. Austern ,中国电力出版社 (有中译本)

Page 34: An Introduction to  Computer Programming

34A tutor on coding , Sep 9, 2011

编程语言编程语言 Java 语言推荐书籍

《 Core Java , Volume I--Fundamentals 》, Cay S. Horstmann , Gary Cornell ,机械工业出版社 (有中译本)

《 Core Java , Volume II – Advanced Features 》, Cay S. Horstmann , Gary Cornell ,机械工业出版社 (有中译本)

《 Thinking in Java》, Bruce Eckel ,机械工业出版社(有中译本)

Java 图形推荐书籍 《 Computer Graphics Using Java 2D and 3D 》, Y. Daniel

Liang , Hong Zhang ,机械工业出版社(有中译本) 《 Foundations of 3D Graphics Programming: Using JOGL and

Java3D》, Jim X. Chen, Chunyang Chen, Springer

Page 35: An Introduction to  Computer Programming

35A tutor on coding , Sep 9, 2011

编程环境编程环境 硬件部分

CPU 指令: Intel 和 AMD 的 X86 指令集( CISC 指令集), IBM Power 系列的 Power 指令集( RISC 指令集)等

系统架构: X86架构, IA 和 IA-64架构, Power架构等 软件部分

编译器 链接器 调试器 系统调用 API 基础类库: windows下的 MFC , Linux下的 QT 等 集成开发环境: Microsoft 的 Visual Studio 系列, Linux下的

kdevelop 或 GTK+GONME + glade + vim 等

Page 36: An Introduction to  Computer Programming

36A tutor on coding , Sep 9, 2011

编程环境编程环境Microsoft 的 Visual Studio 系列

Visual Studio 6.0 :经典版本 Visual Studio 2003 Visual Studio 2005 Visual Studio 2008 :最新版本

Visual Studio Workspace :工程项目的容器 Project :包括源代码、资源文件、编译器选项、子工程等 Project类型:譬如 Win32 Console Application , Win32

Application , Win32 Static Library , Win32 Dynamic Link Library 等(对于不同工程类型, visual studio生成不同的文件,配置缺省的编译选项)

Page 37: An Introduction to  Computer Programming

37A tutor on coding , Sep 9, 2011

编程环境编程环境OpenGL 示例

创建工程文件 编辑源代码 设置编译选项 编译 调试 运行

Page 38: An Introduction to  Computer Programming

38A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍 图形编程接口

通用平台的三维图形编程接口: OpenGL ,适用于Microsoft Windows 系列操作系统, Unix/Linux 操作系统。优点:硬件加速,跨平台,开放的工业标准。最新版本:OpenGL 4.2 + OpenGL Shading Language 4.1

Microsoft Windows 平台: DirectGraphics (DirectDraw + Direct3D) ,优点:硬件加速,功能更新快。最新版本: DirectX 11.0 ,包括 HLSL (High Level Shading Language) 5.0 ,主流版本: DirectX 9.0

Page 39: An Introduction to  Computer Programming

39A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍OpenGL 编程书籍推荐:

《 OpenGL Programming Guide: The Official Guide to Learning OpenGL Version 4.1 》( 8th ), OpenGL Architecture Review Board , Dave Shreiner , Mason Woo , Jackie Neider , Tom Davis , Addison-Wesley Professional Press (经典书籍,俗称红宝书,学习 OpenGL必读)

《 OpenGL Shading Language 》 (3rd) , Randi J. Rost , Bill Licea-Kane Dan Ginsburg , John M. Kessenich , Barthold Lichtenbelt , Hugh Malan , Mike Weiblen , Addison-Wesley Professional Press (经典书籍,俗称橙宝书)

《 OpenGL SuperBible: Comprehensive Tutorial and Reference 》( 5th ), Richard S. Wright , Benjamin Lipchak , Nicholas Haemel , Addison-Wesley Professional Press

http://www.opengl.org/ 内有非常不错的资源

Page 40: An Introduction to  Computer Programming

40A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍DirectX 编程书籍推荐:

《 Inside Directx (Microsoft Programming Series) 》, Bradley Bargen , Terence Peter Donnelly , Microsoft Press

《 Inside Direct3D》, Peter J. Kovach , Microsoft Press 《 DirectX9 Programmable Graphics Pipeline》, Kris

Gray , Microsoft Press 《 DirectX 3D Graphics Programming Bible》, Julio Sanchez ,

Maria P. Canton , IDG Books Worldwide Inc Press

Page 41: An Introduction to  Computer Programming

41A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍 数值线性代数软件库

书籍推荐:《 Matrix Computations 》 , Gene H. Golub, Charles F. van Loan , The Johns Kopkins University Press

一般线性方组求解: CLAPACK 稀疏线性方程组求解: LASPACK , TACUS 等 注意:一定要根据所求解线性方程组的特点,选取合适的求解方法!

Page 42: An Introduction to  Computer Programming

42A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍 计算几何软件库

需要熟悉计算几何的基本算法、数据结构 推荐书籍:

《 Computational Geometry 》 (3rd), Mark de Berg, Marc van Kreveld, Mark Overmars, Otfried Schwarzkopf, Springer Press.

《 Computational Geometric in C 》 (2ed), Joseph O’Rourke, Cambridge University Press.

CGAL :包含计算几何中各种基本算法及数据结构的通用库。优点:2D 和 3D都有,功能全面,采用泛型编程,通用性较好,开源代码,功能更新快。缺点:库很大,初学者不易掌握

Wild Magic :三维实时游戏引擎,包括图形编程中各种基本算法及数据结构的通用库。优点:功能全面,引擎系统,开源代码 《 Geometric Tools for Computer Graphics》, Philip J. Schneider ,

David Eberly , Elsevier Science Inc Press.  OpenMesh :多边形网格库,主要针对网格表示、存储、操作等。优

点:采用泛型编程,针对网格表示特点优化,性能较高 Open Geometry :建立在 OpenGL 库基础上的几何造型高级库

Page 43: An Introduction to  Computer Programming

43A tutor on coding , Sep 9, 2011

软件库介绍软件库介绍 通用数值算法库

数值积分、随机数生成、快数傅立叶变换、最优化算法等 推 荐 书 籍 : 《 Numerical Recipes: The Art of Scientific

Computing 》 (3rd) , William H. Press , Saul A. Teukolsky , William T. Vetterling , Brian P. Flannery

可视化软件库 体绘制、标量场 /向量场可视化、网格处理、图像处理等 推 荐 书 籍 : 《 The Visualization Toolkit An Object-Oriented

Approach To 3D Graphics 》 (4th), Will Schroeder, Ken Martin, Bill Lorensen

数据可视化软件: Tecplot

真实感渲染软件 光线跟踪+辐射度+折射 /反射+过程纹理 +photo mapping 等 推荐软件: PovRay , BMRT , PBRT 等

Page 44: An Introduction to  Computer Programming

44A tutor on coding , Sep 9, 2011

编程进阶编程进阶 如何提高编程水平

勤加练习,学会思考 要看一些有一定深度的书籍(切勿看垃圾书籍!)

提高编程水平的突破点 数据结构与算法 设计模式 编程环境 编程规范 代码调试 代码阅读 软件工程

Page 45: An Introduction to  Computer Programming

45A tutor on coding , Sep 9, 2011

编程进阶编程进阶 数据结构与算法

掌握基本数据结构,譬如堆、栈、队列、树、 Hash 表等;基本算法,譬如排序、查找等

推荐书籍 : 《 The Art of Computer Programming 》 (Volumes 1-3) , Donald

E.Knuth , Pearson Education Inc Press 《 Introduction to Algorithms》( 3rd) , Thomas H. Cormen,

Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein , The MIT Press

Page 46: An Introduction to  Computer Programming

46A tutor on coding , Sep 9, 2011

编程进阶编程进阶 设计模式

在生活和工作当中,不断地重复一些事物和事情的方法,可以看作是一种设计模式

Christopher Alexander : "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice"

如何设计可复用的面向对象软件?必须要找到相关的对象,以适当的粒度将它们归类,再定义类的接口和继承层次,建立对象之间的基本关系。你的设计应该对手头的问题有针对性,同时对将来的问题和需求也要有足够的通用性。每一个设计模式系统的命名、解释和评价了面向对象系统中一个重要的和重复出现的设计。设计模式使人们可以更加简单方便的复用成功的设计和体系结构。

每一个模式描述了一个在我们周围不断重复发生的问题,以及该问题的解决方案的核心。这样你就可以一次又一次的使用该解决方案而不做重复性的劳动。

Page 47: An Introduction to  Computer Programming

47A tutor on coding , Sep 9, 2011

编程进阶编程进阶 基本要素

The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two.

The problem describes when to apply the pattern The solution describes the elements that make up the design,

their relationships, responsibilities, and collaborations The consequences are the results and trade-offs of applying the

pattern

模式分类 按照模式的目的性准则,模式可以分为创建型模式、结构型模式和行为型模式。创建型模式与对象的创建有关;结构型模式处理类和对象的组合;行为型模式对类和对象怎样交互和怎样分配职责进行描述

按照模式的范围准则,模式可以分为类模式和对象模式。类模式处理类和子类的关系,这些关系通过继承建立,是静态的,在编译时就确定下来。对象模式是处理对象之间的关系,这些关系在运行时刻是可以变化的,更具动态性

Page 48: An Introduction to  Computer Programming

48A tutor on coding , Sep 9, 2011

编程进阶编程进阶 设计模式与框架

面向对象软件系统一般划分为三大类:应用程序、工具箱和框架( Framework)

应用程序:指开发工具如 Visual Studio 2008 、 Java 等 工具箱:指开发程序时使用的工具,如服务器控件、控件、组件等 框架:是一个可复用的设计构件,它规定了应用的体系结构,阐明了整个设计、

协作构件之间的依赖关系、责任分配和控制流程,表现为一组抽象类以及其实例之间协作的方法,它为构件复用提供了上下文 (Context)关系。简单说就是使用别人搭好的舞台,你来做表演。而且,框架一般是成熟的,不断升级的软件

软件开发中的重用 软件开发中三种级别的重用:内部重用,即在同一应用中能公共使用的抽象块;

代码重用,即将通用模块组合成库或工具集,以便在多个应用和领域都能使用;应用框架的重用,即为专用领域提供通用的或现成的基础结构,以获得最高级别的重用性

构件通常是代码重用,而设计模式是设计重用,框架则介于两者之间,部分代码重用,部分设计重用,有时分析也可重用

Page 49: An Introduction to  Computer Programming

49A tutor on coding , Sep 9, 2011

编程进阶编程进阶 设计模式推荐书籍

《 Design Patterns : Elements of Reuseable Object-Oriented Software》, Erich Gamma , Richard Helm , Ralph Johnson ,John Vlissides , Addison-Wesley Professional (机械工业出版社,双语版)

《 Head First Design Patterns》, Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra , O‘Reilly Press (东南大学出版社,影印版,中文版)

《大话设计模式 》,程杰,清华大学出版社

Page 50: An Introduction to  Computer Programming

50A tutor on coding , Sep 9, 2011

编程进阶编程进阶 编程规范

编程风格:函数名、变量名的选取,代码缩进,表达式和语句的书写,代码注释(包括使用一些辅助工具,譬如 Doxygen )等等

代码质量:可靠性、安全性、时间效率、空间效率、可移植性、可维护性等

编程语言:如何合理、有效的使用编程语言?软件开发者需要掌握一些窍门

Page 51: An Introduction to  Computer Programming

51A tutor on coding , Sep 9, 2011

编程进阶编程进阶 编程规范推荐书籍

《代码大全》, Steve McConnell (金戈、汤凌、陈硕、张菲译),电子工业出版社

《程序设计实践》, Brian W. Kernigham , Rob Pike (裘宗燕译),机械工业出版社

《 Code Quality》, Diomidis Spinelis ,机械工业出版社 《 Effective C++》( 3rd ), Scott Meyers ,电子工业出版社

(侯捷 ,中文版) 《 More Effective C++ : 35 New Ways to Improve Your

Programs and Designs 》, Scott Meyers ,电子工业出版社(影印版)

《 C++ Coding Standards: 101 Rules, Guidelines, and Best Practices》, Herb Sutter , Andrei Alexandrescu ,人民邮电出版社(影印版)

Page 52: An Introduction to  Computer Programming

52A tutor on coding , Sep 9, 2011

编程进阶编程进阶 代码调试

调试程序比编写程序更像一门艺术 调试程序是成为高素质软件开发人员必备的一项关键技术

软件调试的“生态”系统 CPU 的调试支持:调试功能的硬件基础,譬如中断、异常、单步执行等 操作系统的调试支持:把 CPU 的支持进行必要的封装,并构建一整套

软件调试所需的基础设施,然后以 API 的形式提供给调试器和应用软件 编译器的调试支持:编译器负责产生更易于调试的调试版本以及包含调

试信息的调试符号文件 被调试软件应该努力提高自身的可调试性 调试器负责把所有“成员”的努力化为成果,以简单方便的形式呈现给

用户(调试者),让他们利用强大的调试功能随心所欲的探索软件世界 推荐书籍

《软件调试》,张银奎,电子工业出版社

Page 53: An Introduction to  Computer Programming

53A tutor on coding , Sep 9, 2011

编程进阶编程进阶 代码阅读

Most programming courses and textbooks focus on how to write programs from scratch. However, 40% to 70% of the effort that goes into a software system is expended after the system is first written. That effort invariably involves reading, understanding, and modifying the original code

The rising importance of open-source development efforts and cooperative development processes (including outsourcing, code walkthroughs, and extreme programming) make code reading an essential skill for today's software engineer

The rising importance of open-source development efforts and cooperative development processes (including outsourcing, code walkthroughs, and extreme programming) make code reading an essential skill for today's software engineer

Software source code is the definitive medium for communicating a program's operation and for storing knowledge in an executable form

推荐书籍 《 Code Reading 》 , Diomidis Spinellis, 中国电力出版社 (影印版)

Page 54: An Introduction to  Computer Programming

54A tutor on coding , Sep 9, 2011

编程进阶编程进阶 软件工程

Software engineering is the establishment and use of sound engineering principles in order to obtain economically software that is reliable and works efficiently on real machines — from Fritz Bauer

Software Engineering: (1) The application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software; that is, the application of engineering to software. (2) The study of approaches as in (1) -from IEEE

对于软件开发团队管理者来说,软件工程知识是必备的 推荐书籍

《 Software Engineering: A Practitioner’s Approach 》(6th) , Rogers Pressman ,机械工业出版社(英文,最新版本7th , McGraw-Hill )

《 The Mythical Man-Month: Essays on Software Engineering 》(中文版,人月神话》, Frederick P. Brooks (李琦注释 ),人民邮电出版社

Page 55: An Introduction to  Computer Programming

55A tutor on coding , Sep 9, 2011

Thanks for your attention!