Answer to Question #240204 in Databases | SQL | Oracle | MS Access for Shanu

Question #240204

Explain what is meant by a Programming Paradigm and the main characteristics of Procedural, Object oriented and Event-driven paradigms and the relationships among them. Write small snippets of code as example for the above three programming paradigms using a suitable programming language(s). you also need to critically evaluate the code samples that you have given above in relation to their structure and the unique characteristics.


1
Expert's answer
2021-09-22T00:02:34-0400

Programming paradigm is a ay or style of programming.

1. Procedural paradigms

  - Focuses on sequence of action to be done.

  - It is implemented based on actions.

  Example

  #include <iostream> 
  int sum(int n1, int n2); 
  int main () { 
    int a = 10; 
    int b = 20; 
    int res; 
    res = sum(a, b); 
    std::cout << a << "+" << b << "=" << res << std::endl; 
    return 0; 
  }  
  int sum(int n1, int n2) { 
    int res; 
    res = n1 + n2; 
    return res; 
  } 

   

2. Object oriented paradigms

  - encapsulation

  - polymorphism

  - inheritance

  Example

  class Dog {
  constructor(name, birthday) {
    this.name = name;
    this.birthday = birthday;
  }

  _attendance = 0;

  getAge() {
    return this.calcAge();
  }

  calcAge() {
    return Date.now() - this.birthday;
  }
   
  bark() {
    return console.log("Woof!");
  }

  updateAttendance() {
    this._attendance++;
  }
  }

3. Event-driven paradigms

  - Servise oriented

  - Time driven

  Example

  import asyncio

  def hello_world(lp):
    print('Hello World')
    lp.stop()
   
  lp = asyncio.get_event_loop()
   
  lp.call_soon(hello_world, lp)
   
  lp.run_forever()
  lp.close()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS