Download as pdf or txt
Download as pdf or txt
You are on page 1of 78

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGY

ASSIGNMENT 2

UNIT: PROGRAMMING

STUDENT : NGO NGUYEN NHAT LINH

CLASS : SE06202

STUDENT ID : BD00345

SUPERVISOR : NGUYEN HOANG ANH VU

Da Nang, August 2023


ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 1 HND Diploma in Computing

Unit number and


Unit: Programming
title

Date received (1st


Submission date 07/08/2023
submission)

Re-submission Date received (2nd


date submission)

Student name Student ID

Class Assessor name Nguyen Hoang Anh Vu

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.

Student’s signature:

Nhat Linh

Grading grid:

P2 P3 P4 P5 M2 M3 M4 D2 D3
❒Summative Feedbacks: ❒Resubmission Feedbacks:

Grade: Assessor Signature: Date:


Internal Verifier’s Comments:

Signature & Date:

Perfomed Student: Ngo Nguyen Nhat Linh i


ACKNOWLEDGMENTS
First of all, I would like to thank my mentor Nguyen Hoang Anh Vu for his constant support
in my studies and research, for his patience, motivation, enthusiasm and rich knowledge. His
guidance has helped me throughout the time of studying and writing this thesis. Without your
wonderful help, I would not have been able to achieve this.

In addition to my mentor, I would like to thank my friends who have helped me


improve my knowledge of my subject. Not only that, they are always there to support me when
I need it. And besides, I would like to thank the school for creating all conditions for me to have
adequate facilities to help me complete my work.

Last but not least, I would like to thank my family, who gave birth to me from the beginning
and supported me spiritually. They are always behind to care and help me have more motivation to
complete the work well!

Perfomed Student: Ngo Nguyen Nhat Linh ii


ASSURANCE
I declare that this is my work, based on my research, and that I have recognized all materials
and sources utilized in its production, including books, papers, reports, lecture notes, and any
other type of document, electronic or personal communication.

I further declare that I have not previously submitted this assignment for assessment in any
other unit, except where explicit permission has been granted by all unit coordinators involved, or
at any other time in this unit, and that I have not duplicated or stolen ideas from the work of others
in any way.

Declaration of the learner

I verify that the work I've submitted for this assignment is all my own, and that all
research sources have been properly credited.

Signature of the student: Date:

Nhat Linh

Perfomed Student: Ngo Nguyen Nhat Linh iii


TABLE OF CONTENT

INSTRUCTOR/ SUPERVISOR/ ASSESSOR …………………………………………………..i

REVIEWERS………………………………………………………………………………………..ii
ACKNOWLEDGMENTS ...................................................................................................... ii

ASSURANCE ..................................................................................................................... iii

TABLE OF CONTENT ........................................................................................................ iv

LIST OF TABLES AND FIGURES ...................................................................................... vi

LIST OF ACRONYM ........................................................................................................... ix

INTRODUCTION ................................................................................................................. 1

CHAPTER 1: EXPLAIN THE CHARACTERISTICS OF PROCEDURAL, OBJECT-


ORIENTED AND EVENT-DRIVEN PROGRAMMING, CONDUCT AN ANALYSIS OF A
SUITABLE INTEGRATED DEVELOPMENT ENVIRONMENT (IDE). (LO2) ....................... 2

2.1 Give explanations of what procedural, object-oriented and event-driven paradigms


are; their characteristics and the relationship between them. (P2) .................................. 2

2.1.1 Procedural programming system (POP)............................................................. 2

2.1.2 Oject-oriented programming system (OOPs) ..................................................... 4

2.1.3 Event driven programming (EDP) .................................................................... 13

2.1.4 Relationship between Procedural, Object-oriented, Event-driven. ................... 19

2.2 Analyze the common features that a developer has access to in an IDE. (M2) ....... 22

2.2.1 Introduction about IDE – Visual Studio. ........................................................... 22

2.2.2 The most popular features of Visual Studio...................................................... 27

CHAPTER 2: IMPLEMENT BASIC ALGORITHMS IN CODE USING AN IDE. (LO3) ....... 33

3.1 Write a program that implements an algorithm using an IDE and Use the IDE to
manage the development process of the program. (P3-M3) ......................................... 33

CHAPTER 4: DETERMINE THE DEBUGGING PROCESS AND EXPLAIN THE


IMPORTANCE OF A CODING STANDARD. (LO4) .......................................................... 51

Perfomed Student: Ngo Nguyen Nhat Linh iv


4.1 Explain the debugging process and explain the debugging facilities available in the
IDE. (P4)........................................................................................................................ 51

4.1.1 Definition Debugging. ....................................................................................... 51

4.1.2 Debug process. ............................................................................................... 51

4.1.3 Analyze and give example debugging. ............................................................. 52

4.2 Outline the coding standard you have used in your code. (P5) ............................... 56

4.2.1 Naming Standard in Console. .......................................................................... 56

4.2.2 Naming Standard in C# Winforms. ................................................................... 63

Perfomed Student: Ngo Nguyen Nhat Linh v


LIST OF TABLES AND FIGURES

Figure 1: Procedural programming system (POP) ........................................................ 2

Figure 2: Coures code find the largest number in 3 number ......................................... 4

Figure 3: Code run ........................................................................................................ 4

Figure 4 Oject-oriented programming system (OOPs) .................................................. 5

Figure 5 Classes ........................................................................................................... 5

Figure 6 Object .............................................................................................................. 6

Figure 7 Data abstraction .............................................................................................. 6

Figure 8 Data encapsulation ......................................................................................... 7

Figure 9 Inheritance ...................................................................................................... 7

Figure 10 Polymorphism ............................................................................................... 8

Figure 11 Overloading and Overriding .......................................................................... 8

Figure 12 Binding .......................................................................................................... 9

Figure 13 Message Passing .......................................................................................... 9

Figure 14 Coures code of Money Management Using Inheritance In C# .................... 11

Figure 15 Coures code of Money Management Using Inheritance In C# .................... 11

Figure 16 Coures code of Money Management Using Inheritance In C# .................... 12

Figure 17 Code run ..................................................................................................... 13

Figure 18 Event driven programming (EDP) ............................................................... 13

Figure 19 Coures code of login interface and create an account ................................ 15

Figure 20 Coures code of login interface and create an account ................................ 16

Figure 21 Coures code of login interface and create an account ................................ 17

Figure 22 Code run ..................................................................................................... 19

Figure 23 Visual Studio ............................................................................................... 22

Figure 24 Visual Studio 97 .......................................................................................... 23

Figure 25 Visual Studio 1.0 (1991) .............................................................................. 23

Perfomed Student: Ngo Nguyen Nhat Linh vi


Figure 26 Visual Studio 6.0 (1998) .............................................................................. 24

Figure 27 Visual Studio .NET (2002) ........................................................................... 24

Figure 28 Visual Studio 2005 ...................................................................................... 25

Figure 29 Visual Studio 2010 ...................................................................................... 25

Figure 30 Visual Studio 2015 ...................................................................................... 26

Figure 31 Visual Studio 2019 ...................................................................................... 26

Figure 32 Visual Studio 2022 ...................................................................................... 27

Figure 33 Cross-platform............................................................................................. 27

Figure 34 Hierarchical Storage .................................................................................... 28

Figure 35 Multitasking screen .................................................................................... 28

Figure 36 Code support............................................................................................... 29

Figure 37 Git support................................................................................................... 29

Figure 38 Multilingual support ..................................................................................... 30

Figure 39 Powerful code editor ................................................................................... 30

Figure 40 Debugging ................................................................................................... 31

Figure 41 Build and Deploy ......................................................................................... 31

Figure 42 User Interface Design ................................................................................. 32

Figure 43 Code Analysis and Testing.......................................................................... 32

Figure 44 Microsoft Azure Integration ......................................................................... 33

Figure 45: Open Visual Studio .................................................................................... 34

Figure 46: Create New Project .................................................................................... 34

Figure 47: Select Console App (.Net Framework) ....................................................... 35

Figure 48: Create Name .............................................................................................. 35

Figure 49 Add the statement "using System.Windows.Forms;" .................................. 36

Figure 50 Create Winforms ......................................................................................... 37

Figure 51 Create Winforms ......................................................................................... 37

Perfomed Student: Ngo Nguyen Nhat Linh vii


Figure 52 Choose the tools ......................................................................................... 38

Figure 53 Design is complete ...................................................................................... 38

Figure 54 Set up the properties section....................................................................... 39

Figure 55 Double-click on each component ................................................................ 39

Figure 56 Code each function ..................................................................................... 40

Figure 57 Code each function ..................................................................................... 41

Figure 58 Code each function ..................................................................................... 42

Figure 59 Code each function ..................................................................................... 42

Figure 60 Code each function ..................................................................................... 43

Figure 61 Student management .................................................................................. 43

Figure 62 Code each function ..................................................................................... 44

Figure 63 Debugging ................................................................................................... 45

Figure 64 Debugging ................................................................................................... 45

Figure 65 Debugging ................................................................................................... 46

Figure 66 Connect Two Winforms .............................................................................. 46

Figure 67 Code run ..................................................................................................... 47

Figure 68 Code run ..................................................................................................... 48

Figure 69 Code run ..................................................................................................... 49

Figure 70 Code run ..................................................................................................... 50

Figure 71 Code run ..................................................................................................... 50

Perfomed Student: Ngo Nguyen Nhat Linh viii


LIST OF ACRONYM

Perfomed Student: Ngo Nguyen Nhat Linh ix


INTRODUCTION

Programming plays a very important role in life. It will help us understand more deeply
what an algorithm is, and understand programming models such as procedural
programming, object-oriented programming, the structure of a program, data, basic data,
and introduction.

Give students knowledge of IDE rules of naming in code. At the same time, helping stu-
dents have the knowledge to build basic applications. Coming to this report, we will learn
about the characteristics of procedural, object-oriented and event-driven programming,
conduct an analysis of a suitable Integrated Development Environment (IDE). Let's find out
in this assignment.

This report includes the following:

Chapter 1: Explain the characteristics of procedural, object-oriented and event-driven


programming, conduct an analysis of a suitable integrated development environment (ide).
(LO2)
➢ Give explanations of what procedural, object-oriented and event-driven paradigms are;
their characteristics and the relationship between them. (P2)
➢ Analyze the common features that a developer has access to in an IDE. (M2)
Chapter 2: Implement basic algorithms in code using an IDE. (LO3)
➢ Write a program that implements an algorithm using an IDE. (P3)
➢ Use the IDE to manage the development process of the program. (M3)
Chapter 3: Determine the debugging process and explain the importance of a coding
standard. (LO4)
➢ Explain the debugging process and explain the debugging facilities available in the
IDE. (P4)
➢ Integrates many programs such as code completion, compiler, editor Outline the
coding standard you have used in your code. (P5)
➢ Evaluate how the debugging process can be used to help develop more secure, robust
applications. (M4)

Perfomed Student: Ngo Nguyen Nhat Linh 1


CHAPTER 1: EXPLAIN THE CHARACTERISTICS OF PROCEDURAL,
OBJECT-ORIENTED AND EVENT-DRIVEN PROGRAMMING, CONDUCT
AN ANALYSIS OF A SUITABLE INTEGRATED DEVELOPMENT
ENVIRONMENT (IDE). (LO2)

