0% found this document useful (0 votes)
21 views65 pages

HND Computing Programming Report

This document is a final report for a BTEC Level 5 HND Diploma in Computing, focusing on programming and algorithms. It outlines the importance of avoiding plagiarism, provides a detailed structure for the assignment including definitions, processes, and programming paradigms, and emphasizes the significance of coding standards and debugging. The report includes various parts that cover algorithm definitions, coding processes, and examples of program execution.

Uploaded by

thatdepzai44444
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views65 pages

HND Computing Programming Report

This document is a final report for a BTEC Level 5 HND Diploma in Computing, focusing on programming and algorithms. It outlines the importance of avoiding plagiarism, provides a detailed structure for the assignment including definitions, processes, and programming paradigms, and emphasizes the significance of coding standards and debugging. The report includes various parts that cover algorithm definitions, coding processes, and examples of program execution.

Uploaded by

thatdepzai44444
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ASSIGNMENT FINAL REPORT

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 Student ID

Class Assessor name

Plagiarism
Plagiarism is a particular form of cheating. Plagiarism must be avoided at all costs and students who break the rules, however innocently,
may be penalised. It is your responsibility to ensure that you understand correct referencing practices. As a university level student, you
are expected to use appropriate references throughout and keep carefully detailed notes of all your sources of materials for material you
have used in your work, including any material downloaded from the Internet. Please consult the relevant unit lecturer or your course
tutor if you need any further advice.
Student Declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I declare that the
work submitted for assessment has been carried out without assistance other than that which is acceptable according to the rules of the
specification. I certify I have clearly referenced any sources and any artificial intelligence (AI) tools used in the work. I understand that
making a false declaration is a form of malpractice.
Student’s signature

Grading grid

P1 P2 P3 P4 P5 P6 M1 M2 M3 M4 D1 D2 D3 D4
❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:


Internal Verifier’s Comments:

Signature & Date:


Table of Content
Introduce:..................................................................................................................................................................... 8
Content: ........................................................................................................................................................................ 9
Part1 : Provide a definition of what an algorithm is and outline the process in building an application. ....... 9
1:The definition of algorithm. ............................................................................................................................ 9
2:The Charactericstics....................................................................................................................................... 10
2.1:Some keys of characteristics algorithm: ............................................................................................... 10
3: how to algorithm representation................................................................................................................. 11
4: The example................................................................................................................................................... 11
4.1Example in life: Real life example of boiling eggs .................................................................................. 11
4.2: Math example: Compare and fined the largest number among 2 numbers. ..................................... 13
Part 2: Analyse the process of writing code, including the potential challenges faced. .................................. 13
A. Steps to create a program ......................................................................................................................... 13
Step in program developed............................................................................................................................... 16
Step1: Problem definition: ............................................................................................................................ 16
Step 2: Designed program: ........................................................................................................................... 16
Step3: Coding: ................................................................................................................................................ 18
Step4: Debugging and Testing the Program. ............................................................................................... 18
Step5: Documenting the Program:............................................................................................................... 19
Step6: Deploying and Maintaining the Program:........................................................................................ 19
B. Difficulties that will be faced during the program creation process. .................................................... 20
Part 3: Determine the steps taken from writing code to execution .................................................................. 20
1. Assignment:. .............................................................................................................................................. 20
2. Assignment analysis:................................................................................................................................. 21
a) ABC Company requires input: .............................................................................................................. 21
b) ABC Company requires output: ............................................................................................................ 21
3. Program planning and design: ................................................................................................................. 21
a) Allow input "name", "quantity of water", and can check if input is correct and force re-enter if
incorrect. ........................................................................................................................................................ 22
b) Select customer type. ............................................................................................................................ 22
c) Calculate water bill. ............................................................................................................................... 22
d) Print out the invoice .............................................................................................................................. 22
4. Functions and functional analysis:........................................................................................................... 22
a) The function checks that the input "name" contains only letters, re-enter if it is entered
incorrectly. ..................................................................................................................................................... 22
b) The function checks if the input "this water, last water" is a number, re-enter if it is entered
incorrectly. ..................................................................................................................................................... 23
c) Function to re-enter water quantity when(this water < last water) ................................................ 23
d) Function to enter customer category by 'key'. .................................................................................... 24
5. Program Execution Steps:......................................................................................................................... 26
Step1:.............................................................................................................................................................. 26
Step2:.............................................................................................................................................................. 26
Step3:.............................................................................................................................................................. 27
Step4:.............................................................................................................................................................. 27
Step5:.............................................................................................................................................................. 27
Last step: Print the bill. ................................................................................................................................ 28
Part 4: Explain the characteristics of procedural, object-oriented and event-driven programming ............ 29
1. Procedure-oriented programming........................................................................................................... 29
1.2: Main features of procedural programming:......................................................................................... 29
1.3: Advantages and Disadvantages of procedural programming............................................................. 31
1.4: When to Use Procedural Programming. ............................................................................................... 32
1.5: When to Avoid Procedural Programming. ........................................................................................... 32
2. Object-Oriented Programming (OOP) Paradigm. ................................................................................... 33
2.2: The main features of object -orientated. .............................................................................................. 33
2.3: Advantages and Disadvantages of Object-Oriented Programming. ................................................... 37
3. Event-Driven Programming Paradigm. ................................................................................................... 37
3.2: Main functions of Event-Driven Programming Paradigm................................................................... 38
3.3: When to use event-driven programming model.................................................................................. 38
3.4: Advantages and Disadvantages of Event-Driven Programming Paradigm. ...................................... 39
4. The relationship between the above 3 programming models............................................................... 40
Part 5(P4 + M3): Implement basic algorithms in code using an IDE ................................................................ 40
1. Write a program that implements an algorithm using an IDE .............................................................. 40
2. Analyze the common features that a developer has access to in an IDE. ............................................. 51
a) Examples of Popular IDEs:........................................................................................................................ 52
b) Benefits of Using an IDE:........................................................................................................................... 52
Part 6: Determine the debugging process and explain the importance of a coding standard ........................ 53
1. Explain the debugging process and explain the debugging facilities available in the IDE. ................. 53
a) The typical debugging process consists of the following steps: ........................................................ 53
Reproduce the Bug ........................................................................................................................................ 53
b) Debugging Facilities Available in IDEs ................................................................................................ 54
c) Benefits of Debugging. .......................................................................................................................... 55
d) Debug process in the program. ............................................................................................................ 56
2. Examine how the debugging process can be used to help develop more secure, robust applications.
57
3. Explain the coding standard you have used in your code ...................................................................... 59
a) The definition of coding standard. ....................................................................................................... 59
b) There are many reasons to use coding standards in programming, here are the main
benefits: ........................................................................................................................................................ 59
Conclusion. ................................................................................................................................................................. 64
Material: ..................................................................................................................................................................... 64

