Thursday, 14 February 2019

PROGRAMMING PARADIGMS



INTRODUCTION
When the time passed, different ways of writing code is introduced. Programming paradigms classify them based on their features and characteristics. There are several types of programming paradigms. They are non-structured programming, structured programming, event-driven programming and etc. Also we can divide structured programming part as functional programming and object oriented programming. Also one programming paradigm can classified into multiple categories. E.g.; OOP is structured and also imperative language.

NON-STRUCTURED PROGRAMMING
Non-structured programming paradigms are the ones that use earlier times. It is very difficult to code because of number of lines are increased. So that it becomes more complex. In this non-structured programming it use GOTO statements. BASIC, FORTRAN, COBOL are the example for non-structured programming.

STRUCTURED PROGRAMMING
When we consider about the structured programming, it avoids the problems in non-structured programming. In the structured programming it introducing the way to structure the code using blocks. This structure use functions, procedures, methods, classes and modules.

FUNCTIONAL PROGRAMMING
In computer sciencefunctional programming is a programming paradigm a style of building the structure and elements of computer programs that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements. Functional code is idempotent, the output value of a function depends only on the arguments that are passed to the function, so calling a function f twice with the same value for an argument x produces the same result f(x) each time; this is in contrast to procedures depending on a local or global state, which may produce different results at different times when called with the same arguments but a different program state.

Functional programming use declarative approach. It does not describes how to accomplish the task as a sequence of the programming language primitives. This also helps to minimize the side effects. Functional programming language have largely been emphasized in academic rather than in commercial software development.


LAMBDA CALCULUS
Lambda calculus is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation that can be used to simulate any Turing machine. It was first introduced by mathematician Alonzo Church in the 1930s as part of his research of the foundations of mathematics. Lambda calculus consists of constructing lambda terms and performing reduction operations on them.

PROCEDURAL PROGRAMMING
Procedural programming can be defined as a sub type of imperative programming as a programming paradigms based upon the concept of procedure calls, in which statements are structured into procedures (also known as subroutines or functions). Procedure calls are modular and are bound by scope. Procedural programming paradigms helps to structure the code using blocks called procedures, routines, functions and methods. A procedure can implement a single algorithm using control structure. This use imperative approach. This programming paradigms has side effects.

EVENT-DRIVEN PROGRAMMING
In computer programmingevent-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs or threads. Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g., JavaScript web applications) that are centered on performing certain actions in response to user input. This is also true of programming for device drivers.

This is mainly focus on the events triggered outside the system. Also this is one of mostly related to the systems with GUI's where the users can interact with the GUI elements. This use event-listener (event handlers) to act when the events are triggered. Also an internal event loop (main loop) is used to identify the events and then call the necessary handlers. This can be seen as inversing the control to the event machine.   


DECLARATIVE AND IMPERATIVE PARADIGMS
Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms.

Some paradigms are concerned mainly with implications for the execution model of the language, such as allowing side effects, or whether the sequence of operations is defined by the execution model. Other paradigms are concerned mainly with the way that code is organized, such as grouping a code into units along with the state that is modified by the code. Yet others are concerned mainly with the style of syntax and grammar.

Common programming paradigms include

  • imperative in which the programmer instructs the machine how to change its state,
  • procedural which groups instructions into procedures,
  • object-oriented which group’s instructions together with the part of the state they operate on,
  • declarative in which the programmer merely declares properties of the desired result, but not how to              compute it,
  • functional in which the desired result is declared as the value of a series of function applications,
  • logic in which the desired result is declared as the answer to a question about a system of facts and rules,
  • mathematical in which the desired result is declared as the solution of an optimization problem.


Declarative programming is a programming paradigm … that expresses the logic of a computation without describing its control flow.
Imperative programming is a programming paradigm that uses statements that change a program’s state.

PROCEDURAL & FUNCTIONAL PROGRAMMING
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast with the procedural programming style that emphasizes changes in state.