2.1 Give explanations of what procedural, object-oriented and event-

driven paradigms are; their characteristics and the relationship

between them. (P2)

2.1.1 Procedural programming system (POP)

❖ Definition POP

Procedure oriented programming is the conventional way of programming where an


application problem is viewed as a sequence of steps. In procedure oriented programming
the problems is broken down into various modules such as data entry reporting querying
modules etc. The procedure-oriented programming is the traditional approach of
programming for developing application software.

Figure 1: Procedural programming system (POP)

There are two types of data, which are associated with these modules, one is global and
another is local data.

❖ The characteristics of POP


Perfomed Student: Ngo Nguyen Nhat Linh 2
Some Characteristics exhibited by procedure-oriented programming are:

• Emphasis is on doing things (Algorithms).

• Large programs are divided into smaller programs known as functions.

• Most of the functions share global data.

• Data move openly around the system from function to function.

• Functions transform data from one form to another.

• Employs top-down approach in program design.

❖ Advantages of procedure oriented programming


- It is easy to understand explain and documentation.
- Procedure oriented programming is easier to learn as compared to other new ways of
programming.
- The testing and debugging is also easy.
- Programming in procedural language is easy because the programmer can focus on just
one small, simple problem.
❖ Disadvantages of procedure oriented programming
- It stresses more an algorithm rather than data.
- It takes more time in processing.

- The global data is available to the function so it is easily accessed by any function,
which creates certain problems.
❖ Application of procedural programming (POP)
- File management: By using procedures and functions to perform operations such as
reading, opening and closing files, procedural programming can be applied in reading data
and processing files.
- Embedded systems: Procedural programming can be used Procedural programming
can be used for hardware control, memory management, event handling, and other tasks in
embedded systems.
- Digital Science: It is used in arithmetic computation, data analysis and simulation.
- Application multitasking: POP allows concurrent tasks to be handled through the use
of processes and threads to manage and control tasks sequentially.

Perfomed Student: Ngo Nguyen Nhat Linh 3


❖ An example of POP
Example program to find the largest number in 3 number.

Figure 2: Coures code find the largest number in 3 number

- Coures code:

- Code run:

Figure 3: Code run

2.1.2 Oject-oriented programming system (OOPs)

❖ Definition OOPs
- Object-Oriented Programming (OOP) is a programming paradigm in computer science
that relies on the concept of classes and objects. It is used to structure a software program
into simple, reusable pieces of code blueprints (usually called classes), which are used to

Perfomed Student: Ngo Nguyen Nhat Linh 4


create individual instances of objects. There are many object-oriented programming
languages, including JavaScript, C++, Java, and Python.

Figure 4 Oject-oriented programming system (OOPs)

❖ The characteristics of OOPs


- Classes: Are blueprints or patterns created to create objects.

Figure 5 Classes

Perfomed Student: Ngo Nguyen Nhat Linh 5


- Object: A class that represents real-world objects.

Figure 6 Object

- Data abstraction: Simplify complex objects by defining classes with abstract data
types.

Figure 7 Data abstraction

Perfomed Student: Ngo Nguyen Nhat Linh 6


- Data encapsulation: Encapsulate data and methods in a class to control access and
ensure security.

Figure 8 Data encapsulation

- Inheritance: Objects can inherit properties and behaviors from other objects or classes.

Figure 9 Inheritance

Perfomed Student: Ngo Nguyen Nhat Linh 7


- Polymorphism: Objects can have many forms and have different behaviors.

Figure 10 Polymorphism

- Overloading and Overriding: Methods can be defined with the same name but different
parameters (overloading) and derived classes can provide their own implementation of
inherited methods (overriding).

Figure 11 Overloading and Overriding

Perfomed Student: Ngo Nguyen Nhat Linh 8


- Binding: Binding links object properties together, enabling changes in one property to
affect others, either dynamically or statically.

Figure 12 Binding

- Message Passing: Objects communicate by sending messages to each other, and it


also allowing for complex interactions and program structure.

Figure 13 - Message Passing

Perfomed Student: Ngo Nguyen Nhat Linh 9


❖ Advantages of OOPs
- Improved productivity: OOP's modularity, extensibility, and reusability enable efficient
software development by providing separation of duties, allowing for easy extension of
objects, and promoting code reuse.
- Enhanced maintainability: OOP's modular design facilitates easier maintenance, as
updates can be made to specific parts of the system without requiring large-scale changes.
- Faster development: Code reuse in OOP speeds up development as developers can
leverage existing libraries and previously developed components.
- Lower cost: The reuse of software components reduces development costs, and the
emphasis on object-oriented analysis and design further optimizes overall expenses.
- Higher software quality: With more time and resources available due to faster
development and lower costs, OOP allows for better software verification, potentially
resulting in higher-quality software.
❖ Disadvantages of OOPs
- Steep expectation to learn and adapt: The thought process involved in OOP may be
unfamiliar to some individuals, requiring time and effort to adapt. Creating programs based
on object interactions can be complex, and understanding concepts like inheritance and
polymorphism may initially pose challenges.
- Larger codebase: Object-oriented programs tend to have a larger number of lines of
code compared to procedural programs.
- Slower execution: Object-oriented programs typically execute slower than procedure-
based programs, as they often involve more instructions to be executed.
- Limited suitability: OOP may not be suitable for all types of problems. Some problems
are better suited for other programming paradigms such as functional programming, logic
programming, or procedural programming, and attempting to apply OOP in those cases may
not result in efficient solutions.
❖ Application of OOPs
- Real Time Systems
- Client Server System
- Hypertext and Hypermedia
- Object Oriented Database
- Neural Networks and Parallel Programming
- AI Expert Systems
Perfomed Student: Ngo Nguyen Nhat Linh 10
- Simulation and Modeling System
- CIM/CAD/CAM Systems
- Computer Aided Designs
❖ An example of OOPs
Example Of Money Management Using Inheritance In C#
- Coures code:

