You are on page 1of 37

HIGHER NATIONAL DIPLOMA IN COMPUTING

FINAL REPORT OF ASSIGNMENTS 1 & 2


UNIT: PROGRAMMING
Assignment Name:
Developing Electricity Account
Management Software

Student : Tuong Vi NGUYEN


Class : BD-AF-1901-1
Student ID : BDA180006
Supervisor : Dr. Hoai Phuong DANG

Danang, May 2019


INSTRUCTOR/ SUPERVISOR/ ASSESSOR

Higher Grade Achievement (Where applicable)


Grade Descriptor Comment’s Grade Descriptor Comment’s
/tick /tick
M1: Determine the D1: Examine the
steps taken from implementation of an
writing code to algorithm in a suitable
execution. language. Evaluate the
relationship between the
written algorithm and the code
variant.
M2: Analyse the D2: Critically evaluate the
common features that source code of an application
a developer has which implements the
access to in an IDE. programming paradigms, in
terms of the code structure
and characteristics.
M3: Use the IDE to D3: Evaluate the use of an
manage the IDE for development of
development process applications contrasted with
of the program. not using an IDE.
M4: Evaluate how the D4: Critically evaluate why a
debugging process coding standard is necessary
can be used to help in a team as well as for the
develop more secure, individual.
robust applications.

Assignment Feedback
Formative Feedback: Assessor to Student

Action Plan

Summative feedback

II
REVIEWERS

Higher Grade Achievement (Where applicable)


Grade Descriptor Comment’s Grade Descriptor Comment’s
/tick /tick
M1: Determine the D1: Examine the
steps taken from implementation of an
writing code to algorithm in a suitable
execution. language. Evaluate the
relationship between the
written algorithm and the code
variant.
M2: Analyse the D2: Critically evaluate the
common features that source code of an application
a developer has which implements the
access to in an IDE. programming paradigms, in
terms of the code structure
and characteristics.
M3: Use the IDE to D3: Evaluate the use of an
manage the IDE for development of
development process applications contrasted with
of the program. not using an IDE.
M4: Evaluate how the D4: Critically evaluate why a
debugging process coding standard is necessary
can be used to help in a team as well as for the
develop more secure, individual.
robust applications.

Assignment Feedback
Formative Feedback: Reviewer to Student

Action Plan

Summative feedback

III
ACKNOWLEDGMENTS

First of all, a special thank you goes to my family for giving encouragement,
enthusiasm and invaluable assistant to me. Without all this, I might not be able to
complete this assignment properly.
Secondly, I would like to express my gratitude and appreciation to my
supervisor, Dr. Hoai Phuong DANG, who has given his full effort in guiding me in
achieving the learning outcomes as well as his support during working on this
assignment.
Besides, I have also been helped greatly by many discussions with fellow
classmates at BTEC FPT International College. Therefore, many thanks go to them.
Finally, I would also like to acknowledge the crucial role of the staff of BTEC,
who gave me permission to use the necessary facilities and material to complete the
assignment.

IV
ASSURANCE

I certify that this assignment is my own work, based on my personal study and
that I have acknowledged all material and sources used in its preparation, whether
they be books, articles, reports, lecture notes, and any other kind of document,
electronic or personal communication. I also certify that this assignment has not
previously been submitted for assessment in any other unit, except where specific
permission has been granted from all unit coordinators involved, or at any other time
in this unit, and that I have not copied in part or whole or otherwise plagiarised the
work of other persons.

Learners declaration
I certify that the work submitted for this assignment is my own and research
sources are fully acknowledged.
Student signature: Date:

V
TABLE OF CONTENT

ACKNOWLEDGMENTS iv
ASSURANCE v
TABLE OF CONTENT vi
LIST OF TABLES, PICTURES viii
LIST OF ACRONYM ix

Chapter 1: Algorithm.....................................................................................................1
1.1. Algorithm................................................................................................1
1.1.1. Definition of an algorithm....................................................................1
1.1.2. Characteristics of an algorithm...........................................................1
1.1.3. Criteria to measure a good algorithm.................................................1
1.1.4. Example of an algorithm.....................................................................2
1.2. The process of building an application..................................................3
1.2.1. Feasibility Analysis.............................................................................3
1.2.2. Analysis and Requirements Specification..........................................3
1.2.3. Design (Algorithm)..............................................................................3
1.2.4. Coding.................................................................................................4
1.2.5. Testing and Debugging.......................................................................4
1.2.6. Deployment.........................................................................................4
1.2.7. Maintenance.......................................................................................4
1.3. The steps taken from writing code to execution in general and in C#...4
1.4. The relationship between the written algorithm and the code variant...5
Chapter 2: Programming paradigm...............................................................................6
2.1. Procedure-oriented programming (POP)...............................................6
2.2. Object-oriented programming (OOP).....................................................6
2.3. Event-driven programming.....................................................................6
2.4. An example............................................................................................7
2.4.1. Procedure-oriented programming.......................................................7
2.4.2. Object-oriented programming.............................................................8
2.4.3. Event-driven programming.................................................................9
Chapter 3: Integrated Development Environment.......................................................10
3.1. Definition of an IDE..............................................................................10
3.2. Common features of an IDE................................................................10
3.2.1. GUI designer.....................................................................................10
3.2.2. Code editor.......................................................................................11
3.2.3. Debugger..........................................................................................11
3.2.4. Compiler............................................................................................12
3.2.5. Code completion...............................................................................12

VI
Chapter 4: Electricity Account Management Software...............................................14
4.1. Introduce the software.........................................................................14
4.2. Requirement analysis..........................................................................14
4.3. Develop the program using Microsoft Visual Studio............................16
4.3.1. Design the GUI.................................................................................16
4.3.2. Write and manage code...................................................................17
4.4. Debugging Evaluation..........................................................................19
4.4.1. Debugging process in Visual Studio.................................................19
4..4.2. Debugging evaluation.......................................................................21
4.5. IDE Evaluation.....................................................................................22
4.6. Coding standard evaluation.................................................................22
4.6.1. Benefits of coding standard..............................................................22
4.6.2. Coding standard used in coding the software..................................24
CONCLUSION.............................................................................................................26
REFERENCES

VII
LIST OF TABLES, PICTURES

Table 1-1 From pseudocode to code...........................................................................5

Table 4-1 Description of the objects 14


Table 4-2 Analysis of Add function............................................................................15
Table 4-3 Analysis of Update function.......................................................................15
Table 4-4 Analysis of Delete function........................................................................15
Table 4-5 Analysis of Search function.......................................................................15
Table 4-6 Analysis of Load function...........................................................................16
Table 4-7 Compare using an IDE with not using one................................................22

Figure 1-1 The flowchart of the algorithm....................................................................2


Figure 1-2 The flowchart of the variation.....................................................................3

Figure 2-1 Code in POP 7


Figure 2-2 Result of POP............................................................................................7
Figure 2-3 A class of Book object, its properties and methods...................................8
Figure 2-4 Code in OOP..............................................................................................8
Figure 2-5 Result of OOP............................................................................................9
Figure 2-6 Trigger function..........................................................................................9
Figure 2-7 Result of an event......................................................................................9

Figure 3-1 Microsoft Visual Studio Windows Forms Designer 10


Figure 3-2 PyCharm Code Editor..............................................................................11
Figure 3-3 NetBeans debugger.................................................................................12
Figure 3-4 Microsoft Visual Studio code completion feature.....................................13

Figure 4-1 GUI of the program 16


Figure 4-2 Controls and their properties....................................................................17
Figure 4-3 Auto-generated code................................................................................17
Figure 4-4 Code Account class.................................................................................18
Figure 4-5 Code functions of ListAccount object.......................................................18
Figure 4-6 Code trigger functions..............................................................................19
Figure 4-7 Toolbar before debugging........................................................................19
Figure 4-8 Toolbar in debug mode............................................................................19
Figure 4-9 A breakpoint.............................................................................................20
Figure 4-10 Data tip...................................................................................................20
Figure 4-11 Locals window........................................................................................20
Figure 4-12 Autos window.........................................................................................21
Figure 4-13 Watch window........................................................................................21

VIII
Figure 4-14 Example of being inconsistent in naming..............................................23
Figure 4-15 Example of how to present code............................................................23
Figure 4-16 White space...........................................................................................24
Figure 4-17 Write comments.....................................................................................25
LIST OF ACRONYM

CPU Central Processing Unit


GUI Graphical User Interface
I/O Input /Output
IDE Integrated Development Environment
OOP Object-oriented programming
OS Operating System
POP Procedure-oriented programming

IX
Developing Electricity Account Management Software

Chapter 1: Algorithm

1.1. Algorithm
1.1.1. Definition of an algorithm
An algorithm is a finite sequence of clearly defined instructions to achieve a
predetermined purpose. There are three methods for performing an algorithm:
natural language, flowchart, and pseudocode.
Natural language or everyday language is used to list the steps of the algorithm.
A flowchart is a visual tool, using different symbols to represent the sequence of
activities or operators needed to solve the problem.
Pseudocode is created from borrowing the syntax of a programming language
to represent the algorithm.
1.1.2. Characteristics of an algorithm
Definiteness: Each step of an algorithm must be determined accurately, clearly
and closely for each case. The result of each step is unique and depends only on the
inputs and the results of the previous steps.
Finiteness: The total number of steps in an algorithm must be finite. The
commands are not repeated indefinitely.
Effectiveness: Each step of an algorithm must be basic and essential so that
they can be implemented accurately and within a finite period of time. It means that
after putting in the data, the algorithm works and produces the desired result.
Input and Output: The algorithm receives input, processes and produces output.
An algorithm may have no input but it must produce at least one output.
Generality: An algorithm can be applied to inputs that are different data sets
within a specific domain. The algorithm can solve all cases of the problem, not only
for certain individual cases.
1.1.3. Criteria to measure a good algorithm
To solve a problem, there can be many different ways. There is a need to
choose the "best" way in a sense. Two criteria for evaluating the algorithm are listed
below:
- Simple, easy to understand, easy to program.
- For quick solutions, use fewer computer resources.
Unfortunately, it is often impossible to guarantee both. Depending on the
situation, the first or second standard is applied. If only using algorithms for a few
times, the first standard is more important than the second one. In contrast, if this is a
very common problem, the algorithm will be used many times, then the second
standard is more important.
The purpose of algorithmic research is to build effective programs. The second
standard is the effectiveness of algorithms. An algorithm is called effective if it saves
space and time. Space efficiency is taking up less memory during execution. Time

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

efficiency which is prime importance is needing less time for execution. Assessing
the complexity of the algorithm is to evaluate the time taken.
1.1.4. Example of an algorithm
The algorithm for calculating the sum of first n natural numbers S = 1 + 2 + 3 +
… + n performed in natural language is given below:
Step 1: Enter the value of n.
Step 2: Assign S  0 and i  1.
Step 3: If i > n then jump to step 6.
Step 4: S  S + i.
Step 5: i  i + 1 and go back to step 3.
Step 6: Display the value of S.
Step 7: End of the algorithm.
The flowchart of the algorithm:

Figure 1-1 The flowchart of the algorithm

The pseudocode of the algorithm:


Read (n);
S  0;
I  1;
while I ≤ n
S  S + 1;
I  I + 1;
return S;

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

The above algorithm has definiteness and finiteness, therefore it is effective. It


receives the values of n as the input, executes finite operations and produces S as
the output.
A variation of the algorithm is given below:

Figure 1-2 The flowchart of the variation


Even though this variation is a bit more difficult to understand, the time to
execute this variation would be shorter, since the loop repeats n – 1 times with i
getting the value from 1 to n – 1 in this variation, while it would repeat n times in the
above algorithm. This variation is more effective, so it is a better algorithm compared
to the above algorithm.

1.2. The process of building an application


1.2.1. Feasibility Analysis
Before starting to develop software, a feasibility analysis is needed. It will
decide whether or not to implement the project. If the feasibility study shows that the
project is able to succeed in its limitations, the project can be carried out.
1.2.2. Analysis and Requirements Specification
The project requirements and issues are analyzed to gather the requirements of
the software system. The result of this phase would be a Requirement Specification
document which is a detailed description of software with its functional and non-
functional requirements. It is used to get an outside view of the software system,
identify external and internal factors influencing the system and show the interacting
among the requirements as well.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

1.2.3. Design (Algorithm)


In this stage, a design is developed according to the specifications written in the
second stage. Once the problem is defined clearly, several design methodologies
can be applied. An important approach is Top-Down program design. It is a
structured design technique that breaks up the problem into a set of sub-problems
called modules and creates a hierarchical structure of the modules.
1.2.4. Coding
In the coding phase, the design is implemented into a practical program. It
means the algorithm is written in programming languages such as C #, Java, Python,
or API functions, etc, using an appropriate Integrated Development Environment
(IDE). The logic that has been developed in the algorithm is used to write the
program.
1.2.5. Testing and Debugging
Testing is the process of executing a program with the deliberate intent of
finding errors. This is the necessary stage to check if the expected output matches
the actual output. Programs are tested with several test criteria and the important
ones are given below.
Test whether each and every statement in the program is executed at least one
(Basic path testing).
Test whether every branch in the program is traversed at least once (control
flow).
Test whether the input data flows through the program and is converted to
output (data flow).
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.
1.2.6. Deployment
After the testing process is completed successfully, it comes to the deployment
phase in which the program would be put to practical use. The deployment
sometimes takes place in stages. The first product can be released in a limited
segment. Then based on feedback, the program can be released as it is or with
proposed improvements.
1.2.7. Maintenance
Even after the software is put into use, maintenance and modification must
continue, because new bugs may be found, or customers may require additional
features, as well as to keep pace with changing requirements and technologies.
Maintainability of the program is achieved by modularizing it, providing proper
documentation for it and following the coding standards.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

1.3. The steps taken from writing code to execution in general and in
C#
Step 1: Write source code in the chosen programming language using a code
editor or an appropriate Integrated Development Environment (IDE).
Step 2: Preprocess using the preprocessor which instructs the compiler to do
required pre-processing before actual compilation starts.
Step 3: Compile the program using a software program called a compiler that
translates the code written in a programming language to machine code such as
binary code, which can be understood by the computer.
Step 4: Link the program with functions from the library, which are essential for
executing the program. The compiler automatically calls the linker the final step in
compiling the program. It also links user-defined functions to user-defined libraries.
Step 5: Load machine codes of a program into the system memory using a
loader, which is part of the Operating System responsible for loading programs. It
places programs into memory and prepares them for execution.
Step 6: Execute the program. The Central Processing Unit (CPU) carries out
the instructions of a computer program by performing the basic arithmetic, logical,
control and input/output (I/O) operations specified by the instructions.

1.4. The relationship between the written algorithm and the code
variant
Algorithms provide a general approach towards a problem, often ignoring
implementation details which can surpass the original problem in complexity.
Algorithms are developed in so-called pseudocode, a language that mimics
programming languages but has the writer's desired form.

Table 1-1 From pseudocode to code

Pseudocode Code
Read (n); Console.Write("Enter n = ");
S  0; int n = Convert.ToInt32(Console.ReadLine());
i  1; int S = 0, i = 1;
while i ≤ n
S  S + 1; while (i <= n)
i  i + 1; {
return S; S = S + i;
i = i + 1;
}

Console.WriteLine("S = " + S);


Console.ReadKey();

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Chapter 2: Programming paradigm

2.1. Procedure-oriented programming (POP)


This is a programming paradigm based on the concept of analyzing a function
of processing information into smaller functions. POP uses a top-down approach,
that is, separating from the whole to parts, then from the part to smaller parts. The
functions are relatively high independent, so POP has some advantages such as
easy to assign many people to program, easy to test and edit the program. However,
in POP, the development of functions is often concerned more than data. This makes
data difficult to control and leads to the change of the algorithm when there are
changes in the data structure. In big software projects, POP proves ineffective in
dealing with macro relationships.

2.2. Object-oriented programming (OOP)


This is a programming paradigm that focuses on objects which are entities with
unique identities that encapsulate state. Four characteristics of OOP are
encapsulation, inheritance, polymorphism, and abstraction.
Objects are abstracted into classes. Data is organized into object classes and
there are methods to determine the functions of the object. There may be many
objects which are models of real components, so it is easy to split tasks in a project
based on objects. In OOP, it is easy to upgrade from a small system to a large
system. But there is one drawback is that the program is larger in size than other
programs, taking up more memory and more disk space.

2.3. Event-driven programming


Event-driven programming is a programming paradigm in which program flow is
determined by events such as user actions (mouse clicks, keystrokes), or messages
from chapters another process. Event-driven programming is the dominant model
used in graphical user interfaces. Its characteristics include service oriented, time
driven, event handlers, trigger functions and events.
There are a variety of functions and controls for programmers to choose from.
Programmers can add and code an object at the same time. However, being difficult
to detect errors than other models is a big disadvantage. Besides, programs with
complex interfaces can load and run slower than simpler applications.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

2.4. An example
2.4.1. Procedure-oriented programming
A function to show information of a book is written in POP. This technique
focuses on functions as well as action sequences rather than data. In other words,
data is only for executing functions. So POP has no access specifiers and data can
move freely in the program. Any function can use data that leads to non-security, as
well as the ability to reuse the code is not achieved. Moreover, data is not managed,
so adding new data is not easy.

Figure 2-1 Code in POP

Figure 2-2 Result of POP

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

2.4.2. Object-oriented programming


In OOP, data is managed into the properties of the object. Objects can move
and communicate through member functions which are methods of the object.
Therefore, adding data and new functions can be done easily in OOP. In addition,
OOP has access specifiers such as Public, Private, Protected so data cannot move
easily if it is not specified to allow access. Then, OOP provides better security. Since
functions are methods of the object, their code can be reused when expanding to
new similar objects.

Figure 2-3 A class of Book object, its properties and methods

Figure 2-4 Code in OOP

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 2-5 Result of OOP

2.4.3. Event-driven programming


Entering input data is performed on the Graphical User Interface (GUI). Users
enter book information into textboxes. When the OK button is pressed, the book
information will appear on a message box. The action of clicking the OK button by
the mouse is called an event and the OK button is called the event handler. When
the event of clicking on the event handler starts, the function that determines which
code is run, is called the trigger function.

Figure 2-6 Trigger function

Figure 2-7 Result of an event

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Chapter 3: Integrated Development Environment

3.1. Definition of an IDE


Integrated Development Environment (IDE) is software that offers programmers
an integrated environment including many different tools such as code editor,
compiler or interpreter, automatic build tool, debugger, version management system
and tools to simplify GUI construction, etc. IDEs are usually reserved for a specific
programming language, although some IDEs also have multilingual support. Some
famous IDEs are as follows:
Microsoft Visual Studio supports languages like ASP.NET, DHTML, JavaScript,
JScript, Visual Basic, Visual C #, Visual C ++, Visual F #, XAML, etc.
NetBeans supports languages like C, C ++, C + + 11, Fortan, HTML 5, Java,
PHP, etc.
PyCharm supports languages like AngularJS, Coffee Script, CSS, Python,
HTML, JavaScript, Node.js, Python, TypeScript and sample languages.

3.2. Common features of an IDE


3.2.1. GUI designer
This feature is used for the purpose of building the GUI quickly and smoothly by
using editors and drag-and-drop tools in the IDE. It is used to build the controls inside
or to lock them next to the template. Controls that present data can be linked to data
sources such as databases or queries.

Figure 3-1 Microsoft Visual Studio Windows Forms Designer

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

3.2.2. Code editor


Every IDE has a code editor with language-specific syntax highlighting designed
to write and edit source code. It is easy to use and lots of useful features are
prepackaged. Besides, the massive plugin repository allows users to freely
customize and improve the editor in the most convenient way.

Figure 3-2 PyCharm Code Editor

3.2.3. Debugger
Debugging tools support users to identify and fix errors in source code. They
often simulate real-life scenarios to test functionality and performance. Developers
can check different code segments, identify logic and syntax errors and where they
are.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 3-3 NetBeans debugger

3.2.4. Compiler
The compiler converts entire source code into machine code such as binary
code so that it can be run as its own individual program file. The machine code is
analyzed to ensure its accuracy. The compiler then parses and optimizes the code to
optimize performance.
3.2.5. Code completion
Most IDEs have intelligent code completion features. They support
programmers by identifying and inserting common code components. These features
help developers save time writing code and reduce the possibility of typos and bugs.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 3-4 Microsoft Visual Studio code completion feature

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Chapter 4: Electricity Account Management Software

4.1. Introduce the software


Electricity is used everywhere. Everyone, every organization, and all industries
need electricity consumption. Power consumption is managed in each household,
each organization by an electricity account. It is necessary to store information of
millions of such accounts, so the electricity account management software is
developed.
From the interface of the software, users can perform functions such as adding
an account, updating the account's information, deleting an account, searching and
viewing all information of an account. The basic information of the object to be stored
is Account Number, Full Name, Service Address, Phone Number, and Rate Code. In
particular, the account number is unique for each account and rate code specifies an
account as the type of household or business. For example, PP09000809809,
Nguyen Van A, 123 Dien Bien Phu, 0905090909, household.

4.2. Requirement analysis


The object that the program manages is an electricity account that is abstracted
into an Account class with the following properties:

Table 4-1 Description of the objects

Objects Attributes Description


Account Number Unique for each household
Full Name Full name of the representative of the household
Electricity Service Address Address of the place where electricity is registered
Account Phone number of the representative of the
Phone Number
household
Rate Code Specify household or household business
List
List of accounts
Account

Below is the analysis of methods of objects. The Electricity Account object has
only get and set methods, that is, it is possible to get information about an object and
can also set information to an object. The main functions of the program will be the
methods of the List Account object.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Table 4-2 Analysis of Add function

Description Add a new account to the List Account


Account Number, Full Name, Service Address, Phone Number,
Input
Rate Code
Create a new account with the value of the properties received
Process from the corresponding Input values.
Add account to List Account
Output A new account has been added to List Account
Linked Event Click the Add button

Table 4-3 Analysis of Update function

Description Update the information of an account in List Account


Account Number, Full Name, Service Address, Phone Number,
Input
Rate Code
Find account which requires updating information, using Account
Number
Process
Change the value of the account’s properties with the
corresponding input values
Output Account information has changed
Linked Event Click the Update button

Table 4-4 Analysis of Delete function

Description Delete an account from the List Account


Input Account Number
Find the account to delete in List Account using Account Number
Process
Delete the account from List Account
Output The account has been removed from the List Account
Linked Event Click the Delete button

Table 4-5 Analysis of Search function

Description Find an account in List Account


Input Account Number
Find the account that is needed to find in the List Account using
Process
Account Number
Output The index of the account to find in the List Account
Linked Event Click the Search button

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Table 4-6 Analysis of Load function

