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 (17.76 MB, 62 trang )

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

<b>BTEC FPT INTERNATIONAL COLLEGE </b>

<b>INFORMATION TECHNOLOGY </b>

<b>ASSIGNMENT 2 UNIT: PROGRAMMING </b>

STUDENT : LE TRAN QUOC BAO CLASS : IT05102

STUDENT ID : BD00033

SUPERVISOR : NGUYEN HOANG ANH VU

<b>DaNang, August 2022 </b>

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

<b>ASSIGNMENT 2 FRONT SHEET </b>

<b>Qualification BTEC Level 4 HND Diploma in Computing </b>

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

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

i

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

Internal Verifier’s Comments:

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

<b>vided a lot of knowledge to use as references throughout this exercise. </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.

<b>Learners declaration </b>

I certify that the work submitted for this assignment is my own and research sources are fully acknowledged.

<b>LE TRAN QUOC BAO </b>

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

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-driven programming ... 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, and coding 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

</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 ... 11

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… ... 16

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">

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

<small> </small><b>Programming: </b>

Programming is a job where programmers design, build, and maintain computer programs (software). People who do programming work are called programmers. Using available code, programming languages, and utilities, they build, debug, or improve programs, applications, games, software, websites, processing systems, and more. Help users interact with each other through electronic devices or execute commands with computers.

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

POP is a way to establish information. Procedural programming is the main focus for completing tasks sequentially supporting the concept of procedure calling Procedures (regular form or subroutine) simply contain a series of steps Calculations be done. Save control of the program's organizational flow. If the program is extensible, it is structured in a number of small units called functions, which share data system-wide.

<small> </small><b>A function: </b>

Structured Programming (POP) is a programming technique that divides a large program into many small programs, and the programs are analyzed into several parts to complete a large program called a function. Each function will take on a different function in the system. The small process will be done until the function is simplified.

<b>This purpose is to simplify the structure of the program. </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">

<small>2 </small>

When running the program will get results.

Figure 2-1 Example for Procedural programming.

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

Event-oriented programming is a method of building a system based on developing a graphical interactive interface through objects and defining the behavior of the system through the events of the objects In software development, events -driven programming is a programming model in which all business logic is performed in the program's source code. The program's runtime flow will be determined based on events. Events here can be:

Click the button on the screen Press the key on the keyboard Hover

Timeout

Receive sensor output signal

Receive messages from other programs or threads …

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

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

<small>8 </small>

Figure2-6: Abstraction.

<b> Encapsulation: This property does not allow the user of the object to change </b>

the internal state of an object. Only the internal methods of the object allow to change its state. How the external environment is allowed to affect an object's internal data is entirely up to the coder. This property ensures the integrity of the object.

Figure 2-7 Encapsulation.

<b> Inheritance: This property allows an object to have properties that another object </b>

already has through inheritance. This allows objects to share or extend existing properties without having to redefine them. However, not all object-oriented languages have this property

This means that the parent class can share data and methods among classes. Subclass from must be DEFINITION, outsiders can extend inherited elements and add new ones. Reuse source code Optimize one way, make use of source code.

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

<small>9 </small>

<b> Polymorphism: Expressed through sending messages (message). Sending </b>

these messages is comparable to calling the internal functions of an object. The methods used to respond to a message will respond differently depending on the object to which the message is sent. The programmer can define a property (by method names, for example) for a series of close-by objects, but when implemented using the same name, the implementation of each object will be automatic. occurs according to the characteristics of each object without confusion.

Figure2-9 Polymorphism.

<b>2.1.5 What is the difference between procedural programming (POP) and object-ori- ented programming (OOP). </b>

<b><small>BASIS FOR COMPARISON </small></b>

<small>Basis Main focus is on "how to get the task done" </small>

<small>i.e. on the procedure or structure of a </small>

<small>program . </small>

<small>Main focus is on 'data security'. Hence, only </small>

<small>objects are permitted to access the entities </small>

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

<small>10 </small>

<b><small>BASIS FOR COMPARISON </small></b>

<small>Inheritance Their is no provision of inheritance. Inheritance achieved in three modes public </small>

<small>private and protected. </small>

<small>Data hiding & security There is no proper way of hiding the data, so </small>

<small>data is insecure </small>

<small>Data is hidden in three modes public, </small>

<small>private, and protected. hence data security </small>

<small>increases. </small>

<small>Data sharing Global data is shared among the functions in </small>

<small>the program. </small>

<small>Data is shared among the objects through </small>

<small>the member functions. </small>

<small>Friend functions or </small>

<small>friend classes </small>

<small>No concept of friend function. Classes or function can become a friend of </small>

<small>another class with the keyword "friend". </small>

<small>Note: "friend" keyword is used only in c++ </small>

<small>Virtual classes or </small>

<small>virtual function </small>

<small>No concept of virtual classes . Concept of virtual function appear during </small>

<small>inheritance. </small>

Table 2-1 Compare POP and OPP.

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

<small>11 </small>

<b>2.2 Analyze the common features that a developer has access to in an IDE(M2). 2.2.1 IDE definition: IDE (short for Integrated Development Environment) integrated </b>

environment used to write, develop code for applications.

In addition, the IDE is also integrated with other support tools such as compiler, error checking, information service, directory organization code, search code, formatting highlight code. IDE will make it more convenient and easier for you to develop applications without an IDE. At that time, you can still write the source code, because in fact, the source code of a certain programming language can run, you just need the corresponding compiler of that language itself.

The IDE also has a compiler or interpreter built into it. From there, it helps you to execute code directly while programming the application. Typically: Visual Studio, Eclipse, Xcode, Android Studio, ...

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

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

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

<b>Debugger: Debugging tools help programmers identify errors in the source code. </b>

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.

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

<small>12 </small>

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

<b>Compiler: is the component that translates from this programming language into a </b>

computer-processable language, such as binary code.

<b>Code completion: Full code features help programmers by intelligently detecting </b>

and adding common code elements. These features help developers save coding time and reduce syntax capabilities law.

Figure 2-12 Debugging in Visual studio.

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

<small>13 </small>

<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.

Figure 2-14 Several languages are supported in Visual Studio

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

<small>14 </small>

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

The IDE allows developers to start setting up new applications quickly because many add-ons do not need to be configured and are actively manual as part of the setup process. Developers also don't need to spend time learning how to use different tools when all utilities are combined into one.

This can be special owner is help the new member settings, these people can rely on the IDE to get up to speed on specified tools and jobs. In fact, most of the IDE's features are aimed at saving time, like smart code completion and code auto-generation, eliminating the whole string character problem.

Various feature popular IDEs are intended to help developers organize their processes and solve problems. IDE parsing code when it was writing, because that the error give up by the HUMAN was identified in quick time.

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

<small>15 </small>

<b>CHAPTER 3 IDE problems, debugging procedures, and 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>

<small> </small>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:

<small> </small>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.

<small> </small>These are the steps I took to create a cinema simulation from Visual Studio software

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

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

<small>16 </small>

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.

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 27</span><div class="page_container" data-page="27">

<small>17 </small>

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

<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 28</span><div class="page_container" data-page="28">

<small>18 </small>

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).

Figure 3-4: Adding elements to form

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

<small>19 </small>

<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><span class="text_page_counter">Trang 30</span><div class="page_container" data-page="30">

<small>20 </small>

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

<small>21 </small>

</div>

×