Figure 15 Coures code of Money Management Using Inheritance In C#

Figure 14 Coures code of Money Management Using Inheritance In C#

Perfomed Student: Ngo Nguyen Nhat Linh 11


Figure 16 Coures code of Money Management Using Inheritance In C#

- Code Explanation:

In the above example, I have created two classes: Account and SavingsAccount, using
inheritance method in C#. The Account class is the base class, representing a bank account.
This class has two properties: AccountNumber (account number) and Balance (balance).

The Account class provides methods to deposit (Deposit), withdraw (Withdraw) and
display the balance (DisplayBalance). The Withdraw method checks if the balance is
sufficient for withdrawal.

The SavingsAccount class inherits from the Account class and extends the functionality
by adding an InterestRate property and a CalculateInterest (calculating interest) method.
The CalculateInterest method calculates the interest rate and adds it to the current balance.

In the Main section, I created a SavingsAccount object with the account number and the
corresponding interest rate. Then we make a deposit to the account through the Deposit
method and display the account information using the DisplayBalance method. Next, we
calculate the interest rate and add it to the current balance via the CalculateInterest method.
We withdraw some amount from the account using Withdraw method and show the account
information after withdrawing.

Perfomed Student: Ngo Nguyen Nhat Linh 12


- Code Run:

Figure 17 Code run

2.1.3 Event driven programming (EDP)

❖ Definition EDP

- Event driven programming (EDP) is a paradigm that relies on the occurrence of events
to trigger the execution of certain functions or methods. EDP can improve the
responsiveness, modularity, and scalability of your applications, but it also requires careful
design and organization of your code.

Figure 18 Event driven programming (EDP)

Perfomed Student: Ngo Nguyen Nhat Linh 13


❖ The characteristics of EDP
- Event Handlers: Functions or methods designed to respond to specific events.
- Asynchronous Execution: The program operates non-linearly, responding to events as
they happen, allowing multiple tasks to be performed simultaneously.
- Event-Listener Model: Components or objects register as event listeners to particular
events. When an event occurs, registered listeners are notified and perform appropriate
actions.
- Event Loops: Fundamental part that continuously monitors and dispatches events to
event handlers.
- User-Driven Interaction: User interactions drive program execution, waiting for user
actions before proceeding.
- Flexibility and Modularity: Promotes easy addition, removal, or modification of
components without affecting the entire program's structure.
- GUI Development: Extensively used in graphical user interface development to trigger
responses to graphical elements.
- Non-Blocking Operations: Encourages responsiveness during long-running tasks or
I/O operations.
- Event Propagation: Some systems allow events to propagate through a hierarchy of
objects, providing a flexible control flow.
- Event Synchronization: Requires proper mechanisms to handle concurrent events
effectively and avoid race conditions.
❖ Advantages of Event Driven Programming
- Simplicity: When compared to other types of programming languages, event driven
programming is more easier to use. Once there is a business requirement, the
development of the program is hassle free.
- Convenience: Predictive coding is another feature of event driven programming.
With the help of languages like visual basic, predictive coding is made possible. When the
developer is typing the code, the relevant suggestions are given.
- Flexibility: In event driven programming, there is no specific order from start to finish.
This order can make it easy to carry out the code. In addition to that, this is a type of code
that can be altered when necessary. If there is a requirement or errors in coding, the code
is flexible to be changed.
- GUI Support: A pre-programmed toolbar in the form of Graphical User Interface
(GUI) is available in event driven programming. From this toolbar it is able to create more
Perfomed Student: Ngo Nguyen Nhat Linh 14
interactive programs. For an example, tools such as radio buttons are already included.
- Power Consumption: Implementation of event driven programming is from hardware
interrupts. As a result, there is considerably less power consumption.

❖ Disadvantages of Event Driven Programming


- Speed: As event driven programming is based on GUIs. the programs overall
execute reduced performance. Especially, if the installed memory is insufficient.
- Complexity: Event driven programming is too complex for simple programs. The flow
of the program and stack management is all what makes EDP more complex. If it is a
small program, it is worth considering other options like batch programming.
- Resource Utilization: Event driven programming uses main loop which is well known
to drain system resources. Because, the main loop is constantly functioning in the
background. Moreover, due to the usage of GUI, EDP cannot provide an interface unless
the required specifications are met.
- Language Translation: Once a program is written using the EDP language, you
cannot translate it to a different language. Because some functionalities like button are
programmed to work only with event driven programming.
- Platform Support: Generally, event driven programming is platform dependent.
When a particular program uses EDP, it cannot function on other platforms. For an
example, the program visual basic works using windows library files. If the program is
moved to a different OS, these files cannot be found
❖ An example of EDP
Code the login interface and create an account.
- Coures code:

Figure 19 Coures code of login interface and create an account

Perfomed Student: Ngo Nguyen Nhat Linh 15


Figure 20 Coures code of login interface and create an account

Perfomed Student: Ngo Nguyen Nhat Linh 16


Figure 21 Coures code of login interface and create an account

Perfomed Student: Ngo Nguyen Nhat Linh 17


