Automatic Programming
Automatic Programming
In structured programming, we sub-divide the whole program into small modules so that the
program becomes easy to understand. The purpose of structured programming is to linearize
control flow through a computer program so that the execution sequence follows the sequence
in which the code is written. The dynamic structure of the program than resemble the static
structure of the program. This enhances the readability, testability, and modifiability of the
program. This linear flow of control can be managed by restricting the set of allowed
applications construct to a single entry, single exit formats
We use structured programming because it allows the programmer to understand the program
easily. If a program consists of thousands of instructions and an error occurs then it is
complicated to find that error in the whole program, but in structured programming, we can
easily detect the error and then go to that location and correct it. This saves a lot of time.
Rule 2 of Structured Programming: Two or more code blocks in the sequence are
structured, as shown in the figure.
Rule 5 of Structured Programming: A structure (of any size) that has a single entry
point and a single exit point is equivalent to a code block. For example, we are
designing a program to go through a list of signed integers calculating the absolute
value of each one. We may (1) first regard the program as one block, then (2) sketch in
the iteration required, and finally (3) put in the details of the loop body, as shown in the
figure.
Automatic programming
Automatic programming is a type of computer programming in which some mechanism
generates a computer program to allow human programmers to write the code at a higher
abstraction level.
The major use of automatic programming is hence to avoid writing repetitive and redundant code
and is part of an ideal intelligent system. By ideal, we mean end-user oriented, general purpose
and fully automatic. No programming is required what so ever, the program will be fully end-
user oriented and would only have knowledge of programming. The end-user who will have the
domain knowledge will simply write a brief specification of the problem and the program will
generate the source code
Automatic programming didn’t always mean the generation of programs by another program. Its
meaning evolved over time.
In the 1940s, it meant the automation of the manual process of paper-tape punching which were
the programs of punched card machines.
Code comprehension
Code Quality
Code Predictability
Incorrect entry
For any application to produce correct results, the user must input the
correct data. We defend our code against the incorrect entry by
adding appropriate user entry validation
Invalid operations
To produce valid results, we must pass accurate data into our methods
so that they can correctly perform their operation. We defend our
code against invalid operations by checking arguments passed into
those methods and follow unit testing the operations.
System mishaps
Future developers
You may have seen notes in someone else's not that suggested "Here
be dragons !". Meaning that the piece of code was complex and
could cause issues if refactored without comprehensive knowledge of
its purposes and side effects. If our code is not clear and another
developer doesn't understand our intent, they may make incorrect
assumptions about that code and make inappropriate changes
causing our code to fail. We defend our code against future
developers by writing clean code which is easy to read and
comprehend and by having a set of unit tests to verify any future
change doesn't negatively impact the application's functionality.
It can sometime feel hopeless to write great code when we're facing
constantly changing requirements, legacy issues, time pressure and
rapidly changing environment. But defensive coding can help.
2. Data Coupling: When data of one module is passed to another module, this is called
data coupling.
3. Stamp Coupling: Two modules are stamp coupled if they communicate using
composite data items such as structure, objects, etc. When the module passes non-
global data structure or entire structure to another module, they are said to be stamp
coupled. For example, passing structure variable in C or object in C++ language to a
module.
4. Control Coupling: Control Coupling exists among two modules if data from one
module is used to direct the structure of instruction execution in another.
5. External Coupling: External Coupling arises when two modules share an externally
imposed data format, communication protocols, or device interface. This is related to
communication to external tools and devices.
6. Common Coupling: Two modules are common coupled if they share information
through some global data items.
7. Content Coupling: Content Coupling exists among two modules if they share code, e.g., a
branch from one module into another module.
Module Cohesion
In computer programming, cohesion defines to the degree to which the elements of a
module belong together. Thus, cohesion measures the strength of relationships
between pieces of functionality within a given module. For example, in highly cohesive
systems, functionality is strongly related.
It represents relationships within the module. It helps represent the relationships between
the modules.
It represents the functional strength of the It represents the independence among the
modules. modules.
When modules are highly cohesive, a high When the modules are loosely coupled, it
quality software is built. results in a high quality software.
In cohesion, module focuses on the single The modules would be connected to each
thing. other.