Databases Reference
In-Depth Information
Commands that
change state
“What” not “how”
Software paradigms
Wrap statements
in procedures
Transforms with
no side effects
Imperative
Declarative
Procedural
Object-oriented
Functional
Wrap statements in objects
Figure 10.1 A high-level taxonomy of software paradigms. In the English
language, an imperative sentence is a sentence that expresses a command.
“Change that variable now!” is an example of an imperative sentence. In
computer science, an imperative programming paradigm contains sequences of
commands that focus on updating memory. Procedural paradigms wrap groups of
imperative statements in procedures and functions. Declarative paradigms focus
on what should be done, but not how. Functional paradigms are considered a
subtype of declarative programming because they focus on what data should be
transformed, but not how the transforms will occur.
10.1.1
Imperative programming is managing program state
The programming paradigm of most computer systems created in the past 40 years
centers around state management, or what's called imperative programming systems . Pro-
cedural and object languages are both examples of imperative programming systems.
Figure 10.2 is an illustration of this state-management-focused system.
Logical functions
Physical memory (RAM)
Data
Program state
a=1
Data
block
b=7
reads
writes
Program
Program
block
Instruction
Instruction
Program counter
Instruction
Instruction
Figure 10.2 Imperative programs divide physical memory (RAM) into two
functional regions. One region holds the data block and the other the program block.
The state of the program is managed by a program counter that steps through the
program block, reading instructions that read and write variables in computer
memory. The programs must carefully coordinate the reading and writing of data and
ensure that the data is valid and consistent.
 
Search WWH ::




Custom Search