结构话编程强调的是对流程的控制;

它为面向过程编程提供天然的支持。

Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutinesblock structuresfor and while loops—in contrast to using simple tests and jumps such as the go to statement, which could lead to "spaghetti code" that is difficult to follow and maintain.

Control structures[edit]

Following the structured program theorem, all programs are seen as composed of control structures:

  • "Sequence"; ordered statements or subroutines executed in sequence.
  • "Selection"; one or a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else..endif.
  • "Iteration"; a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as whilerepeatfor or do..until. Often it is recommended that each loop should only have one entry point (and in the original structural programming, also only one exit point, and a few languages enforce this).
  • "Recursion"; a statement is executed by repeatedly calling itself until termination conditions are met. While similar in practice to iterative loops, recursive loops may be more computationally efficient, and are implemented differently as a cascading stack.

 

Graphical representation of the three basic patterns — sequence, selection, and repetition — using NS diagrams (blue) and flow charts (green).

Subroutines[edit]

Subroutines; callable units such as procedures, functions, methods, or subprograms are used to allow a sequence to be referred to by a single statement.

Blocks[edit]

Blocks are used to enable groups of statements to be treated as if they were one statement. Block-structured languages have a syntax for enclosing structures in some formal way, such as an if-statement bracketed by if..fias in ALGOL 68, or a code section bracketed by BEGIN..END, as in PL/Iwhitespace indentation as in Python - or the curly braces {...} of C and many later languages.

https://en.wikipedia.org/wiki/Structured_programming

结构化编程-Structured programming的更多相关文章

  1. C++程序结构---1

    C++ 基础教程Beta 版 原作:Juan Soulié 翻译:Jing Xu (aqua) 英文原版 本教程根据Juan Soulie的英文版C++教程翻译并改编. 本版为最新校对版,尚未定稿.如 ...

  2. [3]第二章 C++编程简介

    (本资料均从 internet 上进行收录整理,若要转载,请与原作者联系) 2.1  机器语言.汇编语言和高级语言 程序员用各种编程语言编写指令,有些是计算机直接理解的,有些则需要中间翻译(tranl ...

  3. Reading | 《C++ Primer Plus》(未完待续)

    目录 一.概述和C++简史 1.早期语言的问题 2.面向对象编程OOP 3.泛型编程 二.入门 1.头文件 2.名称空间 3.cout输出 4.C++语句 5.函数 一.概述和C++简史 C++融合了 ...

  4. 文艺编程 Literate Programming

    (译注:这篇文章是 Donald Knuth 一篇1983年的论文:Literate Programming 的介绍部分.有人翻译为“字面编程”,是极其错误的说法,literate 根本就没有“字面” ...

  5. Core Java Volume I — 4.1. Introduction to Object-Oriented Programming

    4.1. Introduction to Object-Oriented ProgrammingObject-oriented programming, or OOP for short, is th ...

  6. Chapter 1 An Overview of Computers and Programming Languages

    Babylon巴比伦 loom织布机 weaver, WHO uses loom to work census: to count the population tabulate: make into ...

  7. 2018-02-27 "Literate Programming"一书摘记之一

    书到后才发现是Knuth的论文集, 第一篇就在网上: Computer programming as an art (1974). 其中"Taste and Style"(品味和风 ...

  8. DCI:The DCI Architecture: A New Vision of Object-Oriented Programming

    SummaryObject-oriented programming was supposed to unify the perspectives of the programmer and the ...

  9. Comparison of programming paradigms

    Main paradigm approaches[edit] The following are widely considered the main programming paradigms, a ...

随机推荐

  1. Mysql重复数据查询置为空

    前两天产品有个需求,相同的商品因为价格不同而分开展示,但是明细还是算一条明细,具体区分展示出商品的价格和数量信息,其他重复的商品信息要置空. 需求并不难,用程序代码循环处理就可以了.但是后面涉及到打印 ...

  2. Javase 集合1

    package Swxx; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; pu ...

  3. 序列模型(5)-----双向神经网络(BRNN)和深层循环神经网络(Deep RNN)

    一.双向循环神经网络BRNN 采用BRNN原因: 双向RNN,即可以从过去的时间点获取记忆,又可以从未来的时间点获取信息.为什么要获取未来的信息呢? 判断下面句子中Teddy是否是人名,如果只从前面两 ...

  4. 实现el-dialog的拖拽,全屏,缩小功能

    基于el-dialog, 封装了一下.,实在懒得写,所以直接把代码 粘出来了 大概粘了一下效果.自己体会把. 组件使用 <el-dialog v-dialogDrag ref="xhz ...

  5. String,StringBuffer,StringBuild的区别

    1.三者在执行速度方面的比较:StringBuilder >  StringBuffer  >  String 2.String <(StringBuffer,StringBuild ...

  6. Spring Boot浅谈(是什么/能干什么/优点和不足)

    1. Spring Boot是什么,解决哪些问题 1) Spring Boot使编码变简单 2) Spring Boot使配置变简单 3) Spring Boot使部署变简单 4) Spring Bo ...

  7. 微信小程序 全局变量

    微信小程序里面有个app.js,我们可以在这个里面设置全局变量, App({ globalData:{ url:"http://xxx.xxx.xx:3000" } }) 在外面就 ...

  8. Mybatis拦截器执行过程解析

    上一篇文章 Mybatis拦截器之数据加密解密 介绍了 Mybatis 拦截器的简单使用,这篇文章将透彻的分析 Mybatis 是怎样发现拦截器以及调用拦截器的 intercept 方法的 小伙伴先按 ...

  9. 最简单的tomcat安装部署

    [安装环境] 适用于所有Linux操作系统,本人使用的是Centos 7.4 [安装] 浏览器登陆到tomcat官网 http://tomcat.apache.org/ 点击左侧需要下载的版本 右键图 ...

  10. http协议各版本的区别

    HTTP(Hypertext transfer protocol)超文本传输协议,是一个应用层的通信协议. HTTP协议版本介绍: HTTP/0.9 :只接受GET一种请求方法,没有在通信中指定版本号 ...