Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






Jackson Structured Programming

Jackson Structured Programming (JSP) is a program design technique that derives a program's structure from the structures of its input and output data [Ref. 6]. The JSP dictum is that 'the program structure should match the data structure'.

In JSP, the basic procedure is to:

• consider the problem environment and define the structures for the data to be processed;

• form a program structure based on these data structures:

• define the tasks to be performed in terms of the elementary operations available, and allocate each of those operations to suitable components in the program structure.

The elementary operations (i.e statements in the programming language) must be grouped into one of the three composite operations: sequence, iteration and selection. These are the standard structured programming constructs, giving the technique its name.

JSP is suitable for the detailed design of software that processes sequential streams of data whose structure can be described hierarchically. JSP has been quite successful for information systems applications.

Jackson System Development (JSD) is a descendant of JSP. If used, JSD should be started in the SR phase (see ESA PSS-05-03, Guide to the Software Requirements Definition Phase).

PRODUCTION METHODS

Software production involves writing code in a programming language, verifying the code and integrating it with other code to make a working system. This section therefore discusses programming languages and integration methods.

 

30 ESA PSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

3.3.1 Programming languages

Programming languages are best classified by their features and application domains. Classification by 'generation' (e.g. 3GL, 4GL) can be very misleading because the generation of a language can be completely unrelated to its age (e.g. Ada, LISP). Even so, study of the history of programming languages can give useful insights into the applicability and features of particular languages [Ref. 13].

3.3.1.1 Feature classification

The following classes of programming languages are widely recognised:

• procedural languages;

• object-oriented languages:

• functional languages;

• logic programming languages.

Application-specific languages based on database management systems are not discussed here because of their lack of generality. Control languages, such as those used to command operating systems, are also not discussed for similar reasons.

Procedural languages are sometimes called 'imperative languages' or 'algorithmic languages'. Functional and logic programming languages are often collectively called 'declarative languages' because they allow programmers to declare 'what' is to be done rather than 'how'.

3.3.1.1.1 Procedural languages

A 'procedural language' should support the following features:

• sequence (composition);

• selection (alternation);

iteration:

• division into modules.

The traditional procedural languages such as COBOL and FORTRAN support these features.



 

ESA PSS-05-05 Issue 1 (May 1992) 31 METHODS FOR DETAILED DESIGN AND PRODUCTION

The sequence construct, also known as the composition construct, allows programmers to specify the order of execution. This is trivially done by placing one statement after another, but can imply the ability to branch (e.g. GOTO).

The sequence construct is used to express the dependencies between operations. Statements that come later in the sequence depend on the results of previous statements. The sequence construct is the most important feature of procedural languages, because the program logic is embedded in the sequence of operations, instead of in a data model (e.g. the trees of Prolog, the lists of LISP and the tables of RDBMS languages).

The selection construct, also known as the condition or alternation construct, allows programmers to evaluate a condition and take appropriate action (e.g. IF... THEN and CASE statements).

The iteration construct allows programmers to construct loops (e.g. DO...). This saves repetition of instructions.

The module construct allows programmers to identify a group of instructions and utilise them elsewhere (e.g. CALL...). It saves repetition of instructions and permits hierarchical decomposition.

Some procedural languages also support:

• block structuring;

• strong typing;

recursion.

Block structuring enforces the structured programming principle that modules should have only one entry point and one exit point. Pascal, Ada and Ñ support block structuring.

Strong typing requires the data type of each data object to be declared. This stops operators being applied to inappropriate data objects and the interaction of data objects of incompatible data types (e.g. when the data type of a calling argument does not match the data type of a called argument) [Ref. 2]. Ada and Pascal are strongly typed languages. Strong typing helps a compiler to find errors and to compile efficiently.

Recursion allows a module to call itself (e.g. module A calls module A), permitting greater economy in programming. Pascal, Ada and Ñ support recursion.

 

32 ESA PSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

3.3.1.1.2 Object-oriented languages

An object-oriented programming language should support all structured programming language features plus:

inheritance;

polymorphism:

messages.

Examples of object-oriented languages are Smalltalk and C++. Reference 14 provides a useful review of object-oriented programming languages.

Inheritance is the technique by which modules can acquire capabilities from higher-level modules, i.e. simply by being declared as members of a class, they have all the attributes and services of that class.

Polymorphism is the ability of a process to work on different data types, or for an entity to refer at runtime to instances of specific classes. Polymorphism cuts down the amount of source code required. Ideally, a language should be completely polymorphic, so the need to formulate sections of code for each data type is unnecessary. Polymorphism implies support for dynamic binding.

Object-oriented programming languages use 'messages' to implement interfaces. A message encapsulates the details of an action to be performed. A message is sent from a 'sender object' to a 'receiver object' to invoke the services of the latter.