TABLE OF FIGURE
Figure 0-1: Algorithm .................................................................................................................................................... 9
Figure 0-2Example of Algorithm ................................................................................................................................. 10
Step 1: prepare Eggs 1 ................................................................................................................................................ 11
Step 2: Add water ....................................................................................................................................................... 12
Step 2: Remove eggs ................................................................................................................................................... 12
Figure 0-3: Example Compare Algorithm.................................................................................................................... 13
Figure 0-4: Step1 ......................................................................................................................................................... 14
Figure 0-5: Step 2 ........................................................................................................................................................ 14
Figure 0-6: Step 3 ........................................................................................................................................................ 15
Figure 0-7: Step 4 ........................................................................................................................................................ 15
Figure 0-8: Debugg ...................................................................................................................................................... 18
Figure 0-9: Example Algorithm ................................................................................................................................... 22
Figure 0-11:Example Algorithm .................................................................................................................................. 23
Figure 0-12:Example Algorithm .................................................................................................................................. 24
Figure 0-13: [Link] Asm1 ......................................................................................................................................... 25
Figure 0-14 : ASM 1 ..................................................................................................................................................... 26
Figure 0-15: ASM 1...................................................................................................................................................... 26
Figure 0-17: ASM 1...................................................................................................................................................... 27
Figure 0-18: ASM 1...................................................................................................................................................... 27
Figure 0-19: ASM 1...................................................................................................................................................... 27
Figure 0-20: BILL.......................................................................................................................................................... 28
Figure 0-21: RESULT .................................................................................................................................................... 28
Seqence of In struction 1 ............................................................................................................................................ 29
Function ...................................................................................................................................................................... 30
Global Data ................................................................................................................................................................. 30
Control ........................................................................................................................................................................ 31
Moduarity ................................................................................................................................................................... 31
Object programming ................................................................................................................................................... 33
Encapsulation.............................................................................................................................................................. 35
Polymorphism ............................................................................................................................................................. 36
Code ASM 2 ................................................................................................................................................................. 41
Code ASM 2 ................................................................................................................................................................. 41
Code ASM 2 ................................................................................................................................................................. 42
Code ASM 2 ................................................................................................................................................................. 44
Code ASM 2 ................................................................................................................................................................. 44
Code ASM 2 ................................................................................................................................................................. 45
Code ASM 2 ................................................................................................................................................................. 46
Code ASM 2 ................................................................................................................................................................. 47
Code ASM 2 ................................................................................................................................................................. 48
Code ASM 2 ................................................................................................................................................................. 48
Code ASM 2 ................................................................................................................................................................. 49
STEP 1: Set breakpoint ................................................................................................................................................ 56
STEP 2: Debugging process ......................................................................................................................................... 56
STEP 2: Debugging process ......................................................................................................................................... 56
lOG IN FORM ............................................................................................................................................................... 57
Figure 0-22: PASCAL CASE........................................................................................................................................... 60
Figure 0-23: CAMEL CASE ........................................................................................................................................... 60
Figure 0-24: ALL CAP ................................................................................................................................................... 60
Figure 0-25: CLASS ...................................................................................................................................................... 61
Figure 0-26: LAYOUT STANDARD ................................................................................................................................ 62
Figure 0-27: COMMENT STANDARD ........................................................................................................................... 63

Introduce:
I have applied for a post as a trainee with a software development company and have been invited
for an interview. I have been asked to demonstrate your problem solving and basic programming
skills. To do this I have to prepare a report on using algorithms to solve problems. In this
assignment I will explain what is algorithm, and ouline process in building application.

Vocational Scenario:

1. Create a program that can import:


 Customer name
 Last month’s water meter readings
 This month’s water meter readings
2. For each customer, an invoice with the following information can be displayed:

 the customer name


 Last month’s water meter readings
 This month’s water meter readings
 Amount of consumption (This month’s water meter readings - Last month’s water meter
readings)
 Total water bill
 Sort, search for customer, generate invoices notifying customer and payments dues is one of
the feature enhancement suggestions.
3. Explain some of programming paradigms. Evaluate why and how your program use these (or
some of) paradigms.
4. Explain the common features of an IDE should have and evidence of how the IDE was used to
manage the development of your code
Content:

Part1 : Provide a definition of what an algorithm is and outline the process in building an
application.

Figure 0-1: Algorithm

1:The definition of algorithm.


- An algorithm is a procedure used for solving a problem or performing a computation.
Algorithms act as an exact list of instructions that conduct specified actions step by step in
either hardware- or software-based [Link] are widely used throughout all
areas of IT. In mathematics, computer programming and computer science, an algorithm
usually refers to a small procedure that solves a recurrent problem. Algorithms are also used
as specifications for performing data processing and play a major role in automated
systems.([Link])
Figure 0-2Example of Algorithm

2:The Charactericstics
- An algorithm is a properly defined sequence of steps or commands designed to clear up a
selected problem or perform a selected task. It is a scientific method to problem-fixing that
outlines the important movements or operations to be accomplished in a clean and
unambiguous manner. Algorithms can be expressed in various bureaucracy, along with
natural language, pseudocode, flowcharts, or programming languages.

2.1:Some keys of characteristics algorithm:

- Well-described steps: Algorithms are composed of a specific and unambiguous set of


instructions or steps that can be observed to perform a selected task or solve a problem. Each
step ought to be well-defined, leaving no room for ambiguity or confusion.
- Input and output: Algorithms take inputs, which might be the preliminary records or facts
furnished to the algorithm, and produce outputs, which are the results or solutions generated
by using the set of rules after processing the inputs. The relation among the inputs and outputs
is decided by means of the algorithm's good judgment.
- Correctness: Algorithms must be designed to produce correct results for all legitimate inputs
inside their domain. They must accurately solve the problem they may be designed for, and
their outputs must match the anticipated consequences.
- Understandability: Algorithms need to be designed with clarity and ease in mind, making them
easy to apprehend and implement. Well-documented and readable code can enhance the
understandability of an algorithm.([Link])
3: how to algorithm representation
- Flowcharts are a traditional and straightforward way to represent the steps of an algorithm.
They use different shapes to denote different types of actions or steps, such as processes,
decisions, and inputs/outputs, connected by arrows indicating the flow of control.

4: The example.

4.1Example in life: Real life example of boiling eggs


- Step1: Prepare some eggs and put them in the pot.

Step 1: prepare Eggs 1

- Step 2: Add water to the contents and turn on the stove.


Step 2: Add water

- Step 3: Remove eggs after 15 minutes

Step 2: Remove eggs


4.2: Math example: Compare and fined the largest number among 2 numbers.

Figure 0-3: Example Compare Algorithm

Part 2: Analyse the process of writing code, including the potential challenges faced.
A. Steps to create a program
Step 1: Click on "Visual Studio", and select "Create a new project".

Figure 0-4: Step1

Step 2: Then go to the search bar and type "Console App(Net)", then select.

Figure 0-5: Step 2


Step 3: Then select the program name and select the drive to store the data.

Figure 0-6: Step 3

Step 4: Finally the program is successfully created. And can write lines of code.

Figure 0-7: Step 4


Step in program developed.

Step1: Problem definition:

- The first step in the program development cycle is to define the problem. This is done by
identifying and understanding why is the program or software developed. Usually, it’s in the
form of a program specification. In larger development teams, the system analyst is
responsible for this step.
- The program specification defines the problem statement, what is required from the
software development team, and what is the output of the solution to the problem they’ve
been tasked with solving.([Link])

Step 2: Designed program:


- The next step in the process is to design the program itself. This process starts by focusing on
the program's main goal, which the team defined in the previous step. The goal is then
broken down into manageable parts, all of which play a different role in helping achieve the
goal.
- The well designed program is had to easier to read and understand later. Less of bugs and
errors. Easier to extend to add new features. Easier to program in the first place
Step3: Coding:

- Once the design process is complete, converting algorithm to a program by selecting any one
of the high – level languages that is suitable for the problem.
- Coding is generally a very small part of the entire program development process and also a
less time consuming activity in reality.
- In this process we identify and eliminate all the syntax errors related to spelling, missing
commas, undefined labels etc.
- For effective coding some of the guide lines are to be follow:
 Use of meaningful names and labels of variables
 Simple and clear expressions
 Modularity with emphasis on making modules generalized
 Making use of comments and indenting the code properly
 Avoiding jumps in the program to transfer control

Step4: Debugging and Testing the Program.


- Even though one of the requirements to move onto this step is an error-free program,
sometimes errors still occur. This is why the program is tested in this stage to find any logic,
syntax, and other types of errors. The testing can be done internally, called alpha testing, or
externally, called beta testing
1. Debugging:

Figure 0-8: Debugg

- Debugging is a process of correcting the errors:


 Programs may have logical errors which cannot be caught during compilation
 Debugging is the process of identifying their root causes
 One of the ways is to print out the intermediate results at strategic points of
 computation
 Another way is to use support from the IDE
2. Testing:

 Testing is the process of executing a program with the deliberate intent of finding
errors
 Testing is needed to check whether the expected output matches the actual output
 Testing is done during every phase of program development
 Initially, requirements can be tested for its correctness
 Then, the design (algorithm, flow charts) can be tested for its exactness and efficiency

Step5: Documenting the Program:


- After the testing is complete, the PDLC has reached its final stages. All the structure charts,
flowcharts, decision tables, and pseudocode that were designed and used during the design
phase are now part of the documentation that other people involved in the software project
can use.
- Document explains
 How the program works and how to use the program (user manual)
 How to maintain the program (developer manual)
 Details of particular programs, or particular pieces of programs, are
- easily forgotten or confused without suitable documentation

Step6: Deploying and Maintaining the Program:


- The final step involves deploying the program for the customer. Usually, the development
team keeps a tab on the project for some time, as this is usually the stage where actual usage
problems can be seen.
1) Program maintenance
 Continuing process of maintenance and modification
 To keep pace with changing requirements and technologies
2) Maintainability of the program is achieved by
 Modularizing it
 Providing proper documentation for it
 Following standards and conventions (naming conventions, using symbolic constants,
etc.)
B. Difficulties that will be faced during the program creation process.

1. Setup and Configuration Issues


Installation Issues: Sometimes Visual Studio may not install properly or may be missing
components needed to build a project. Ensuring the correct version and required
components (e.g. .NET, C++ tools, Python support) are installed can be time consuming.
Incorrect IDE Settings: Incorrect IDE settings, such as compiler paths or environment
variables, can lead to build errors.

2. Compilation errors
Syntax errors: This is a very common error that I encounter, and can be difficult to diagnose
if the code is large or the error message is unclear.
Link errors: These errors occur when the compiler cannot find the required functions or
objects. These errors can be frustrating to troubleshoot, especially if the error message is
unclear or if dependencies are not linked correctly.

Part 3: Determine the steps taken from writing code to execution


1. Assignment:.
- The CEO of the company has reviewed the client requirements and has determined that this
is a suitable project for you to take on. The company wants to see how you use and apply the
development environments and code standards.
- The requirements are that ABC wants a program that will allow a user to enter the
- following information:
o Customer name
o Last month’s water meter readings
o This month’s water meter readings
- The program can allow user to enter type of customer, enter number of people to know if it’s
a household

Househol To 10people 5.973VND/m3 597,30


d 10-20people 7.052VND/m 705,20
customer 3
20-30people 8.699VND/m 866,90
3
Over 30 15.929VND/ 1.592,90
people m3
Administrative 9.955VND/m 995,50
agency, public, services 3
Production units 11.615VND/ 1.161,50
m3.
Business services 22.068VND/ 2.206,80
m3
- For each customer, the program should then output the following information:
o the customer name
o Last month’s water meter readings
o This month’s water meter readings
o Amount of consumption (This month’s water meter readings - Last month’s (water meter
readings)
o Total water bill
o Sort, search for customer, generate invoices notifying customer and payments dues is one of
the feature enhancement suggestions.
2. Assignment analysis:
a) ABC Company requires input:
- Customer name
- Last month’s water meter readings
- This month’s water meter readings
b) ABC Company requires output:
- The customer name
- Last month’s water meter readings
- This month’s water meter readings
- Amount of consumption (This month’s water meter readings - Last month’s water meter
readings)
 There is more water this month than last month.
- Total water bill
 The formula for calculating water bill is ((this month's water volume minus last month's
water volume) + (this month's water volume minus last month's water volume) multiplied
by 10% environmental protection fee).
3. Program planning and design:
Input
Variable Error
Customer name With “name”, I use “string” variable I use a "while" loop and the
statement
"[Link](name, "^[a-
zA-Z\\s]+$");" so that when
the name is entered
incorrectly, the program will
force me to re-enter it.
Last month’s With 2 inputs “this water and last I use a "while" loop and the
water water” , I used “float” variable. "([Link](input1,
This month’s out last))" statement so that
water when the number entered is
incorrect, the program will be
forced to re-enter it.
The program has main functions such as:
a) Allow input "name", "quantity of water", and can check if input is correct and force re-enter if
incorrect.

b) Select customer type.

c) Calculate water bill.


d) Print out the invoice

4. Functions and functional analysis:


a) The function checks that the input "name" contains only letters, re-enter if it is
entered incorrectly.

Figure 0-9: Example Algorithm


b) The function checks if the input "this water, last water" is a number, re-enter if it is
entered incorrectly.
- Try. Parse tries to convert a string into a specific data type. Instead of throwing an error
when you hand it a strange input (like trying to convert “banana” into a number), it simply
says, “Hey, I couldn’t do that!”, providing a false Boolean result and leaving you unharmed

Figure 0-10:Example [Link]

Figure 0-11:Example Algorithm

c) Function to re-enter water quantity when(this water < last water)


- It matches any character that is not an 'a', 'b', all the way to 'z', an 'A', 'B', all the way to 'Z', a
single quote ('), a Dollar sign ($), a dash (-) or any spacing character (space, tab, new line,
carriage return, vertical tab, or anything that the character encoding treats as a spacing

character).
Figure 0-12:Example Algorithm

d) Function to enter customer category by 'key'.


- The test condition is given in the beginning of the loop and all statements are executed till
the given boolean condition satisfies, when the condition becomes false, the control will be

out from the while loop.


Figure 0-13: [Link] Asm1
5. Program Execution Steps:
Step1:

I process the input "name". I use a function with type "bool" named "corectName()" . Combined with the
"while" loop . This step is to enter the customer's name and can re-enter if the character is wrong

Figure 0-14 : ASM 1

Figure 0-15: ASM 1

Step2:

I process the input data "water this month, water last month", with the data type "double". I use the
"[Link]" command to turn "input1,2" into double numbers. Combined with the "while" loop. This step is to
enter the quantity and can re-enter if the character is wrong.

Figure 0-16: ASM 1


Step3:

I set the condition (this month's water > last month's water) to be able to calculate the "amount of water
used". amount of water used = this month's water - last month's water.

Figure 0-17: ASM 1

Step4:

I use "while" to loop and print out the statements, customer types for the user to choose. Along with the
input are numbers from 1 -4 in the keyboard.

Figure 0-18: ASM 1