Description Load an account's information in List Account


Input Account Number
Find the selected account in the List Account using Account
Process Number
Display account’s information on the program interface
Output Information of a selected account
Linked Event Click to select a line in datagridview

4.3. Develop the program using Microsoft Visual Studio


4.3.1. Design the GUI
Visual Studio supports to design interface easily, just drag and drop the toolbox
controls and customize them on the properties tab visually with the language used is
English. Each time programmers add or remove controls or change properties of
controls on the form, the code changes automatically, making the form change.

Figure 4-1 GUI of the program

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-2 Controls and their properties

Figure 4-3 Auto-generated code

4.3.2. Write and manage code


Visual Studio includes a code editor that supports syntax highlighting and code
completion using IntelliSense not only for variables, functions, and methods but also
language structures such as control loops or queries. The interface of code editor is
friendly and easy to use.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-4 Code Account class

Figure 4-5 Code functions of ListAccount object

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-6 Code trigger functions

4.4. Debugging Evaluation


4.4.1. Debugging process in Visual Studio
Programs may have logical errors which cannot be caught during compilation.
Debugging is the process of identifying their root causes and correcting them. One of
the ways is to use support from the IDE. Visual Studio provides a lot of visual tools to
simplify the debugging process, make it easier to find and fix program errors. Below
are debugging facilities available in the IDE.
Toolbar: To start debugging, click the Start button on the toolbar, or go to the
menu and select Start → Debug or F5 key. When the program is in debug mode and
has a breakpoint, the Start button becomes Continue.

Figure 4-7 Toolbar before debugging

Figure 4-8 Toolbar in debug mode

Breakpoints are locations where the program will temporarily stop executing so
that the programmer considers the changes of the variables to each command line,
thus detecting the location of the faulty code line. A breakpoint is denoted by a red
dot at the beginning of the code line. To create a breakpoint, simply click on the
beginning of the code line. To cancel a breakpoint, click on the breakpoint again. It is
also possible to create or cancel breakpoints with the F9 key.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-9 A breakpoint

Watch window is a collection of tools that help programmers observe the


current value of a variable when the program stops at a certain breakpoint. They
include Data Tip, Locals, Autos, and Watch.
Data tip: When moving the mouse pointer to a variable name at any position
within the current pair of variables {} (scope), the value of the variable will be
displayed on the screen.

Figure 4-10 Data tip

Locals: The Locals window automatically displays all variables related to the
current code line.

Figure 4-11 Locals window

Autos: Autos window displays the variables used in the previous code.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-12 Autos window

Watch: It allows programmers to enter specific variable or function names to


test in the current scope.

Figure 4-13 Watch window

When the program stops at a breakpoint, the debugger provides the ability to
simply pass the code lines as follows:
Step Over (F10): Run step by step, skip the function (only receive the return
value of the function).
Step Into (F11): Run step by step, go to the content of the child function.
Step Out (Shift + F11): Jump to the next breakpoint. If no breakpoints are
available, the debugger will end. In addition, it also has the function of running
through the current subfunction.
4..4.2. Debugging evaluation
The debugging process provides the most useful information about data
structures and assists developers in minimizing useless and distracting information.
Debugging process helps programmers understand the program's implementation
better. Then it is possible to create more robust applications.
From the security perspective, it is the developer’s responsibility to ensure that
the code written would not contain security errors. Debuggers are designed so that
developers can monitor and control the execution state of the program, understand
the mechanism of action, and thereby detect application security vulnerabilities.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

4.5. IDE Evaluation


The IDE integrates most of the support tools for developing applications into a
software. Its main features have been analyzed above. In addition, the IDE has other
advantages that make developers always choose to use when developing
applications.

Table 4-7 Compare using an IDE with not using one

Use an IDE Not use an IDE


