Procedural and Event-Driven Programming: A Comparison, Essays (university) of Computer Science

An overview of procedural and event-driven programming, their characteristics, and the relationship between them. Procedural programming is a top-down approach, while event-driven programming is service-oriented and time-driven. The document also includes information about input and output in the context of the given program.

Typology: Essays (university)

2020/2021

Uploaded on 05/10/2021

jackie-ming
jackie-ming 🇬🇧

8 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Nguyễn Lâm Thắng
Student ID
GCH18545
Class
GCH0716
Assessor name
Trương Công Đoàn
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P2
P3
P4
P5
M2
M3
M4
D2
D3
D4
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Procedural and Event-Driven Programming: A Comparison and more Essays (university) Computer Science in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Nguyễn Lâm Thắng Student ID GCH Class GCH0716 Assessor name Trương Công Đoàn Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P2 P3 P4 P5 M2 M3 M4 D2 D3 D

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

  • I. Introduction
  • II. Procedural, object-oriented and event-driven paradigms
    • 1.Procedural
    • 2.Object-oriented
      1. Event-driven
  • III. Characteristics of three models and the relationship between them
    • 1.Characteristics
      • 1.1 Procedural
      • 1.2 Object-oriented.............................................................................................................................
      • 1.3 Event-driven.................................................................................................................................
      1. The relationship between them
  • IV. Write a program that implements an algorithm using an IDE.
      1. Business problem
      1. Input / Output
      • 2.1 Input.............................................................................................................................................
      • 2.2 Output
      1. Example
      1. Algorithm
      1. Flowchart.........................................................................................................................................
      1. Implementation
      1. Code
      1. Result
  • V. Explain the debugging process and explain the debugging facilities available in the IDE.
      1. Theory of debugging
      1. Show evidence how to use debugging in your code
      • 2.1 Break point
      • 2.2 Step over
      • 2.3 Step into
      • 2.4 Step out
      1. Explain the debugging facilities available in the IDE.
      • 3.1 Break point
      • 3.2 Step over statements
      • 3.3 Variable popup
      • 3.4 Debug conditionally
  • VI. Outline the coding standard you have used in your code.
      1. Theory of coding standard
      • 1.1 What is coding standard?
      • 1.2 Name convention
      • 1.3 Statement convention
      • 1.4 Layout
      • 1.5 Comment....................................................................................................................................
      1. How to apply
  • VII. Conclusion
  • VIII. References
  • Figure 1 : How to calculate the money
  • Figure 2 : Implementation
  • Figure 3: Calculate button
  • Figure 4 : Add button
  • Figure 5 : Edit button
  • Figure 6 : Save button
  • Figure 7: Cancel button
  • Figure 8: Delete button
  • Figure 9 : Start program
  • Figure 10 : Add information of first customer
  • Figure 11 : After adding and click Save butoon
  • Figure 12 : Add information of second customer
  • Figure 13 : Add information of second customer successfully
  • Figure 14 : Edit second customer
  • Figure 15 : Edit successfully....................................................................................................................
  • Figure 16 : Delete second customer
  • Figure 17 : Delete successfully
  • Figure 18 : Debug ( break point ).............................................................................................................
  • Figure 19 : Debug ( break point next )
  • Figure 20 : Debug ( Step over )

Figure 21: Debug ( Step into ) ................................................................................................................. 21 Figure 22 : Debug ( Step out ) ................................................................................................................. 22 Figure 23 : Variable popup ...................................................................................................................... 23 Figure 24 : Debug conditionally .............................................................................................................. 24 Figure 25: comment ................................................................................................................................ 26 Figure 26 : apply comment ...................................................................................................................... 27 Figure 27 : apply to name variable........................................................................................................... 27

I. Introduction

This report, I will show you some information about Procedural, object-oriented and event-driven paradigms. Moreover I also explain clearly about Debbuging, Coding Standard, include examples and how I use them in my program. These documents help you develop effective programs from Application Visual Studio 2019. After that, I will solve business problem by writing a program by using IDE. Finally, In my assignment I will make it with Visual Studio 2019

II. Procedural, object-oriented and event-driven paradigms

