Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming Paradigms & IDEs: Procedural, Object-oriented, Event-driven, Study Guides, Projects, Research of Information Technology

Software EngineeringData Structures and AlgorithmsProgramming Languages

An introduction to programming paradigms, including Procedural Programming, Object-oriented Programming, and Event-driven Programming. It also covers the basics of Integrated Development Environments (IDEs) and their benefits for developers. Students will learn about the characteristics, advantages, and disadvantages of each programming paradigm and gain insights into the importance of IDEs in software development.

What you will learn

  • Which programming paradigm is best suited for large-scale applications?
  • How does an IDE support code completion and debugging?
  • What are some common coding standards that improve code readability and maintainability?
  • What are the advantages and disadvantages of using an IDE for software development?
  • What are the key differences between Procedural Programming, Object-oriented Programming, and Event-driven Programming?

Typology: Study Guides, Projects, Research

2019/2020

Uploaded on 10/02/2022

nguyen-thi-tuyet-nhung
nguyen-thi-tuyet-nhung 🇻🇳

4

(3)

21 documents

1 / 59

Toggle sidebar

Related documents


Partial preview of the text

Download Programming Paradigms & IDEs: Procedural, Object-oriented, Event-driven and more Study Guides, Projects, Research Information Technology in PDF only on Docsity!

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGY

ASSIGNMENT 2

UNIT: PROGRAMMING

STUDENT : NGUYEN THI TUYET NHUNG

CLASS : IT

STUDENT ID : BDAF

SUPERVISOR : NGUYEN HOANG ANH VU

DaNang, August 2021

ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 4 HND Diploma in Business Unit number and title Unit: Programming Submission date 10 /08/ Date received (1st sub- mission) Re-submission date Date received (2nd submission) Student name Nguyen Thi Tuyet Nhung Student ID BDAF Class IT16102 Assessor name Nguyen Hoang Anh Vu Student declaration I certify that the assignment submission is entirely my own work and I fully understand the con- sequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature: TUYETNHUNG Grading grid P1 M1 D1 P2 P3 P4 P5 M2 M3 M4 D2 D3 D

i

 Summative Feedbacks:  Resubmission Feedbacks:

Grade: Assessor Signature: Date: Internal Verifier’s Comments: Signature & Date:

ii

TABLE OF CONTENT

Contents TABLE OF CONTENT .............................................................................................. ii LIST OF TABLES AND FIGURES .......................................................................... iv LIST OF ACRONYM ................................................................................................ vi INTRODUCTION ...................................................................................................... 1 CHAPTER 1 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE………………………………............................................................................................ 2 Give explanations of what procedural, object-oriented and event-driven paradigms are; their characteristics and the relationship between them. (P2) ................. 2 1.1 Definition of programming models .......................................................... 2 1.1.1 Procedural Programming………………………………………….............. 2 1.1.2 Object-oriented Programming …………………………………………........ 4 1.1.3 Event-driven programming.…………………………………………............. 6 1.2 Characteristics of programming models .................................................. 8 1.2.1 Procedural Programming………………………………………………....... 8 1.2.2 Object-oriented Programming …………………………………………...... 10 1.3.3 Event-driven programming.…………………………………………........... 11 1.3.4 Compare.…………………………………………..................................... 12 Analyze the common features that a developer has access to in an IDE. (M2)……………………………………………………………………………………………... 13 2.1 What is IDE? ......................................................................................... 13 2.2 Features of IDE ..................................................................................... 13 CHAPTER 2 IMPLEMENTING THE BASIC ALGORITHM WITH THE IDE, DISCUSSING THE DEBUGGING PROCESS AND THE IMPORTANCE OF CODING STANDARDS……………………………………………………………………………………... 17 Write a program that implements an algorithm using an IDE. (P3) .............. 17