Step5:

I use "switch-case" statement to select each case, especially in case 1 "household customer" there will be 4
more cases about number of people to calculate separate price.

Figure 0-19: ASM 1


Last step: Print the bill.

Figure 0-20: BILL

Figure 0-21: RESULT

Testing and debugging.

Difficulties/methods in solving the problem.

Difficulties:

Syntax Errors
- Syntax errors occur when your code does not conform to the C# language syntax rules.
Debugging Issues

Part 4: Explain the characteristics of procedural, object-oriented and event-driven


programming
1. Procedure-oriented programming.

1.1: Definition: Procedural programming is a programming paradigm built around the idea
that programs are sequences of instructions to be executed. They focus heavily on splitting
up programs into named sets of instructions called procedures, analogous to functions. A
procedure can store local data that is not accessible from outside the procedure's scope and
can also access and modify global data variables.

 Some of the earliest procedural programming languages were Fortran and ALGOL. Ideas
developed in ALGOL are very much relevant and prevalent in modern-day programming
languages.
1.2: Main features of procedural programming:
a) Sequence of Instructions:
- The top-down approach is a way of dividing and subdividing the procedure into a sequence
of commands. As you break down the commands and get further through the sequence, the
instructions become more specific. The top-line level of commands is often a broad task
with little detail, for example. As you separate the command into smaller parts, each part
becomes increasingly detailed and specific until there's a set of specific commands that let
the program achieve the top-line objective.

Seqence of In struction 1
b) Procedures (Functions):
- Sometimes developers code new instructions and functions into their programs. You may
use common technology commands and functions frequently when writing a program. Pre-
defined functions are common, ready-to-use functions. Developers identify them by name,
and they're generally part of a larger programming library that professionals can access
rather than programming a new function. Back-end developers often use these pre-defined
resources as blueprints.

Function

c) Global Data:
- Global variables are the opposite of local variables. Although local variables have a limited
scope of one subprogram, a global variable piece of data is visible in all subprograms across
the wider program. Developers can therefore use a global variable in all functions of the
program.

Global Data

d) Control Structures:
- Procedural code relies heavily on common control flow structures like loops, conditionals
(if-else), and function calls.
Control

e) Modularity:
- Modularity relates to the top-down approach of breaking down overall tasks into smaller
tasks and commands. It is the programming approach of having two different tasks
grouped together under a wider process. The proper functioning of this process depends
on these two tasks in the shared group. Both finish at the same time to complete a more
prominent task first. This lets developers prioritise tasks within their procedural sequence.

Moduarity

1.3: Advantages and Disadvantages of procedural programming.


a. Advantages:

- Simplicity: For simple, linear tasks or small programs, procedural programming can
be straightforward and easy to implement.
- Efficiency: Since the flow of control is linear and typically directly tied to the
sequence of operations, procedural programs can often be more efficient than other
paradigms, especially for smaller applications.

b. Disadvantages:

- Poor Scalability: As applications grow, procedural programs can become difficult


to manage and maintain. The lack of encapsulation and the tendency to rely on
global state makes debugging and extending the program challenging.
- Code Duplication: Without mechanisms like inheritance or polymorphism (which
exist in object-oriented programming), procedural programming can lead to
duplicated code and a lack of reusability.
- Tightly Coupled Code: Functions and data may be tightly coupled, making it harder
to modify and test individual parts of the program without affecting other parts.

1.4: When to Use Procedural Programming.


- Small-scale applications where the program’s logic is straightforward and doesn't
require complex data structures or relationships.
- Scripts or tools that automate tasks (like batch processing).
- System-level programming (e.g., operating systems, embedded systems) where
direct control over hardware or memory is required.
- Performance-sensitive applications where the overhead of object-oriented
structures or event-driven models might be too expensive.

1.5: When to Avoid Procedural Programming.

- The application is large or complex, and you need a more structured approach to
organizing and maintaining the code.
- Data and behaviors are inherently tied and should be grouped together (for
instance, in the case of GUI applications or complex simulations).
- Code reuse and scalability are priorities, as OOP and event-driven models better
support these goals.
2. Object-Oriented Programming (OOP) Paradigm.

Object programming

2.1: Definition: Object-oriented programming (OOP) is defined as a programming paradigm


(and not a specific language) built on the concept of objects, i.e., a set of data contained in
fields, and code, indicating procedures – instead of the usual logic-based system. system.
2.2: The main features of object -orientated.
a) Abstraction:

- This provides essential features without describing any background details.


Abstraction is important because it can hide unnecessary details from reference
objects to names. It is also necessary for the construction of programs. Instead of
showing how an object is represented or how it works, it focuses on what an object
does. Therefore, data abstraction is often used for managing large and complex
programs.
b) Inheritance:

- Inheritance is an important pillar of OOP(Object-Oriented Programming). The


capability of a class to derive properties and characteristics from another class is
called Inheritance. When we write a class, we inherit properties from other classes. So
when we create a class, we do not need to write all the properties and functions again
and again, as these can be inherited from another class that possesses it. Inheritance
allows the user to reuse the code whenever possible and reduce its redundancy.
c) Encapsulation:

Encapsulation

- Encapsulation is defined as the wrapping up of data under a single unit. It is the


mechanism that binds together code and the data it manipulates. In Encapsulation,
the variables or data of a class are hidden from any other class and can be accessed
only through any member function of their class in which they are declared. As in
encapsulation, the data in a class is hidden from other classes, so it is also known
as data-hiding.
d) Polymorphism:

Polymorphism

- The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form. For
example, A person at the same time can have different characteristics. Like a man at
the same time is a father, a husband, an employee. So the same person posses
different behavior in different situations. This is called polymorphism.
2.3: Advantages and Disadvantages of Object-Oriented Programming.
a) Advantages:
Modularity: Software is organized into distinct classes and objects, making it easier to
understand and modify.
Reusability: Code can be reused through inheritance, reducing redundancy.
Maintainability: Changes to one part of the system can be made without affecting
others, especially if encapsulation is used properly.
Scalability: OOP allows systems to be extended and new functionality to be added with
minimal disruption to existing code.

b) Disadvantages:
Complexity: OOP can introduce unnecessary complexity for small projects or for those
who are unfamiliar with the paradigm.
Performance: The overhead introduced by objects and method calls may impact
performance, especially in resource-constrained environments.

3. Event-Driven Programming Paradigm.

3.1: Definition: Event-driven programming (EDP) is a programming paradigm where external


events determine the flow of program execution. These events come in different shapes: user actions
(e.g., button clicks, keyboard inputs), system events (like a finished file download), messages from other
programs, sensor outputs, etc.

3.2: Main functions of Event-Driven Programming Paradigm.


1. Event: An event is any significant occurrence or action that the program can respond to. In
the context of user interfaces, common events include:
- Mouse clicks
- Keyboard presses
- Window resizing
- Timer events
- System notifications
2. Event Handlers
- These are special functions or methods that are triggered by specific events. When an
event occurs, the corresponding event handler is called to handle the event. For example,
when a button is clicked in a graphical user interface (GUI), an event handler for that
button's click event will execute
3. Event Loop:
- The event loop is a core concept in event-driven programming. It is a continuous cycle
that listens for events and dispatches them to the appropriate handlers. The event loop
typically runs in the background, waiting for events to occur. When an event happens, the
event loop ensures the correct event handler is executed.
4. Callback Functions:
- Callback functions are functions that are passed as arguments to other functions and are
called when certain events happen. In an event-driven system, callback functions are
used as event handlers to define how the program should respond when an event occurs.