1.Procedural The procedural programming paradigm is represented as a series of steps in which a computer programmer writes a code to perform a specific task. The first line of code is executed first, then the second line of code, then the third, up to last line of code. Therefore, procedural programming is a top-down approach to executing lines of codes. The most popular languages that use procedural paradigm are BASIC, COBOL, PASCAL and FORTRAN. In these languages, a program comprises of steps or procedures that operate on data. Procedural programming has many characteristics like local variables, global variables, pre-defined functions, modularity, and parameter passing in function and procedures. (https://study.com, 2019) 2.Object-oriented The object-oriented paradigm is based on objects and classes and their re-use to perform a specific code- function. So, unlike the procedural paradigm, the object-oriented paradigm uses bottom-up approach. In the simplest form, these objects contain data in the form of fields. Programs are divided into smaller units known as objects belonging to a class. These objects interact with each other through functions. Most popular languages that use object-oriented paradigm are C++, Java, Objective-C, Python. The characteristics of languages using the object-oriented paradigms are the use of objects, classes, encapsulation, inheritance, data abstraction, dynamic binding, message passing and polymorphism. (https://study.com, 2019)

  • Generic classes – Class definitions for unspecified data. They are known as container classes. They are flexible and reusable.
  • Class libraries – Built-in language specific classes
  • Message passing – Objects communicates through invoking methods and sending data to them. This feature of sending and receiving information among objects through function parameters is known as Message Passing. (https://www.careerride.com, 2019) 1.3 Event-driven
  • Service orientated : Service oriented is a programming paradigm that is used to write programs that are made for services. If something is requested, the action is carried out, if a user wanted to minimize an application that they are using, they would click on the – icon in the top right of the page and the application will minimize into the task bar, this is service orientated.
  • Time driven : Time driven in event driven programming is a paradigm, it is code that runs on a time trigger, this could be a piece of code that runs at a specific time, which could be once a week or whenever a program is launched, this means it is a pre-set task. An example of this is MAC OS X mavericks, it checks for updates at a specific time every day, if an update is found it informs you to do the update now or to postpone it to a later time or date.
  • Event handlers : Event handler is a function or method that takes place when a certain event happens, they are executed in response to a certain event that takes place, for example this could be on a button, when a button is clicked the code is ran, if the button is clicked again after that it will run again, this is an event handler.
  • Trigger functions : Trigger functions decide what code is ran when a specific event occurs, they are used to choose when event handlers are ran for the event that occurs, most applications have a trigger function for each event that is likely to occur.
  • Events (Mouse, keyboard and user interface): 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, for example, click a button by a mouse, use keyboard to select a button and etc. (https://zakkcuthbertunit14eventdrivenprogramming.wordpress.com, 2019) 2. The relationship between them Procedural paradigm is your looking at the process needed to solve a problem. I do a, then I do b, and then I do c. There’s a definite process and the flow of the data is highly predictable.

Object oriented is looking at the actors and creating objects to represent those actors. For example, an emulator for a movie line queue. You’ve got people, the line, and a ticket booth. So, you build objects around those actors. Event driven, is used when you have spontaneous moments that need to be taken care of. You can add event handlers to both procedural and object oriented paradigms. So, as a stand alone, it’s not a complete paradigm. For instance your procedural report writer could have an event to handle out of paper. Or the object oriented program could have an event to handle when lightning hits a person standing line for the movie. (https://www.quora.com, 2019)

IV. Write a program that implements an algorithm using an IDE.

1. Business problem Suppose that I'm an employee at an electrical station at Thanh Xuan county in Ha Noi. Whenever becoming the end of the month, I have to collect the number of electricity of every customer at Thanh Xuan county. Then I have to calculate the money which has to pay based on the electric price public. This takes me very much time because of calculating them. Final, I need to have a list that includes information, number of electricity and the money has to pay. Then I send that list for an other employee so as to that employee needs to do other necessary work. Because calculating the money has to pay takes me very much time, I decide to design a program that can help me do that easily. That program has some functions, such as entering information ( include name, address, the number of electricity ), showing list that was entered , edit information and delete the customer which user wants. 2. Input / Output 2.1 Input To enter information of customers, I need to input data, include name of customer ( has type string ), address of customer ( has type string ) and the number of electricity ( has type int ). After processing by program, the money ( has type int ) which has to pay, is calculated and this money will be showed. 2.2 Output After entering everything, output is the list that was entered ( include name, address, the number of electricity and the money has to pay ).

5. Flowchart Figure 1 : How to calculate the money

6. Implementation To implement, I design the program has 6 buttons and 4 textboxs. 6 buttons are Add , Edit , Delete , Calculate , Save and Cancel. 4 textboxs are “ name of customer “, “ Address “, “number of electricity” and “ money “. At textbox money , user can’t enter anythings because this textbox will show the money after clicking button Calculate. To input data into program, first, have to click Add, then input data into every textbox, include Name of customer, Address, Number of electricity. After that user need to click button Calculate. Finally, to finish entering, user just click button Save. Now, every information is in the list. If user want to add more, user just click button Add again. To edit information, user just click at the customer which user want to edit. Then click button Edit, now user enter new information. After entering, to finish editing, user just click button Save. After that, information of that customer is editted automatically. If user want to delete a customer. First, user click at the customer which user want to delete. Then click button Delete. After that, a warning message will be showed, user click Yes to be sure that want to delete this customer. After clicking Yes , the list customer will be update ( doesn’t have the customer which was deleted ). After adding information, If user enters wrong data, user can click button Cancel to re-enter data. Figure 2 : Implementation

Figure 5 : Edit button Figure 6 : Save button

Figure 7 : Cancel button Figure 8 : Delete button

8. Result There are some screenshots when running program: Figure 9 : Start program

Figure 12 : Add information of second customer ( NOTE : At all textboxs, user doesn’t enter anythings and then click Save button ) Figure 13 : Add information of second customer successfully

Figure 14 : Edit second customer Figure 15 : Edit successfully

V. Explain the debugging process and explain the debugging facilities available in the

IDE.

1. Theory of debugging Definiton : Debugging is the routine process of locating and removing computer program bugs, errors or abnormalities, which is methodically handled by software programmers via debugging tools. Debugging checks, detects and corrects errors or bugs to allow proper program operation according to set specifications. (www.techopedia.com, 2019) 2. Show evidence how to use debugging in your code 2.1 Break point After I set a break point, I start running the debugger program by press f5 /Debug =>start debugging. Figure 18 : Debug ( break point ) After running program ( Enter data and click Calculate button ), the program stop, so breaking point is working so well. The program will be excuted until the breakpoint is met and before data money is calculated.

Figure 19 : Debug ( break point next ) 2.2 Step over

  • After debugger hits the breakpoint, you may need to execute the code line by line.
  • Debug >Step over or F10 command is used to execute the code line by line. Figure 20 : Debug ( Step over )