IDE helps project management be more It is not supported. Developers must
effective especially in teamwork manage the files created during the
environments. Project is managed by project implementation themselves.
directory containing all files, solutions,
and designs, etc.
IDE offers features like code completion,
There are no suggestions and no
compiler, etc. compilers. Programmers must code all
themselves and compile by terminal or
cmd (on window)
Template support for different project Programmers create structures for the
types such as Winform, Console App, project themselves
etc, then structures, components are
available.
IDE supports library (.dll), import The library is not supported. If
mechanism programmers want to use any library,
they have to find it and import it
themselves.

4.6. Coding standard evaluation


4.6.1. Benefits of coding standard
Coding standard is a set of guidelines that shows how to write the code that
programmers are required to follow when developing a program. These rules greatly
save time in the software development process and also during product
maintenance.
When working on a team, if there is no unified way of coding between team
members, developers will code in their own favorite style. When assembling parts
together then, the program will not work because there is no consistency. It would
take a lot more time to standardize. In contrast, the coding standard instructs
developers how to write code. The project is coded in a consistent style even though
each part is written by different programmers. This facilitates the division of work in a
large project, increases project completion performance.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-14 Example of being inconsistent in naming

The coding standard also teaches how to write clean code, and comment for
important functions. This not only makes the code easier to understand but also
ensures that any developer looking at the code knows what to expect throughout the
application. It helps improve the readability of source code for other developers.
From making the code easy to understand, it also increases the ability to
maintain and correct errors for the application. It would be bad if developers had to
make changes to the code that required a lot of energy to search and decode.
Looking through unfamiliar code will be much easier if it is well presented and
everything is neatly commented. It helps in unit test implementation to avoid potential
errors. Potential errors can be limited right from the development stage of the
program.

Figure 4-15 Example of how to present code

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

4.6.2. Coding standard used in coding Electricity Account Management


software
Names of classes, variables, etc, are set according to Pascal case. It means
that the first letter of each word is capitalized, the rest are written in lowercase.
Names of the controls on the interface are set like the class name but with a prefix.
Names have the ability to reminisce; limit abbreviation to avoid confusing; do not
name too long or too short because it can mess with the program or lead to
ambiguous meaning.
For example: Class: Account
Properties: AccountNumber, ServiceAddress
Functions: AddAccount, LoadAccountInfo
Controls: ButSearch, TxtName
White Space: Two lines of code separated by one step are separated by an
indentation unit. Spaces are followed by commas and semicolons, and around
operators.
{}: The "{" must be placed in a new line, not with the same line as if, for, while,
etc.

Figure 4-16 White space

Comment: Comments should be written as simple as possible, not fussy and


written only when the code is too complicated. When using multiple endline
comments on consecutive lines of code, these comments must be aligned equally.
Code and write comments at the same time, avoid writing the code and then write a
comment.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

Figure 4-17 Write comments

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

CONCLUSION

After studying programming and working on this assignment, I have learned a


lot. I understand not only algorithms and how to design algorithms to solve problems,
but also the basic knowledge in programming such as programming paradigms, the
process of programming an application and how to use the IDE effectively to
increase productivity. After that, I have been able to apply this knowledge to develop
a small application with the purpose of managing electricity account information.
However, because of limited knowledge only in programming techniques, the
application is built quite simple and cannot be used in practice. Since I have no
practical experience, this program is still not really complete and there are still many
errors. During my next study at BTEC, I will work hard to perfect this application so
that it can be used practically.

Performed Student: Tuong Vi NGUYEN Instructor: Hoai Phuong DANG


Developing Electricity Account Management Software

REFERENCES

Dr. Hoai Phuong DANG’s lecture notes


Dr. Duc Hoang VO’s lecture notes
Steps for c program execution by Rumman Ansari (https://www.slideshare.net)
Chuẩn mã nguồn by Eric Lee
https://learn.g2crowd.com
https://www.quora.com

REFERENCES

You might also like