5. Asynchronous Programming:
- Event-driven programming often involves asynchronous operations, where the program
can respond to multiple events without waiting for one task to finish before starting
another. This is particularly useful in GUI applications or systems that require
responsiveness, such as web servers.

3.3: When to use event-driven programming model.

a) Graphical User Interfaces (GUIs): In GUI applications, users interact with the system by
clicking buttons, selecting menu options, or typing in fields. The program responds to
these events by triggering appropriate functions or methods.
b) Real-time Systems: In real-time applications like gaming or simulations, the system must
respond to user input, changes in the environment, or other real-time data events
continuously.
c) Web Servers: Event-driven programming is used in handling HTTP requests
asynchronously. The server waits for incoming requests and handles them as they come
in.
d) Embedded Systems: Embedded systems with limited resources often rely on event-
driven programming to handle sensor input, button presses, or other hardware events.

3.4: Advantages and Disadvantages of Event-Driven Programming Paradigm.


a) Advantages:

- Responsiveness: Since the program reacts to user input or external events, it can be very
responsive. For example, in a GUI application, the program can continue to function while
waiting for user actions.
- Scalability: Event-driven systems can handle many different types of events and can scale
well when dealing with multiple concurrent users or devices.
- Flexibility: Event-driven programming allows for the easy addition of new events and
handlers, making it ideal for dynamic, real-time applications.
- Simplicity in GUI Applications: EDP makes it easier to handle user interactions like
mouse clicks and key presses. These events can be managed in a natural and intuitive way
by defining separate handlers for each type of interaction.

b) Disadvantages:
- Complexity in Event Management: In large applications, managing events and event
handlers can become complex, especially when events are chained or need to interact in
specific sequences.
- Harder to Debug: Since the flow of the program is non-linear and asynchronous, it can be
harder to trace program execution and debug issues related to event handling.
- Concurrency Issues: In systems that handle many events at the same time (e.g., web
servers), proper management of concurrency and synchronization is necessary to avoid
race conditions or inconsistent states.

4. The relationship between the above 3 programming models


- The Event-Driven Programming (EDP), Object-Oriented Programming (OOP), and
Procedural Programming (PP) paradigms can work together in many applications. Event-
driven programming focuses on handling events and responding to user or system actions
asynchronously, often using event loops and callback functions.
- This can be implemented using object-oriented principles, where events are managed as
methods within objects, enhancing modularity and reusability. While OOP organizes code
into classes and objects, encapsulating data and behavior, procedural programming
follows a linear flow of execution, organizing code into functions.
- In practice, OOP and PP can coexist, with OOP providing structure and abstraction and PP
handling specific tasks or procedural flow, while event-driven logic can be integrated within
both paradigms to create interactive, responsive systems.

Part 5(P4 + M3): Implement basic algorithms in code using an IDE


1. Write a program that implements an algorithm using an IDE
Nowadays, everything is fast and digital, so calculating and managing water bills
manually like 20 years ago is impossible. So I developed a software to help calculate
and manage water bills more clearly and quickly.
In this Assignment I have built a Window form application to manage water bill
payment including: Add, edit, delete, sort customers, calculate water bill.
Like other software, there must be a login section, only for employees to know
customer information. I created an account with "USERNAME: phongdzz", and
"PASSWORD: 123456".
To run the Form Login first I need to write this code:

Code ASM 2

To log in the account I wrote the code in “LOGIN” button, with “CLICK” event:

Code ASM 2

I have created 2 variables “u , p” with string data type, “u ” corresponds to “


USERNAME”, “ P” corresponds to “PASSWORD”.
[Link](“phngdzz”) && [Link](“123456”)
Meaning if you enter USERNAME = phongdzz, PASSWORD = 123456 correctly. A
successful login message will appear.
Form1 form = new Form1():
Here is how to save a Form in WINDOWS FORM with the LOGIN form named "Form1".
[Link](); mean closed form LOGIN
ShowDialog(); mean open form manage water , and cannot interact again on the Login
form.
After the successful login message appears, the interface will appear like this :

In this form I will set the corresponding variables to save: name, number of countries,
customer type, ....

Code ASM 2

Data type + [] …. = new data type + []


Here is how to create a list to store the data for that variable.
name = Name Of Customer
type = Type of Customer
lastMonths = Water Meter Last Month
thisMonths = Water Meter This Month
numberPeople = Number Of People
usage = amount of water. is calculated by (thisMonths – lastMonths)
totalCost = water bill

Create the GetPriceUnit() function to determine the price for each customer type and
number of users.
CustomerType == 0 mean that User selects customer type "Household".
If the number of people < 10 then unit value = 5973.
If the number of people < 20 then unit value = 7052.
If the number of people < 30 then unit value = 8699.
If the number of people > 30 then unit value = 15929.
CustomerType == 1 mean that User selects customer type " Administrative".
The unit value = 9955.
CustomerType == 0 mean that User selects customer type " Production units".
The unit value = 11615.
CustomerType == 0 mean that User selects customer type " Business services".
The unit value = 22068.
Code ASM 2

Display() function to create columns in DataGridview.


[Link] = null; mean that clear any existing data from the DataGridView.
New DataTable() : Create a new table in DataGridVIew with name “bill”
[Link](“…”): Create new columns for “name, last Month, This Month, usage,
Total Cost”.
“For” loop to save the values " name, last Month, This Month, usage, Total Cost " , with
each loop adding 1 value to the table.
[Link] = bill; This is the command line to display values in each column
in DataGridView

Code ASM 2
First I assign the value of cboType = SelectedIndex.
“SelectedIndex” is an integer representing the selected position in the comboBox.
If (SelectedIndex ==0) means selecting the first position in ComboBox(HouseHold),
then the 2 items "lblNumberPeople", "txtPeople" appear.
[Link] = true;
[Link] = true;
Otherwise these 2 items will disappear if the user selects another position in the
ComboBox.
[Link] = false;
[Link] = false;

Code ASM 2

This is the code line that can display the bill as a notification through "MessagaBox".
string nameCustomer = [Link];
string costumerPeople = [Link];
nameCostumer get value from txtName, this is cuxtomer names.
costumerPeople get vaue from txtPeople, this is the number of people in household.
double lastMonth = [Link]([Link]);
double thisMonth = [Link]([Link]);
“Parse” has the effect of coercing the value to "double"
“lastMonth”: Converts the value from the txtLastMonth input cell (amount or index of the
previous month) to a double data type.
“thisMonth”: Converts the value from the txtThisMonth input cell (amount or index of this
month) to a double data type.
int customerType = [Link];
customerType gets the selected index (ie customer type), SelectedIndex returns the selected
index.
0 = household
1 = Administrative
2 = Production units
3 = Business services

double usageTotal = thisMonth - lastMonth;


usageTotal is the amount of water used, calculated by subtracting the amount of water last
month from the amount of water this month.
double priceUnit = GetPriceUnit(customerType, usageTotal);0
priceUnit: Call a method named GetPriceUnit, passing in the customerType and usageTotal to
get the unit price value. This method will likely return a unit value based on the customer
type and usage (different prices may apply depending on the customer type or usage).
double totalBill = priceUnit * usageTotal * 1.1;
totalBill: Calculates the customer's total bill by multiplying the unit value (priceUnit) by the
total usage (usageTotal), then multiplying by a factor of 1.1(10%).