- Namespace and Using Directives: start with the namespace declaration and
using directives, providing the ability to use classes and methods in the respective
libraries and namespaces.
- Class "Lognhap" (Login Form): This is the main class for the login and
account creation interface. It inherits from the "Form" class of Windows Forms.
- Private Variables: There are four private variables in Dangnhap class:
"username", "password", "username1" and "password1". These variables are
used to store user information when they log in or create a new account.
- Constructor: The Dangnhap class has a parameterless constructor. This
function is called when the form is created.
- Events: The code snippet contains event methods to handle actions from the
user, like a click on the login button or the create account button. These events
include "btn_login_Click", "btn_tao_Click", "chk_showp_CheckedChanged",
"chk_show_CheckedChanged", "btn_delete_Click", and "pictureBox3_Click".
- Handling Login and Account Creation: In the "btn_login_Click" and
"btn_tao_Click" event methods, the user enters a username and password, then
the program checks if this information is correct. If the information is valid, the
program will allow login and display the student management screen
("StudentManagement"). If the information is not correct, the program will display
the corresponding message.
- Show Password: Checkboxes "chk_showp" and "chk_show" allow users to
display passwords when needed.
- Create Account: In the "btn_tao_Click" method, the program will allow the
user to create a new account. The user enters the required information and
confirms the password.
- Delete Login Data and Create Account: Two buttons "btn_delete_Click" and
"btn_xoa_Click" allow to delete user information entered in the form.
- Switch Between Two Panels: Two labels "labelquaylai_Click" and
"label_taoacc_Click" allow switching between two panels (paneldangnhap and
paneltaoacc) to display the login and account creation interface.

Perfomed Student: Ngo Nguyen Nhat Linh 18


- Code run:

Figure 22 Code run

❖ Event-Driven Programming Applications


➢ Event-driven programming is generally used in three cases:

- When programming games in which a set of objects carries out control flow.
- When creating server applications, it is undesirable to spawn service
processes if, for one reason or another.
- When building user interfaces, including graphical ones.

2.1.4 Relationship between Procedural, Object-oriented, Event-driven.

- Procedural and Event Driven describe the general workflow of the application or
decision making logic where as Object Oriented describes more the structure of the decision
making logic
- Procedural describes a sequential workflow of logic, in general there are many steps
that must be performed in a sequence, there may be criteria between each step that might

Perfomed Student: Ngo Nguyen Nhat Linh 19


be dependent on the outcome from previous steps, however the sequence of logic is pre-
determined and hard coded into the application.
- In procedural programming the State of the system is generally passed directly
between the steps so it does not need to exist in a context outside of the executing logic and
there is less need to formally manage the shape or structure of this State.
- Prodedural logic complements Functional programming architectures but can be used
in many contexts.
- Procedural logic suits scenarios where interaction with external systems is
instantaneous or not required or if it is OK for your logic to halt processing until the external
system responds.
- Procedural logic may raise events for external event driven logic to respond to, that
doesn't make it event driven.
- From a testing point of view, to properly test a pure Procedural Programming
application will require the whole application to be completed. You could also test each step
in the process by directly evaluating the state or result of each step but in pure PP the state is
not maintained in a context that we can easily access outside of the logic, so the only way
to test is to run each process to completion to review the results.
- This means that the external state is generally less of a concern for testing PP logic.
- End-To-End testing is greatly simplified because there are less permutations of
outcomes to consider.
- Event Driven describes a workflow where the system raises event messages, or
responds to events raised from other systems. The application logic is executed in direct
response to these events, in explicit contrast to Procedural Programming the timing of the
events is considered not controllable and due to this many events may need to be serviced
concurrently, this is in direct contract the procedural programming where each step needs
to run to completion to be ready for the next step in the chain can be executed.
- This means that in Event Driven logic it is more important to check the state of the
system when performing decision logic. As the steps could conceivably be executed in any
order, at any time, the state needs to be managed in a context outside of most of the logic,
this is where OO concepts can start to become really helpful.
- Most Graphical User Interfaces will implement forms of Event Driven programming.
Think of a simple button click event, the user controls the timing of the execution, or if the
button is clicked at all.

Perfomed Student: Ngo Nguyen Nhat Linh 20


- From a testing point of view, the current state of the system is important to evaluate or
control before testing a process. Depending on the type of events this can raise
complications during testing, you may need to simulate, impersonate or intercept other
systems or events from or to other
- Object Oriented Programming describes a style where the state of the system is
modelled using classes that describe a set of metadata and the behaviours and interactions
with other objects. We can create Instances of a class to create objects. In this way you can
think of OO as first defining a series of templates, and then creating objects from those
templates.
- OO therefore ends up with a lot of additional boiler plate logic and a lot more effort
needs to go into the design of the state and environment before you really get into the
behavioural or reactionary logic.
- OO pairs really well with Event Driven programming, objects make it easier to
represent the environment and nuanced changes to it.
- From a testing point of view, OO makes it possible to replicate state or the environment
without having access to the real operating environment. Because the logic is defined a
more granular set of behaviours within each object we can easily test these behaviours in
isolation from the rest of the system.
- This same boon can become a burden though, more care needs to be taken to ensure
the state is defined accurately enough to obtain meaningful test results. To complete end-
to-end testing there can be a lot of moving parts, because the timing of events is less
constrained (if at all) compared to PP, there is a greater permutation of potential outcomes
to define and automate. Therefor in OOP it becomes more important to test properly at a
granular level to verify discrete logic blocks to gain confidence before testing in larger
cascading sets of rules.

Perfomed Student: Ngo Nguyen Nhat Linh 21


2.2 Analyze the common features that a developer has access to in

an IDE. (M2)

2.2.1 Introduction about IDE – Visual Studio.

- Visual Studio is a well-known and widely used integrated development environment


(IDE) among professional programmers, particularly those working with languages like VB+
and C#. It has a rich history of development and continuous improvement over the years.

Figure 23 Visual Studio

❖ History Of Visual Studio

