Tải bản đầy đủ (.docx) (69 trang)

ASSIGNMENT 2 UNIT PROGRAMMING

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.55 MB, 69 trang )

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGY
ASSIGNMENT 2
UNIT: PROGRAMMING

STUDENT

: NGUYEN THANH DAT

CLASS

: IT05101

STUDENT ID

: BD00118

SUPERVISOR

: NGUYEN HOANG ANH VU

DANANG, AUGUST 2022


ASSIGNMENT 2 FRONT SHEET

Qualification

BTEC Level 1 HND
Diploma in Computing



Unit number
and title

Unit: Programming

date

Date
received (1st
submission)

Resubmission date

Date
received (2nd
submission)

Submission

14/08/2022

Student name NGUYEN THANH DAT

Student ID

Class

Assessor


IT050101

14/08/2022

BD00118
NGUYEN HOANG ANH VU

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:
DAT

Grading grid
P2

P

P4

P5

M2

M3

M4


3

1
PERFOMED STUDENT: NGUYEN THANH DAT


❒ Summative Feedbacks: ❒Resubmission Feedbacks:

Grade:

Assessor Signature:

Date:

Internal Verifier’s Comments:

Signature & Date:

2
PERFOMED STUDENT: NGUYEN THANH DAT


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: my parents 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.

3
PERFOMED STUDENT: NGUYEN THANH DAT


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 st olen ideas from the work of others in any was

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: DAT

Date: 17/08/2022

4
PERFOMED STUDENT: NGUYEN THANH DAT



TABLE OF CONTENT
ASSIGNMENT 2 FRONT SHEET...............................................................................................................i
ACKNOWLEDGMENTS..........................................................................................................................iii
ASSURANCE..........................................................................................................................................iv
TABLE OF CONTENT..............................................................................................................................v
LIST OF TABLES AND FIGURES............................................................................................................viii
INTRODUCTION....................................................................................................................................xi
CHAPTER 2: PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE........................................1
1

Give explanations of what procedural, object-oriented and event-driven paradigms are; their

characteristics and the relationship between them. (P2)....................................................................1
1.1

Procedural paradigm..................................................................................................1

1.1.1

Definiton:.............................................................................................................1

1.1.2

Characteristics:.....................................................................................................1

1.1.3

Give examples:.....................................................................................................2

1.2


Object – Oriented paradigm.......................................................................................3

1.2.1

Definition:............................................................................................................3

1.2.2

The characteristics of OOPs:................................................................................4

1.2.3

Data Abstraction..................................................................................................5

1.2.4

Data Encapsulation:.............................................................................................7

1.2.5

Inheritance.........................................................................................................10

1.2.6

Polymorphism....................................................................................................12

1.3

Event – driven paradigm...........................................................................................15


1.3.1

Definition:..........................................................................................................15

1.3.2

The characteristics of EDP:.................................................................................15

1.4

Advantages, disadvantages of the 3 models............................................................16
5

PERFOMED STUDENT: NGUYEN THANH DAT


1.5

Relationship between Procedural, Object – oriented and Event – driven paradigms.
17

2

3

4

Write a program that implements an algorithm using an IDE. (P3)...........................................17
2.1


These are source codes:...........................................................................................18

2.2

Testing:......................................................................................................................20

Explain the debugging process and explain the debugging facilities available in the IDE. (P4)22
3.1

Definition Debugging................................................................................................22

3.2

Debug process..........................................................................................................22

3.3

The following are some of the most frequent bugs techniques:.............................23

3.4

Here are some examples of form errors:..................................................................27

Integrates many programs such as code completion, compiler, editor Outline the coding

standard you have used in your code. (P5)........................................................................................30
4.1

Variable:....................................................................................................................30


4.1.1

5

Variable names are named as follows:..............................................................30

4.2

This function's name is:............................................................................................30

4.3

Indent:.......................................................................................................................31

4.4

There are several different methods in Winform, for naming objects:....................31

4.5

Scenario:...................................................................................................................31

4.6

Issues:.......................................................................................................................32

4.7

Idea:..........................................................................................................................32


4.8

Describe the idea of the program algorithm:...........................................................32

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

What is an IDE?.........................................................................................................36

5.2

Components of IDEs.................................................................................................37

