Elements of Programming Languages ( E. Control Level Structure)

CONTROL STRUCTURE

 A control structure is a primary concept in most high-level programming languages. In its simplest sense, it is a block of code. More specifically, control structures are blocks of code that dictate the flow of control. In other words, a control structure is a container for a series of function calls, instructions and statements. A simple example of a control structure is, if a then b else c. These statements will be included or excluded based o­n the condition of a. This simple notion of if then comprises the bulk of even the most sophisticated software applications. There are many other types of control structures than the if then structure. In broad terms, these include the jump or unconditional branch, the conditional branch, the loop, which is essentially a conditional branch, subroutines, co-routines, continuations, and the conditional halt. There are also lower level flow controls, such as interrupts and signals. The most common specific forms of those control structures are gotos, subroutines, for loops, do while loops, if then, try catch finally, so o­n and so forth. The names deviate between languages but for the most part these concepts are universal across all imperative programming languages. The concept of the conditional branch, or if then else, exists in C++ as it does in Visual Basic.NET as it does in Ruby. Programmers reading or maintaining code need to be able to identify these control structures easily. Formatting them in a structured way allows them to be identifiable and distinct from each other. The coding standard structures them by combining a series of style rules. In most standards, these rules center o­n indentation and line breaks. Let us consider the C-style condition if (a == 5) { b = 1 } else { b = 0 }; This is a perfectly acceptable C-style condition. However, the widely accepted coding standard would have us write it as such: if ( a == 5 ) { b = 1 } else { b = 0 };

Walang komento:

Mag-post ng isang Komento