iii Use the IDE to manage the development process of the program. (M3) ..... 23 Evaluate the use of an IDE for development of applications contrasted with not using an IDE. (D3) ......................................................................................................... 30 Explain the debugging process and explain the debugging facilities available in the IDE. (P4) .............................................................................................................. 31 Evaluate how the debugging process can be used to help develop more secure, robust applications. (M4) ................................................................................... 38 Outline the coding standard you have used in your code. (P5) .................... 42 Critically evaluate why a coding standard is necessary in a team as well as for the individual. (D4) ......................................................................................................... 48 CONCLUSION ........................................................................................................ 49 CRITICAL EVALUATION ....................................................................................... 50 REFERENCES ....................................................................................................... 51

iv

  • Table 1: Compare Procedural Programming and OOP LIST OF TABLES AND FIGURES
  • Table 2: Naming objects in Win-form ………………………….……………………………….
  • Table 3: Example of an equation solving form ………………………….…………………….
  • Figure 1: Example of Procedural Programming
  • Figure 2: Example of OOP...................................................................................................
  • Figure 3: Example of Event-driven Programming
  • Figure 4: Example of text editor in Visual Studio
  • Figure 5: Debugger in Visual studio
  • Figure 6: Example of compiler …………………………………………………........................
  • Figure 7: Code completion in Visual studio ………………………………………………….....
  • Figure 8 : Several languages are supported in Visual Studio..….……………………………..
  • Figure 9 : Visual Studio 2019 …………………………………………………………………….
  • Figure 10: Visual Studio 2019 interface
  • Figure 11: Create a new project
  • Figure 12: Choose a project template
  • Figure 13 : Name and choose a folder to save
  • Figure 14 : Workspaces in Visual Studio
  • Figure 15: Program Hello World
  • Figure 16: Create a New Item in Visual Studio
  • Figure 17: Create a new Class
  • Figure 18: Class workspace in Visual Studio
  • Figure 19: Create Breakpoints in Visual Studio
  • Figure 20: Check the lines of code
  • Figure 21: Follow the program v
  • Figure 22: Some kind of IDE..............................................................................................
  • Figure 23: Example of the algorithm to swap two numbers
  • Figure 24: Example of the algorithm to swap two numbers
  • Figure 25: Example of the algorithm to swap two numbers
  • Figure 26: Example of the algorithm to swap two numbers
  • Figure 27: Example of the algorithm to swap two numbers
  • Figure 28: Example of the algorithm to swap two numbers
  • Figure 29: Example of the algorithm to swap two numbers
  • Figure 30: Example of Login Form
  • Figure 31: Example of Login Form
  • Figure 32: Example of Login Form
  • Figure 33: Example of Login Form
  • Figure 34: Example of Login Form
  • Figure 35: Example of Login Form
  • Figure 36: Algorithm to calculate the sum of two complex numbers
  • Figure 37: Example of an equation solving form................................................................

vi

LIST OF ACRONYM

RAM Random Access Memory GUI Graphical User Interface IDE Integrated Development Environment CPU Central Processing Unit DOS Disk Operating System OOP Object-Oriented Programming

INTRODUCTION

Programming is one of the subjects that help master the foundation of computer knowledge. Programming works in which users use programming languages; available codes and utilities. Thereby, helping users perform commands with computers or interact with each other through electronic devices. At the same time, it is possible to build programs, software, games, applications, websites, and more. The following report introduces us to programming paradigms such as Procedural Programming, Object-Oriented Programming and Event-driven Programming; algorithms, and IDE basics. Learn more about debugging processes and debugging facilities in the IDE. Outline the coding standards used in your code.  Chapter 1: Problems related to programming methods and IDE.  Chapter 2: Implementing the basic algorithm with the IDE, discussing the debugging process and the importance of coding standards.

CHAPTER 1 PROBLEMS RELATED TO PROGRAMMING METHODS

AND IDE.

LO2 Explain the characteristics of procedural, object-oriented and event-driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE).

Give explanations of what procedural, object-oriented and event-driven

paradigms are; their characteristics and the relationship between them.