Code ASM 2

Similar to above I create variables for each value.


"n" is the number of values, "n" means there is no specific value. If the user enters the items
"name of customer, water meter last month, water meter this month, type of customer,
number of people" it will be saved in the lists as "name, type, lastMonth, thisMonth,
numberPeople, usage, totalCost"
Display() is a function that displays the data just entered into the DataGridView.
Code ASM 2

int index = -1;


The index variable is the index that the user selects in the ComboBox, -1 mean the default is
nothing selected.
Index = [Link];
“[Link]” return the index the user selected, and displays it in ComboBox.
[Link] = lastMonths[index].ToString();
[Link] = thisMonths[index].ToString();
“lastMonth[index]” retrieves the value of the previous month at index position in the
“lastMonths” array and converts it to a string to display in “txtLastMonth”.
“thisMonths[index]” similarly, retrieves the value of the current month from the
“thisMonths” array and displays it in “txtThisMonth”.
[Link] = name[index];
Get the value from the array name at position index and assign it to "txtName", a data input
field on the user interface to display the name.
[Link] = type[index];
[Link] = (type[index] == 0) ? numberPeople[index].ToString() : "";
The condition (type[index] == 0) checks if type is 0. If true, get the number of people from the
"numberPeople" array at index position and display it in "txtPeople". Otherwise, the
"txtPeople" cell is cleared (set to blank).
Code ASM 2

The Edit() function has the same command line as "Save".


DialogResult Result = [Link]("M co chac muon sua", "confirm", [Link],
[Link]);
“result” is a DialogResult variant type, used to store the result the user selected in the
validation dialog(messageBox).
[Link]()
This is the method called to display a message box to the user. This method can have multiple
parameters to customize the contents of the dialog box.
(Result == [Link])

This is when the user selects "Yes" in the confirmation dialog. It will then run the commands
to save the values and print them to the DataGridView.

Code ASM 2
for(int i = index; i<n; i++)
Loop through all elements from index to n (the size of the array). This means starting from
the position to be deleted (stored in the index variable), and deleting all elements from there
until the last element in the list.
name[i] = name[i+1];
type[i] = type[i+1] ;
lastMonths[i] = lastMonths[i+1] ;
thisMonths[i] = thisMonths[i+1] ;
numberPeople[i] = numberPeople[i+1] ;
usage[i] = usage[i+1] ;
totalCost[i] = totalCost[i+1] ;
The values in the array will be shifted forward (incremented) to "delete" the element at
position i. For example, name[i] = name[i + 1]; will replace the name at position i with the
name at the next position (i + 1). Similarly, other values in the arrays such as type,
LastMonths, thisMonths, numberPeople, Usage, TotalCost are also treated similarly.
n --;
It shows that 1 element has been subtracted.

Code ASM 2

The Swap() function swaps positions.


(name[i], name[j]) = (name[j], name[i] );
(type[i], type[j]) = (type[j], type[i]) ;
(lastMonths[i], lastMonths[j] ) = (lastMonths[j], lastMonths[i]) ;
(thisMonths[i], thisMonths[j]) = (thisMonths[j], thisMonths[i]);
(numberPeople[i], numberPeople[j]) = (numberPeople[j], numberPeople[i]) ;
(usage[i], usage[j]) = (usage[j], usage[i]);
(totalCost[i], totalCost[j]) = (totalCost[j], totalCost[i]);
Swap the positions of "j" to "i" , and "i" to "j", in the arrays "name, type, lastMonths,
thisMonths, usage, totalCost"
for(int i = 0; i <n - 1; i++)
This is the main loop of the Bubble "Sort algorithm". This loop will execute from i = 0 to i = n -
2. Each iteration of the outer loop helps to "push" the largest unsorted element to the correct
final position (similar to a "bubble" floating on the water surface, so this algorithm is called
Bubble Sort).
for(int j =0; j < n-i -1; j++)
This is the sub-loop, which is used to compare and swap elements in the totalCost array. Each
time the outer loop is incremented, the number of elements to compare decreases because
the largest elements have been "brought up" in previous loops.
"n - i - 1" helps reduce the number of elements to compare after each outer loop run.
(totalCost[j] > totalCost[j+1] )
This is a condition to check if the current element "totalCost[j]" is greater than the next
element "totalCost[j + 1]". If true, it means the elements are not in the correct ascending
order, so we need to swap them
(totalCost[j] < totalCost[j + 1])
This is a condition to check whether the current element "totalCost[j]" is less than the next
element "totalCost[j + 1]". If it is true then the elements are not in the correct ascending
order so we need to swap them
Swap(j, j+1);
That means if the condition (totalCost[j] > totalCost[j + 1]) is true then it will swap the stored
arrays "name, type, ..."
string search = [Link];
Get the value from “txtSearch” and assign it to the variable “search”.
if (![Link](search))
If the user only enters even 1 character, the program will filter the data.
Otherwise, the program will leave it intact without filtering anything.
var filteredBills = new DataTable();
[Link]("name");
[Link]("type");
[Link]("last Month");
[Link]("this Month");
[Link]("usage");
[Link]("Total Cost");
filteredBills is a new data table (DataTable) that will contain filtered bills.
The columns of filteredBills correspond to the bill information: "name", "type", "last Month",
"this Month", "usage", and "Total Cost".
for (int i = 0; i < n; i++)
if (name[i] != null && name[i].IndexOf(search, [Link]) != -1)
[Link](name[i], type[i], lastMonths[i], thisMonths[i], usage[i], totalCost[i]);

This loop iterates over all elements in the name[] array (the array containing the names of
the invoices).
n is the number of invoices (or the number of elements in the respective arrays).
name[i] != null: Ensures that the invoice name is not null.
name[i].IndexOf(search, [Link]) != -1: Checks whether the
invoice name (name[i]) contains the search keyword.
IndexOf(search, [Link]) returns the position of the keyword
in the invoice name. If not found, it returns -1. This checks whether the search keyword
appears in the invoice name, regardless of upper or lower case.
2. Analyze the common features that a developer has access to in an IDE.
Definition: An Integrated Development Environment (IDE) is a software application that
provides developers with a comprehensive set of tools for writing, testing, and debugging
code. It is designed to make the software development process more efficient by combining
several essential features into one platform.

a) Examples of Popular IDEs:

- Visual Studio Code (VS Code): A highly customizable, open-source IDE from Microsoft,
known for its lightweight nature and support for multiple languages.
- Eclipse: Popular for Java development but also supports other languages through plugins.
- IntelliJ IDEA: A widely-used IDE for Java, Kotlin, and other languages, known for its
powerful code assistance and smart refactoring features.
- PyCharm: A Python-specific IDE, designed to streamline Python development with built-
in tools for testing, debugging, and package management.
- Xcode: The official IDE for macOS and iOS development, used for building apps in Swift
and Objective-C.

b) Benefits of Using an IDE:

- Efficiency: All the tools you need are in one place, which saves time spent switching
between different applications.
- Error Reduction: Features like syntax highlighting, auto-completion, and real-time error
checking help reduce mistakes.
- Learning Curve: Many IDEs offer features that make it easier for beginners to get started,
such as tutorials, templates, and simple debugging tools.
- Productivity: Built-in automation features like code refactoring, linting, and debugging
tools streamline development, enabling developers to focus more on writing good code.