5.2.1

Debugger............................................................................................................38
6

PERFOMED STUDENT: NGUYEN THANH DAT


6

5.2.2

Source code editor.............................................................................................39

5.2.3


Windows Forms Designer..................................................................................40

5.3

Benefits of using IDE.................................................................................................41

5.4

Benefits of IDEs for programmers............................................................................42

Use the IDE to manage the development process of the program.(M3)...................................42
6.1

Step 1: Start C# and use a project with Console App (.NET Framework).................43

6.2

Step 2: Create a Form by clicking Project->Add Form (Windows Forms).................44

6.3

Step 3: Add Button, Label, and Textbox and edit as you like....................................45

6.4

Step 4: Add code to make buttons work..................................................................45

6.5

Step 5: Back to the program, you must add Using System.Windows.Forms to run


the program and add a command line Application.Run(new Login()) to allow it to run the Form
program that we created................................................................................................................46

7

6.6

Step 6: Run the program and test the functions to see if there are any errors.......46

6.7

Step 6: Complete error test and deliver the project................................................47

Evaluate how the debugging process can be used to help develop more secure, robust

applications.(M4)................................................................................................................................47
7.1

Debugger Security.....................................................................................................47

7.2

Security Best Practices..............................................................................................48

7.3

Managed Debugging Security...................................................................................48

7.4


Remote Debugging Security......................................................................................48

CONCLUSION......................................................................................................................................51
REFERENCES.......................................................................................................................................52

LIST OF TABLES AND FIGURES
7
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 1-1: Paradigm............................................................................................................................1
Figure 1-2: Flowchart............................................................................................................................2
Figure 1-3: Code...................................................................................................................................3
Figure 1-4: Definition............................................................................................................................4
Figure 1-5: Class and Object.................................................................................................................4
Figure 1-6: Class....................................................................................................................................5
Figure 1-7: Data Abstraction.................................................................................................................6
Figure 1-8: Code Abstraction................................................................................................................7
Figure 1-9: Encapsulation.....................................................................................................................8
Figure 1-10: Code Encapsulation..........................................................................................................9
Figure 1-11: Inheritance.....................................................................................................................10
Figure 1-12: Inheritance.....................................................................................................................11
Figure 1-13: Polymorphism................................................................................................................12
Figure 1-14: Polymorphism................................................................................................................14
Figure 1-15: driven paradigm.............................................................................................................15
Figure 1-16: Login...............................................................................................................................16
Figure 2-1: Form.................................................................................................................................18
Figure 2-2: Plus...................................................................................................................................18
Figure 2-3: Minus................................................................................................................................18

Figure 2-4: Multipy.............................................................................................................................19
Figure 2-5: Split...................................................................................................................................19
Figure 2-6: Delete...............................................................................................................................19
Figure 2-7: Exit....................................................................................................................................19
Figure 2-8: Program............................................................................................................................20
Figure 2-9: testing...............................................................................................................................21
8
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 2-10: Invalid Value...................................................................................................................21
Figure 3-1: Debug...............................................................................................................................22
Figure 3-2: Debug process.................................................................................................................23
Figure 3-3: bugs..................................................................................................................................24
Figure 3-4: Bugs CS0103....................................................................................................................25
Figure 3-5: Error declaring variable....................................................................................................26
Figure 3-6: Login.................................................................................................................................27
Figure 3-7: Bug....................................................................................................................................28
Figure 3-8: Fix bug..............................................................................................................................28
Figure 3-9: Form login........................................................................................................................29
Figure 3-10: Bug..................................................................................................................................29
Figure 3-11: Fix bug............................................................................................................................30
Figure 4-1: Name objects...................................................................................................................31
Figure 4-2: Form Login........................................................................................................................33
Figure 4-3: Source code of form login................................................................................................33
Figure 4-4: Account management form.............................................................................................34
Figure 4-5: Change password.............................................................................................................35
Figure 4-6: Change phone number....................................................................................................35
Figure 4-7: Source code changes information....................................................................................36
Figure 5-1: IDE....................................................................................................................................37