Visual Studio was first released in 1997. The first version of Visual Studio was numbered
"Visual Studio 97" and was released in February 1997. Before that, Microsoft had separate
development tools. for each language such as Visual Basic, Visual C++ and Visual FoxPro.

Visual Studio 97 is the first time these tools have been combined into a single integrated
development environment (IDE), providing a unified and integrated development experience
for developers.

Perfomed Student: Ngo Nguyen Nhat Linh 22


Figure 24 Visual Studio 97
❖ The Development Process Of Visual Studio
➢ Visual Studio started in the early 1990s and has gone through many versions and
improvements over the years:
- Visual Studio's development journey began in the early 1990s and has seen numerous
versions and enhancements since then. Some key milestones include:
- Visual Studio 1.0 (1991): Introduced as version 1.0, supporting various programming
languages like Visual Basic 4.0, Visual C++ 4.0, Visual FoxPro 2.5, and Visual SourceSafe
4.0. It marked the advent of Microsoft's first integrated development environment.

Figure 25 Visual Studio 1.0 (1991)

Perfomed Student: Ngo Nguyen Nhat Linh 23


- Visual Studio 6.0 (1998): Released as version 6.0, it brought updates to programming
languages and remained widely used for an extended period.

Figure 26 Visual Studio 6.0 (1998)


- Visual Studio .NET (2002): A crucial turning point, introducing the .NET Framework
and supporting new languages like C# and ASP.NET. It enabled development for mobile,
web, and personal computer applications.

Figure 27 Visual Studio .NET (2002)

Perfomed Student: Ngo Nguyen Nhat Linh 24


- Visual Studio 2005: Introduced in 2005 with improved features and enhanced web
development tools, supporting the .NET Framework 2.0.

Figure 28 Visual Studio 2005

- Visual Studio 2010: Released in 2010, it offered an improved user interface, .NET
Framework 4.0 support, and integration with Windows Azure.

Figure 29 Visual Studio 2010


Perfomed Student: Ngo Nguyen Nhat Linh 25
- Visual Studio 2015: Launched in 2015, it provided support for .NET Core and allowed
cross-platform application deployment.

Figure 30 Visual Studio 2015

- Visual Studio 2019: Introduced in 2019, continues to improve performance, integrate


new tools, and enhance the development experience.

Figure 31 Visual Studio 2019

Perfomed Student: Ngo Nguyen Nhat Linh 26


- Visual Studio 2022: This is the latest version of Visual Studio, there are many new and
improved features such as: 64-bit IDE, .NET support, Intellicode, Hot Reload, Find in Files
faster

Figure 32 Visual Studio 2022


2.2.2 The most popular features of Visual Studio.

❖ Here are some highlights about Visual Studio:

- Cross-platform support: Available on Windows, Linux, and MacOS, offering


convenience for developers across different platforms.

Figure 33 Cross-platform

Perfomed Student: Ngo Nguyen Nhat Linh 27


- Hierarchical Storage: Organizes snippet data files for easy access and management.

Figure 34 Hierarchical Storage

- Multitasking screen: Allows simultaneous opening of multiple files and folders,


promoting efficient multitasking.

Figure 35 Multitasking screen

Perfomed Student: Ngo Nguyen Nhat Linh 28


- Code support: Suggests alternative options to improve code convenience and usability.

Figure 36 Code support


- Git support: Seamlessly connects to GitHub, enabling easy copying, drag-and-drop,
and code collaboration.

Figure 37 Git support

Perfomed Student: Ngo Nguyen Nhat Linh 29


- Multilingual support: Supports various programming languages, including C#, C++, F#,
Visual Basic, JavaScript, Python, TypeScript, and more.

Figure 38 Multilingual support


- Powerful code editor: Features syntax highlighting, smart code hints, and syntax error
checking for efficient coding.

Figure 39 Powerful code editor


Perfomed Student: Ngo Nguyen Nhat Linh 30
- Debugging: Provides a powerful environment for debugging code, with variable
monitoring and error capture.

Figure 40 Debugging
- Build and Deploy: Offers customization options for building, releasing, and deploying
applications.

Figure 41 Build and Deploy

Perfomed Student: Ngo Nguyen Nhat Linh 31


- User Interface Design: Provides drag-and-drop tools for creating UI in Windows Forms,
WPF, and ASP.NET web applications.

Figure 42 User Interface Design

- Code Analysis and Testing: Offers Code Analysis and Code Metrics tools for optimizing
code quality and identifying issues.

Figure 43 Code Analysis and Testing

Perfomed Student: Ngo Nguyen Nhat Linh 32


- Microsoft Azure Integration: Seamlessly integrates with Microsoft Azure services,
simplifying application deployment and resource management.

Figure 44 Microsoft Azure Integration

CHAPTER 2: IMPLEMENT BASIC ALGORITHMS IN CODE USING AN IDE.


(LO3)

3.1 Write a program that implements an algorithm using an IDE and

Use the IDE to manage the development process of the program. (P3-

M3)

In this part, I will write a program to create an interface with login / account creation
function, then open the student management interface, which has the function of entering
and updating information using DataGridview.

Perfomed Student: Ngo Nguyen Nhat Linh 33


❖ Step 1: Open Visual Studio:

Figure 45: Open Visual Studio

❖ Step 2: Click Create New Project:

Figure 46: Create New Project

Perfomed Student: Ngo Nguyen Nhat Linh 34


❖ Step 3: Select Console App (.Net Framework):

Figure 47: Select Console App (.Net Framework)

❖ Step 4: Create Name Of The Project:

Figure 48: Create Name

Perfomed Student: Ngo Nguyen Nhat Linh 35


❖ Step 5: Once the project has been created, to run the win form program you
need to add the statement "using System.Windows.Forms;" in the library
declaration.

