Tải bản đầy đủ (.pdf) (62 trang)

information technology 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 (1.46 MB, 62 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

<b> </b>

<b>BTEC FPT INTERNATIONAL COLLEGE </b>

<b>INFORMATION TECHNOLOGY ASSIGNMENT 2 </b>

<b>UNIT: PROGRAMMING </b>

STUDENT : HO TAN RIN CLASS : IT16102 STUDENT ID : BDAF200038

SUPERVISOR : NGUYEN HOANG ANH VU <b> </b>

<b>DaNang, August 2021 </b>

</div><span class="text_page_counter">Trang 2</span><div class="page_container" data-page="2">

<b> ASSIGNMENT 2 FRONT SHEET </b>

<b>Unit number and title Unit: Programming </b>

<b>Grading grid </b>

<b> </b>

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

i

<b>Summative Feedbacks: Resubmission Feedbacks:</b>

<b>Grade:Assessor Signature:Date:Internal Verifier’s Comments:</b>

<b>Signature & Date:</b>

</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4">

ii

<b> ACKNOWLEDGMENTS </b>

First of all, I would like to express a special and enormous thanks to my family for their invaluable encouragement, enthusiasm, and support. Without all of this, I couldn't have achieved it Second, I would like to sincerely thank teacher NGUYEN HOANG ANH VU for enthusiastically supporting me to achieve my academic results and thanking him for his support in the exercises as well as the knowledge that he taught and taught. solve whole-heartedly.Besides, I would also like to thank my friends at BTEC FPT International College for allowing me to exchange knowledge and help me understand the issues in this course. Finally, I would also like to thank the authors, brothers, sisters and friends who have pro-vided a lot of knowledge to use as references throughout this exercise <b>.</b>

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

iii

<b> ASSURANCE </b>

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

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

iv

<b>TABLE OF CONTENT </b>

<b>INSTRUCTOR/ SUPERVISOR/ ASSESSOR………IREVIEWERS………..IACKNOWLEDGMENTS……….….II</b>

<b>TABLE OF CONTENT……….…..IVLIST OF TABLES AND FIGURES………..…….VIINTRODUCTION………...VIII </b>

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE……….1

LO2 Explain the characteristics of procedural, object-oriented and event driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE)……… ….………1

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

2.1.1 Procedure-Oriented Programming(POP)……….…….………1

2.1.2 Event-<b>driven programming………..……….</b>2

2.1.3 Object-oriented programming (OOP)……… …………5

2.1.4 Characteristics of the programming models……….6

2.1.5 What is the difference between procedural programming (POP) and object-oriented programming (OOP)……….9

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

2.2.1 IDE definition………10

2.2.2 Basic features of common IDE………..10

2.2.3 Benefits of IDE for programmers……….………..13

CHAPTER 3 IDE problems, debugging procedures, andcoding standards………...14

LO3 Implement basic algorithms in code using an IDE ……….……14

LO4 Determine the debugging process and explain the importance of a coding standard..14

3.1 Write a program that implements an algorithm using an IDE(P3)………. ……..14

3.2 Use the IDE to manage the development process of the program(M3)……… ………23

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

v 3.3 Evaluate the use of an IDE for development of applications contrasted with not using an IDE(D3)………..……….30

4.1 Explain the debugging process and explain the debugging facilities available in the IDE(P4)……….31 4.2 Evaluate how the debugging process can be used to help develop more secure, robust

Critically evaluate why a coding standard is necessary in a team as well as for the ual(D4)……….………41 5.1 Outline the coding standard you have used in your code(P5)……… ……….…………42

<b>CONCLUSION ... 51REFERENCES ... 52</b>

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

vi

<b>LIST OF TABLES AND FIGURES </b>

Table 2-1 Compare POP and OPP………..9

Table 3-1: Some coding standard……….………..………..36

Figure 2-1 Example for Procedural programming………2

Figure2-2 CODE…………..……….….4

Figure 2-3 Result………5

Figure 2-4 Object Oriented Programming (OOP)……… ….…..5

Figure 2-5 algorithm results……….……….……6

Figure2-6 Abstraction………8

Figure 2-7 Encapsulation……….……….8

Figure 2-8 Inheritance……….……….8

Figure 2-9 Polymorphism……….……….8

Figure 2-10 Example about text editor in Visual studio……….………..11

Figure2-11 This is a debugger in Visual studio……….……… …….1.. 1

