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

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 1: Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Tran Duc Luong Student ID BH00108

Class IT0502 Assessor name

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

Grading grid

P2 P3 P4 P5 M2 M3 M4 D2 D3 D4

1
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:

2
Table of Contents
A.Introduction ...................................................................................................................................................................................................................................................................... 5
B. Content .............................................................................................................................................................................................................................................................................. 5
I. Programming paradigms. ........................................................................................................................................................................................................................................ 5
1. Procedure oriented programming. .............................................................................................................................................................................................................. 5
2. Object Oriented Programming..........................................................................................................................................................7
II. IDE Algorithm Settings......................................................................................................................................................................10
III. Debugging Process............................................................................................................................................................................27
1.Define...............................................................................................................................................................................................27
2.Describe the debugging process.......................................................................................................................................................27
IV. Coding standards..............................................................................................................................................................................28
1. What is the coding standard?..........................................................................................................................................................28
2. Why use it (Benefits of using standard coding).....................................................................................................................................28
3. Code standards used in the program......................................................................................................................................................28
4.Commenting conventions.......................................................................................................................................................................30
C.Conclusion............................................................................................................................................................................................30
D.Reference.............................................................................................................................................................................................30

3
1. Procedure oriented programming 1……………………………………………………… ........................................................................................................... 5

Example 1:............................................................................................................................................................................................................. 6

Example 2.............................................................................................................................................................................................................. 7

Example 3.............................................................................................................................................................................................................. 9

4
A. Introduction
In today's ASM post I will show everyone about 3 basic programming models and their relationship, along with it is a program
that can help you manage employees more easily and present debugging process, and finally the standards when coding.
B.Content
I. Programming paradigms
1. Procedure oriented programming
-A programming model that divides a program into functions or subroutines. The procedural approach divides a large program
(function) into blocks of functions or functions (procedures) that are small enough to be easy to program and test. Each function
has a start and an end point and has its own data and logic.

1. Procedure oriented programming 1

Example: Procedure-oriented programming it is similar to the diagram below.

5
Example 1:

-Procedure oriented programming features:


+Focus on the work to be done (algorithms)
+A large program is divided into subroutines, each of which can be called one or more times in any order.
+Most functions use common data
+Data in the system is moved from one function to another.
+Function that converts data from one form to another
+Using a top-down approach in program design
-Advantages:
+Clear reasoning.
+Simple, easy to understand.
-Defect:
+In structured programming we are often interested in developing functions that are less concerned with the data that they use to
do the work. (This makes the data difficult to control)
+Does not support reuse of source code: each data structure is only suitable for some algorithms, when changing the data structure,
the algorithm must change accordingly.

6
+Not suitable for large problems with many modules.

2. Object Oriented Programming:


-Object Oriented Programming is a computer programming model that designs software around data, or objects, rather than
functions and logic.
Example: We can consider the design of a house like we design a blueprint of a house.

Example 2

-Characteristics:
+Abstraction
+Inheritance
+Encapsulation
+Polymorphism

7
features 1

-Advantages:
+Data is not freely changed in a program like structured programming.
+When changing the data structure of an object, there is no need to change the source code of other objects, but only need to
change some component functions.
+Source code can be reused through inheritance
+Suitable for complex and large software.
+Rated as easy to learn, productive, simple, easy to maintain, easy to extend…
-Defect:
The disadvantage of object programming method OOP can cause data to be processed separately, when the data structure changes,
it will lead to the algorithm being changed. In addition, OOP does not automatically initialize and release dynamic data, and does
not fully and honestly describe the actual system.
3.Event-driven programming
-An event-instruction is a model-setting program in which the program executes the flow specified by the event.
- Example: User actions like clicking a button on the desktop, pressing a key on the keyboard, hovering the mouse...

8
Example 3

-Advantages:
+Event-driven programming also has some advantages over online resources. Instead of sending a static page to visitors, websites can
change what is returned based on events.
-Defect:
+Event-driven programming is significantly harder for beginners than other programming paradigms, so most courses and manuals
avoid teaching it at first. However, after gaining skills in more traditional programming techniques, most students can understand and
use it.
4. The relationship between the 3 programming paradigms
Procedural programming is only used to teach programming for beginners or algorithms for thinking, breaking problems into small
problems. It doesn't work in large systems.
Object-oriented programming, it applies to large systems and problems. However, it has not been used for practical applications.
To create a real problem or real application, object-oriented and event-driven programming models must be used to build a real
application system (e.g. student management program, management book management...)

9
II. IDE Algorithm Settings
-In today's large factories, there are a large number of workers, so to manage all workers, in this ASM post I have built a window form
application to manage workers.
-In a window form application it has the following functions:
+ Add
+ Edit
+ Clear
+ Delete
+ Exit

- To manage workers I need to declare " class Worker " as shown below.

-In the above code I have created properties for the objects that other classes can access.
-In that Worker class there are 5 properties:
+WorkerID
+WorkerName
+Address
+Gender
+Number
10
-After we have created the properties for the classes. Since it is a business management program, a login program is required.
-To create the login program first we have to create the form login. We have to create the form as shown below:

-In there:

+ The text line in the label account is used to enter the account name.

+Text in password enter the account's password.

+Login button used to login account.

+The exit button is used to exit the program.


-Next we need to write the code for the program.
-First so that the program can log in to the worker management program. We need to have conditions for the program to log in and we
need to make the worker management program appear.

11
- To do that, we need to code the program at the login button part as shown below:

- The above code is used to log into the program. The above code is used to log into the program. It informs us whether we have
successfully logged in or failed to log in.

-This code is used to terminate the program and hide the login program so that the management program appears next.
12
-If the program is running and we want to exit, we just need to code as shown below:

-At this exit button we can make the running program shut down immediately.
-Next we will create the worker management program. Like the login program, we need to create the first form.

-In there:

used to enter the ID issued by the management to the worker.


Enter the names of the workers.

enter worker's address.


13
determine the gender of the worker.

Enter the worker's phone number.

used to add data used to edit data Used to delete data Used to delete data in a datagridview used to exit the program
on input lines.

display data after adding, editing or deleting.


-Next we have to write the code for the employee management program. To be able to cause data to be entered in the datagridview we
have to write the code as shown below:

14
-This line of code helps us when writing code that can make the data from the class appear in the datagridview.

-Next is the code on each line so that the data from the datagridview can be saved and displayed.

-Next is the add button. It helps us to add the data we just entered to the datagridview.

15
-We can see these lines of code are used to add data from the respective textboxes.

-Next, if we can add data then we can also edit data. We will code like the code below.

16
-This code helps the data that is in the datagridview, when entered again, still in that line, the data will be corrected.

-We already have more data, edit data next is to delete data.

-This line of code warns us that we really want to delete the data.

17
-If we want to delete then the next code is used to clear the data in the datagridview and inform us that we have deleted the data
successfully.

-And the Clear button is quite simple. The Clear button is only used to delete the data, and on the textbox lines to enter new data.

-The exit button is like that, it simply warns us whether we want to exit the program or not and if so, it will execute the program exit.

18
-In the next part, we will run the program.

-The first step is to enter the login account:


-I have: Account : luong2003
Password:123

19
-The program will notify successful login and it will switch to the worker management program.

20
-We will enter any value.

-Press the add button and it will add the data.


21
-We can see that there seems to be an error in the code that makes it not display the Address and Gender data and the Gender data is mistaken for
Number. So we need to do debugging.
-We see that when adding data with the add button, an error occurs, we can infer 1 is at the data of the datagrid is faulty or at the button add is
faulty so we will put 2 break points there.

-We can see that at the first break point there is no error so we will step out to the second break point.

22
-At the 2nd break point we can have 2 logic errors. Those are the lines:
+
+
-Then we'll fix it like this.

-Then we continue to run the program.

23
-If we want to edit the first line, we just need to click on the line with the data and then press Clear to delete the existing data on the textbox.

-Next is to edit the data we want to edit.

24
-If you want to delete the first line, just click on the first line and then press delete.

25
-We can see that all data on that line has been deleted.

-If everything is done and we want to exit the program just press the exit button and select yes to exit the program.

26
III. Debugging Process
1.Define
-Debug is the process of finding and discovering errors as well as the causes of these errors in order to have a fix.
-Debugging is the process: user has to start with a problem, isolate the source code of the problem, and then fix it. A user of a program must know
how to fix the problem as knowledge about problem analysis is expected. When the bug is fixed, then the software is ready to use.
-Debugging tools (called debuggers) are used to identify coding errors at various development stages. They are used to reproduce the conditions in
which error has occurred, then examine the program state at that time and locate the cause.
-Advantages: Debugging is not only to remove errors from the program, but also to help programmers better understand the program and the
software that is running. Therefore, debugging is also an ability used to assess the level of programmers.
2.Describe the debugging process
-Step 1: Set break point

- Start the debugging process:


+We can see that at the first break point there is a logic error, this error is usually due to our inattention, so we just need to fix this code.

27
to look like this
+Next, we press Step out to jump to the next break point.
+At the second break point we can see that this line has a syntax error.
So we just need to add a ".". And it will turn out like this.
IV. Coding standards
1. What is the coding standard?
-Coding Standards are a set of rules that specify how to write the code of a program that programmers must follow when participating
in a project to develop that program. There are different standards for each project.
2. Why use it (Benefits of using standard coding)
-Coding standards help:
Programmers know what they're doing, and what's going on with their code. So they can easily find and correct mistakes.
New people can get used to it faster, without making the same mistakes over and over again.
Newbies don't waste time creating their own coding style and "defending it to death".
People are less likely to make mistakes in a consistent environment.
3. Code standards used in the program
-Define:

+Variable name: lowercase, meaningful name or lowercase

+Function Name: Capitalize the first letter

+class name: all uppercase or first letter.


-Layout:
28
+Good layout uses formatting to emphasize the structure of your code and to make the code easier to read. Microsoft examples and samples
conform to the following conventions:
+Use the default Code Editor settings (smart indenting, four-character indents, tabs saved as spaces). For more information, see Options, Text
Editor, C#, Formatting.
+Write only one statement per line.
+Write only one declaration per line.
+If continuation lines are not indented automatically, indent them one tab stop (four spaces).
+Add at least one blank line between method definitions and property definitions.
+Use parentheses to make clauses in an expression apparent, as shown in the following code.

4.Commenting conventions
Place the comment on a separate line, not at the end of a line of code.
Begin comment text with an uppercase letter.
End comment text with a period.
Insert one space between the comment delimiter (//) and the comment text, as shown in the following example.

29
C.Conclusion
In this article I have presented about 3 programming directions: procedural programming, object-oriented programming, event-oriented
programming and explained their relationship. I then created a worker management program and detailed how to code the program and test it.
After that, the debugging process and coding standards are presented.
D.Reference
https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions
https://topdev.vn/blog/oop-la-gi/
https://viblo.asia/p/su-khac-biet-giua-lap-trinh-huong-thu-tuc-pop-va-lap-trinh-huong-doi-tuong-oop-bWrZnxOm5xw
https://freetuts.net/thu-thuat/lap-trinh-huong-su-kien-la-gi-2261t.html

30

You might also like