Welcome to Edukum.com

# Introduction to Programming

Programming Languages
A programming language is a set of rules that provides a way of telling a computer what operations to perform or it can be defined as is a notational system for describing computation in a machine-readable and human-readable form.
Programming Techniques
Programming Techniques is defined as way or manner in which problem is approached & Code is written. Basically, Programming Techniques can be categorized as follows:

• Unstructured programming
• Procedural Programming
• Modular Programming
• Object-Oriented Programming

Unstructured Programming
Usually, people start learning to program by writing small and simple programs consisting only of one main program. Here  main program'' stands for a sequence of commands or statements which modify data which is global throughout the whole program. We can illustrate this as shown in figure below:

Procedural Programming
Pascal, FORTRAN, C, and similar languages are procedural languages. A program in a procedural language is a list of instructions. Each instruction tells the computer to do something. To write a program, a programmer creates a list of instructions, and the computer carries them out. No other organizing principle or paradigm is needed for writing programs. Later, the concepts of functions and modules were introduced as a part of structured programming to make large programs more comprehensible.

The main program is responsible for passing data to the individual calls, the data is processed by the procedures and, once the program has finished, the resulting data is presented. The main program coordinates call to procedures and hands over appropriate data as parameters.Thus, the flow of data can be illustrated as a hierarchical graph, a tree, as shown in Figure below for a program with no sub procedures.

#### Some issues with procedural programming are:

• Problems with Structured Programming:
As programs grow larger, even structured programming approach begins to show signs of strain. No matter how well the structured programming approach is implemented, the project becomes too complex, the schedule slips, more programmers are needed, and costs skyrocket.
• Data Undervalued
Data is given second-class status in the organization of procedural languages. A global data can be corrupted by functions. Since many functions access the same global data, the way the data is stored becomes critical.
• Relationship to the Real World
Procedural programs are often difficult to design because their chief components – functions and data structures – don’t model the real world very well.
• New Data Types
It is difficult to create new data types with procedural languages. Furthermore, most Procedural languages are not usually extensible and hence procedural programs are more complex to write and maintain.

Modular Programming:
Modular programming (sometimes known as structured programming) is a subset of procedural programming that enforces a top-down design model, in which developers map out the overall program structure into separate subsections to make programs more efficient and easier to understand and modify. A defined function or set of similar functions is coded in a separate module or sub-module, which means that code can be loaded into memory more efficiently and that modules can be reused in other programs. In this technique, program flow follows a simple hierarchical model that employs three types of control flows: sequential, selection, and iteration.(C++ Programming with Object-Oriented Approach

Modular programmingAlmost any language can use structured programming techniques to avoid common pitfalls of unstructured languages. Most modern procedural languages include features that encourage structured programming. Object-oriented programming (OOP) can be thought of as a type of structured programming, uses structured programming techniques for program flow, and adds more structure for data to the model. Some of the better known structured programming languages are Pascal, C, PL/I, and Ada.

• Object – Oriented Programming:
The fundamental idea behind object-oriented programming is to combine or encapsulate both data (or instance variables) and functions (or methods) that operate on that data into a single unit. This unit is called an object. The data is hidden, so it is safe from accidental alteration. An object’s functions typically provide the only way to access its data. In order to access the data in an object, we should know exactly what functions interact with it. No other functions can access the data. Hence OOP focuses on data portion rather than the process of solving the problem.
An object-oriented program typically consists of a number of objects, which communicate with each other by calling one another’s functions. This is called sending a message to the object. This kind of relation is provided with the help of communication between two objects and this communication is done through information called message. In addition, object-oriented programming supports encapsulation, abstraction, inheritance, and polymorphism to write programs efficiently. Examples of object-oriented languages are Java, Python, C#, Simula, Visual Basic .NET, Smalltalk, C++ and Ruby etc. (Object Oriented Programming in C++

#### Reference for Object Model:

Object
Objects are the entities in an object-oriented system through which we perceive the world around us. We naturally see our environment as being composed of things which have recognizable identities & behavior.

Methods
Methods are common operation that object can perform. In earlier paradigms, it was popularly known as Function or Procedure.

Attribute
When describing objects, it is common to make reference to attributes. Attributes describe an object. Attributes are sometimes called fields or instance variables.

State
The term 'state' describes the value of an attribute/instance variable at any given time. The following example shows different attributes for an object, in this case, a train. At any point in time, the attributes will have a state. The state of an attribute is simply its current value.