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 HUYNH TRAN ANH KHOA Student ID GCS200283 Class GES0904 NX Assessor name THAI THI THANH THAO 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.
Trang 1ASSIGNMENT 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 HUYNH TRAN ANH KHOA Student ID GCS200283
Class GES0904_NX Assessor name THAI THI THANH THAO
Trang 2 Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date:
Lecturer Signature:
Trang 3Table of Contents
P2 Give explanations of what procedural, object-oriented and event-driven paradigms are; their characteristics and the relationship between them 4
1) Procedural Programming 4
a Definitions 4
b Characteristics 4
2) Object-oriented Programming 5
a Definitions 5
3) Event-driven paradigms 6
a Definitions 6
b Characteristics 6
4) Relationship 7
P3 Write a program that implements an algorithm using an IDE 7
1) Analysis Problem: 7
3) Designed 8
4) Code 8
5) Flowchart 14
P4 Explain the debugging process and explain the debugging facilities available in the IDE 15
1) What is Debugging? 16
2) Process 16
3) Facilities available in the IDE 16
Code Highlighting: is a possibility of text editors used in programming languages When an IDE detects a syntax error, it will frequently assist you by highlighting the section of code where the error was detected It is important to keep in mind that the IDE may not always highlight the actual error 17
Breakpoints: Breakpoints are most popular used to stop a running program immediately before executing an incorrect instruction by specified programmer Breakpoints usually add to the code editor by clicking the line number on the left They usually have a red area on the line number 17
Debugging facilities: 18
P5 Outline the coding standard you have used in your code 19
Conclusion 20
The IDE is of great help to programmers, it help you solve a lot of difficult problems in human life Programmers can rely on the IDE to solve some complex algorithms quickly because there are many similar relationships between them If I didn’t have an IDE, I couldn’t finish my task 20
References 20
Trang 4P2 Give explanations of what procedural, object-oriented and event-driven
paradigms are; their characteristics and the relationship between them
b Characteristics
There are 5 popular characteristics of procedural programming:
• A large program is broken down into small manageable procedures or functions This reduces code repetition,
which improves code capabilities
• Different functions can share data via global variables Functions are all free and independent, so if we want to share
data for computers to understand, we need to declare it scoped on
• Functions can change global data Since global data are transferred from function to function; during the course of the
transformation, the global data may be altered in function chains.
• Top-down methodology Procedural programming follows the top-down rule, the workflow must go from the top to
the bottom
Trang 5Figure 1: Procedural Programming
2) Object-oriented Programming
a Definitions
Object-oriented Programming ( OOP ) is programming that helps to approach and see our human life as a collection of
objects They work in tandem to solve a particular problem at hand
b Characteristics
There are 4 popular characteristics of Object-oriented Programming:
• Encapsulation – Encapsulation is the most secure collection and collection of data and privacy from external interfaces
• Inheritance- This is the process by which a class can be derived from a base class with all features of the base class and
some of its own This increases code reusability.
• Polymorphism- This is a feature that can exist in many different forms For example, a problem can be stacked to add
two integers and two reals.
• Abstraction- This is basic level data feature without any details
Trang 6Figure 2: Object-Oriented Programming
3) Event-driven paradigms
a Definitions
An event-driven paradigm is a type of programming pattern used in important events, programs are identified by events such
as user actions, outputs, or messages passed from various programs 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 This is also true of programming for device drivers
• Simplicity of Programming and Ease of Development
• Compare Event Driven Programming with Object-oriented Programming (OOP)
Trang 7P3 Write a program that implements an algorithm using an IDE
Example: You own a showroom of Mercedes Benz car More and more customers come to buy cars, so the management becomes much more difficult So you need an application software to help you manage your showroom
Trang 81) Analysis Problem:
• Proceed to import more new cars
• Determine the quantity of all products of cars
• Count the number of customers ordering products
• Calculate total revenue
Trang 94) Code
Trang 155) Flowchart
Trang 16P4 Explain the debugging process and explain the debugging facilities
available in the IDE
1) What is Debugging?
Debugging is a process of checking and uncovering existing, potential bugs in software code that can cause it to behave
unexpectedly or crash Debugging is the process of removing the above errors to help prevent the incorrect operation of a
software or system The main purpose of debugging is to find and solve errors or defects in the process of programming or writing code
Almost all IDEs, such as Eclipse, Visual Studio, Android Studio, Net Beans, and others, include debugging tools The steps to debugging are frequently determined by the type of error that you are attempting to debug I will explain two types of
debugging processes
They are quite as same as together
• Run-time Error : This is a basic error that you will often encounter in programming For example, if you are stuck in
DevideByZeroExceptions, you can add a breakpoint or more points to this function and run it in debug mode to see how
your code gets a variable with a value of zero.
• Logic Error : This is more advanced error in programming, it is more difficult than Run-time Error Logic Errors cause the program to run correctly but abnormally, for example, crashes or time errors This error creates other errors that no one wants or unusual behavior that you may not immediately notice
2) Process
One of the most popular used tools in the debug cycle is the power supply debugger Within the IDE, the strong tool is
provided with an intuitive debugging environment that is fully integrated with other workbench tools, giving you the
flexibility you need to best solve problems that arise.
To use, take full advantage of this debug perspective effectively, you must use complied executables for debugging These executables contain additional debugging information that allows the debuggers to create direct links between the source code and binaries generated from that source In the IDE, you will see dissimilar icons: arrowhead icon for executables that are not compiled for debugging
Trang 173) Facilities available in the IDE
Code Highlighting: is a possibility of text editors used in programming languages When an IDE detects a syntax error, it will frequently assist you by highlighting the section of code where the error was detected It is important to keep in mind that the IDE may not always highlight the actual error.
Figure 4: Code Highlighting
Trang 18Breakpoints: Breakpoints are most popular used to stop a running program immediately before executing an incorrect instruction by specified programmer Breakpoints usually add to the code editor by clicking the line number on the left They usually have a red area on the line number
Figure 5: Breakpoints in Visual Studio
Trang 19Parallel Stacks CTR: +SHIFT+D, S Parallel Watch CTR: +SHIFT+D, (1, 2, 3, 4)
5) Debugging in Visual Studio
In the process of using Visual Studio, you will often encounter application errors in programming That means you will run the program with debug feature attached with debug mode When you do this, debugging provides many ways to check what your code is doing at runtime
Here are some debuggers that you often encounter in Visual Studio:
a Set a breakpoint and start the debugger
- To Debug you need to open your visual studio app with debugging attached to the application process Press F5 to start the process Debug, press F5 is the most common and simplest way However, you don’t currently have any breakpoints installed to test the Visual Studio application code, so we will do the first thing before we start debugging Breakpoints are the most basic and essential part of reliable debugging A breakpoint indicates where Visual Studio will pause the program with your error code so it can review variable values or memory operations, or a branch of code that is not suitable for running
- Besides pressing F5, you can use the Start Debugging on the top of Button Start Debugging in the Debug Toolbar, and run to the first breakpoint when it encounters an errors You can also select the line and press F9, select Debug >
Trang 20Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint The breakpoint appears as a red dot in the left margin
b Navigate code in the debugger using step commands
- We provide command data shortcuts because they make navigating your application code faster If you don’t know the buttons, you can use the default features above Button
- To start your application with the debugger attached, press the F11 key F11 is the Step Into command key and more efficient execution of the application one statement at a time When you activate the F11 key with the application, the debug feature will interrupt the first statement to be executed
- This yellow arrow will represent the statement that debugger broke, which also pause the execution of the application at the same time
- Pressing F11 is the best way to examine the execution in detail By default the debugger ignores non-user code
Trang 21c Step into a property
- By default Visual Studio, debugging will ignore managed fields, but the Step Into Specific command allows you to override this behavior
- Right click on forte and select Step Into Specific then choose one of the predefined options
d Run to a point in your code quickly using the mouse
- When debugging, move your mouse over a line of code until the Run to Click button
Trang 22- Using this button is similar to setting a temporary breakpoint This command is also useful during debuggin, helping to move quickly in the visible area of the application code
P5 Outline the coding standard you have used in your code
Visual Studio is a modern, goal-oriented programming software, especially easy to use and manipulate It was created by Microsoft under the leadership of Anders Hejlsberg and his team as part of the NET initiative and has been approved by the European computer technology association and international organizations It includes familiar, modern and easy to use programming languages, C, C++, Java, Python,…
1 The names of classes and methods should always be in Pascal Case
Trang 232 Camel Case should always be used for method arguments and local variables
3 Avoid the use of underscore “_” while naming identifiers
Trang 244 Avoid the use of System data types and prefer using the Predefined data types
Conclusion
The IDE is of great help to programmers, it help you solve a lot of difficult problems in human life Programmers can rely on the IDE to solve some complex algorithms quickly because there are many similar relationships between them If I didn’t have an IDE, I couldn’t finish my task
Trang 25References
[1] Object-Oriented Programming, 07/2021, Available at: https://hackr.io/blog/procedural-programming
[2] Characteristics of Object-Oriented programming language , 07/2021, Available at:
https://www.careerride.com/oops-characteristics.aspx
[3] Characteristics of procedural programming, 07/2021, Available at:
https://www.tuannguyen.tech/2019/05/programming-paradigms-what-is-procedural-programming/
[4] Debugging, 07/2021, Available at: https://economictimes.indiatimes.com/definition/debugging
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.ide.userguide%2Ftopic%2Fdebug _Base_.html
[6] Syntax highlighting, 07/2021, Available at: https://en.wikipedia.org/wiki/Syntax_highlighting
[7] Breakpoint, 07/2021, Available at: https://en.wikipedia.org/wiki/Breakpoint
[8] Procedural Programming, 07/2021, Available at: https://en.wikipedia.org/wiki/Procedural_programming [9] Event-Driven Programming Features, 07/2021, Available at: https://www.ukessays.com/essays/computer- science/eventdriven-programming-features-6167.php
[10] Visual Studio Debugger, 07/2021, Available at:
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019