(P2)

1.1 Definition of programming models

1.1.1 Procedural Programming “Procedural programming is a programming paradigm, derived from imperative programming, based on the concept of the procedure call. Procedures (a type of routine or subroutine) simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. The first major procedural programming languages appeared circa 1957 – 1964, including Fortran, ALGOL, COBOL, PL/I and BASIC. Pascal and C were published circa 1970– 1972 .” [1] [1] https://en.wikipedia.org/wiki/Procedural_programming In a nutshell, procedural programming involves writing down a list of instructions to tell the computer what it should do to complete a task. Example: write a program to input an array of integers from the keyboard:  Sort and output the array just entered to the screen.  Output the element with the smallest value to the screen.  Calculate and output to the screen the average of the elements divisible by 3.

Figure 1. Example of Procedural Programming 1.1.2 Object-oriented Programming Object-oriented programming is a programming paradigm based on the concept of "object technology", which can contain data and code: data in the form of fields (called properties) and code in the form of procedures. (called a method). “One feature of objects is that the object's own procedures can access and modify its own data fields (objects have a notion of this or self). In OOP, computer programs are designed by turning them out of objects that interact with each other. OOP languages are diverse, but the most popular ones are class-based, which means that objects are instances of classes, which also define their types.” [2] [2] https://en.wikipedia.org/wiki/Object-oriented_programming

Example: Create a Rectangle class with two properties length and width; and getPerimeter() and getArea() methods to calculate perimeter and area. The Export() method will output the width, length, circumference and area to the screen. Create a Square class that inherits from the Rectangle class and override the Export() method to output edge, perimeter and area information. Write a program to input two Rectangles and a Square and then output them to the screen

Figure 2. Example of OOP 1.1.3 Event-driven Programming “Event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other programs or threads. In an event-driven application, there is typically a main loop that listens for events and then fires a callback when one of those events is detected. In embedded systems, the same can be achieved by using hardware interrupts instead of a continuously running main loop. Event-driven programs can be written in any programming language, although the task is easier in languages that provide high-level abstractions, such as await and closures.” [3] [ 3 ] https://en.wikipedia.org/wiki/Event-driven_programming

Example: Design an interface for calculations. Enter numbers n and number m, then choose one of the addition, subtraction, multiplication and division operations to perform the calculation and give the result. For division, you must enter m greater than 0, otherwise you must re-enter it. If you enter the wrong number, you can choose DELETE and then re-enter it. After the calculation is complete, you can choose EXIT to exit.

Figure 3. Example of Event-driven Programming

1.2 Characteristics of programming models

1.2.1 Procedural Programming While designing a program, procedural programming follows a top-down programming approach. Most functions allow system-wide data to be shared. It also divides larger programs into smaller parts called functions. It allows to move data freely around the system. Data is converted by functions from one form to another.

Languages used in procedural programming: FORTRAN, ALGOL, COBOL, BASIC, Pascal and C. Key features of Procedural Programming:Predefined functions: a predefined function is a directive that is identified by name. Usually, predefined functions are built into higher-level programming languages, but they are derived from a library or registry, not a program.  Modularity: when two different systems have two different tasks but are grouped together to finish a larger task first. Each system group will then have its own task to be completed in turn until all tasks are completed.  Local variable: this is a variable declared in the main structure of a method and limited to the local scope to which it is provided. A local variable can only be used within the method in which it is defined, and if used outside of the defined method, the code will stop working.  Global variable: this is a variable declared outside of every other function defined in the code. Therefore, a global variable can be used in all functions, unlike a local variable.  Parameter passing: is the mechanism used to pass parameters to functions, subroutines or procedures. Parameter passing is done through “pass by value”, “pass by reference”, “pass by result”, “pass by value – result” and “pass by name”. Advantages of Procedural Programming:  Coding is simple and easy.  The code can be reused in other parts of the program without having to duplicate the code.  It is easier to follow the flow of code in a program written with a procedural programming model.  Through Procedural Programming technique, the memory requirement also slashes.  Lots of books and online course materials are available based on tested algorithms that make learning easier.  The source code is portable, therefore, it can be used to target a different CPU as well.