REFERENTIAL TRANSPARENCY
Referential transparency and referential opacity are properties of parts of computer programs. An expression is called referentially transparent if it can be replaced with its corresponding value without changing the program's behavior. This requires that the expression is pure, that is to say the expression value must be the same for the same inputs and its evaluation must have no side effects. An expression that is not referentially transparent is called referentially opaque.

In mathematics all function applications are referentially transparent, by the definition of what constitutes a mathematical function. However, this is not always the case in programming, where the terms procedure and method are used to avoid misleading connotations. In functional programming only referentially transparent functions are considered. Some programming languages provide means to guarantee referential transparency. Some functional programming languages enforce referential transparency for all functions.

The importance of referential transparency is that it allows the programmer and the compiler to reason about program behavior as a rewrite system. This can help in proving correctness, simplifying an algorithm, assisting in modifying code without breaking it, or optimizing code by means of memorization, common sub expression elimination, lazy evaluation, or parallelization.

FEATURES OF OBJECT ORIENTED PROGRAMMING
OOP stands for Object Oriented Programming and the language that support this Object Oriented programming features is called Object oriented Programming Language. An example of a language that support this Object oriented features is C++.

Features of Object oriented Programming:
The Objects Oriented programming language supports all the features of normal programming languages. In addition it supports some important concepts and terminology which has made it popular among programming methodology.

The important features of Object Oriented programming are:

  1.        Inheritance
  2.        Polymorphism
  3.        Data Hiding
  4.        Encapsulation
  5.        Overloading
  6.        Reusability


Let us see a brief overview of these important features of Object Oriented Programming. But before that it is important to know some new terminologies used in Object Oriented programming namely.

      Objects
      Classes

Objects:
In other words object is an instance of a class.

Classes:
These contain data and functions bundled together under a unit. In other words class is a collection of similar objects. When we define a class it just creates template or Skelton. So no memory is created when class is created. Memory is occupied only by object.

  • Encapsulation:

The technical term for combining data and functions together as a bundle is encapsulation.

  • Inheritance:

Inheritance as the name suggests is the concept of inheriting or deriving properties of an existing class to get new class or classes. In other words we may have common features or characteristics that may be needed by number of classes. So those features can be placed in a common tree class called base class and the other classes which have these characteristics can take the tree class and define only the new things that they have on their own in their classes. These classes are called derived class. The main advantage of using this concept of inheritance in Object oriented programming is it helps in reducing the code size since the common characteristic is placed separately called as base class and it is just referred in the derived class. This provide the users the important usage of terminology called as reusability

  • Reusability:

This usage is achieved by the above explained terminology called as inheritance. Reusability is nothing but re- usage of structure without changing the existing one but adding new features or characteristics to it. It is very much needed for any programmers in different situations. Reusability gives the following advantages to users

It helps in reducing the code size since classes can be just derived from existing one and one need to add only the new features and it helps users to save their time.

For instance if there is a class defined to draw different graphical figures say there is a user who want to draw graphical figure and also add the features of adding color to the graphical figure. In this scenario instead of defining a class to draw a graphical figure and coloring it what the user can do is make use of the existing class for drawing graphical figure by deriving the class and add new feature to the derived class namely add the feature of adding colors to the graphical figure.

  • Polymorphism and Overloading:


Poly refers many. So Polymorphism as the name suggests is a certain item appearing in different forms or ways. That is making a function or operator to act in different forms depending on the place they are present is called Polymorphism. Overloading is a kind of polymorphism. In other words say for instance we know that +, – operate on integer data type and is used to perform arithmetic additions and subtractions. But operator overloading is one in which we define new operations to these operators and make them operate on different data types in other words overloading the existing functionality with new one. This is a very important feature of object oriented programming methodology which extended the handling of data type and operations.


SOFTWARE RUNTIME ARCHITECTURE
Programming language can be categorized according to the way they are processed and executed. This also needs additional components for communication between the application and the OS.
         Compiled language
         Scripting language
         Markup language

  • Compiled language:


Programming languages are those that their end results are compiled. You most certainly use IDEs (Integrated Development Environments) to make use of these languages. If u think about it their examples are as follows: Java, visual basic, C, C++, C#, etc.
In this language some executable can be directly run on the OS(C on windows). Also some executable use virtual runtime machines. (Java, .net)

  • Scripting language:


Scripting languages are languages that are not compiled, more like interpreted at run-time. It's like a file containing instructions for a computer to follow to carry out a task. Think of it like this. If you were to feature in a movie, u will definitely be given a script to read, memorize and follow. Hence the script becomes your guide to perform your roles in that movie. It’s as simple as that. Example of scripting languages are JavaScript, VB script, Perl, python, php, she'll script, etc.

  • Markup language:

Markup languages are languages that are not in any way executed or used to perform actions but they are used to structure data, identify data or present data as the case may be. Examples are HTML (defines web content), XHTML (same with html but with some differences), XML (for structuring data, in some cases for defining UI structure as it’s used in Android app development), etc.

VIRTUAL RUNTIME MACHINE
The runtime environment provides a state for the target machine to have access to resources such as software libraries, system variables and environment variables, and provide all necessary services and support to the processes involved in the execution of the application or program.
In computing, a virtual machine (VM) is an emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination.

There are different kinds of virtual machines, each with different functions:
System virtual machines (also termed full virtualization VMs) provide a substitute for a real machine. They provide functionality needed to execute entire operating systems. A hypervisor uses native execution to share and manage hardware, allowing for multiple environments which are isolated from one another, yet exist on the same physical machine. Modern hypervisors use hardware-assisted virtualization, virtualization-specific hardware, primarily from the host CPUs. Process virtual machines are designed to execute computer programs in a platform-independent environment.
Some virtual machines, such as QEMU, are designed to also emulate different architectures and allow execution of software applications and operating systems written for another CPU or architecture. Operating-system-level virtualization allows the resources of a computer to be partitioned via the kernel. The terms are not universally interchangeable.

DEVELOPMENT TOOLS
Computer Aided Software Engineering (CASE) tools are used throughout the engineering life cycle of the software systems. The main steps are,

        Requirements
        Designing
        Development
        Testing
        Implementation
        Maintenance

CASE software types are,
    
        Individual tools - for specific task
        Workbenches – multiple tools are combined, focusing on specific part of SDLC.
        Environments – combines many tools to support many activities throughout the SDLC.


FRAMEWORKS & LIBRARIES & PLUGINS
Framework is a collection of libraries, tools, rules, structures and control to build software systems. At the run times it create the structure of the application, place your code in necessary place, you may use the given libraries to write your code, you can include additional libraries and plugins. Frameworks will call your code at the runtime.

Plugins provides specific tools for development. At the development time the plugin (source code files, modules, packages, executable and etc.) is placed in the project. Also apply some configurations using code. Plugin will be invoked via the configurations at the run time.

Libraries provide an API (Application Programming Interface), the corder can use it to develop some features when writing code.
At the development time it add the library to the project (source code files, modules, packages). Also the library will called by the code at the run time.
Key Difference and Definition of Library and Framework. The key difference between a library and a framework is "Inversion of Control". When you call a method from a library, you are in control. But with a framework, the control is inverted: the framework calls you. A library is just a collection of class definitions.

Plugin Framework for Java (PF4J) a plugin is a way for a third party to extend the functionality of an application. A plugin implements extension points declared by application or other plugins.

The main difference between plugin and library is that a plugin is an extension that improves the capabilities of an application while a library is a collection of classes and functions that helps to develop a software. A plugin is an add-on for a software program that adds new functionality to it.                           


2 comments:

  1. very useful for our studies..best of luck brother

    ReplyDelete
  2. Hope you'll continue this good work :)

    ReplyDelete