



















































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!




















































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
ii
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
vi
RAM Random Access Memory GUI Graphical User Interface IDE Integrated Development Environment CPU Central Processing Unit DOS Disk Operating System OOP Object-Oriented Programming
Perfomed Student: Nguyen Thi Tuyet Nhung 2
LO2 Explain the characteristics of procedural, object-oriented and event-driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE).
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.
Perfomed Student: Nguyen Thi Tuyet Nhung 5 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
Perfomed Student: Nguyen Thi Tuyet Nhung 6 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
Perfomed Student: Nguyen Thi Tuyet Nhung 8 Figure 3. Example of Event-driven Programming
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.
Perfomed Student: Nguyen Thi Tuyet Nhung 9 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.
Perfomed Student: Nguyen Thi Tuyet Nhung 11 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.
Perfomed Student: Nguyen Thi Tuyet Nhung 12 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