c) Common features that users can access:

- Code Editor: A text editor optimized for writing source code, which often includes
features like syntax highlighting, auto-completion, and code folding to help developers
write code more efficiently and with fewer errors.
- Compiler/Interpreter: IDEs typically include a built-in compiler (for compiled languages
like C, C++) or an interpreter (for interpreted languages like Python), allowing you to
convert your source code into executable programs or run code directly from the IDE.
- Debugger: A tool to test and troubleshoot code by running it in a controlled environment,
allowing you to step through the program, inspect variables, and find bugs.
- Build Automation Tools: IDEs can integrate with tools that automate the process of
compiling and linking code, which can speed up development, especially for large projects.
- Version Control Integration: Many modern IDEs offer built-in integration with version
control systems like Git, making it easier to track changes in your codebase, collaborate
with others, and manage different versions of your software.
- User Interface (UI) Tools: For creating and designing graphical user interfaces (GUIs),
some IDEs offer drag-and-drop UI builders.
- Project Management: IDEs often support managing large codebases with project and file
organization, making it easier to navigate through files, libraries, and dependencies.

Part 6: Determine the debugging process and explain the importance of a coding
standard
1. Explain the debugging process and explain the debugging facilities available in
the IDE.
What is debugging ?
Debugging is an essential part of software development because it helps ensure that your code
runs as intended and meets its requirements. Bugs or errors are a natural part of
programming, and debugging is the process of finding and fixing these issues to make sure the
software works correctly.

a) The typical debugging process consists of the following steps:


Reproduce the Bug
- Understanding the Bug: First, determine the conditions under which the bug occurs. This
often involves observing error messages, the unexpected behavior of the program, or user
feedback.
- Isolate the Trigger: Try to reproduce the issue in a controlled environment. This means
figuring out the sequence of actions or input that leads to the error.
Analyze the Bug
- Check Logs and Errors: Look for any relevant error messages, stack traces, or logs that
provide information on where the error occurred.
- Determine the Type of Bug: Is the bug a syntax error, runtime error, or logical error?
Understanding the type helps in narrowing down the debugging process.
Locate the Source of the Problem
- Trace the Program Flow: Identify where the issue is occurring in the code. This can be done
using print statements, logs, or more advanced debugging tools.
- Divide and Conquer: Isolate parts of the code to narrow down the problem. You can do this
by commenting out sections of code or disabling specific features to see if the issue persists.
Fix the Bug
- Once the cause of the bug is identified, apply the necessary changes to the code. This could
involve fixing a typo, correcting a logic error, or modifying an algorithm.
- Test: After fixing the bug, test the program again to ensure that the issue is resolved and that
no new issues have been introduced.
Validate and Optimize
- Regression: Ensure that the bug fix does not interfere with other parts of the code.
- Optimize: Sometimes fixing a bug involves not just correcting the issue but improving the
efficiency or structure of the code to prevent future bugs.

b) Debugging Facilities Available in IDEs


Breakpoint
- Setting Breakpoints: A breakpoint allows the debugger to pause the execution of the program
at a specific line of code. This is especially useful for inspecting the state of the program at
particular moments.
- Conditional Breakpoints: Some IDEs allow you to set breakpoints that are triggered under
specific conditions, such as when a variable reaches a certain value.

Step Through
- Step Over: This allows you to move over a line of code without entering any function calls it may
contain. This is useful when you want to skip over functions that you know are working fine.
- Step Into: This allows you to dive into function calls and observe how the code executes
inside those functions. This is essential for tracking down bugs in specific functions or
methods.
- Step Out: This lets you exit from the current function and return to the calling function. It’s useful for
quickly moving out of deeply nested functions.

Variable Inspection
- Watch Variables: You can watch the values of specific variables during execution. The IDE will
show you how their values change at different points in the program. This is helpful for
detecting logical errors.
- Hover to Inspect: Many IDEs allow you to hover over variables while the program is paused,
displaying the current value of that variable.
- Variable Scope: You can view the scope of variables—local, global, or parameters of a
function—so you can better understand where the values are coming from and how they
change.

Call Stack
- Viewing the Call Stack: The call stack shows the sequence of function calls that led to the
current point in the program. It can help identify which function is responsible for an issue,
particularly in recursive or deeply nested calls.
- Call Stack Navigation: You can navigate through the stack to examine previous function calls,
making it easier to trace how the program reached a certain point.
Logging and Output Windows
- Console Output: IDEs often provide a built-in terminal or console window where you can
view print statements, logs, or error messages generated by your program.
- Logging: You can log information such as variable values, execution paths, or custom
messages. This is useful for tracking down issues that only happen under certain conditions.

Exception Handing and Stack Trace


- Automatic Break on Exception: Some IDEs automatically pause execution when an exception
is thrown, allowing you to inspect the exception’s stack trace and the state of the program at
the point where it occurred.
- Custom Exception Handling: You can define custom exception handling to log information or
take specific actions when an error occurs.

Memory Management Tools


- Memory Profiling: Some IDEs (especially those that support C, C++, or similar languages)
include tools for tracking memory usage, detecting memory leaks, and analyzing how memory
is allocated and deallocated during program execution.
- Garbage Collection: In languages like Java or C#, IDEs can show when garbage collection
occurs and how it impacts the performance of the application.

c) Benefits of Debugging.

- Improves Code Quality: Debugging helps identify and fix errors, ensuring the software
functions correctly and reliably.
- Enhances Developer Understanding: It allows developers to understand the code’s behavior,
pinpoint issues, and improve logic.
- Saves Time and Resources: Early detection of bugs leads to faster problem resolution,
reducing future testing and rework.
- Optimizes Performance: Debugging helps identify inefficiencies like memory leaks and
bottlenecks, improving the overall performance of the software.
- Reduces Future Errors: Fixing existing issues often prevents similar bugs from appearing
later, leading to cleaner, more maintainable code.
- Increases Productivity: By resolving issues quickly, developers can focus on adding features
and enhancing the product rather than spending time troubleshooting later.
- Improves User Experience: Debugging ensures the software runs smoothly without crashes
or errors, leading to a better user experience.

d) Debug process in the program.

Step 1 : Set break point:

STEP 1: Set breakpoint

Step 2: Start debugging process:

STEP 2: Debugging process

STEP 2: Debugging process


lOG IN FORM

In this case i put "username = phongdzz", "password = 123456"

We can easily see that when I enter username = "phong", and password = "123", it is wrong
with the condition, so the program automatically "oversteps" to the "else" condition.