Figure2-12 Debugging in Visual studio………..…..12 Figure2-13 Debugging in Visual studio………..…..12 Figure 2-14 Several languages are supported in Visual Studio………..…13 Figure 3-1 Main interface………..……….………15 Figure 3-2 Create new project………..………….… ….1.. 6

Figure 3-3 Main Form………....…17 Figure 3-4 Adding elements to form………..………....….18 Figure 3-5: Element properties………..22

Figure 3-6 Example of IDE project……….…….………..22

Figure 3-7 results……….23

Figure 3-8 Create a new project or open project……….…..24

Figure 3-9: Create a new project………..….… …... 25

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

vii Figure 3-10: Choose project templates……….….….26

Figure 3-11: Set the name of the new project and select a framework……….………26

Figure 3-12: Introduce workspace in Visual studio……….…27

Figure 3-13 count the factorials from 1 to n……….…27

Figure 3-14 Result………..……….…28 Figure 3-15: Create a new item in Visual studio……….…….…28

Figure3-16: Create a new class………..……….…..29

Figure3-17 Workspace of class in Visual Studio………..……..29

Figure3-18 Set breakpoint in Visual studio……….…….30

Figure3-19 How to follow the program……….………30

Figure3-20 Some IDEs……… ………... 31

Figure3-21 Result………..………..32

Figure3-22 Result………..………..36 Figure3-23 Program has error……….………..39

Figure3-24 IDE debugger find error ……….39

Figure3-25 The program is out of error……….40

Figure3-26 For example……….……41 Figure 3-27 The program has a line of code with the wrong keyword………41 Figure 3-28 Symbolic of Coding standards………..46

Figure 3-29 Form Design……… ……….. .……….47 Figure 3-30 Code Form……….………..48 Figure 3-31 Finish form……….……….……49 Figure 3-32 Test……….………...… …... 49

.

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

viii

<b> INTRODUCTION </b>

Programming is one of the subjects to master the knowledge base, understanding programming models such as procedural programming, object-oriented programming, and event-oriented programming, the structure of a program, data, basic data, at the same time to introduce to students the knowledge of IDE, the functions of the IDE and some standard rules, rules of naming in code. At the same time, it helps students gain knowledge to build basic applications.

This report includes the following:

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE. LO2 Explain the characteristics of procedural, object-oriented and event driven

programming, conduct an analysis of a suitable Integrated Development Environment (IDE). CHAPTER 3 IDE problems, debugging procedures, and coding standards.

LO3 Implement basic algorithms in code using an IDE .

LO4 Determine the debugging process and explain the importance of a coding standard

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS

<b> AND IDE. </b>

<b> LO2 Explain the characteristics of procedural, object-oriented and event-driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE). </b>

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

<b>Programming: </b>

is an imaginary developer-driven cycle that instructs the PC how to perform a task. A program can be a series of guidelines that refer to the PC's attempt to return feedback for a difficult alternative. There are different ways to deal with programming interaction, given as a programming paradigm. In a genral sense, different models deal with different ways of solving synthetic answers to obvious types of problems using programming. Most programming languages etablish a model, but some have components of multiple models.

<b>2.1.1 Procedure-Oriented Programming(POP): </b>

Procedure-oriented programming can be a programming paradigm, derived from imperative programming, that supports the concept of procedure invocation. Procedures (regular forms or subroutines) simply contain a series of steps Calculations to be performed. Any given procedure can be called at any time during the execution of the program, including other procedures or.

<b>A function: </b>

is a subroutine within a large program. The function takes (or doesn't) satisfy and returns (or doesn't) a value to a program that calls it. It makes it conceivable to fragment a program into discrete pieces that operate independently of a giant program. This implies that a capacity can be used in one program but can also be used in another, making it simple to check and update the program <b>. </b>

<b>• For example: Create a recursive function to calculate the factorial of a number </b>

The first is to create the main function:

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

Next, create a recursive function:

When running the program will get results.

<b>For example: Generate electricity bill. </b>

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

• I use the "TextBox" to enter the A and B values and print them out, and the " Button" to click the result and delete the result. Data A when entering them should enter a non-zero number if entering 0 it will say "Or enter another 0"

The example below will show us