3.3.1.1.3 Functional languages

Functional languages, such as LISP and ML, support declarative structuring. Declarative structuring allows programmers to specify only 'what' is required, without staling how it is to be done. It is an important feature, because it means standard processing capabilities are built into the language (e.g. information retrieval) .

With declarative structuring, procedural constructs are unnecessary. In particular, the sequence construct is not used for the program logic. An underlying information model (e.g. a tree or a list) is used to define the logic. If some information is required for an operation, it is automatically obtained from the information model. Although it is possible to make one operation depend on the result of a previous one, this is not the usual style of programming.

 

ESA PSS-05-05 Issue 1 (May 1992) 33 METHODS FOR DETAILED DESIGN AND PRODUCTION

Functional languages work by applying operators (functions) to arguments (parameters). The arguments themselves may be functional expressions, so that a functional program can be thought of as a single expression applying one function to another. For example if DOUBLE is the function defined as DOUBLE(X) = X+ X, and APPLY is the function that executes another function on each member of a list, then the expression APPLY(DOUBLE, [1, 2, 3]) returns [2, 4, 6].

Programs written in functional languages appear very different from those written in procedural languages, because assignment statements are absent. Assignment is unnecessary in a functional language, because all relationships are implied by the information model.

Functional programs are typically short, clear, and specification-like, and are suitable both for specification and for rapid implementation, typically of design prototypes. Modern compilers have reduced the performance problems of functional languages.

A special feature of functional languages is their inherent suitability for parallel implementation, but in practice this has been slow to materialise.

3.3.1.1.4 Logic programming languages

Logic programming languages implement some form of classical logic. Like functional languages, they have a declarative structure. In addition they support:

backtracking;

• backward chaining:

• forward chaining. Prolog is the foremost logic programming language.

Backtracking is the ability to return to an earlier point in a chain of reasoning when an earlier conclusion is subsequently found to be false. It is especially useful when traversing a knowledge tree. Backtracking is incompatible with assignment, since assignment cannot be undone because it erases the contents of variables. Languages which support backtracking are, of necessity, non-procedural.

Backward chaining starts from a hypothesis and reasons backwards to the facts that cause the hypothesis to be true. For example if the fact A and hypothesis  are chained in the expression IF

 

34 ESA PSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

A THEN B, backwards chaining enables the truth of A to be deduced from the truth of  (note that A may be only one of a number of reasons for  to be true).

Forward chaining is the opposite of backward chaining. Forward chaining starts from a collection of facts and reasons forward to a conclusion. For example if the fact X and conclusion Y are chained in the expression IF X THEN Y, forward chaining enables the truth of Y to be deduced from the truth of X.

Forward chaining means that a change to a data item is automatically propagated to all the dependent items. It can be used to support 'data-driven' reasoning.

Applications

Commonly recognised application categories for programming languages are:

• real-time systems, including control systems and embedded systems:

• transaction processing, including business and information systems,

• numerical analysis:

simulation;

• human-computer interaction toolkits (HCI);

• artificial intelligence (Al);

• operating systems;

The application area of language strongly influences the features that are built into it. There is no true 'general purpose language', although some languages are suitable for more than one of the application categories listed above.

FORTRAN

FORTRAN was the first widely-used high-level programming language. Its structuring concepts include the now-familiar IF... THEN alternation, DO iteration, primitive data types such as integer, and procedure composition. FORTRAN does not support recursion.

FORTRAN is familiar to generations of programmers who have learned to use it safely. It is a simple language, compared with Ada, and can be compiled rapidly into efficient object code. Compilers are available for most hardware, but these are not always compatible, both

 

ESAPSS-05-05 Issue 1 (May 1992) 35 METHODS FOR DETAILED DESIGN AND PRODUCTION

because of the addition of machine-dependent features, especially input/output, and because of successive versions of FORTRAN itself. However, good standards exist.

The language includes some features now generally considered risky, such as:

• the GOTO statement, which allows the rules of structured programming to be easily broken:

• the EQUIVALENCE statement, which permits different names to be used for the same storage location:

• local storage, which permits possibly undesired values to be used from a previous call;

• multiple entry and exit points.

FORTRAN remains the primary language for scientific software. Most compilers allow access to operating system features, which, at the expense of portability, allows FORTRAN to be used for developing real-time control systems.

COBOL

COBOL remains the most widely used programming language for business and administration systems. As a procedural language it provides the usual sequence, selection (IF... OTHERWISE...) and iteration constructs (PERFORM...). COBOL has powerful data structuring and file handling mechanisms (e.g. hierarchically arranged records, direct access and indexed files). Although its limited data manipulation facilities severely restricts the programmers' ability to construct complex arithmetic expressions, it does allow fixed point arithmetic, necessary for accurate accounting.

