Nguyen Le Thanh Cong-Bs01057
Nguyen Le Thanh Cong-Bs01057
Nguyen Le Thanh Cong-Bs01057
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Grading grid
P3 P4 P5 P6 M2 M3 M4 D2 D3 D4
Summative Feedback: Resubmission Feedback:
List of Table:
Table 1: Relationship between three programming paradigms ........................................ 10
List of Figure:
Figure 1: The visual application before enter Submit button ............................................ 13
Figure 2: The visual application after enter Submit button ............................................... 14
Figure 3: Flowchart of program ........................................................................................ 15
Figure 4: Have to enter name for running the program .................................................... 17
Figure 5: Have to choose type for running the program ................................................... 18
Figure 6: Have to enter number of people in case of household customer ...................... 19
Figure 7: Can't enter number of people in case of customer is not household ................. 20
Figure 8: Have to enter last month's water uses for running the program ....................... 21
Figure 9: Have to enter this month's water uses for running the program ...................... 22
Figure 10: The program can not run if last month’s water uses more than this month .... 22
Figure 11: Let customer enter their Last month water's uses and This month water's uses
and enter their name ........................................................................................................ 23
Figure 12: Requirement for running program ................................................................... 23
Figure 13: Condition for bool isChecktype ........................................................................ 23
Figure 14: Function for printing water bill for customer who is Administrative agency,
public services and Production Units and Business Services ............................................. 24
Figure 15: Function for printing water bill for customer who is Household ...................... 24
Figure 16: Price to calculate water bill for customer who is Household............................ 25
Figure 17: Price to calculate water bill for customer who isn't Household ....................... 25
Figure 18: Declare variable Consume and Price to calculate total water bill ..................... 25
Figure 19: Calculate total price and printing water bill for customer who is Household and
having one person in family .............................................................................................. 26
Figure 20: Calculate total price and printing water bill for customer who is Household and
having more than 2 persons in family ............................................................................... 27
Figure 21: Calculate total price and printing water bill for customer who is Administrative
agency, public services or Production Units or Business Services ..................................... 28
Figure 22: Condition for import people number if customer who is household
requirement ..................................................................................................................... 29
Figure 23: Output total price and printing water bill for customer who is Administrative
agency, public services ..................................................................................................... 30
Figure 24: Output total price and printing water bill for customer who is Production Units
......................................................................................................................................... 30
Figure 25: Output total price and printing water bill for customer who is Business Services
......................................................................................................................................... 31
Figure 26: Output total price and printing water bill for customer who is Household and
having 1 person in family .................................................................................................. 32
Figure 27: Output total price and printing water bill for customer who is Household and
having more than 2 persons in family ............................................................................... 33
Figure 28: Meaningful variable names .............................................................................. 34
Figure 29: Comments ....................................................................................................... 34
Figure 30: Names representing types must be in mixed case starting with upper case .... 34
Figure 31: Variable names must be in mixed case starting with lower case...................... 35
I. Introduction
In this essay, I will show my project about calculating bill water application that was
produced using the IDE and was subject to Coding standards for a comprehensive business
problem. As a result, I have to write a WinForm application in the C# programming language
of Microsoft Visual Studio. I also introduce to three programming paradigms: Procedural
Programming, Object Orientated Programming, Event Driven Programming.
1. Procedural programming:
Procedural programming is a way of telling a computer what to do by giving it a list of
instructions. These instructions a grouped together into smaller tasks called procedures.
Procedural programming completes the task into step by step instructions. This style of
programming is focused on the steps themselves, rather than on the date the program
works with. It’s a good way to code for simpler tasks but this way couldn’t be suitable for
complex tasks.
The program constantly listens for these events, and when one happens, it triggers a
specific piece of code designed to handle that situation. This makes event-driven
programming useful for programs that need to be flexible and react to unexpected changes.
EDP is particularly useful for programs that need to handle many things at once, or that
need to react to unpredictable events from the outside world. For example, user interfaces,
video games, and network servers all heavily rely on event-driven programming.
Encapsulation
Abstraction
Inheritance
Polymorphism
4. Comparison between three programming paradigms:
1. Definition:
An IDE stands for Integrated Development Environment. It's basically a software application
that combines a bunch of different tools that programmers use to write computer
programs.
2. Features:
Source code editor: This is where programmers write their code. IDEs typically
have features like syntax highlighting, which makes the code easier to read, and
code completion, which can help programmers write code faster.
Build automation tools: These tools help programmers automate the process of
building their programs. This can save programmers a lot of time and effort.
Debugger: This tool helps programmers find and fix errors in their code.
There are also many other features that IDEs may have, such as version control
integration, unit testing frameworks, and code profilers.
IDEs can be used for a variety of programming languages, including Python, Java,
C++, and web development languages like HTML, CSS, and JavaScript.
3. Debugging:
3.1. Definition:
Debugging refers to the process of identifying and fixing errors, or bugs, in software. It's a
vital part of software development to ensure the final product works as intended.
Debugging involves finding and resolving issues that cause a program to malfunction,
perform poorly, or generate incorrect results. These issues are often called bugs.
Stepping through code: Allows examining the program line by line, seeing variable
values at each step.
Setting breakpoints: Pauses the program execution at specific points to analyze its
state.
Inspecting variables: Viewing the values of variables in the code at any point.
3.4. Process of debugging:
1. Identify the Error: This initial step involves recognizing that something isn't
working as expected. This could be through program crashes, unexpected
outputs, incorrect results, or unusual behavior.
2. Reproduce the Error: Once you identify an error, it's crucial to be able to
reproduce it consistently. This allows you to isolate the root cause more
effectively. Sometimes specific steps or conditions might trigger the bug, so
pinpointing these helps in debugging.
3. Isolate the Error Location: With the error reproduced, you can narrow down
the part of the code that's causing the issue. Debuggers come in handy here.
They allow you to step through the code line by line, examining variable values
at each stage. This helps pinpoint the specific line or section where the error
occurs.
4. Analyze the Error: Now that you know where the error is happening, it's time
to understand why. Analyze the code logic and identify what's causing the
unexpected behavior. This might involve reviewing the code itself, checking
variable assignments, and understanding the flow of data.
5. Fix the Error (Implement a Solution): Once you understand the root cause,
you can fix the bug. This might involve correcting a syntax error, fixing a logical
mistake in the code, or handling unexpected inputs differently.
6. Test the Fix: After implementing the fix, thoroughly test the program again.
Verify that the error is resolved and no new issues are introduced. Sometimes,
fixing one bug might uncover another, so it's important to retest
comprehensively.
7. Document the Fix: It's good practice to document the bug, the solution
implemented, and any relevant notes for future reference. This helps maintain
the codebase and can be valuable for other developers working on the project.
IV. Coding Implementation
1. Design of program:
The program was designed by a window form, in the context of Windows Forms
development, is the foundation of a graphical user interface (GUI) for desktop applications.
Customer’s name
Type of customer
People number (for customer is household)
Last month water’s uses
This month water’s uses
Consumption of water
Total price
Figure 8: Have to enter last month's water uses for running the program
Figure 9: Have to enter this month's water uses for running the program
The program can not run if last month’s water uses more than this month’s water
uses
Figure 10: The program can not run if last month’s water uses more than this
month
3.4. Code and result:
Code
Figure 11: Let customer enter their Last month water's uses and This month water's uses
and enter their name
Figure 15: Function for printing water bill for customer who is Household
Figure 16: Price to calculate water bill for customer who is Household
(include 10% fee protect environment)
Figure 17: Price to calculate water bill for customer who isn't Household
(included 10% fee protect environment)
Figure 18: Declare variable Consume and Price to calculate total water bill
Figure 19: Calculate total price and printing water bill for customer who is Household and
having one person in family
Figure 20: Calculate total price and printing water bill for customer who is Household and
having more than 2 persons in family
Figure 21: Calculate total price and printing water bill for customer who is Administrative
agency, public services or Production Units or Business Services
Figure 22: Condition for import people number if customer who is household
requirement
Result
Figure 23: Output total price and printing water bill for customer who is Administrative
agency, public services
Figure 24: Output total price and printing water bill for customer who is Production Units
Figure 25: Output total price and printing water bill for customer who is Business Services
Figure 26: Output total price and printing water bill for customer who is Household and
having 1 person in family
Figure 27: Output total price and printing water bill for customer who is Household and
having more than 2 persons in family
4. Coding standard
4.1. Definition:
A coding standard, also sometimes called a coding convention or programming style
guide, is a set of rules and best practices that programmers follow when writing code.
These rules define how the code should be formatted, structured, and documented.
4.2. Coding standards I have used in the program:
Meaningful variable names: Variable names like LastMonthWaterUse,
ThisMonthWaterUse and UserName are descriptive and make the code
easier to understand
Figure 30: Names representing types must be in mixed case starting with upper case
Variable names must be in mixed case starting with lower case: Like variable
names isChecktype, checkType
Figure 31: Variable names must be in mixed case starting with lower case
V. References
(No date) What is procedural programming? A beginner’s guide. Available at:
https://programiz.pro/resources/what-is-procedural-programming/ (Accessed: 24
March 2024).
Gillis, A.S. and Lewis, S. (2021) What is object-oriented programming (OOP)?, App
Architecture. Available at:
https://www.techtarget.com/searchapparchitecture/definition/object-oriented-
programming-OOP (Accessed: 24 March 2024).