Figure 5-2: Types of IDES....................................................................................................................37
Figure 5-3: Visual Studio 2022............................................................................................................38
Figure 5-4: Debuggers........................................................................................................................39
Figure 5-5: Code.................................................................................................................................40
Figure 5-6: Form.................................................................................................................................41
9
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 6-1: C#......................................................................................................................................42
Figure 6-2: Project..............................................................................................................................43
Figure 6-3: Form.................................................................................................................................44
Figure 6-4: Add...................................................................................................................................45
Figure 6-5: Code.................................................................................................................................45
Figure 6-6: Add code program............................................................................................................46
Figure 6-7: Run the program..............................................................................................................47
Figure 7-1: Look in the error list table for declared errors.................................................................49
Figure 7-2: View the warning to see what problems may have occurred..........................................49
Figure 7-3: Check for errors................................................................................................................49
Figure 7-4: Fix.....................................................................................................................................50

10
PERFOMED STUDENT: NGUYEN THANH DAT


INTRODUCTION
Programming plays an extremely important role in life. Coming to this report, we will learn
about understanding programming models such as procedural programming, object- oriented
programming, and event-oriented programming.
As well as the structure of a program, data, and basic data, while also introducing

students to the use of an integrated development environment (IDE), its functions, and some
standard rules, such as naming in code. At the same time, it assists students in learning how
to create simple apps. Let's find out in this assignment!
❖ This report includes the following:
CHAPTER 2: PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE
1.
2.
3.

Explain what procedural, object-oriented, and event-driven models are; their characteristics
and the relationship between them. (P2)
Implement basic algorithms in code using the IDE. And give specific examples (LO3)
Write programs to implement an algorithm using the IDE. Then for example (P3)

4.

Define the debugging process and explain the importance of coding standards. And give
specific examples (LO4)

5.

Explain the procedures for debugging and explain the debugging facilities available in the
IDE. Give specific examples (P4)

6.

List programs like code completion, compiler, editor Outline the coding standards you used in
your code. (P5)

7.


Analyze common features that developers have access to in the IDE. Give an example (M2)

8.

Let's use the IDE to write a program manage. And give specific examples (M3)

9.

Evaluate debugging processes that can be used to help develop more robust and secure
applications. Give specific examples. (M4)

10.

11
PERFOMED STUDENT: NGUYEN THANH DAT


CHAPTER 2: PROBLEMS RELATED TO PROGRAMMING METHODS AND
IDE
1

Give explanations of what procedural, object-oriented and event-driven
paradigms are; their characteristics and the relationship between them.
(P2)

1.1

Procedural paradigm.


1.1.1 Definiton:
- The procedural programming approach is the implementation of the above functionoriented approach. The method further breaks down a large program into functions or
functions that are small enough to be easily set up and tested. Each function has a start
and an end point and has its own data and logic. (1)

Figure 1- 1: Paradigm
1.1.2 Characteristics:
- Is possible to manage a huge program by breaking it down into smaller manageable
operations or functions. Global variables allow different functions to exchange data.
Functions have the ability to modify global variables. This is known as a top-down
approach.

1
PERFOMED STUDENT: NGUYEN THANH DAT


1.1.3 Give examples:

Figure 1- 2: Flowchart

2
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 1- 3: Code

1.2

Object – Oriented paradigm.


1.2.1 Definition:
- Object-oriented programming (OOP) is a software development approach built on
objects. This paradigm divides data into objects (data fields) and specifies object
contents and behavior using class declarations (methods). For the majority of a

3
PERFOMED STUDENT: NGUYEN THANH DAT


programmer's school career, OOP is the most common programming paradigm and is
taught as the conventional method to code.

Figure 1- 4: Definition
1.2.2 The characteristics of OOPs:


Class and Object

Figure 1- 5: Class and Object
- Class: is category is a set of items that have features common to data and a few
program components. It is a type of entity that describes how an object is
implemented and what it contains. In other terms, it is a blueprint or collection of
instructions for constructing a certain object.
4
PERFOMED STUDENT: NGUYEN THANH DAT


- Object: Objects include methods and properties to make a concrete, usable, and useful
data object. They will represent a person, a location, a bank account, a knowledge
sheet, or any other thing the program should influence. When a program is run, objects

communicate by sending messages to one another. Each object contains data as well as
code for controlling the information.
- Example: Source code about example about Object – oriented paradigm with class
Student and objects in class student