2. Examine how the debugging process can be used to help develop more secure, robust
applications.
1. Identifying and Fixing Security Vulnerabilities
Debugging helps me detect issues that can create security vulnerabilities:
- Buffer Overflow: Using debugging tools such as breakpoints and memory watches,
engineers can detect buffer overflows that could be exploited by attackers to execute
malicious code.
- SQL Injection Vulnerabilities: Debugging allows developers to examine database queries
sent from the application. By examining input and output, they can detect points where
user input is not properly sanitized and could be vulnerable to SQL Injection.
- XSS (Cross-Site SAcripting): Debugging allows developers to monitor how user input is
processed and displayed, helping to ensure that untrusted data is properly sanitized or
encoded to prevent XSS attacks.
2. Ensuring Correctness and Reliability
Debugging helps find logical errors, race conditions, and unhandled edge cases, ensuring that
the application behaves correctly under different circumstances:
- Crash Prevention: Debugging tools help developers pinpoint crashes and unhandled
exceptions by providing stack traces and detailed error logs, enabling the application to be
more stable and crash-resistant.
- Concurrency Issues: In multi-threaded applications, debugging allows developers to
observe thread synchronization and detect race conditions, which can cause unpredictable
behavior, crashes, or corruption of critical data.
- Memory Leaks: Debuggers can monitor memory usage to track down memory leaks and
unfreed memory, which could cause performance degradation or crashes over time,
resulting in less robust applications.
- Boundary Cases: Debugging helps ensure that edge cases, such as extreme input values,
are handled correctly, preventing crashes or incorrect outputs. These tests improve the
robustness of the application in real-world scenarios.
3. Improving Application Performance
Debugging is not only for identifying errors but also for fine-tuning performance. By using
performance debugging tools, developers can:
- Profile Performance: Debuggers can profile an application’s resource usage (e.g., CPU,
memory), helping to identify performance bottlenecks that could impact scalability and
efficiency.
- Optimize Algorithms: By inspecting how the application handles large inputs or complex
operations, developers can optimize algorithms for better performance, which
contributes to both robustness and security. For instance, slow code may lead to denial-
of-service vulnerabilities due to resource exhaustion.

4. Testing Edge Cases


Debugging facilitates in-depth testing of how the application handles various inputs and
conditions, especially the edge cases that often break applications. For instance, a debugger
allows developers to simulate and test conditions

5. Enforcing Coding Standards and Best Practices


While debugging, developers can spot areas of the code that don’t adhere to security and
design best practices. This includes:

- Use of Hardcoded Secrets: Debugging may uncover hardcoded passwords or API keys,
which are a common security risk. Developers can replace these with environment
variables or secure vault solutions.
- Use of Unsafe Functions: Debuggers can help identify unsafe functions (like gets() in C)
that may lead to buffer overflows or other vulnerabilities.

6. Automated Debugging and Continuous Integration


Debugging isn’t just a manual process; automated debugging tools, such as static analysis and
dynamic analysis tools, can be integrated into a continuous integration/continuous
deployment (CI/CD) pipeline. These tools can:
- Automatically identify common bugs and vulnerabilities during the development process.
- Help catch regressions (security or functionality issues) early, ensuring the application
remains robust and secure as it evolves.

3. Explain the coding standard you have used in your code


a) The definition of coding standard.
- Coding standards, also known as coding guidelines or programming style guides, are
rules and conventions that developers follow when writing code. These rules define the
code characteristics necessary to maintain a uniform codebase and facilitate
collaboration among developers.

b) There are many reasons to use coding standards in programming, here


are the main benefits:

1. Enhancing efficient of the software development process:


- Developers spend a large part of their time fixing quality issues that could have been
avoided. Implementing coding standards help developers detect these problems early on or
prevent them entirely.
2. Reducing code complexity and the number of bugs :
- If a developer’s codebase is complex, the chances of it having bugs are higher. Coding
standards help you develop less complex software and therefore reduce errors.
3. Improvement of the bug fixing process:
- With coding standards, it becomes easier for developers to find and fix bugs in the code
because it’s written in a consistent manner.
4. Improvement of the code maintenance process:

- If developers are following coding standards, the code is consistent and can be easily
maintained. Anyone can understand it and modify it easily at any time.

Coding standard used in program.

1) Naming Convention.

Pascal Case: Used for class names, methods, properties, events, and constants. The first letter of
each word is capitalized.

Example: TaxRate, Name….


Figure 0-22: PASCAL CASE

In the above code, I am using the standard encoding name. It represents a type that should
have both lowercase and uppercase letters, starting with an uppercase letter.

camelCase: Used for variables and method parameters. The first letter of the first word is
lowercase, and subsequent words start with an uppercase letter.

 Example: totalAmount, userName, productList.

Figure 0-23: CAMEL CASE

In the above code, I am using standard encoding name. It represents variable name, it has
both lowercase and uppercase, first letter is lowercase. There is letter "s" after variable name
if there is more than 1.

ALL CAPS: Used for constants.

 Example: MAX_SIZE, PI.

Figure 0-24: ALL CAP


In the above code, I use the standard encoding name. It represents rows of numbers, usually
all digits are uppercase, and underscores can be used.

Class: Each class should be in its own file, and the file name should match the class name. Ensure
that classes have clear responsibilities and avoid overly large classes (typically, they should not
exceed 200–300 lines of code).

 Example: The file name should be [Link] if the class is Customer.

Figure 0-25: CLASS

Methods: Methods should have descriptive names. Each method should perform a specific task
(Single Responsibility Principle).

 Example: CalculateTotalAmount(), GetCustomerInfo().


In the above code, I used a standard code name. It is a function, which can represent a value
or just a name and the statements in it. A function represents a specific function.

2) Layout Standard:

Figure 0-26: LAYOUT STANDARD

3) Comment Standard
Figure 0-27: COMMENT STANDARD
Conclusion.
In this article I have presented my understanding of algorithms and steps of building a
program. Then I have applied it in practice. I have written the code on Visual Studio
application.

Reference

P1: I’ve defined what an algorithm is and outlined the process of building an application. (Page
8)
M1: I analyzed the coding process, including the potential challenges faced.
+) I analyzed the coding process based on the water bill problem. I demonstrated an
understanding of inputs and outputs, created flowcharts, and proceeded to write code in the C#
programming language.(Page 13)
P2: I’ve determined the steps taken from writing code to execution. (Page 16)

P3: I’ve explained and provided a clear and concise overview of procedural, object-oriented, and
event-driven paradigms. Each paradigm is presented in a structured manner, with sub-sections
for definition, features, advantages, and disadvantages. (Page 25)

M2 I analyze the relationship between 3 types of events, thereby helping the software become
better.(36)

P4,M3: I have used the C# programming language with WinForms to develop a water bill
management program. . The management program has functionality of system login page, home
page, searching, adding, editing and deleting functions.(Page 36)
P5: I’ve explained the entire debugging process, from the definition of debugging to the role of
the debugger and the steps involved in the debugging process.(Page 49)
M4: I have Examine how the debugging process can be used to help develop more secure, robust
applications.(Page 53)
P6: I’ve explained about the coding standard I have used in my code (Advantages, Disadvantages,
Text Editor, Generate Executable Code, Debugging) (Page 53)

Material:
Indeed Career Guide. (2024). What is procedural programming language? (And its uses).
[online] Available at: [Link]
programming-language.
BasuMallick, C. (2022). What is OOP (object oriented programming)? Meaning, concepts, and
benefits. [online] Spiceworks. Available at:
[Link]

[Link]. (2021). Tech Glossary for Understanding Innovations | Lenovo US. [online]
Available at: [Link] [Accessed 9 Dec. 2024].
Neubauer, T. (2023). The what, why and how of event-driven programming. [online] [Link].
Available at: [Link]
SearchSoftwareQuality. (n.d.). What is integrated development environment (IDE)? -
Definition from [Link]. [online] Available at:
[Link]
environment.
[Link]. (n.d.). What is Debugging? Types & Tools Definition Guide. [online]
Available at: [Link]

Link: [Link]

LINK: [Link]

You might also like