Figure 49 Add the statement "using System.Windows.Forms;"

Perfomed Student: Ngo Nguyen Nhat Linh 36


❖ Step 6: Next select Console.App1 and select Add >> Form(Windows Form).

Figure 50 Create Winforms

Figure 51 Create Winforms

Perfomed Student: Ngo Nguyen Nhat Linh 37


❖ Step 7: Next you choose the tools in the tool box to design your winform.

Figure 52 Choose the tools

❖ Step 8: After the design is complete, you will get an interface as follows.

Figure 53 Design is complete

Perfomed Student: Ngo Nguyen Nhat Linh 38


❖ Step 9: Next we will select each component of the winform such as: button, text
box, ... then set up the properties section to set its properties.

Figure 54 Set up the properties section

❖ Step 10: And after setting the properties for each element in the winform, we
continue to double-click on each component to code each function for each
component.

Figure 55 Double-click on each component

Perfomed Student: Ngo Nguyen Nhat Linh 39


Figure 56 Code each function

Perfomed Student: Ngo Nguyen Nhat Linh 40


Figure 57 Code each function

Perfomed Student: Ngo Nguyen Nhat Linh 41


Figure 58 Code each function

Figure 59 Code each function

Perfomed Student: Ngo Nguyen Nhat Linh 42


❖ Step 11: Doing the same steps as above, I have created a second interface
that is student management.

Figure 61 Student management

Figure 60 Code each function

Perfomed Student: Ngo Nguyen Nhat Linh 43


Figure 62 Code each function

Perfomed Student: Ngo Nguyen Nhat Linh 44


❖ Step 12: Debugging, if you accidentally hit delete part of your code and make it error,
then something like this happens just go back to your source code and press control + z
until your code is back to normal.

Figure 63 Debugging

Figure 64 Debugging

Perfomed Student: Ngo Nguyen Nhat Linh 45


Figure 65 Debugging

❖ Step 13: To connect two created winforms together you need to use the command

Figure 66 Connect Two Winforms

below.

Perfomed Student: Ngo Nguyen Nhat Linh 46


❖ Step 14: Code run

- When running the code, you will first be taken to the account creation interface
to log in.

Figure 67 Code run

Perfomed Student: Ngo Nguyen Nhat Linh 47


- After successfully creating an account, you will click the back to login button.

Figure 68 Code run

Perfomed Student: Ngo Nguyen Nhat Linh 48


- Next, log in to your newly created account.

Figure 69 Code run

Perfomed Student: Ngo Nguyen Nhat Linh 49


- After the system checks and confirms your account is correct, you will be taken
to the student management interface.

Figure 70 Code run

- Here you can enter, add, delete student information.

Figure 71 Code run

Perfomed Student: Ngo Nguyen Nhat Linh 50


CHAPTER 4: DETERMINE THE DEBUGGING PROCESS AND EXPLAIN
THE IMPORTANCE OF A CODING STANDARD. (LO4)

4.1 Explain the debugging process and explain the debugging

facilities available in the IDE. (P4)

4.1.1 Definition Debugging.

- Debugging is the process of identifying and fix errors or defects in a computer program
to ensure that it runs correctly and produces the correct result expected output. It involves
a systematic approach to locating and resolving issues that prevent the program from
functioning as intended. And Visual Studio provides us with many tools to simplifythe
process of debugging, finding and fixing program errors easier and faster.

4.1.2 Debug process.

The debugging process typically including the these steps:


❖ Step 1: Locate the Error

- The first step is to identify error in the program. This can be done through various
means, such as observing unexpected behavior, incorrect outputs, or encountering
exceptions during program execution or by Breakpoints in Visual Studio.

❖ Step 2: Find the Cause of the Error


- After detecting the error, the next step is to determine cause of the issue. There are
many errors in programming, such as:
- Syntax Error: These occur when there are mistakes in the code's structure or syntax.
- Declaration Error: These errors arise when variables or command are declared
incorrectly.
- Algorithm Error: These are logical errors that lead to incorrect result.
❖ Step 3: Troubleshooting
- Once the cause of the error is identified, the programmer needs to troubleshoot and
analyze the code to understand why the error occurred and how to fix it. This may involve
inspecting variables, stepping through the code, and check the program's flow.
❖ Step 4: Run and Test
- After fixed and troubleshooting the code, it is crucial to run various case on the
program to ensure that the error has been resolved successfully, and the program now
functions as expected.
Perfomed Student: Ngo Nguyen Nhat Linh 51
The debugging utilities that Visual Studio provides:
- Breakpoints: mark the wrong code to pause program execution at specific lines,
allowing inspection of the program's state, variable values, and control flow.
- Step-through Execution: execute the program line by line, observing behavior and
examining variable values at each step.
- Watch Window: monitor variable values and expressions during program execution.
- Locals Window: view the values of local variables and parameters within the current
scope.
- Immediate Window: execute code directly during debugging and see immediate
results.
- Call Stack Window: view the sequence of function calls leading to the current point of
execution, aiding understanding of the program's flow.
- Exception Settings: configure how exceptions are handled during debugging, including
breaking on unhandled exceptions or customizing exception behavior.
- Debug Console: for console applications, view and interact with console output during
debugging.

4.1.3 Analyze and give example debugging.

Some of the most common console errors:

I will write a simple project that sum of two number so that it prints to the screen.

Error 1:

Perfomed Student: Ngo Nguyen Nhat Linh 52


In this code, there is a logical error in the way the program is taking input for variable 'b'.
The code is using the same input (st) for both 'a' and 'b', causing the program to calculate
the sum of the same value twice instead of taking two different input values for 'a' and 'b'.
Make the program inoperable.

And here are debugging of this code:

Error 2:

Perfomed Student: Ngo Nguyen Nhat Linh 53


In this code, at line 15 I forgot word "e" and at line 18 I forgot sign ";" .

And here are debugging of this code:

Some of the most common Winforms errors:

Error 1:

In the above code, there is a logical error that I forgot to set the division condition in case
b is zero, causing the Form to run the calculation wrong.

Perfomed Student: Ngo Nguyen Nhat Linh 54


To fix the error in the above code I will rewrite the above code using " if - else "
conditional statement.

Perfomed Student: Ngo Nguyen Nhat Linh 55


Error 2:

The next error is that I forgot to declare the library.

This makes when declaring " Application " it will give an error as shown below if we do not declare
the library " using System.Windows.Forms; "

And to fix the above error we just need to declare the library used to run Winforms with the
statement " using System.Windows.Forms; "

4.2 Outline the coding standard you have used in your code. (P5)

4.2.1 Naming Standard in Console.

- There are many Coding Standard Used, but here are some of the most usually:

Variable Naming:

Perfomed Student: Ngo Nguyen Nhat Linh 56


- Minimize the use of global variables, and only use them when necessary. Prefer local
variables within functions or classes to limit their scope.

- Use meaningful and self-explanatory names for variables to enhance code


readability.

- Provide clear comments or footnotes explaining the purpose and usage of variables,
especially for complex or less intuitive ones.

Naming Rules:

- Avoid using the same names with different cases (case sensitive), as it can lead to
confusion and unintended behaviors.

Perfomed Student: Ngo Nguyen Nhat Linh 57


- Be consistent with naming conventions across namespaces, method parameters, and
variables to maintain code clarity and avoid potential bugs.

- When naming abbreviations, use Pascal Case or Camel Case to make them easily
distinguishable from regular words and to improve code understanding.

- Avoid using acronyms or parts of identifiers that might cause ambiguity or conflicts
within the codebase.

- Always use English for function and variable names.

Conventional Types of Capitalization:

Perfomed Student: Ngo Nguyen Nhat Linh 58


- Pascal Case should be used for names with three or more characters, where the
initial letter of the identifier and the first letter of each subsequent word are capitalized.

- Use Camel Case for names starting with a lowercase letter, followed by capitalized
first letters of subsequent words. This convention is ideal for local variables and method
names.

- Uppercase identifiers should be reserved for constants or predefined values, using


all capitalized letters.

Namespace Naming:

Perfomed Student: Ngo Nguyen Nhat Linh 59


- Follow Pascal syntax when naming namespaces to maintain consistency across
projects, make them easily distinguishable and use prefixes to avoid namespace conflicts
in larger codebases or collaborations with external libraries.

Class, Struct, and Interface Naming:

- Choose meaningful nouns or noun phrases for class and struct names in Pascal
Case, clearly indicating the object's purpose and responsibilities.

- Name interfaces with adjective phrases or noun phrases, and prefix them with "I" to
distinguish them from classes.

Perfomed Student: Ngo Nguyen Nhat Linh 60


- Avoid using the prefix "C" for class names, as it might be redundant and not add
much value.

- When inheriting classes, the derived class name should reflect the base class's name
to maintain a clear hierarchy.

Method, Property, and Field Naming:

- Use verb or verb phrases for method names, clearly conveying their actions or
operations.

Perfomed Student: Ngo Nguyen Nhat Linh 61


- Name properties with nouns, noun phrases, or adjectives, avoiding "Get" prefixes for
attributes since properties implicitly represent attributes.

- Fields should be named in Pascal Case, using nouns, noun phrases, or adjectives,
and avoiding prefixes to keep code clean and concise.

Indentation:

- Utilize proper indentation to enhance source code readability and maintain a


consistent visual structure.

- Indent every substatement inside a block to clearly define code hierarchy and control
flow.

- Maintain aligned opening braces in a straight column with the corresponding closing
brace to make code blocks visually coherent.

Perfomed Student: Ngo Nguyen Nhat Linh 62


- Write concise and clear functions, avoiding excessively long functions that could
reduce code comprehension.

4.2.2 Naming Standard in C# Winforms.

in C# Winforms there are many rules for naming objects, but below is a summary
of some common naming conventions for objects in Winforms:

Perfomed Student: Ngo Nguyen Nhat Linh 63


OBJECT NAME SET NAME FOR OBJECT EXAMPLE

Button btn Btn_Login

Check Box chk Chk_ShowPass

Data View dvw Dvw_Student

Form frm Frm_LogIn

Label lbl lbl_NameUser

Link Label llbl Llbl_Facebook

List View lsvw Lsvw_Staff

Numeric nud Nud_Hour


Up Down

Picture Box pic Pic_Logo

Scroll Bar sbr Sbr_Table

Tab Control tab Tab_Design

Textbox txt Txt_Password

Timer tmr Tmr_Deadline

ToolTip tip Tip_Copy

Tree View tre Tre_Books

RadioButton rdb rdb_Option

DataGridView dgv dgv_Managerment

ComboBox cmb cmb_Name

GroupBox grb grb_Car

Perfomed Student: Ngo Nguyen Nhat Linh 64


Exemple:
- In this part I wrote a Winforms with functions like addition, subtraction, multiplication
and division like a notebook.

Perfomed Student: Ngo Nguyen Nhat Linh 65


Perfomed Student: Ngo Nguyen Nhat Linh 66
In the above code I used rules for naming objects like " txt_ketqua " ; " btn_pheptinh " ;
" btn_number " ; " btn_nutbang " ; " btn_nutcong " ; " btn_nutxoa " ; " btn_nutce ".

Perfomed Student: Ngo Nguyen Nhat Linh 67

You might also like