Wednesday, 16 December 2015

PROGRAMMING PARADIGMS

What is Structured Programming?

Structured programming is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify structure

What are the features of Structured Programming?


    1. Emphasis on doing things (algorithm)
    2. Large programs are divided into smaller programs known as functions
    3. Most of the functions share the global data
    4. Functions transform data from one form to another
    5. Employs top-down approach

List down some program paradigms.


    1. Procedural programming – COBOL, FORTRAN, Pascal, C
    2. Functional Programming – LISP
    3. Logic Programming – PROLOG
    4. Structured Programming
    5. Object Oriented Programming
    6. 4th Generation Programming – Dbase
    7. Visual / Event Driven Programming – Visual Basic

Define Event Driven Programming.

Event Driven Programming is a programming paradigm or system architecture that decomposes a program into a set of event handlers.The primary source of events is hardware I/O

What is an event?

An event can be anything such as , button click or mouse click on a window

Explain how an Event Driven Programming works, with a simple example.


  • Event Driven Programming is a programming paradigm or system architecture that decomposes a program into a set of event handlers.
  • An event can be anything such as : mouse click or button click on  window.
  • The primary source of events is hardware I/O.
  • Each window is sent messages via function calls that tell it what has happened based on the events, which are then processed accordingly.
  • If a button is clicked, the parent window is sent a message via a function call to tell what has happened
  • Each window has a window procedure that handles all of the messages sent to it.

Differentiate Procedural and Event Driven Programming.

Procedural Programming Code : We write the set of instructions, and they are executed in the sequence specified or decided by the logic
Event Driven Programming Code : It waits for certain events to occur and then react accordingly
e.g:
Calculation of a math problem :
Procedural Programming
Because, the algorithm to solve the math problem can be programmed sequentially.
Web Browser / GUI : 
Event driven programming
Because, events are good to handle a lot of things at once, or stuff we might not expect to happen or expect to happen, just not sure when.

Explain Windows Programming Paradigms.

  • A Paradigm is essentially a high level model of what computation is about.
  • Following are some programming paradigms :
    • Procedural :
      • It focus on grouping organizations and/or code by similar operations or by operations that can be done on them.
        • e.g : COBOL, FORTRAN, Pascal, C
    • Functional :
      • Program contains entirely functions.
      • Program itself is written as function which receives inputs as arguments and output as result.
      • There is no assignment statements, thus, a variable value once assigned will never change
      • It acts as an abstract for solution to polymorphism.
      • Function can create or manipulate other functions.
        • e.g : LISP
    • Logical :
      • Basic constructs of logical programming : term and statements are inherited from logic
      • There are 3 types of statements in logical programming : facts, rules and queries
      • Logical relationship between various entities are declared
      • Programmer writes the database of term and rules.
      • User supplies the queries
      • System tries to prove it. If it matches a fact, then succeeds.
      • Logical Programming Languages, tend to be declarative languages.
      • They concentrate more on the relationship between the parts of the problem, rather than the sequence to solve the problem
        • e.g : SQL, PROLOG
    • Structured
      • Structured Programming is a subset of procedural programming paradigm that enforces a logical structure on the program being written to make it more efficient and easy to understand and modify structure
      • There are 3 types of structures that can be used in a program : Sequence, Decision and Loop
    • Object Oriented
      • Here, Data type and Function type of data structures are defined.
      • Data structure become the object with data and function.
      • Relationship between objects can be created. E.g : Inheritance.
    • 4th Generation Languages (4GL) :
      • 1GL - Machine Language - String of 1, 0
      • 2GL - Assembly Language
      • 3GL - 
        • High Level Languages like C, C++, etc.
        • These programs are compiled into machine language using Java Virtual Machine as a part of the OS
      • 4GL 
        • These are closer to the natural languages than 3GL
        • Most of the languages used to retrieve database are 4GL
          • e.g : SQL
    • Visual / Event Driven : Visual Programming
      •  It is programming paradigm or system architecture that decomposes a program into a set of event handlers.
      • Events can be anything such as , button click or mouse click on window
      • The primary source of events is hardware IO
      • Each window is sent messages via function calls, telling it what has happened, based on the events, which are then processed accordingly.
      • Each window has a window procedure that handles all of the messages sent to it.
        • e.g : Visual Basic

No comments:

Post a Comment