Disadvantages of Procedural Programming:  Focus on functions more than data.  Modifying global data requires modifying the functions that use it.  Maintaining and enhancing program code is still difficult because of global data.  The Procedural code is often not reusable, which may pose the need to recreate the code if is needed to use in another application.  Difficult to relate with real-world objects.  Global data usage is error prone and it can be a hindrance in case of maintenance and improvement. 1.2.2 Object-oriented Programming The goal of OOP is to optimize source code management, increase reusability, and importantly, help encapsulate procedures with known properties through the use of objects.  Object: it is the instance of the class, consists of 2 main ingredients: attributes and method. Attributes are information and characteristics of an object. Methods are the behaviors that an object can perform.  Class: is an abstraction of the object. Objects with similar properties will be grouped into a class. Classes also include properties and methods. An object will be treated as an instance of the class. The most popular OOP languages: Java, C++, PHP, JavaScript, Python, C#, Swift, Scala, Ruby, Objective-C. Basic characteristics of OOP:Encapsulation: allows hiding information and the internal processing properties of the object. This property helps to increase the security of the object and avoid data corruption.  Inheritance: allows to build a new class (subclass), inherit and reuse properties and methods based on the old class (parent class) that was previously available. Subclasses inherit all the members of the parent class, do not need to be redefined, and can extend the inherited components or add new ones.

Polymorphism: allows different objects to perform the same function in different ways.  Abstraction: helps to get rid of the complicated, unnecessary things of the subject and focus only on what is important. Advantages of OOP:  OOP mimics the real world, making it easier to understand.  Modeling complex things as simple structures.  Reusable OOP code, which saves resources.  High security.  Easily extend the project.  Fixing errors is easy, simple and takes less time. Disadvantages of OOP:  Due to the large program size, more instructions need to be executed.  Programs built using this model may take longer to create.  OOP tend to be slower and use more memory. 1.2.3 Event-driven Programming Theoretically, event-driven programming is supported in all programming languages, but they may differ in implementation. There is a main loop in an event driven application that is used to listen for events and trigger a callback when an event is detected. Key features and characteristics of Event-driven Programming:Service Oriented: used to write programs created for services; does not slow down the computer because the service orientation consumes less processing power of the computer and the services usually run on the operating system background.  Time Driven: is a specific code that runs at a specific time, be it once an hour, once a week or once a month, this means it is already set up to do the task.  Simplicity of Programming and Ease of Development: Event-driven programming is simpler and easier to program than other programming styles because it is very intuitive; makes it easy for users to insert pre-written code into an existing application because it allows the user to pause the code while it is running.

Trigger Functions: this is a function that decides what code to run when a particular event occurs, used to choose the event handler to use for the event when a specific event occurs.  Events: events include mouse, keyboard, and user interface, which events need to be triggered in the program to occur, i.e. the user must interact with an object in the program.  Event Handlers: is a type of function or method that runs a specific action when a particular event is fired. Advantages of Event-driven Programming:  Very easy to decompose.  Allow multiple programs to interact.  Using Hardware Interrupts, reduces the computer's power usage.  Allows sensors and other hardware to easily interact with the software. Disadvantages of Event-driven Programming:  Programs with too many forms that confuse or annoy users.  Programs with complex GUIs may load and run slower than simple programs, if RAM is insufficient.  Harder to detect errors than simple, procedural programs.  Program flow is often less logical and clear.  Event-driven programming is often more complex and cumbersome. 1.2.4 Compare Below is a table comparing Procedural Programming and OOP: Procedural Programming OOP 1

  • There is no access specifier. - Defines access as “public”, “private”, “protected”. 2
  • There is no concept of inheritance and polymorphism.
  • There is inheritance support that allows using properties and functions of different classes by inheritance.
  • The languages used are Pascal, C, etc. - The languages used are Ruby, C++, Java, etc. 4
  • The main focus is on how the task is performed.
  • The main focus is on data security. 5 -^ Use a^ top-down approach.^ -^ Use a down-top approach. 6
  • Large programs are divided into units called functions.
  • The entire program is divided into objects. 7
  • Without proper data hiding, the data is freely accessible between functions, so the data is not safe.
  • Data is hidden in three modes "public", "private", "protected" thus increasing data security. Table 1. Compare Procedural Programming and OOP

