Object-Oriented Programming, Event-Driven Programming, Procedural Programming

Object-Oriented Programming, Event-Driven Programming, Procedural Programming

There are a number of advantages to using object-oriented programming (OOP) to procedural programming. OOP is a type of computer programming in which the data structure and functions are well defined and added in the data structure (Phillips, 2010). In OOP, an objects attributes are classified as a single unit. On the other hand, procedural programming involves the break-up of complicated programs into smaller procedures. Object-oriented programming is better in that it enables a programmer to reuse the code during application development. Thus a developer can be able to reuse the code instead of writing a new one which may be time consuming. Procedural programming does not allow reuse of the code. Another advantage of OOP is that it enhances inheritance (Phillips, 2010). OOP enables a programmer to base an object on an existing class or object. This is referred to as class-inheritance and prototypal inheritance respectively.

The following is an example of simple class with one at least one attribute and one method.

import datetime # utilized for date objects.

 

class Person:

 

def __init__(self, name, birthdate, surname, telephone, address, email):

self.name = name

self.birthdate = birthdate

self.surname = surname

 

 

self.telephone = telephone

self.address = address

self.email = email

 

def age(self):

today = datetime.date.today()

age = today.year self.birthdate.year

 

if today < datetime.date(today.year, self.birthdate.month, self.birthdate.day):

age -= 1

 

return age

 

person = Person(

“mark”,

“doe”,

datetime.date(1992, 3, 12), # year, month, day

“No. 21 Swift Street, Smallville”,

“555 456 0987”,

“mark.doe@example.com”

)

 

give(person.name)

give(person.email)

give(person.age())

 

 

Class represents related data that is grouped together and functions applied to act upon the data. The class above represents personal data of a particular individual. The classes store a number of attributes. These include birthdate, name, age, address, telephone and email. The purpose of the related method is to establish a new object by using the provided data. The class, attributes and methods are related. The first type of relationship stems from the fact that all of them describe the same object but in different ways.

Feature of object-oriented programming that Visual Logic Lacks

Visual Logic supports development of programs which have multiple procedures but does not support the development of classes in programming. In Visual Logic, classes or objects cannot share common attributes or features as often happens in inheritance. This feature is present in object oriented programming. Lack of class development has been a major challenge impacting the application of Visual Logic in programming. In object oriented programming, it is easy for the programmer to establish class hierarchies which is quite difficult while using Visual Logic. Class hierarchies can be easily identified while using design class diagrams and other tools while using Unified Modeling Language (Dale & Weems, 2007).

Another drawback with the use of Visual Logic are inherent challenges in the programming language being used. Visual Logic commonly employs Prolog as the programming language. In most of the programming languages such as Prolog, the programmer is forced to determine all the procedural aspects detailing the execution of the program (Dale & Weems, 2007). In this case, the logical semantics are incompatible with the procedural semantics established in the program. This means that the programmer must spend more time in developing the semantics to use. It is also more expensive, a reason why most programmers opt for object oriented programming.

Advantage of using event-driven programming, compared to purely procedural programming

The use of event-driven programming has a number of advantages to using purely procedural programming. First, event-driven programming is known for its high flexibility compared to procedural programming (Yeager, 2014). This is because in event-driven programming, the application flow is controlled by events rather than a sequential program. In most cases, there is no need for users to get an understanding of how tasks in event-driven programming are executed or performed. Procedural programming executes commands in particular order. This leads to rigidity in execution of tasks which limits users on how tasks can be performed or executed. Owing to this limitation, procedural programming is better suited to small projects such as in computers. For instance, it can be applied in giving instructions to computers on various tasks such as multiplying numbers and displaying the results.

Another advantage of using event-driven programming is that it offers robustness (Yeager, 2014). Event-driven programming is less sensitive to the order of activities performed by the users. In procedural programming, a sequence of all the activities must be maintained and well thought out during the developmental stages. The programmer must anticipate all the sequence of activities that a user can implement while using the program. This is followed by identification of feedbacks on all the steps anticipated. Signals provide crucial feedback upon which future decisions are based. This makes purely procedural programming less robust compared to event-driven programming. Event-driven programming is reaction-bound in nature (Yeager, 2014). This means that it works through receiving signals or events from users. Procedural programming is based on acting rather than being reaction based. Another benefit of event-driven programming is that it is service oriented and time driven.

References

Nell B. Dale, Chip Weems, Programming and problem solving with Java, Edition 2, Jones &       Bartlett Publishers, 2007,

Phillips, D. (2010). Python 3 object oriented programming: Harness the power of Python 3          objects. Birmingham, U.K: Packt Pub.

Yeager, D. P. (2014). Object-oriented programming languages and event-driven programming.   Dulles, VA: Mercury Learning and Information.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *