Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of two fundamental programming paradigms: procedural programming and object-oriented programming (oop). It explains the key features and characteristics of each approach, including procedural programming's focus on process and algorithms, and oop's emphasis on data and concepts like abstraction, encapsulation, inheritance, and polymorphism. The document also discusses the drawbacks of procedural programming, such as difficulty in implementing changes and maintaining code, and how oop was introduced to address these issues. Additionally, the document covers the event-driven programming paradigm, which is centered on responding to user actions and events. This comprehensive overview of programming paradigms can be valuable for students and learners interested in understanding the fundamental concepts and approaches in software development.
Typology: Schemes and Mind Maps
1 / 19
Procedural Programming Object-Oriented Programming Abstraction Encapsulation Inheritance Polymorphism Event-Driven Programming
Programmer implements requirement by breaking down them to small steps (functional decomposition). Programmer creates the “recipe” that computer can understand and execute. A program in a procedural language is a list of instruction where each statement tells the computer to do something. It focuses on procedure (function) and algorithm is needed to perform the computation.
It focuses on process rather than data. It takes a problem as a sequence of things to be done such as reading, calculating and printing. Hence, a number of functions are written to solve a problem. A program is divided into a number of functions and each function has clearly defined purpose. Most of the functions share global data. Data moves openly around the system from function to function.
What’s drawback with procedural programming language? (^) When requirements change It hard to implement new feature that were not planned in the beginning. Code blocks gets bigger and bigger. Changes in code introduce many bugs. Code gets hard to maintain.
Programming languages are based on two fundamental concepts, data and ways to manipulate data. Traditional languages such as Pascal and C used the procedural approach which focused more on ways to manipulate data rather than on the data itself. This approach had several drawbacks such as lack of re-use and lack of maintainability. To overcome these difficulties, OOP was introduced, which focused on data rather than the ways to manipulate data. The object-oriented approach defines objects as entities having a defined set of values and a defined set of operations that can be performed on these values.
Object-oriented programming provides the following features: Abstraction Encapsulation Inheritance Polymorphism
Abstraction is the feature of extracting only the required information from objects. Hide unnecessary details which are irrelevant for current purpose (and/or user). Reduces complexity and aids understanding. For example, consider a television as an object. It has a manual stating how to use the television. However, this manual does not show all the technical details of the television, thus, giving only an abstraction to the user.
Consider a class called Vehicle that consists of a variable called color and a method called Speed(). These data members of the Vehicle class can be inherited by the TwoWheelerVehicle and FourWheelerVehicle classes. The following figure illustrates an example of inheritance:
The purpose of inheritance is to reuse common methods and attributes among classes without recreating them. Reusability of a code enables you to use the same code in different applications with little or no changes.
Consider a class named Animal which defines attributes and behavior for animals. If a new class named Cat has to be created, it can be done based on Animal because a cat is also an animal. Thus, you can reuse the code from the previously-defined class.
(^) Area(float radius) (^) Area(float base, float height)
class Area { static int CalculateArea(int len, int wide) { return len * wide; } static double CalculateArea(double valOne, double valTwo) { return 0.5 * valOne * valTwo; } static void Main(string[] args) { int length = 10; int breadth = 22; double tbase = 2.5; double theight = 1.5; Console.WriteLine(“Area of Rectangle: “ + CalculateArea(length, breadth)); Console.WriteLine(“Area of triangle: “ + CalculateArea(tbase, theight)); } } Output Area of Rectangle: 220 Area of triangle: 1.
Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications that are centered on performing certain actions in response to user input
Service Oriented Service oriented is a key features in event-driven programming that used to write programs that are made for services and it takes does not slow down the computer as service oriented only consume little of the computer processing power and usually services run in the background of OS Time Driven In event driven programming, time driven is a paradigm, it’s a code that runs on a time trigger, time driven can be a specific code that runs on a specific time, which could be once an hour, once a week or once a month, this means it’s a pre-set to do task Event Handlers Event handlers is a type of function or method that run a specific action when a specific event is triggered
Trigger Functions Trigger functions in event-driven programming are a functions that decide what code to run when there are a specific event occurs, which are used to select which event handler to use for the event when there is specific event occurred Events Events include mouse, keyboard and user interface, which events need to be triggered in the program in order to happen, that mean user have to interacts with an object in the program Simplicity of Programming and Ease of Development Event-driven programming is simple and easier to program compared to other type of programming as it’s very visual Event-driven programming also easy for user to insert a pre-written code scripts into an existing application because it allows user to pause the code while it’s running