Figure 1- 6: Class
1.2.3 Data Abstraction
- Data abstraction is the reduction of a particular body of data to a simplified
representation of the whole. Abstraction, in general, is the process of removing
characteristics from something to reduce it to a set of essential elements. To this end,
data abstraction creates a simplified representation of the underlying data, while
hiding its complexities and associated operations. In computing, data abstraction is
commonly used in object-oriented programming (OOP) and when working with a
database management system (DBMS).

5
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 1- 7: Data Abstraction.
1.2.3.1 Advantages and disadvantages.


-

Advantages:
It reduces the complexity of viewing things.
Avoids code duplication and increases reusability.
Helps to increase the security of an application or program as only essential details are
provided to the user.

It improves the maintainability of the application.
It improves the modularity of the application.
The enhancement will become very easy because without affecting end-users we can
able to perform any type of changes in our internal system.
Disadvantages
It offers complexity at many levels of the database that might create confusion for
developers.
The navigation becomes extremely difficult when an extra layer is added to the code.

1.2.3.2 Example:

6
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 1- 8: Code Abstraction
1.2.4 Data Encapsulation:
- According to this principle, all-important information is contained inside an object and
only select information is exposed. Each object's implementation and state are kept
private within a specified class. Other objects do not have access to or power over this
class. They can only call a set of public functions or methods.

7
PERFOMED STUDENT: NGUYEN THANH DAT


Figure 1- 9: Encapsulation
1.2.4.1 Advantages and disadvantages.



-

Advantages:
Encapsulation protects an object from unwanted access by clients.
Encapsulation allows access to a level without revealing the complex details below that
level.
It reduces human errors.
Simplifies the maintenance of the application
Makes the application easier to understand.
Disadvantages:
The length of the code increases significantly in the case of encapsulation because we
need to provide all the methods with the identifiers.
As the size of the code increases, you need to provide more instructions for every
method.
Encapsulation leads to an increase in program execution time. That's because more
commands are added to the code, so they require more time to execute.

8
PERFOMED STUDENT: NGUYEN THANH DAT


1.2.4.2 Example:

Figure 1- 10: Code Encapsulation

9
PERFOMED STUDENT: NGUYEN THANH DAT


1.2.5 Inheritance.

- Almost all object-oriented languages that allow classes provide the concept of
"inheritance." Classes can be arranged in hierarchies, with each class having one or
more parent or child classes. If a class has a parent class, we say it is derived or
inherited from the parent class, and the connection is of the "IS-A" type. That is, the
parent class's child class "IS-A" type. As a result, if a class inherits from another class, it
inherits a lot of that class's functionality and attributes and may be expanded to
incorporate distinct code and data. Because the functionalities of a parent class do not
need to be re-defined in any of its child classes, inheritance frequently leads to
effective code reuse.

Figure 1- 11: Inheritance
1.2.5.1 Advantages and disadvantages.

-

Advantages:
It reduces code redundancy.
It provides code reusability.
Reduces source code size and improves code readability.
After using this code is easy to manage and divided into parent and child classes.
It supports code extensibility by overriding the base class functionality within child
classes.
10

PERFOMED STUDENT: NGUYEN THANH DAT




Disadvantages:

- In Inheritance base class and child classes are tightly coupled. Hence, If you change the
code of parent class, it will get affects to the all the child classes.
- In the class hierarchy, many data members remain unused and the memory allocated
to them is not utilized. Hence affect the performance of your program if you have not
implemented inheritance correctly.

1.2.5.2 Example:

Figure 1- 12: Inheritance
11
PERFOMED STUDENT: NGUYEN THANH DAT


1.2.6 Polymorphism.

Objects are intended to
share behavior and can
take on several forms.
The program will identify
which
meaning or usage is
required for each
execution of that object
from a parent class,
eliminating the
need for duplicate code.
The parent class's
functionality is then
extended by creating a
child class.

12
PERFOMED STUDENT: NGUYEN THANH DAT


Polymorphism enables
many sorts of objects to
flow via the same
interface.
Objects are intended to
share behavior and can
take on several forms.
The program will identify
which
meaning or usage is
required for each
execution of that object
from a parent class,
eliminating the
need for duplicate code.
The parent class's
13
PERFOMED STUDENT: NGUYEN THANH DAT


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×