THE AUTOMATED FLOWCHART DESIGN AND CODE WRITING SYSTEM

LogicCoder on-line Tutorial

PRINCIPLES OF PROGRAM FLOWCHARTING

This section gives a concise introduction to the concepts and principles of flowcharting as a means for illustrating program algorithms to be executed on digital computer systems. The main objective is to help you understand the basic principles on which Logic Coder operates and to provide you with a conceptual guide for design of your program algorithms. This on-line documentation is not intended to be a detailed practical guide. Reference sources that gives more practical learning material including programming language concepts and design techniques are given at the link to additional learning resources.

WHAT IS PROGRAM FLOWCHARTING?

Program flowcharting is the art of illustrating program algorithms graphically using standard symbols and their interconnection. A computer program algorithm is the sequence of logical steps that must be executed on a machine in order to derive the solution to a programming problem.

There is no known standard accepted technique that restricts the design of program flowcharts using standard flowcharting symbols. In LogicCoder there are restrictions that the user must follow before program code can be generated by the system from a design. These restrictions may appear to be counterproductive when deriving the design for certain programming problems. In this case, the programming problem is usually trivial in nature. However, years of teaching and programming experience have shown that the advantages from the approach used in LogicCoder strongly outweigh the disadvantages. These rules ensure that all control logic structures are well defined, can be easily identified, edited or abstracted. In later version of LogicCoder we show how these rules are developed further to create data flow diagrams and for identification of parallelism in an algorithm. Hence, LogicCoder provides facilities for you to convert elements of a uni-processor algorithm to one that can be implemented on a parallel system. We define a uni-processor algorithm as an algorithm which when implemented on a Digital Computer System under the Stored Program Concept, is executed in time sequence as determine by its flow of control logic. At any instance in time, the system is executing only one intended instruction or group of instructions associated with the flowchart logic. Each symbol in a flowchart except connectors and lines represents a process that can be implemented on a digital computer that operates under the stored program concept. In this system of flowcharting, there are only three basic kinds of control logic structures

  1. Sequence - for executing a list of processes in time order

  2. Loop - for repetitive processing in time order and

  3. Case - for making decisions on alternative or complex selection processing

The manner in which these restrictions are implemented in LogicCoder are hinted at in the rules given in the following sections.

ADVANTAGES OF FLOWCHARTS FOR PROGRAM DESIGN

I have listed here, some of the advantages from using flowcharts.

They are self-documenting.

Allow easy review and maintenance of a software system. This results in less time spent on debugging

Helps to develop reusable algorithmic structures hence they are useful for identifying the logic of generic systems. Hence they help the user to develop concise generalize algorithmic solutions to similar problems.

Force careful and concise solution to the logic of a program problem.

A simplified consistent means for developing program logic

FLOWCHARTING SYMBOLS

You show the flow of program control in a flowchart by connecting flowcharting symbols together in a systematic manner. Each non-line symbol except for connectors in the flowchart represents some processing to be done at that point in the program. Each symbol represents a specific kind of operation that can be done on the computer. The symbols illustrated below does not exhaust those used in many technical documentation on computer systems. Symbols used in some documentation are appropriate to the kind of operations on computer systems they are intended to represent. The set of flowchart symbols illustrated below are appropriate to the kind of operations implemented by LogicCoder. However, LogicCoder has variant of these symbols that represents operations unique to Logic Coder. The most commonly used flowcharting symbols and a brief explanation of their use is listed below.

 

PROCESSING

Indicates process such as calculation, Data movement or any other kind of internal processing that affects the value of data in a program.

INPUT/OUTPUT

Indicates the point in the program where data is made available to the program through some input device or where processed data is made available for output from the program. Logic Coder provides additional Input/Output and Process symbols that can be used to illustrate more complex or specific kinds of Input/Output or Process operations in a flowchart.

DECISION

Shows the point in the program execution sequence where a jump takes place base on the outcome of a tested condition. In Logic Coder, Decision symbols are used only for establishing loops, case and switch-case structures.

CONNECTOR

Shows the exit from a case, a switch-case control structure or a common point where two or more control logic merges to create a single flow path. Logic Coder uses two concentric circles to distinguish a normal connector from a Switch Case connector. The Switch Case connector is illustrated and explained below.

TERMINAL

Shows the start or end point in the flow of control logic in a single flowchart. A complete flowchart must always have only one terminal symbol that indicates its beginning and a terminal symbol that indicates its termination. Logic Coder looks for a terminal symbol that indicates the start of the flowchart when doing an interconnection operation.

PREDEFINE

Shows a series of predefined processes that can be encapsulated as a single process and therefore represented as a subroutine, i.e. function, procedure or method. Logic Coder also uses the predefine symbol to represent an abstracted control structure. The detailed logic of the control structure is preserved.

INTERNAL STORAGE

Shows an output operation where data is stored internally on the computer system. This storage is usually on a mass storage device such as a Hard disk or CD ROM. Logic Coder does not use this symbol.

PAGE CONNECTOR

Used in multi-page documents to show the point in the program logic where control is pass from the logic on a given page to the logic on another page. Use this symbol when you need to restrict the size of your flowchart document. This may be due to the fact that you ant to print your flowchart on a printer that is restricted. However, Logic Coder will not be able to connect a flowchart that uses the off-page connector symbol.

ARROWS

Shows the flow of program control or data flow. Flow-lines can have any one of four directions. Logic Coder does not use arrows to determine the flow of control logic in a flowchart. The way this is done is explain further on in the manual. Logic Coder provides a function that you can use to see the flow of control logic in a flowchart as determine by Logic Coder.

COMMENT

Used to show points in the program logic where comments are written for the purpose of internal documentation. Logic Coder insert comments written in this symbol into the generated source program.