COBOL was conceived as the first 'end-user' programming language. It relies on verbal expressions, not symbols (e.g. ADD, SUBTRACT, MULTIPLY, DIVIDE instead of +, -, x and +). It has therefore been criticised as forcing a verbose programming style. While this does help make COBOL programs self-explanatory, COBOL programs can still be difficult to understand if they are not well-structured. Jackson's Principles of Program Design are explained with the aid of examples of good and bad COBOL programming [Ref. 6].

 

36 ESAPSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

Pascal

Pascal was conceived by a single designer (Nikiaus Wirth) to teach the principles of structured programming. It is accordingly simple and direct, though perhaps idiosyncratic. It contains very clear constructs: IF... THEN... ELSE, WHILE... DO, REPEAT... UNTIL, CASE... OF, and so on. Sets, procedures, functions, arrays, records and other constructs are matched by a versatile and safe data typing system, which permits the compiler to detect many kinds of error.

Wirth omitted several powerful features to make Pascal compile efficiently. For example, functions may not return more than one argument, and this must be a primitive type (although some extensions permit records to be returned). String handling and input/output functions are simplistic and have been the source of portability problems.

Pascal handles recursive data structures, such as lists and trees by means of explicit pointers and (sometimes) variant records. These defeat the type checking mechanism and are awkward to handle.

Pascal is now well-defined in an ISO standard, and is very widely available with good compilers and supporting tools. To a considerable extent the language enforces good programming practice.

Ñ

Ñ is a language in the same family as Pascal, with its roots in Algol. The language is less strongly typed than Pascal or Algol. It is easy and efficient to compile, and because of its low-level features, such as bit manipulation, can exploit machine-dependent facilities.

Ñ has a rich variety of operators that allow programmers to adopt a very terse style. This can unfortunately make programs difficult to read and understand. Discipline is required to produce code that is portable and maintainable. Coding standards are especially necessary to make Ñ code consistent and readable.

One advantage of Ñ is its close connection with the Unix operating system, which guarantees Ñ a place as a (or the) major systems programming language. A very wide range of tools and library modules are available for the language.

 

ESAPSS-05-05 Issue 1 (May 1992) 37 METHODS FOR DETAILED DESIGN AND PRODUCTION

Modula-2

Modula-2 is derived from Pascal. It offers a few new constructs and considerably more power and generality. Two important features are modularity, including incremental compilation, and simulation of concurrency and inter-process communication (via co-routining).