<b>` </b>

</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">

Figure2-2 CODE This is the result:

</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15">

Figure2-4 Object Oriented Programming (OOP).

<b>For example: write simple student management programs: </b>

</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">

first create a new class and initialize the student properties:

Next is the main part:

When running the program will get results:

Figure2-5 algorithm results.

<b>2.1.4 Characteristics of the programming models Procedural programming: </b>

<b> Functional characteristics: </b>

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

<b>They have two forms of passing parameters to a method as it is called by reference and by reference: </b>

• A variable provides a parameter to the value, the variable value is copied and treated in the method as a surrounding variable so that the outer variable is unchanged.

• The variable in the parameter itself is already using it by the function using the reference, instead of creating a variable area inside the function, so it has a do something on the variables inside out. To the application of the reference, express the parameters in the method, as you want when choosing whether to use the keyword. • <b>Recursive Method: Recursion is the declaration method, in its body, it calls itself. </b>

Recursion is quite similar to a loop, you need a stop condition to avoid endless crecursion. Most recursive methods can be switched to using loops, so keep in mind that if the loop is simple, loops should be used.

<b> Characteristics of procedural programming.</b>

• when we set up a certain program, POP will in some way follow a hierarchical programming approach.

• Most of the functions allow information to be shared widely throughout the system. • It also classifies large projects into smaller pieces called functions.

• The system allows being freely developed information around.

• Functions are responsible for converting data from one structure to another.

<b>Event-driven programming: </b>

<b>• Service-oriented: Since it consumes less power on the computer's prcessing power </b>

and the services normally run in the operating platform, this feature is used to write programs that render services and do not slow the computer down. It is also a key feature in event-driven programming processing power and usually, services run in the background of OS.

<b>• Time-Driven: Time-driven is a model, it is code that runs on a time trigger, it can be </b>

a piece of code that runs over a specified period of time. It is set up for duty.

<b>• Event Handlers: A kind of function or method that will run a specific action when an </b>

event is fired.

<b>• Trigger functions: When a particular event occurs, the trigger is what determines </b>

what code to run, used to choose the event handler when an event can occur.

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

<b>• Events: Are keyboard, mouse, interface, If we want events to happen, we have to </b>

activate them.

<b>Simplicity of Programming and Ease of Development: </b>

Compared to other types of programming, event-driven programming is considered one of the simplest and easiest to use. We can add or remove an object, event, or code directly into the application with just one click or pressing a button on the keboard. We have more custom properties, how it works for each object without having to manually write lengthy, lengthy code. Thanks to its simplicity and ease of use, it's easy for developers to develop applications in the future.

<b>Object-Oriented Programming </b>

Object-Oriented Programming has four basic properties: inheritance, polymorphism, encapsulation, and abstraction.

<b> Characteristics of the properties: </b>

<b>• Abstraction: Means generalizing something up, without paying attention to the details </b>

inside. It doesn't care what the details are inside and people still understand it every time they hear about it.

Figure2-6 Abstraction.

<b>• Encapsulation: Related data and methods are packaged into classes for easy </b>

management and use.

Figure 2-7 Encapsulation.

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

<b>• Inheritance: it allows us to build a class based on the definition of a created class. That </b>

means that the parent class can share data and methods between the child classes. When inheriting the child class, all the methods and properties of the parent class are inherited. Subclasses do not need to be redefined, other than extending the inherited components and adding new ones. Reuse the source code optimally, take advantage of the source code. Some common types of inheritance are single inheritance, multiple inheritances, multiple inheritances, hierarchical inheritance.

Figure2-8 Inheritance.

<b>• Polymorphism: considered as an action that can be performed in many different </b>

ways. This is another property that can be considered as containing almost all the power of object-oriented programming.

states "public", "private", " protected"

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

<b>Security </b> There's no proper way of hiding data, so it's not safe

Data is hidden in three modes "public", "private", "protected", thus increasing data security.

<b>Functions and Classes </b>

There is no concept of Function and Class

Classes or functions can communicate with each other with keywords. (depending on different languages, the keyword will be different)

<b>Commonly used languages </b>

C, Pascal C++, JAVA, VB.NET, C# .NET, Ruby,...

<b>Data sharing System-wide data is shared </b>

between functions in the gram<b>. </b>

pro-Data is shared between objects through functions.

Table 2-1 Compare POP and OPP.

<b>2.2 Analyze the common features that a developer has access to in an IDE(M2). 2.2.1 IDE definition: An integrated development environment (IDE). IDE is considered an </b>

interface for users to write code to develop applications, organize groups of documents, automate programming activities. The IDE is also integrated with other supporting features such as compiler, compiler, interpreter, error checking (Debugger), formatting organizing code folders, searching code.

<b>2.2.2 Basic features of common IDE: </b>

<b>Text editor:</b> code editor<b> is a feature designed to write and edit code.</b>

</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21">

Figure 2-10 Example about text editor in Visual studio.

<b>Debugger:</b>Debugging tools help programmers identify errors in the source code. When there is an error, it will report the error to the programmer and indicate the error line so that the programmer knows and corrects the error.

Figure 2-11 This is a debugger in Visual studio.

computer-processable language, such as binary code.the line is in error!

<small>information about each </small>error

</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">

<b>Code completion:</b> Full code features help programmers by intelligently detecting and adding common code elements. These features help developers save coding time and reduce syntax capabilities law.

Figure 2-12 Debugging in Visual studio.

Figure 2-13 Debugging in Visual studio.

<b>Programming language support: IDEs are typically specific to one programming </b>

language, however, some applications such as Sublime Title and Visual Studio are supported in multiple languages. Before we go into coding, we need to find out the language we want to use and then choose a suitable IDE.

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

Figure 2-14 Several languages are supported in Visual Studio.

<b>2.2.3 Benefits of IDE for programmers: </b>

• The IDE creates a homogenous environment between tools that can meet developer requirements, including version control and debugging tools.

• The IDE provides us with quick ideas, complete statements and code, and it also automatically detects problems and points out errors in specific lines of code. • It easily adapts to many different operating systems. Besides, it allows adding of new

features to meet the needs of programmers.

• The standard IDE development interface is considered an effective assistant to help programmers collaborate more easily, speed up deployment quickly and increase work efficiency.

• IDE makes developing software and game applications more convenient and easier on mobile and desktop platforms.

• Create a working environment that helps programmers become easier and more convenient in their work. Thereby improving their working results.

select the language you want to choose

</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">

<b>CHAPTER 3 IDE problems, debugging procedures, and </b>

<b> </b>

<b>coding standards. </b>

<b>LO3 Implement basic algorithms in code using an IDE </b>

<b>LO4 Determine the debugging process and explain the importance of a coding standard. </b>

<b>3.1 Write a program that implements an algorithm using an IDE(P3). </b>

I will write an event-driven program that creates a Windows form to manage employee information. First, I will talk about the properties of the components that I will use to write the program:

I write software to manage employee information and find employee information, it includes:

• Enter information: Staff code, full name, date of birth, hometown, Age, Gender, salary.

• In the information section, I use 3 buttons "Button". The first button I named " Additional" is used to add the data I entered above into the system, the second button is named "Amend" it has a function to correct information when we fill in the wrong information, the third button is called "Delete" it has the function of de-leting information on the system we entered.

• I use the "TextBox" button to record the employee's information and there is a "DateTime picker" button that has the function to select the date of the year. • Find employee information by searching by hometown, Gender, hometown. • In the search section, I use the "checkBox" button to mark the information I need

to search and I also use the "Button" button called "search" it has the function of searching for data information on the system. the system that I entered earlier in the information section.

Here are the steps I took to create the employee information table from Visual Studio software

<b>Step 1: Create a new Project. </b>

</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">

<b> </b>

Figure 3-1 Main interface.

<b>Step 2: when entering the previously created project, we will create window forms in </b>

that project. I will show you the steps to do it with pictures as follows. First we right click on ConsoleApp1.

<b> </b>

After right clicking on ConsoleApp1, it will appear on the table, click Add and then we select Form(windows form)

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

<b>After selecting the Form (window form) it will ap+pear a table for us to name the project. </b>

<b>Step 3: Enter a name for the project. Here I will default to the initial name is :Form1.cs </b>

and click Add.

Figure 3-2 Create new project

<b>Step 4: In the Properties section of the Form you can change the Text as you like, </b>

this is the title of the software. Will appear in the upper left corner of the form. Here I will leave the default as Form1.

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

Figure 3-3 Main Form.

<b>Step 5: You add the necessary components to the Form, here I will add Label, </b>

TextBox, Button, Datatimepicker, Panel, ComboBox , and checkBox ....(These components are in the ToolBox section).

</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">

Figure 3-4: Adding elements to form.

<b>Step 6: To edit you can edit in the Properties of the components </b>

Figure 3-5: Element properties.

<b>Step 7: After preparing the interface, I start to code. You double click on the button1 </b>

to capture the event (or the event in Properties). You can coding like a picturebelow:

</div>

×