C-Programming- Introduction to Programming Language
Introduction to programming language
Programming languages are the method used to instruct a computer on how to accomplish a task. A programming language is a collection of operators and instructions, with specific rules or syntax regarding how the instructions are placed together. Various operations can be combined in an almost infinite number of ways to achieve the tasks we want the computer to perform.
It is a formal language comprising a set of instructions that produce various kinds of output. Programming languages are used in computer programming to implement algorithms. Most programming languages consist of instructions for computers.
The programming language is the medium of communication between human and computer systems. It is the set of instructions written in a specific style (coding) to instruct the computer to perform a specific task.
Some programming languages are bound to a particular set of hardware, commonly called "low level" languages. An example of a low level language is Assembly, where the target is for a particular CPU instruction set. Other languages are more abstract from the hardware, and are known as "high level" languages. An example of a high level language is Java.
Programming languages are tools, and every tool has its strengths and weaknesses. While a high-level language isolates a programmer from hardware, the programmer loses the ability to directly control that hardware. Choosing the right tool for a problem is very important.
Characteristics of a programming Language –
- A programming language must be simple, easy to learn and use, have good readability and human recognizable.
- Abstraction is a must-have Characteristics for a programming language in which ability to define the complex structure and then its degree of usability comes. • A portable programming language is always preferred.
- Programming language’s efficiency must be high so that it can be easily converted into a machine code and executed consumes little space in memory.
- A programming language should be well structured and documented so that it is suitable for application development.
- Necessary tools for development, debugging, testing, maintenance of a program must be provided by a programming language.
- A programming language should provide single environment known as Integrated Development Environment (IDE).
- A programming language must be consistent in terms of syntax and semantics.
Types of programming languages
There are two types of programming languages, which can be categorized into the following ways:
- Low level language
- Machine language (1GL)
- Assembly language (2GL)
- High level language
- Procedural-Oriented language (3GL)
- Problem-Oriented language (4GL)
- Natural language (5GL)
1.Low level language
Low level languages are the basic computer instructions or better known as machine codes. A computer cannot understand any instruction given to it by the user in English or any other high-level language. These low-level languages are very easily understandable by the machine.
The main function of low-level languages is to interact with the hardware of the computer. They help in operating, syncing and managing all the hardware and system components of the computer. They handle all the instructions which form the architecture of the hardware systems.
It can be further categorized into:
a. Machine Language (1GL)
This is one of the most basic low-level languages. The language was first developed to interact with the first-generation computers. It is written in binary code or machine code, which means it basically comprises of only two digits – 1 and 0.it is the only one language, that the processor directly understands. Machine language has an Merits of very fast execution speed and efficient use of primary memory.
Advantages
- It is directly understood by the processor so has faster execution time since the programs written in this language need not to be translated.
- It doesn’t need larger memory.
Disadvantages:
- It is very difficult to program using 1GL since all the instructions are to be represented by 0s and 1s.
- Use of this language makes programming time consuming.
- It is difficult to find error and to debug.
- It can be used by experts only.
b. Assembly Language(2GL)
Assembly language is the second-generation programming language. It is also known as low-level language because to design a program programmer requires detailed knowledge of hardware specification. It is a development on the machine language, where instead of using only numbers, we use English words, names, and symbols i.e. it uses mnemonics code (symbolic operation code like ‘ADD’ for addition) in place of 0s and 1s. The program is converted into machine code by assembler. The resulting program is referred to as an object code.
Advantages
- It is makes programming easier than 1GL since it uses mnemonics code for programming. Eg: ADD for addition, SUB for subtraction, DIV for division, etc. • It makes programming process faster.
- Error can be identified much easily compared to 1GL.
- It is easier to debug than machine language.
Disadvantages:
- Programs written in this language is not directly understandable by computer so translators should be used.
- It is hardware dependent language so programmers are forced to think in terms of computer’s architecture rather than to the problem being solved.
- Being machine dependent language, programs written in this language are very less or not portable.
- Programmers must know its mnemonics codes to perform any task.
2.High level language
The programming languages that are close to human languages (example like English languages) are called the high-level languages.
High level language are the machine-independent programming languages, which are easy to write, read, edit, and understand. The examples of high-level languages are: Fortran,COBOL,Basic,Pascal,C,C++,Java etc.
High-level programming languages have special keywords, functions, and class libraries. Using these we can easily build a computer program.The computer does not understand the program written in such languages directly, As the computer understands only Machine code. So, Programming language translators are required to convert a high-level program to its equivalent Machine code.
Programming translators are generally called Compilers and Interpreters. Compilers are the system software that converts a program written in particular programming languages to its equivalent Machine code.
High level language can be further categorized as:
a) Procedural-Oriented language (3GL)
Procedural Programming is a methodology for modelling the problem being solved, by determining the steps and the order of those steps that must be followed in order to reach a desired outcome or specific program state. These languages are designed to express the logic and the procedure of a problem to be solved. It includes languages such as Pascal, COBOL, C, FORTAN, etc.
Procedural languages are also known as third generation languages (3GLs). In a procedural language, a program is designed using procedures. A procedure is a sequence of instructions having a unique name. The instructions of the procedure are executed with the reference of its name.
In procedural programming languages, the program instructions are written in a sequence or in a specific order in which they must be executed to solve a specific problem. It means that the order of program instructions is very important.
This is a type of programming language has well-structured steps and complex procedures within its programming to compose a complete program. It has a systematic order functions and commands to complete a task or a program.
Typically, this type of programming language uses multiple variables, heavy loops and other elements, which separates them from functional programming languages. Functions of procedural language may control variables, other than function’s value returns. For example, printing out information.
Advantages:
- Because of their flexibility, procedural languages are able to solve a variety of problems.
- Programmer does not need to think in term of computer architecture which makes them focused on the problem.
- Programs written in this language are portable.
Disadvantages
- It is easier but needs higher processor and larger memory.
- It needs to be translated therefore its execution time is more.
b) Problem-Oriented language (4GL)
It allows the users to specify what the output should be, without describing all the details of how the data should be manipulated to produce the result. In Problem-Oriented programming languages, the order of program instructions is not important. The importance is given only to, what is to be done. This is one step ahead from 3GL. These are result oriented and include database query language. Eg: Visual Basic, C#, PHP, etc.
The objectives of 4GL are to:
- Increase the speed of developing programs.
- Minimize user’s effort to obtain information from computer.
- Reduce errors while writing programs.
Advantages:
- Programmer need not to think about the procedure of the program. So, programming is much easier.
Disadvantages
- It is easier but needs higher processor and larger memory.
- It needs to be translated therefore its execution time is more.
c) Natural language (5GL)
Natural language are still in developing stage where we could write statements that would look like normal sentences.
Advantages:
- Easy to program.
- Since, the program uses normal sentences, they are easy to understand. • The programs designed using 5GL will have artificial intelligence (AI). • The programs would be much more interactive and interesting.
Disadvantages
- It is slower than previous generation language as it should be completely translated into binary code which is a tedious task.
- Highly advanced and expensive electronic devices are required to run programs developed in 5GL. Therefore, it is an expensive approach.
3) Language processor
Any program written in a high-level language is known as source code. However, computers cannot understand source code. Before it can be run, source code must first be translated into a form which a computer understands.
A language processor or translator is a program that converts source code into machine code.
Generally, there are three types of language processor /translator:
- compilers
- interpreters
- assemblers
Compiler –
The language processor that reads the complete source program written in high level language as a whole in one go and translates it into an equivalent program in machine language is called as a Compiler. Example: C, C++, C#, Java
In a compiler, the source code is translated to object code successfully if it is free of errors. The compiler specifies the errors at the end of compilation with line numbers when there are any errors in the source code. The errors must be removed before the compiler can successfully recompile the source code again.
Compilers have several advantages:
- Compiled programs run quickly, since they have already been translated. • A compiled program can be supplied as an executable file. An executable file is a file that is ready to run. Since an executable file cannot be easily modified, programmers prefer to supply executables rather than source code.
- Compilers optimise code. Optimised code can run quicker and take up less memory space.
- Compilers also have disadvantages:
- The source code must be re-compiled every time the programmer changes the program.
- Source code compiled on one platform will not run on another - the machine code is specific to the processor's architecture.
Assembler –
The Assembler is used to translate the program written in Assembly language into machine code. The source program is a input of assembler that contains assembly language instructions. The output generated by assembler is the object code or machine code understandable by the computer.
Interpreter –
The translation of single statement of source program into machine code is done by language processor and executes it immediately before moving on to the next line is called an interpreter. If there is an error in the statement, the interpreter terminates its translating process at that statement and displays an error message. The interpreter moves on to the next line for execution only after removal of the error. An Interpreter directly executes instructions written in a programming or scripting language without previously converting them to an object code or machine code. Example: Perl, Python and MATLAB.
Interpreters have several advantages:
- Instructions are executed as soon as they are translated.
- Errors can be quickly spotted - once an error is found, the program stops running and the user is notified at which part of the program the interpretation has failed. This makes interpreters extremely useful when developing programs.
- Interpreters also have several disadvantages:
- Interpreted programs run slowly as the processor has to wait for each instruction to be translated before it can be executed.
- Additionally, the program has to be translated every time it is run.
- Interpreters do not produce an executable file that can be distributed. As a result, the source code program has to be supplied, and this could be modified without permission.
- Interpreters do not optimise code - the translated code is executed as it is.
Difference between Compiler and Interpreter –
S.N | Compiler | Interpreter |
1. | A compiler is a program which converts the entire source code of a programming language into executable machine code for a CPU. | interpreter takes a source program and runs it line by line, translating each line as it comes to it. |
2. | Compiler takes large amount of time to analyse the entire source code but the overall execution time of the program is comparatively faster. | Interpreter takes less amount of time to analyse the source code but the overall execution time of the program is slower. |
3. | Compiler generates the error message only after scanning the whole program, so debugging is comparatively hard as the error can be present anywhere in the program. | Its Debugging is easier as it continues translating the program until the error is met |
4. | Generates intermediate object code. | No intermediate object code is generated. |
5. | Examples: C, C++, Java | Examples: Python, Perl |
4) Program Errors
Errors are the problems or the faults that occur in the program, which makes the behaviour of the program abnormal, and experienced developers can also make these faults. Programming errors are also known as the bugs or faults, and the process of removing these bugs is known as debugging. These errors are detected either during the time of compilation or execution. Thus, the errors must be removed from the program for the successful execution of the program.
There are mainly five types of errors exist in C programming:
- Syntax error
- Run-time error
- Linker error
- Logical error
- Semantic error
1.Syntax error
Syntax errors are also known as the compilation errors as they occurred at the compilation time, or we can say that the syntax errors are thrown by the compilers. These errors are mainly occurred due to the mistakes while typing or do not follow the syntax of the specified programming language. These mistakes are generally made by beginners only because they are new to the language. These errors can be easily debugged or corrected. Example
#include < stdio.h>
int main()
{
printf("Hello World")
}
Output:
Commonly occurred syntax errors are:
- If we miss the parenthesis (}) while writing the code.
- Displaying the value of a variable without its declaration.
- If we miss the semicolon (;) at the end of the statement.
2.Run-time error
Sometimes the errors exist during the execution-time even after the successful compilation known as run-time errors. When the program is running, and it is not able to perform the operation is the main cause of the run-time error. The division by zero is the common example of the run-time error. These errors are very difficult to find, as the compiler does not point to these errors.
Example.1
#include < stdio.h>
int main()
{
int a=2;
int b=2/0;
printf("The value of b is : %d", b);
return 0;
}
Output
Example2
#include < stdio.h>
int main()
{
int x = 52;
int y = 0;
printf("Div : %f", x/y);
}
Output :
Program crashes during runtime.
In the above output, we observe that the code shows the run-time error, i.e., division by zero.
3.Linker error
This kind of errors are occurred, when the program is compiled successfully, and trying to link the different object file with the main object file. When this error is occurred, the executable is not generated, For example some wrong function prototyping, incorrect header file etc. If the main() is written as Main(), this will generate linked error.
Example.
#include < stdio.h>
int Main()
{
int a=78;
printf("The value of a is : %d", a);
return 0;
}
Output:
4.Logical error
The logical error is an error that leads to an undesired output. These errors produce the incorrect output, but they are error-free, known as logical errors. These types of mistakes are mainly done by beginners. The occurrence of these errors mainly depends upon the logical thinking of the developer. If the programmers sound logically good, then there will be fewer chances of these errors.
Example.
#include < stdio.h>
int main()
{
int sum=0; // variable initialization
int k=1;
for(int i=1;i<=10;i++); // logical error, as we put the semicolon after loop
{
sum=sum+k;
k++;
}
printf("The value of sum is %d", sum);
return 0;
}
Output
In the above code, we are trying to print the sum of 10 digits, but we got the wrong output as we put the semicolon (;) after the for loop, so the inner statements of the for loop will not execute. This produces the wrong output.
5.Semantic error
Semantic errors are the errors that occurred when the statements are not understandable by the compiler or it occurs due to an improper use of program statements.
The following can be the cases for the semantic error:
- Use of a un-initialized variable.
int i;
i=i+2;
- Type compatibility
int b = "javatpoint";
- Errors in expressions
int a, b, c;
a+b = c;
- Array index out of bound
int a[10];
a[10] = 34;
Example
#include < stdio.h>
int main()
{
int a,b,c;
a=2;
b=3;
c=1;
a+b=c; // semantic error
return 0;
}
In the above code, we use the statement a+b =c, which is incorrect as we cannot use the two operands on the left-side.
Output
5.Feature of good program
Every computer requires appropriate instruction set (programs) to perform the required task. The quality of the processing depends upon the given instructions. If the instructions are improper or incorrect, then it is obvious that the result will be superfluous.
Therefore, proper and correct instructions should be provided to the computer so that it can provide the desired output. Hence, a program should be developed in such a way that it ensures proper functionality of the computer. In addition, a program should be written in such a manner that it is easier to understand the underlying logic.
A good computer program should have following characteristics:
- Portability: Portability refers to the ability of an application to run on different platforms (operating systems) with or without minimal changes. Due to rapid development in the hardware and the software, nowadays platform change is a common phenomenon. Hence, if a program is developed for a particular platform, then the life span of the program is severely affected.
- Readability: The program should be written in such a way that it makes other programmers or users to follow the logic of the program without much effort. If a program is written structurally, it helps the programmers to understand their own program in a better way. Even if some computational efficiency needs to be sacrificed for better readability, it is advisable to use a more user-friendly approach, unless the processing of an application is of utmost importance.
- Efficiency: Every program requires certain processing time and memory to process the instructions and data. As the processing power and memory are the most precious resources of a computer, a program should be laid out in such a manner that it utilizes the least amount of memory and processing time.
- Structural: To develop a program, the task must be broken down into a number of subtasks. These subtasks are developed independently, and each subtask is able to perform the assigned job without the help of any other subtask. If a program is developed structurally, it becomes more readable, and the testing and documentation process also gets easier.
- Flexibility: A program should be flexible enough to handle most of the changes without having to rewrite the entire program. Most of the programs are developed for a certain period and they require modifications from time to time. For example, in case of payroll management, as the time progresses, some employees may leave the company while some others may join. Hence, the payroll application should be flexible enough to incorporate all the changes without having to reconstruct the entire application.
- Generality: Apart from flexibility, the program should also be general. Generality means that if a program is developed for a particular task, then it should also be used for all similar tasks of the same domain. For example, if a program is developed for a particular organization, then it should suit all the other similar organizations.
- Documentation: Documentation is one of the most important components of an application development. Even if a program is developed following the best programming practices, it will be rendered useless if the end user is not able to fully utilize the functionality of the application. A well-documented application is also useful for other programmers because even in the absence of the author, they can understand it.
Different Program Paradigm
Paradigm can also be termed as method to solve some problem or do some task. Programming paradigm is an approach to solve problem using some programming language or also we can say that it is a method to solve a problem using tools and techniques that are available to us.
A programming paradigm is a style, or “way,” of programming. There are lots for programming language that are known but, all of them needs to follow some strategy when they are implemented. Apart from varieties of programming language there are lots of paradigms to fulfil each and every demand. They are discussed below:
- Imperative programming paradigm:
- The imperative paradigm is the oldest and most popular paradigm
- Based on the Von Neumann architecture of computers
- Imperative programs define sequences of commands/statements for the computer that change a program state (i.e., set of variables)
- Commands are stored in memory and executed in the order found
- Commands retrieve data, perform a computation, and assign the result to a memory location
- The hardware implementation of almost all computers is imperative
- Machine code, which is native to the computer, and written in the imperative style
Machine code
8B542408 83FA0077 06B80000 C9010000 008D0419 83FA0376 B84AEBF1 5BC3
Central elements of imperative paradigm:
- Assignment statement: assigns values to memory locations and changes the current state of a program
- Variables refer to memory locations
- Step-by-step execution of commands
- Control-flow statements: Conditional and unconditional (GO TO) branches and loops to change the flow of a program
Example of computing the factorial of a number:
unsigned int n = 5;
unsigned int result = 1;
while(n > 1)
{
result *= n;
n--;
}
Advantage:
- Very simple to implement
- It contains loops, variables etc.
Disadvantage:
- Complex problem cannot be solved
- Less efficient and less productive
- Parallel programming is not possible
Examples of Imperative programming paradigm:
C: developed by Dennis Ritchie and Ken Thompson
Fortan: developed by John Backus for IBM
Basic: developed by John G Kemeny and Thomas E Kurtz
Example:
// average of four number in C
#include
int main(){
int marks[4]={10,11,12,13};
int sum=0;
float average;
for (int i=0;i<4;i++){
sum=sum+marks[i];
}
average=sum/4;
printf("The average is %f",average);
return 0;
}
Imperative programming is divided into three broad categories:
- Procedural
- OOP and
- Parallel processing.
Procedural programming paradigm
- Procedural programming is a refinement of the imperative paradigm adding subroutines (or procedures)
- Procedures can be used the same way that built-in commands are used (allows re-usability)
- Some state changes are localized in this way
- Creating a procedure from the previous example:
int factorial (unsigned int n)
{
unsigned int result = 1;
while(n > 1)
{
result *= n; n--;
}
return result;
}
Examples of Procedural programming paradigm:
C: developed by Dennis Ritchie and Ken Thompson
C++: developed by Bjarne Stroustrup
Java: developed by James Gosling at Sun Microsystems
ColdFusion: developed by J J Allaire
Pascal: developed by Niklaus Wirth
Example: Find factorial of given number using C++
#include
using namespace std;
int main()
{
int i, fact = 1, num;
cout << "Enter any Number: ";
cin >> number;
for (i = 1; i <= num; i++) {
fact = fact * i;
}
cout << "Factorial of " << num << " is: " << fact << endl;
return 0;
}
Object oriented programming:
The program is written as a collection of classes and object, which are meant for communication. The smallest and basic entity is object and all kind of computation is performed on the objects only. More emphasis is on data rather procedure. It can handle almost all kind of real-life problems which are today in scenario.
Advantages:
- Data security
- Inheritance
- Code reusability
- Flexible and abstraction is also present
Examples of Object-Oriented programming paradigm:
Simula: first OOP language
Java: developed by James Gosling at Sun Microsystems
C++: developed by Bjarne Stroustrup
Objective-C: designed by Brad Cox
Visual Basic .NET: developed by Microsoft
Python: developed by Guido van Rossum
Ruby: developed by Yukihiro Matsumoto
Smalltalk: developed by Alan Kay, Dan Ingalls, Adele Goldberg
Example: use of object and class in java
import java.io.*;
//Defining a Student class.
class Student{
int id=1; //field or data member or instance variable
String name="Ram";
//creating main method inside the Student class
public static void main(String args[]){
Student s1=new Student();//creating an object of Student
//Printing values of the object
System.out.println(s1.id);
//accessing member through reference variable
System.out.println(s1.name);
}
}
Parallel processing approach
Parallel processing is the processing of program instructions by dividing them among multiple processors. A parallel processing system posse many numbers of processor with the objective of running a program in less time by dividing them. This approach seems to be like divide and conquer.
Examples are NESL (Nested Data-Parallel Language) one of the oldest parallel processing language and C/C++ also supports because of some library function.
- Declarative programming paradigm
declarative programming is a style of building programs that expresses logic of computation without talking about its control flow. It often considers programs as theories of some logic. It may simplify writing parallel programs. The focus is on what needs to be done rather how it should be done, basically emphasize on what code is actually doing. It just declare the
result we want rather how it has be produced. This is the only difference between imperative (how to do) and declarative (what to do) programming paradigms.
Declarative programming is futher divided into three broad categories:
- Logic programming paradigms:
- Functional programming paradigms
- Database/Data driven programming approach
Logic programming paradigms:
Logic Programming is a computer programming paradigm in which program statement express facts and rules about problems within a system of formal logic. Rules are written as logical clauses with a head and a body; for instance, "H is true if B1, B2, and B3 are true." Facts are expressed similar to rules, but without a body; for instance, "H is true." Some logic programming languages, such as Datalog and ASP (Answer Set Programming), are purely declarative. They allow for statements about what the program should accomplish, with no explicit step-by-step instructions on how to do so. Others, such as Prolog, are a combination of declarative and imperative. They may also include procedural statements, such as "To solve H, solve B1, B2, and B3."
Functional programming paradigms
Functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that each return a value, rather than a sequence of imperative statements which change the state of the program.
The functional programming paradigms has its roots in mathematics and it is language independent. The key principal of this paradigms is the execution of series of mathematical functions. The central model for the abstraction is the function which are meant for some specific computation and not the data structure. The function hide their implementation. Function can be replaced with their values without changing the meaning of the program. Some of the languages like perl, javascript mostly uses this paradigm.
Examples of Functional programming paradigm:
JavaScript: developed by Brendan Eich
Haskwell: developed by Lennart Augustsson, Dave Barton
Scala: developed by Martin Odersky
Erlang: developed by Joe Armstrong, Robert Virding
Lisp: developed by John Mccarthy
ML: developed by Robin Milner
Clojure: developed by Rich Hickey
Database/Data driven programming approach
This programming methodology is based on data and its movement. Program statements are defined by data rather than hard-coding a series of steps. A database program is the heart of a business information system and provides file creation, data entry, update, query and reporting functions. There are several programming languages that are developed mostly for database application.
For example SQL. It is applied to streams of structured data, for filtering, transforming, aggregating (such as computing statistics), or calling other programs. So it has its own wide application.
CREATE DATABASE databaseAddress;
CREATE TABLE Addr
(
PersonID int,
LastName varchar(200),
FirstName varchar(200),
Address varchar(200),
City varchar(200),
State varchar(200)
);
Software Development Models:
The software development models are the methodologies that are being selected for the development of the project depending on the project’s aims and goals. There are many development life cycle models that have been developed in order to achieve different required objectives. The models specify the various stages of the process and the order in which they are carried out.
The selection of model has very high impact on the testing that is carried out. It will define the what, where and when of our planned testing, influence regression testing and largely determines which test techniques to use.
There are various Software development models or methodologies. They are as follows:
- Waterfall Model
- V-Shaped Model
- Evolutionary Prototyping Model
- Spiral Model
- Iterative and Incremental Model
- Agile development Model
Waterfall Model
The Waterfall Model is a linear sequential flow. In which progress is seen as flowing steadily downwards (like a waterfall) through the phases of software implementation. This means that any phase in the development process begins only if the previous phase is complete. The waterfall approach does not define the process to go back to the previous phase to handle changes in requirement. The waterfall approach is the earliest approach and most widely known that was used for software development.
Projects which not focus on changing the requirements, for example, projects initiated from a request for proposals (RFPs), the customer has a very clear documented requirements.
Advantages
- Easy to explain to the users.
- Structures approach.
- Stages and activities are well defined.
- Helps to plan and schedule the project.
- Verification at each stage ensures early detection of errors/misunderstanding. • Each phase has specific deliverables
Disadvantages
- Assumes that the requirements of a system can be frozen.
- Very difficult to go back to any stage after it finished.
- A little flexibility and adjusting scope is difficult and expensive.
- Costly and required more time, in addition to the detailed plan
V-Shaped Model
It is an extension of the waterfall model, instead of moving down in a linear way, the process steps are bent upwards after the implementation and coding phase, to form the typical V shape. The major difference between the V-shaped model and waterfall model is the early test planning in the V-shaped model.
This model is used when Software requirements clearly defined and known and Software development technologies and tools are well-known.
Advantages
- Simple and easy to use
- Each phase has specific deliverables.
- Higher chance of success over the waterfall model due to the development of test plans early on during the life cycle.
- Works well for where requirements are easily understood.
- Verification and validation of the product in the early stages of product development.
Disadvantages
- Very inflexible, like the waterfall model.
- Adjusting scope is difficult and expensive.
- The software is developed during the implementation phase, so no early prototypes of the software are produced.
- The model doesn’t provide a clear path for problems found during testing phases. • Costly and required more time, in addition to a detailed plan
Prototyping Model
The Prototyping Model is one of the most popularly used Software Development Life Cycle Models (SDLC models). This model is used when the customers do not know the exact project requirements beforehand. In this model, a prototype of the end product is first developed, tested and refined as per customer feedback repeatedly till a final acceptable prototype is achieved which forms the basis for developing the final product.
It is an activity that can occur in software development and It is used to visualize some component of the software to limit the gap of misunderstanding the customer requirements by the development team. This also will reduce the iterations may occur in the waterfall approach and hard to be implemented due to the inflexibility of the waterfall approach.
The prototyping model is a method of system development in which a prototype is created, tested and then reconstructed as necessary until an appropriate result is attained by which to develop the complete system or product. Based on the requirements, the design is created and prototype for particular design is modelled and delivered to the users, then based on the feedback form the user the appropriate changes has been done.
Phases of the Prototyping Model
The different phases are as follow:
Communication: This is the phase where the developer and Client set up the meeting and talk about the objectives that need to be achieved for the software.
Design: The design has been done quickly as the requirements are cleared from both ends in providing and receiving end. It is used to construct the prototype. It includes the important aspects of the software that is input and output but mainly focused on visible aspects than planned activities.
Modelling: It provides a better idea of the requirement to develop the software and a better understanding of the software product.
Deployment: Before deployment, the client evaluates the software and if the client is not satisfied then it is refined according to the client’s requirements. This process goes on until the point client requirements do not accomplish. After the client’s satisfaction with the
product, the product finally deploys to the production environment. It is thoroughly evaluated and tested, and maintenance is done on a regular basis.
It has some types, such as:
Rapid Throwaway prototyping:
Rapid throwaway is based on the preliminary requirement. It is quickly developed to show how the requirement will look visually. The customer's feedback helps drives changes to the requirement, and the prototype is again created until the requirement is baselined.
In this method, a developed prototype will be discarded and will not be a part of the ultimately accepted prototype. This technique is useful for exploring ideas and getting instant feedback for customer requirements.
Evolutionary prototyping:
In this method, the prototype developed initially is incrementally refined on the basis of customer feedback till it finally gets accepted. In comparison to Rapid Throwaway Prototyping, it offers a better approach which saves time as well as effort. This is because developing a prototype from scratch for every iteration of the process can sometimes be very frustrating for the developers.
Fig:-Evolutionary prototyping model
Incremental prototyping:
In incremental Prototyping, the final product is decimated into different small prototypes and developed individually. Eventually, the different prototypes are merged into a single product. This method is helpful to reduce the feedback time between the user and the application development team.
Extreme prototyping:
Extreme prototyping method is mostly used for web development. It is consisting of three sequential phases.
1) Basic prototype with all the existing page is present in the HTML format. 2) You can simulate data process using a prototype services layer.
3) The services are implemented and integrated into the final prototype.
The advantages of the Prototyping Model are as follows −
- Increased user involvement in the product even before its implementation. • Since a working model of the system is displayed, the users get a better understanding of the system being developed.
- Reduces time and cost as the defects can be detected much earlier.
- Quicker user feedback is available leading to better solutions.
- Missing functionality can be identified easily.
- Confusing or difficult functions can be identified.
The Disadvantages of the Prototyping Model are as follows −
- Risk of insufficient requirement analysis owing to too much dependency on the prototype.
- Users may get confused in the prototypes and actual systems.
- Practically, this methodology may increase the complexity of the system as scope of the system may expand beyond original plans.
- Developers may try to reuse the existing prototypes to build the actual system, even when it is not technically feasible.
- The effort invested in building prototypes may be too much if it is not monitored properly.
Spiral Model (SDM)
Spiral model is one of the most important Software Development Life Cycle models, which provides support for Risk Handling. it looks like a spiral with many loops. The exact number of loops of the spiral is unknown and can vary from project to project. Each loop of the spiral is called a Phase of the software development process. The exact number of phases needed to develop the product can be varied by the project manager depending upon the project risks.
The Radius of the spiral at any point represents the expenses(cost) of the project so far, and the angular dimension represents the progress made so far in the current phase. Below diagram shows the different phases of the Spiral Model:
Each phase of Spiral Model is divided into four quadrants as shown in the above figure. The functions of these four quadrants are discussed below
- Objectives determination and identify alternative solutions: In this phase , requirements are gathered from the customers and the objectives are identified, elaborated and analysed at the start of every phase. Then alternative solutions possible for the phase are proposed in this quadrant.
- Identify and resolve Risks: this phase lies in the second quadrant where all the possible solutions are evaluated to select the best possible solution. Then the risks associated with that solution is identified and the risks are resolved using the best possible strategy. At the end of this quadrant, Prototype is built for the best possible solution.
- Develop next version of the Product: this phase lies in the third quadrant, in this phase the identified features are developed and verified through testing. At the end of the third quadrant, the next version of the software is available.
- Review and plan for the next Phase: In the fourth quadrant, the Customers evaluate the so far developed version of the software. In the end, planning for the next phase is started.
Advantages of Spiral model:
- High amount of risk analysis hence, avoidance of Risk is enhanced. • Good for large and mission-critical projects.
- Strong approval and documentation control.
- Additional Functionality can be added at a later date.
- Software is produced early in the software life cycle.
Disadvantages of Spiral model:
- Can be a costly model to use.
- Risk analysis requires highly specific expertise.
- Project’s success is highly dependent on the risk analysis phase.
- Doesn’t work well for smaller projects.
When to use Spiral model:
- When costs and risk evaluation is important
- For medium to high-risk projects
- Long-term project commitment unwise because of potential changes to economic priorities
- Users are unsure of their needs
- Requirements are complex
- New product line
- Significant changes are expected (research and exploration)
Iterative and Incremental Model
It is developed to overcome the weaknesses of the waterfall model. It starts with an initial planning and ends with deployment with the cyclic interactions in between. The basic idea behind this method is to develop a system through repeated cycles (iterative) and in smaller portions at a time (incremental), allowing software developers to take advantage of what was learned during the development of earlier parts or versions of the system. It can consist of mini waterfalls or mini V-Shaped model
In an Iterative Incremental model, initially, a partial implementation of a total system is constructed so that it will be in a deliverable state. Increased functionality is added. Defects, if any, from the prior delivery are fixed and the working product is delivered. The process is repeated until the entire product development is completed. The repetitions of these processes are called iterations. At the end of every iteration, a product increment is delivered.
The advantages of Iterative Incremental model −
- You can develop prioritized requirements first.
- Initial product delivery is faster.
- Customers gets important functionality early.
- Lowers initial delivery cost.
- Each release is a product increment, so that the customer will have a working product at hand all the time.
- Customer can provide feedback to each product increment, thus avoiding surprises at the end of development.
- Requirements changes can be easily accommodated.
The disadvantages of the Iterative Incremental model are −
- Requires effective planning of iterations.
- Requires efficient design to ensure inclusion of the required functionality and provision for changes later.
- Requires early definition of a complete and fully functional system to allow the definition of increments.
- Well-defined module interfaces are required, as some are developed long before others are developed.
- Total cost of the complete system is not lower.
When to Use Iterative Incremental Model?
Iterative Incremental model can be used when −
- Most of the requirements are known up-front but are expected to evolve over time. • The requirements are prioritized.
- There is a need to get the basic functionality delivered fast.
- A project has lengthy development schedules.
- A project has new technology.
- The domain is new to the team.
Agile Model:
In earlier days Iterative Waterfall model was very popular to complete a project. But nowadays developers face various problems while using it to develop a software. The main difficulties included handling change requests from customers during project development
and the high cost and time required to incorporate these changes. To overcome these drawbacks of Waterfall model, in the mid-1990s the Agile Software Development model was proposed.
The Agile model was primarily designed to help a project to adapt to change requests quickly. So, the main aim of the Agile model is to facilitate quick project completion. To accomplish this task agility is required. Agility is achieved by fitting the process to the project, removing activities that may not be essential for a specific project. Also, anything that is wastage of time and effort is avoided.
Agile model is a combination of iterative and incremental process models with focus on process adaptability and customer satisfaction by rapid delivery of working software product. Agile Methods break the product into small incremental builds. These builds are provided in iterations. Each iteration typically lasts from about one to three weeks. Every iteration involves cross functional teams working simultaneously on various areas like −
- Planning
- Requirements Analysis
- Design
- Coding
- Unit Testing and Acceptance Testing.
At the end of the iteration, a working product is displayed to the customer and important stakeholders.
Here is a graphical illustration of the Agile Model –
Agile model believes that every project needs to be handled differently and the existing methods need to be tailored to best suit the project requirements. In Agile, the tasks are divided to time boxes (small time frames) to deliver specific features for a release. Iterative approach is taken and working software build is delivered after each iteration. Each build is incremental in terms of features; the final build holds all the features required by the customer.
Advantages of Agile model:
- Customer satisfaction by rapid, continuous delivery of useful software. • People and interactions are emphasized rather than process and tools. Customers, developers and testers constantly interact with each other.
- Working software is delivered frequently (weeks rather than months). • Face-to-face conversation is the best form of communication.
- Close, daily cooperation between business people and developers.
- Continuous attention to technical excellence and good design.
- Regular adaptation to changing circumstances.
- Even late changes in requirements are welcomed
Disadvantages of Agile model:
- In case of some software deliverables, especially the large ones, it is difficult to assess the effort required at the beginning of the software development life cycle. • There is lack of emphasis on necessary designing and documentation. • The project can easily get taken off track if the customer representative is not clear what final outcome that they want.
- Only senior programmers are capable of taking the kind of decisions required during the development process. Hence it has no place for newbie programmers, unless combined with experienced resources.
When to use Agile model:
- When new changes are needed to be implemented. The freedom agile gives to change is very important. New changes can be implemented at very little cost because of the frequency of new increments that are produced.
- To implement a new feature the developers, need to lose only the work of a few days, or even only hours, to roll back and implement it.
- Unlike the waterfall model in agile model very limited planning is required to get started with the project. Agile assumes that the end users’ needs are ever changing in a dynamic business and IT world. Changes can be discussed and features can be newly effected or removed based on feedback. This effectively gives the customer the finished system they want or need.
- Both system developers and stakeholders alike, find they also get more freedom of time and options than if the software was developed in a more rigid sequential way. Having options gives them the ability to leave important decisions until more or better data or even entire hosting programs are available; meaning the project can continue to move forward without fear of reaching a sudden standstill.
Agile Testing Methods:
- Scrum
- Crystal
- Dynamic Software Development Method(DSDM)
- Feature Driven Development(FDD)
- Lean Software Development
- eXtreme Programming(XP)
Program Development Life Cycle:
When we want to develop a program using any programming language, we follow a sequence of steps. These steps are called phases in program development. The program development life cycle is a set of steps or phases that are used to develop a program in any programming language.
It is a systematic way of developing quality software. It provides an organized plan for breaking down the task of program development into manageable chunks, each of which must be successfully completed before moving on to the next phase.
Generally, the program development life cycle contains 6 phases, they are as follows:
- Problem Definition
- Problem Analysis
- Algorithm Development
- Coding & Documentation
- Testing & Debugging
- Maintenance
- Problem Definition
In this phase, we define the problem statement and we decide the boundaries of the problem. In this phase we need to understand the problem statement, what is our requirement, what should be the output of the problem solution. These are defined in this first phase of the program development life cycle.
- Problem Analysis
In phase 2, we determine the requirements like variables, functions, etc. to solve the problem. That means we gather the required resources to solve the problem defined in the problem definition phase. We also determine the bounds of the solution.
- Algorithm Development
During this phase, we develop a step by step procedure to solve the problem using the specification given in the previous phase. This phase is very important for program development. That means we write the solution in step by step statements.
- Coding & Documentation
This phase uses a programming language to write or implement the actual programming instructions for the steps defined in the previous phase. In this phase, we construct the actual program. That means we write the program to solve the given problem using programming languages like C, C++, Java, etc.,
- Testing & Debugging
During this phase, we check whether the code written in the previous step is solving the specified problem or not. That means we test the program whether it is solving the problem for various input data values or not. We also test whether it is providing the desired output or not.
- Maintenance
During this phase, the program is actively used by the users. If any enhancements found in this phase, all the phases are to be repeated to make the enhancements. That means in this phase, the solution (program) is used by the end-user. If the user encounters any problem or wants any enhancement, then we need to repeat all the phases from the starting, so that the encountered problem is solved or enhancement is added.
System Design tool
What is a System?
The word System is derived from Greek word Systema, which means an organized relationship between any set of components to achieve some common cause or objective.
A system is “an orderly grouping of interdependent components linked together according to a plan to achieve a specific goal.”
Constraints of a System
A system must have three basic constraints:
- A system must have some structure and behaviour which is designed to achieve a predefined objective.
- Interconnectivity and interdependence must exist among the system components. 3. The objectives of the organization have a higher priority than the objectives of its subsystems. For example, traffic management system, payroll system, automatic library system, human resources information system.
Systems development
Systems development is systematic process which includes phases such as planning, analysis, design, deployment, and maintenance. Here, primarily focus on:
- Systems analysis
- Systems design
Systems Analysis
System Analysis is the process that decomposes a system into its component pieces for the purpose of defining how well those components interact to accomplish the set requirements.
It is a process of collecting and interpreting facts, identifying the problems, and decomposition of a system into its components.
System analysis is conducted for the purpose of studying a system or its parts in order to identify its objectives. It is a problem-solving technique that improves the system and ensures that all the components of the system work efficiently to accomplish their purpose. Analysis specifies what the system should do.
Systems Design
Systems design is the process of defining the architecture, modules, interfaces, and data for a system to satisfy specified requirements. Systems design could be seen as the application of systems theory to product development.
It is a process of planning a new business system or replacing an existing system by defining its components or modules to satisfy the specific requirements. Before planning, you need to understand the old system thoroughly and determine how computers can best be used in order to operate efficiently.
The purpose of the System Design process is to provide sufficient detailed data and information about the system and its system elements to enable the implementation consistent with architectural entities as defined in models and views of the system architecture.
System Design focuses on how to accomplish the objective of the system. System Analysis and Design (SAD) mainly focuses on:
- Systems
- Processes
- Technology
Systems Analysis and Design is an active field in which analysts repetitively learn new approaches and different techniques for building the system more effectively and efficiently. The primary objective of systems analysis and design is to improve organizational systems.
Elements of a System
The following diagram shows the elements of a system:
Outputs and Inputs
- The main aim of a system is to produce an output which is useful for its user. • Inputs are the information that enters into the system for processing. • Output is the outcome of processing.
Processor(s)
- The processor is the element of a system that involves the actual transformation of input into output.
- It is the operational component of a system. Processors may modify the input either totally or partially, depending on the output specification.
- As the output specifications change, so does the processing. In some cases, input is also modified to enable the processor for handling the transformation.
Control
- The control element guides the system.
- It is the decision–making subsystem that controls the pattern of activities governing input, processing, and output.
- The behaviour of a computer System is controlled by the Operating System and software. In order to keep system in balance, what and how much input is needed is determined by Output Specifications.
Feedback
- Feedback provides the control in a dynamic system.
- Positive feedback is routine in nature that encourages the performance of the system. • Negative feedback is informational in nature that provides the controller with information for action.
Environment
- The environment is the “supersystem” within which an organization operates. • It is the source of external elements that strike on the system.
- It determines how a system must function. For example, vendors and competitors of organization’s environment, may provide constraints that affect the actual performance of the business.
Boundaries and Interface
- A system should be defined by its boundaries. Boundaries are the limits that identify its components, processes, and interrelationship when it interfaces with another system.
- Each system has boundaries that determine its sphere of influence and control. • The knowledge of the boundaries of a given system is crucial in determining the nature of its interface with other systems for successful design.
Some of the major system design tools are as flows:
1.Data Flow Diagram
Data flow diagram is graphical representation of flow of data in an information system. It is capable of depicting incoming data flow, outgoing data flow and stored data. The DFD does not mention anything about how data flows through the system.
There is a prominent difference between DFD and Flowchart. The flowchart depicts flow of control in program modules. DFDs depict flow of data in the system at various levels. DFD does not contain any control or branch elements.
Types of DFD
Data Flow Diagrams are either Logical or Physical.
Logical DFD - This type of DFD concentrates on the system process, and flow of data in the system. For example, in a Banking software system, how data is moved between different entities.
Physical DFD - This type of DFD shows how the data flow is actually implemented in the system. It is more specific and closer to the implementation.
DFD Components:
DFD can represent Source, destination, storage and flow of data using the following set of components –
Entities - Entities are source and destination of information data. Entities are represented by a rectangle with their respective names.
Process - Activities and action taken on the data are represented by Circle or Round-edged rectangles.
Data Storage - There are two variants of data storage - it can either be represented as a rectangle with absence of both smaller sides or as an open-sided rectangle with only one side missing.
Data Flow - Movement of data is shown by pointed arrows. Data movement is shown from the base of arrow as its source towards head of the arrow as destination.
Levels of DFD
Level 0 - Highest abstraction level DFD is known as Level 0 DFD, which depicts the entire information system as one diagram concealing all the underlying details. Level 0 DFDs are also known as context level DFDs.
Level 1 - The Level 0 DFD is broken down into more specific, Level 1 DFD. Level 1 DFD depicts basic modules in the system and flow of data among various modules. Level 1 DFD also mentions basic processes and sources of information.
Level 2 - At this level, DFD shows how data flows inside the modules mentioned in Level 1. Higher level DFDs can be transformed into more specific lower level DFDs with deeper level of understanding unless the desired level of specification is achieved.
Entity-Relationship Model
Entity-Relationship model is a type of database model based on the notion of real world entities and relationship among them. We can map real world scenario onto ER database model. ER Model creates a set of entities with their attributes, a set of constraints and relation among them.
ER Model is best used for the conceptual design of database. ER Model can be represented as follows :
Entity - An entity in ER Model is a real world being, which has some properties called attributes. Every attribute is defined by its corresponding set of values, called domain. For example, Consider a school database. Here, a student is an entity. Student has various attributes like name, id, age and class etc.
Relationship - The logical association among entities is called relationship. Relationships are mapped with entities in various ways. Mapping cardinalities define the number of associations between two entities.
Mapping cardinalities:
- one to one
- one to many
- many to one
- many to many
Context Diagram:
- The system context diagram (also known as a level 0 DFD) is the highest level in a data flow diagram and contains only one process, representing the entire system, which establishes the context and boundaries of the system to be modeled.
- It identifies the flows of information between the system and external entities (i.e. actors). A context diagram is typically included in a requirements document. It must be read by all project stakeholders and thus should be written in plain language, so the stakeholders can understand items.
- The context diagram is used to establish the context and boundaries of the system to be model, which things are inside and outside of the system being model, and what is the relationship of the system with these external entities.
- A context diagram, sometimes called a level 0 data-flow diagram, is drawn in order to define and clarify the boundaries of the software system. It identifies the flows of information between the system and external entities. The entire software system is shown as a single process.
The Purpose of a System Context Diagram
- The objective of the system context diagram is to focus attention on external factors and events that should be considered in developing a complete set of systems requirements and constraints. A system context diagram is often used early in a project to determine the scope under investigation. Thus, within the document.
- A system context diagram represents all external entities that may interact with a system. The entire software system is shown as a single process. Such a diagram pictures the system at the centre, with no details of its interior structure, surrounded by all its External entities, interacting systems, and environments.
System Context Diagram Example – Hotel reservation system
- This example shows the requirements of a computerized system that distributes and stores information of a hotel which enables hotel managers in managing their sales and online marketing, enabling them to upload their room rates and room available which can be easily seen by their sales channels. Sales channels may include online travel agencies, as well as conventional travel agencies.
Programming
Structure Charts
Structure chart is a chart derived from Data Flow Diagram. It represents the system in more detail than DFD. It breaks down the entire system into lowest functional modules, describes functions and sub-functions of each module of the system to a greater detail than DFD. Structure chart represents hierarchical structure of modules. At each layer a specific task is performed.
Structure Chart partitions the system into black boxes . Inputs are given to the black boxes and appropriate outputs are generated.
Modules at top level called modules at low level. Components are read from top to bottom and left to right. When a module calls another, it views the called module as black box, passing required parameters and receiving results.
Here are the symbols used in construction of structure charts
Module - It represents the process or task of the system. It is of three types. • Control Module
A control module branches to more than one sub module.
- Sub Module
Sub Module is a module which is the part (Child) of another module.
- Library Module
Library Module are reusable and invokable from any module.
Condition - It is represented by small diamond at the base of module. It depicts that control module can select any of sub-routine based on some condition.
Jump - An arrow is shown pointing inside the module to depict that the control will jump in the middle of the sub-module.
Loop - A curved arrow represents loop in the module. All sub-modules covered by loop repeat execution of module.
Data flow - A directed arrow with empty circle at the end represents data flow.
Control flow - A directed arrow with filled circle at the end represents control flow.
Physical Storage
Physical Storage is that where all the information are to be stored.
Example: Structure chart for an Email server
========================== End of Unit-1 ==========================