Nikiaus Wirth, the inventor of both Pascal and Modula-2, intended that Modula-2 replace Pascal. However Modula-2 is not widely used because of the scarcity of development tools for popular platforms. In contrast to Ada, its main competitor, it is a 'small' language (its compiler is only about 5000 lines, as opposed to Ada's several hundred thousand lines [Ref. 13]).

Ada

Ada is a powerful language well suited for the creation of large, reliable and maintainable systems. Unlike most languages it was systematically developed (from a US Department of Defense specification [Ref. 7]). Its many features include tasks (processes) able to communicate asynchronously with each other, strong typing and type checking, and generic programming.

Ada derives ideas from many sources, including several of the languages mentioned here. Although it is a large' language, and therefore difficult to master, it can seem relatively familiar to Ñ and Pascal programmers. Applications written in Ada may often be slower than comparable applications written in other languages, perhaps largely due to the immaturity of the compilers. This may become less of a problem in time (as has been seen with other languages).

Ada provides features normally called from the operating system by other languages, providing a valuable degree of device independence and portability for Ada programs. However Ada real time control features may not be adequate for some applications, and direct access to operating system services may be necessary.

Ada does not support inheritance, so it is not an object-oriented language. Ada allows programmers to create 'generic packages' which act as classes. However it is not possible to structure generic packages and inherit package attributes and services.

 

38 ESA PSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

Smalltalk

Smalltalk is the leading member of the family of object-oriented languages. The language is based on the idea of classes of object, which communicate by passing messages, and inherit attributes from classes to which they belong.

Smalltalk is inherently modular and extensible: indeed, every Smalltalk program is an extension of the core language. Large libraries are available offering a wide range of predefined classes for graphics, data handling, arithmetic, communications and so on. Programs can often be created by minor additions to, or modifications of, existing objects.

The language is thus very suitable for rapid iterative development and prototyping, but it is also efficient enough for many applications. It is the language of choice for educating software engineers in object-oriented programming.

Smalltalk differs from other programming languages in being a complete programming environment. This feature is also the language's Achilles heel: using Smalltalk is very much an 'all or nothing' decision. Interfacing to software written in other languages is not usually possible.

3.3.1.10 C++

C++ is an object-oriented and more strongly typed version of C. It therefore enforces greater discipline in programming than C. It is a noticeably more modern language, exploiting the strongest concepts of Pascal and Smalltalk, while providing all the features of its parent language C. The rapid emergence of C++ has been helped by the appearance of tools and standards.

LISP

LISP was the first list processing language. It is mostly a functional language but with some procedural features. Because a program is itself a list, it can readily be treated as data by another program. Hence, LISP is an excellent language for writing interpreters and expert systems, and much pioneering work in artificial intelligence has been done in the language.

 

ESAPSS-05-05 Issue 1 (May 1992) 39 METHODS FOR DETAILED DESIGN AND PRODUCTION

LISP is now a mature language and accordingly has a rich set of predefined tools (functions) and environments available for it. LISP compilers are available on most architectures, but these are not well standardised; so-called Common LISP is a widespread dialect with commercial backing. LISP is often run on specialised workstations with language-sensitive editors, interpreters and debuggers, and sometimes with dedicated hardware. Interfaces to Ñ and Prolog, and to procedural components like graphics packages, are frequently provided.

The language was once heavily criticised for inefficiency and illegibility. List manipulation is inherently more costly than, say, array manipulation, but careful optimisation and good compilers have greatly reduced the overheads. The style of LISP programs is more verbose and less legible than that of modern functional languages such as ML. However, recent versions of LISP have again become more purely functional and have updated their syntax. The problem of understanding heavily bracketed expressions (lists of lists) has largely been solved with pretty-printers and automatic bracket checkers.

ML

ML (short for Meta-Language) is the most widely used of a family of functional (i.e. non-procedural) programming languages that include Hope and Miranda. Like Prolog, it is declarative and admirably free of side-effects. Functions are similar to those in Pascal, except that they may take any desired form and return essentially any type of result as a structure. ML is notably modular and polymorphic, permitting creation of reusable components in a style analogous to that of Ada. ML lacks the quirkiness of some functional languages, and permits procedural constructs for efficiency.

Prolog

Prolog was the first of a family of logic programming languages. Full predicate logic is too complex to implement efficiently, so Prolog compromises by implementing a restricted but useful subset, namely Horn Clause logic. This permits a single affirmative conclusion, but from any number of premises. If a conclusion can be reached in more than one way, more than one clause is provided for it. Thus, groups of clauses act as the analogues of IF... THEN or CASE statements, while a single clause is effectively a procedure or function.

 

40 ESAPSS-05-05 Issue 1 (May 1992) METHODS FOR DETAILED DESIGN AND PRODUCTION

Because a conclusion may fail to be reached by one route, but the same, or another conclusion may be reached by another route, Prolog permits backtracking. This provides a powerful search mechanism. The need to maintain an extensive stack means, however, that Prolog requires a lot of run-time storage.

The language is essentially declarative, not procedural, as the clauses relate one fact or conclusion to another: thus, if something is true then it is always true. Prolog is very well suited to systems embodying rules, deduction, and knowledge (including databases), though it is capable of graphics, arithmetic and device control on a range of machines. It is not ideally suited for highly numerical applications. Prolog itself is (virtually) typeless and freely polymorphic, making it insecure: many of its daughter languages embody varieties of type checking. The language is inherently extensible. With its interactive environment, it is very suitable for prototyping; it has also been used for specification. Most Prolog compilers permit modules of Ñ to be called, typically as if they were built-in predicates.

 

ESAPSS-05-051ssue1 (May 1992) 41 METHODS FOR DETAILED DESIGN AND PRODUCTION

Summary

Table 3.3.1.14 lists the programming languages, their types, primary applications and standards.

Language Type Primary Applications Standard
FORTRAN Procedural Numerical analysis IS01539
    Real-time systems  
COBOL Procedural Transaction processing IS01989
Pascal Procedural Numerical analysis ISO 7185
    Real-time systems  
Ñ Procedural Real-time systems ANSI
    Operating systems  
Modula-2 Procedural Real-time systems  
    Numerical analysis  
Ada Procedural Real-time systems MIL STD
    Simulation 1815A-1983
Smalltalk Object-oriented Simulation Smalltalk-80
    HCI toolkits  
C++ Object-oriented Real-time systems AT&T
    Simulation  
    HCI toolkits  
LISP Functional Al Common LISP
ML Functional Al  
Prolog Logic programming Al Edinburgh syntax

Table 3.3.1.14 Summary of Programming Languages


Date: 2016-01-03; view: 960


<== previous page | next page ==>
PLANNING THE TRANSFER PHASE | Integration methods
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.015 sec.)