Analyze the common features that a developer has access to in an IDE.

(M2)

2.1 What is IDE? IDE is an integrated environment used to write code for application development. The IDE includes source code editor, compiler, build automation tools, format or highlight code, interpreter, debugger, code directory organization, code search, etc. Currently, there are 2 types of popular IDEs: IDEs with built-in compilers or interpreters such as Visual Studio, Code::Block, Eclipse, and IDE does not have a built-in compiler and interpreter, if you want to run the program, you must use an external compiler, some form like Atom, Bracket, Notepad++, etc. 2.2 Features of IDE The IDE has the ability to complete commands and code quickly; it can automatically check for errors and report the error location at a specific line of code, etc. The basic features of the IDE are:  Text editor: designed to write and manipulate source code. There are source code editing tools like grammar highlighting, sentence auto completion, syntax highlighting for better readability.

Figure 4. Example of text editor in Visual StudioDebugger: help users identify and fix errors in the source code; test different code segments and identify bugs before the app is released. Figure 5. Debugger in Visual studio

Compiler: it has the ability to help programmers switch from programming language to machine language, such as binary code, and then parse and optimize the code to optimize performance. Figure 6. Example of compilerCode completion: help programmers create pre-existing code, save time, reduce the possibility of syntax errors when writing; when writing it will show suggestions for keywords, variables, functions... that are already available or have been created and it also displays symbols when writing a certain statement incorrectly. Figure 7. Code completion in Visual studio

Programming language support: IDEs are usually specific to one programming language, although some IDEs also offer multilingual support. Some popular IDE like Visual Studio, Visual Studio Code, Ruby, Python, Java, etc. So, if we're going to use these apps, before coding, the first step is to figure out what language you're going to code in and narrow down your list of potential IDEs accordingly. Figure 8. Several languages are supported in Visual Studio

CHAPTER 2 IMPLEMENTING THE BASIC ALGORITHM WITH THE

IDE, DISCUSSING THE DEBUGGING PROCESS AND THE

IMPORTANCE OF CODING STANDARDS

LO3 Implement basic algorithms in code using an IDE. LO4 Determine the debugging process and explain the importance of a coding standard.

Write a program that implements an algorithm using an IDE. (P3)

Write an Event-Driven program to create a Book Sales Management form that includes the following attributes: Customer Name, Number of Books, Customer Is a Student. Build methods of Payment, Statistics, Next, Exit and output information to the screen. o Enter Customer Name. o Enter the Number of Books purchased by the customer. o Determine whether the customer is a student or not. o Print out the amount the customer needs to pay. o Print out Total Number of Customers, Total Number of Student Customers and Total Revenue for that day. Presenting the idea of handling, using Event-Driven programming methods: According to the topic, we need to enter: o Customer name. o Number of books. o Determine if the customer is a student. Methods:  Create Form: To enter the above data, first we need to design a Book Sales Management Form. In this Form, create 2 groupBox, name these 2 groupBox Invoice and Statistics. In the groupBox Invoice includes 1 checkbox named "Customer is a Student"; 3 Label and its corresponding textbox, Label is named "Customer Name", "Number of Book", "Into Money". Textbox can be renamed, for example, Label is "Customer Name", the textbox can be set to "txtCustomerName". In the groupBox Statistical, there are 3 Labels and corresponding textbox. The Labels are named "Total Number of Customer", "Total Number of Student