CONTROL ELEMENTS OF A PROGRAM LOGIC

The ability of the computer to fetch and execute instructions repeatedly, accurately and at very high speed coupled with its ability to make decision on alternative processing makes the computer appears to be a powerful device. The programmer writes code in a programming language that specifies what instruction is to be executed in a program. The kind of processing done by the basic control elements that determine branching during the sequence of program statement execution can be described as:

  1. Alternative processing or

  2. Repetitive processing.

Actually, both type of processing is base on a process of decision making. The difference is that the control path in one case does not lead to a repeat of processing done before. Alternative processing in a program is implemented using the control logic known as the case structure or the comparing logic structure. Loops are implemented using the loop logic structure.

EVALUATING THE CONTROL LOGIC IN A FLOWCHART

When interpreting the logic of a flowchart, traversal of this logic is from top-to-bottom, left-to-right, both right-to-left and left-to-right at case decisions, and bottom-to-top followed by right-to-left when terminating a loop. Therefore, evaluating the logic in a control structure can be determined by the basic rules that govern that structure. For example, the logic in a loop can be evaluated on the basis of the basic loop logic structure along with any other nested internal structures. We use an example program flowchart to illustrate these points.

EXAMPLE
An example program flowchart is illustrated by figure 2. In this system, a program is to be coded that reads sales persons record and then calculate sales commission base on individual sales value. A 7% commission is calculated if the sales value is greater than or equal to 500.00. Otherwise, the sales commission is calculated at 5%. The total of all commission is printed at the end of processing all sales record. The logic illustrated by the flowchart below gives a more concise description of the processes to be done on a computer system.

The implementation code in a source programming language is the actual instructions to the computer system that causes the intended processes to be executed by the system. In most case, the source code consist of high level instruction code that must be translated to machine level code before the program can be executed on a computer system. Some high level source language are specialize in their application and provides facilities to the programmer that results in convenient code development. When developing the logic of a software system to be implemented in a target source language, you should be aware of the available facilities in that source language.

However, with Logic Coder, you no longer need to be too concerned about details of the implementation control structures in the language once you have completed a proper design using a flowchart. The logic illustrated by a flowchart is then used to write the program solution in a selected programming language. For example, the logic illustrated by the flowchart in above can be implemented in C as illustrated below. Notice that the code does not deal with programming issues such as systems environment setting and preprocessing directives. These requirements are not documented in the flowchart.

THE C/C++ PROGRAM CODE

The programming language used to code the program logic will to a large extent be determine by the nature of the descriptive statements used in the flowchart and the nearness of their meaning to specific statements that can be implemented in a language that fits closely to these description. If the program logic is well-designed, then the implementation source code can be any programming language.

Therefore, good algorithmic description in a program flowchart is essential to good program documentation, maintainability and portability of their implementation. The illustration below is the implementation code in BASIC for the program flowchart illustrated above. Coding a program is an exact skill that a programmer must develop by paying careful attention to detail and the precise use of the syntax of a programming language. However, with LogicCoder you need not pay much attention to the syntax of a programming language.

THE BASIC PROGRAM CODE

Certainly! it is possible to implement the logic of a flowchart in Assembly Language using LogicCoder. In this case, the description of events illustrated in the flowchart would in most case refer to the hardware elements of the system on which the program algorithm is to be implemented.

CORRECTNESS OF LOOPS AND CASE STRUCTURES

The alternative but incorrect logic implementation is illustrated below. The justification to use this implementation is that in looping this way you save on unnecessary coding. However, this is not the most efficient technique for saving on program code over the long run.In addition, "saving on program code" does not always result in a more efficient program. Using well defined control structures in a program design is a better aid to discovering ways for implementing efficient and correct program code. Because of the importance of the basic loop logic structure, two "Read a Record" processing statements are required in the program source code.

To pass back program control to the first command statement as illustrated in the figure below violates the rules of the loop control structure. In this implementation, the first statement in the loop is not a decision. The correct implementation follows the rule that the first statement in a loop should be the decision that determines whether the body of the loop is to be executed or not. The value of this rule is not immediately apparent in this simple example. It takes more complex algorithm to realize the soundness of this rule.

The information given here is only intended to be a guided sample of that to be found in Logic Coder's Technical Reference Manual. The information presented here is therefore incomplete. More detailed explanation of program flowcharting can be found in our teaching resources and the Technical reference manual.

A STRUCTURED APPROACH TO PROGRAMMING

LogicCoder supports a structured approach to the development of software systems. LogicCoder makes it easier for developers to document and maintain their software systems with less uncertainty, more consistency and greater control over the management of changes. Hence, both design and program maintenance are made easier. Correctness of a program can more easily be aligned with its algorithmic description. Structured programming languages generally emphasize the use of well-established control statements that implement well-established control structures. The layouts of program code in these languages emphasize and make it easy to deduce these control structures. This helps to enhance the readability of the program logic and the maintainability of the program code. LogicCoder generates code in conformity to these basic principles. However, you no longer needs to pay attention to these details when developing software systems.

THE PROGRAM DEVELOPMENT CYCLE

The Program Development Cycle is the well-established standard approach towards the development of professional maintainable software systems. Because of the precise nature of the sequence and kind of instructions involved in the solution to a programming problem, it is important that the programmer approach the solution to a programming problem in a systematic and discipline manner. This systematic approach is called the program development life cycle. The program development life cycle consist of the following stages:

1. Review of program specification
2. Program design
3. Program coding
4. Program testing and debugging
5. Program documentation

Copy right May 2002
Logic Code Generator Ltd
142A Shenley Road
Borehamwood
Hertfordshire WD6 1EQ
United Kingdom

Tel: +44(0)