











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Procedural Programming Object-Oriented Programming Abstraction Encapsulation Inheritance Polymorphism Event-Driven Programming
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.
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.
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.
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
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