過(guò)程式程序設計(英語(yǔ):Procedural programming),又稱(chēng)過(guò)程式編程、過(guò)程化編程,一種編程范型,有時(shí)會(huì )被視為是命令式編程的同義語(yǔ)。派生自結構化編程(Structured programming),主要采取程序調用(procedure call)或函數調用(function call)的方式來(lái)進(jìn)行流程控制。流程則由包涵一系列運算步驟的程序(Procedures),例程(routines),子程序(subroutines), 方法(methods),或函數(functions)來(lái)控制。在程序運行的任何一個(gè)時(shí)間點(diǎn),都可以調用某個(gè)特定的程序。任何一個(gè)特定的程序,也能被任意一個(gè)程序或是它自己本身調用。著(zhù)名的例子有Linux內核,git,以及Apache HTTP Server等。
面向對象程序設計(英語(yǔ):Object-oriented programming,縮寫(xiě):OOP)是種具有對象概念的程序編程范型,同時(shí)也是一種程序開(kāi)發(fā)的抽象方針。它可能包含數據、屬性、代碼與方法。對象則指的是類(lèi)的實(shí)例。它將對象作為程序的基本單元,將程序和數據封裝其中,以提高軟件的重用性、靈活性和擴展性,對象里的程序可以訪(fǎng)問(wèn)及經(jīng)常修改對象相關(guān)連的數據。在面向對象程序編程里,計算機程序會(huì )被設計成彼此相關(guān)的對象。重要的面向對象編程語(yǔ)言包含Common Lisp、Python、C++、Objective-C、Smalltalk、Delphi、Java、Swift、C#、Perl、Ruby 與 PHP等。
Procedural programming languages are also imperative languages, because they make explicit references to the state of the execution environment. This could be anything from variables (which may correspond to processor registers) to something like the position of the 'turtle' in the Logo programming language. Often, the terms 'procedural programming' and 'imperative programming' are used synonymously. However, procedural programming relies heavily on blocks and scope, whereas imperative programming as a whole may or may not have such features. As such, procedural languages generally use reserved words that act on blocks, such as if, while, and for, to implement control flow, whereas non-structured imperative languages use goto statements and branch tables for the same purpose.
The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object-oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. The most important distinction is that while procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together, so an 'object', which is an instance of a class, operates on its 'own' data structure.
聯(lián)系客服