Sunday, August 6, 2017

Modular Programming

What is Modular Programming?

Modular programming is the process of breaking down a problem into smaller tasks. These tasks can then be broken down into sub-tasks.

Modular programming is an important and beneficial approach to programming problems.

Example

Following diagram is showing how we can divide a task into sub-tasks.

Benefits of modular programming

Distributed development

Modular programming allows distributed development. By breaking down the problem into multiple tasks, different developers can work in parallel. And this will shorten the development time.

Code re-usability

A program modules can be reused in the programs. This is a convenient feature because it reduces redundant code. Modules can also be reused in future projects. It is much easier to reuse a module than recreate program logic from scratch.

Program readability

Modular programming leads to more readable programs. Modules can be implemented as user defined functions. A programs with a plenty of functions is straightforward. But a program with no functions can be very long and hard to follow.

Manageable task

Breaking down a programming project into modules makes it more manageable. These individual modules are easier to design, implement and test. Then you can use these modules to construct the overall program.

Procedural Programming (Procedure Oriented Programming)

What is Procedural Programming?


Conventional programming, using high level languages such as COBOL, FORTRAN and C, is commonly known as procedural programming. In this programming approach, the problem is viewed as a sequence of things to be done such as reading, calculating and printing. A number of functions are written to accomplish this task. The primary focus is on functions.
A program in a procedural language is a list of instruction where each statement tells the computer to do something. It focuses on procedure (function) & algorithm is needed to perform the derived computation.When program become larger, it is divided into function & each function has clearly defined purpose.
The first major procedural programming languages first appeared circa 1960, including Fortran, ALGOL, COBOL and BASIC. Pascal and C were published closer to the 1970s.


Characteristics of Procedural Programming:-

  1. It focuses on process rather than data.
  2. It takes a problem as a sequence of things to be done such as reading, calculating and printing. Hence, a number of functions are written to solve a problem.
  3. A program is divided into a number of functions and each function has clearly defined purpose.
  4. Most of the functions share global data.
  5. Data moves openly around the system from function to function.

Drawback of Procedural Programming:-

  1. It emphasis on doing things. Data is given a second class status even through data is the reason for the existence of the program.
  1. Since every function has complete access to the global variables, the new programmer can corrupt the data accidentally by creating function. Similarly, if new data is to be added, all the function needed to be modified to access the data.
  1. It is often difficult to design because the components function and data structure do not model the real world.

Imperative programming

Procedural programming languages are also imperative languages, because they make explicit references to the state of the execution environment. This could be anything from variables (which may correspond to processor registers) to something like the position of the "turtle" in the Logo programming language.
Often, the terms "procedural programming" and "imperative programming" are used synonymously. However, procedural programming relies heavily on blocks and scope, whereas imperative programming as a whole may or may not have such features. As such, procedural languages generally use reserved words that act on blocks, such as if, while, and for, to implement control flow, whereas non-structured imperative languages use goto statements and branch tables for the same purpose.

Tuesday, August 1, 2017

Flowchart

What is a flowchart?

A flowchart is a pictorial representation of an algorithm. A flowchart is a visual representation of the sequence of steps and decisions needed to perform a process. Each step in the sequence is noted within a diagram shape. Steps are linked by connecting lines and directional arrows. This allows anyone to view the flowchart and logically follow the process from beginning to end. Flowcharts are used in designing and documenting simple processes or programs. Like other types of diagrams, they help visualize what is going on and thereby help understand a process, and perhaps also find flaws, bottlenecks, and other less-obvious features within it. 

The main advantage of flowcharts in programming is that, while drawing a flowchart, a programmer need not pay attention to the details of the elements of any programming language. Hence, he/she can fully concentrate on the logic of the solution to problem at hand.

Flowchart Symbols

Image result

Sample Flowchart

Image result for flowchart examples











Difference Between Compiler and Interpreter

Interpreter

Compiler

Translates program one statement at a time.Scans the entire program and translates it as a whole into machine code.
It takes less amount of time to analyze the source code but the overall execution time is slower.It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.
No intermediate object code is generated, hence are memory efficient.Generates intermediate object code which further requires linking, hence requires more memory.
Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.
Programming language like Python, Ruby use interpreters.Programming language like C, C++ use compilers.












VigLink badge