Docsity

What is meant by a Programming Paradigm, Study notes of Computer science

Toggle sidebar
bg1
Define what is meant by a Programming Paradigm. Explain the main characteristics
of Procedural, Object oriented and Event-driven paradigms and the relationships
among them.
Procedural programming
Procedural programming can be the first paradigm of programming that would be
learned by a new developer. Basically, the procedural code is the one that explicitly
instructs a computer in logical steps about how to complete a task. This model uses a
top-down linear approach and considers knowledge and procedures as two separate
entities.
Procedural programming divides the program into procedures, which are also known
as routines or functions, based on the idea of a procedure call, simply containing a
series of steps to be performed.
Simply put, procedural programming involves writing down a list of instructions to
tell the computer what it should do step by step to complete the task at hand.
Main characteristics of procedural programming
Predefined functions: - Usually, a predefined function is an instruction identified by
a name. The predefined functions are usually built into higher-level programming
languages, but rather than the program, they are derived from the library or the
registry. ‘CharAt()’ is an example of predefined function, which searches for a
character location in a string.
Local variable: - A local variable is a variable declared in the main structure of a
method and restricted to the local scope it is given. The local variable may only be
used in the system in which it is specified, and the code will cease to operate if it is to
be used outside of the defined method.
Global variable: - A global variable is a variable that is declared outside of the code
specified by any other function. Because of this, unlike a local variable, global
variable can be used in all functions.
Modularity: - Modularity is when two different systems have two separate tasks at
hand, but are clustered together to first accomplish a larger task. When all tasks are
completed, each group of systems will then have its own tasks completed one after the
other.
pf3
pf4

Partial preview of the text

Download What is meant by a Programming Paradigm and more Study notes Computer science in PDF only on Docsity!

Define what is meant by a Programming Paradigm. Explain the main characteristics of Procedural, Object oriented and Event-driven paradigms and the relationships among them. Procedural programming  Procedural programming can be the first paradigm of programming that would be learned by a new developer. Basically, the procedural code is the one that explicitly instructs a computer in logical steps about how to complete a task. This model uses a top-down linear approach and considers knowledge and procedures as two separate entities.  Procedural programming divides the program into procedures, which are also known as routines or functions, based on the idea of a procedure call, simply containing a series of steps to be performed.  Simply put, procedural programming involves writing down a list of instructions to tell the computer what it should do step by step to complete the task at hand. Main characteristics of procedural programmingPredefined functions: - Usually, a predefined function is an instruction identified by a name. The predefined functions are usually built into higher-level programming languages, but rather than the program, they are derived from the library or the registry. ‘CharAt()’ is an example of predefined function, which searches for a character location in a string.  Local variable: - A local variable is a variable declared in the main structure of a method and restricted to the local scope it is given. The local variable may only be used in the system in which it is specified, and the code will cease to operate if it is to be used outside of the defined method.  Global variable: - A global variable is a variable that is declared outside of the code specified by any other function. Because of this, unlike a local variable, global variable can be used in all functions.  Modularity: - Modularity is when two different systems have two separate tasks at hand, but are clustered together to first accomplish a larger task. When all tasks are completed, each group of systems will then have its own tasks completed one after the other.

Object-Oriented Programming (OOP) A structure of the programming language in which the data and its related processing (“methods”) are specified as self-contained entities called objects. The norm today, OOP languages, such as C++ and Java, provide a structured collection of rules for creating and managing objects. If the data has a complex structure the data is stored in a traditional relational database or in an object database. [hackr.io, (2021).] Main characteristics of Object-Oriented Programming (OOP)Encapsulation Enforces Modularity : - Encapsulation refers to the creation of self-contained modules that connect the data to processing functions. These user defined data types are called “classes”, and an example of a class is an “object”. Encapsulation guarantees good modularity of code, which keeps routine separate and less likely to clash with other.  Inheritance passes “knowledge” down :- In hierarchies, classes are created, and inheritance enables the hierarchy to be passed down to the structure and techniques in one class, that means when adding functions to complex systems, less programming is needed. When a step is introduced at the bottom of a hierarchy, it is important to include only the processing and data associated with that particular step. Everything else is inherited. A major benefit of object technology is known to be the ability to reuse existing objects.  Polymorphism takes any shape : - OOP facilitates the development of object related procedures whose exact form is not known until runtime. For instance, depending on the program mode, a screen curser could change its shape from an arrow to a line. In response to mouse movement, the routine to move the cursor on the screen would be written as “cursor”, and polymorphism allows the cursor to take on whatever shape is required at runtime. It also enables the easy integration of new shapes. [pcmag.com, (2021).]

Relationship between procedural programming paradigm, OOP paradigm and event driven programming paradigm  When you define a program and its subprograms as a series of steps that means it is a procedural programming. On the other hand, declarative programs attempt to explain the result without regard to the steps taken to compute it, but rather some description or denotation of the expected result.  OOP is a way for code to be structured around the concepts of encapsulation, inheritance, replacement, interface programming etc. Usually, OOP are mostly procedural.  Event driven programming is about writing procedures for event handling and getting the core event loop provided by the underlying system. You can save the trouble of writing your own event loop in this way and benefit from different libraries that already function with the system provided event loop. Event driven programs use object-oriented type to write quite frequently but not always.  Thus, these three groups are not exclusively hierarchically connected, but they are mostly nested within one another in common stage. [quora.com, (2021).]