Tải bản đầy đủ (.pdf) (59 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 (4.63 MB, 59 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</b>

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

<b>ASSIGNMENT 2 FRONT SHEET</b>

<b>QualificationBTEC Level 4 HND Diploma in Computing</b>

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

<b>Submission date14/8/2022Date received (1stsubmission)</b>

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

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

First of all, I would like to express a special and enormous thanks to my family for theirinvaluable encouragement, enthusiasm, and support. Without all of this, I couldn't haveachieved it Second, I would like to sincerely thank teacher NGUYEN HOANG ANH VU forenthusiastically supporting me to achieve my academic results and thanking him for hissupport 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 Collegefor 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-

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

I certify that this assignment is my work, based on my study and that I have acknowledgedall 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. Ialso certify that this assignment has not previously been submitted for assessment in anyother unit, except where specific permission has been granted from all unit coordinatorsinvolved, or at any other time in this unit, and that I have not copied in part or whole orotherwise stealing ideas the work of other persons.

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

<b>INTRODUCTION ... VIII</b>CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE ... 1

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

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

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

2.1.2Event-driven programming ... 2

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

2.1.4 Characteristics of the programming models…...6

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

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

2.2.1 IDE definition...10

2.2.2Basic features of common IDE… ... 10

2.2.3Benefits 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 143.1Write a program that implements an algorithm using an IDE(P3) ... 14

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

<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

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

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

Programming is one of the subjects to master the knowledge base, understandingprogramming models such as procedural programming, object-oriented programming, andevent-oriented programming, the structure of a program, data, basic data, at the sametime to introduce to students the knowledge of IDE, the functions of the IDE and somestandard rules, rules of naming in code. At the same time, it helps students gainknowledge 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 .

</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 computerprograms (software). People who do programming work are called programmers. Usingavailable code, programming languages, and utilities, they build, debug, or improveprograms, applications, games, software, websites, processing systems, and more.Help users interact with each other through electronic devices or execute commandswith computers.

<b>2.1.1Procedure-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 largeprogram into many small programs, and the programs are analyzed into several partsto complete a large program called a function. Each function will take on a differentfunction 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</b>

number The first is to create the main function:

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

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 graphicalinteractive interface through objects and defining the behavior of the system through the eventsof the objects In software development, events -driven programming is a programming model inwhich all business logic is performed in the program's source code. The program's runtime flowwill be determined based on events. Events here can be:

Click the button on the screenPress the key on the keyboardHover

Receive sensor output signal

Receive messages from other programs or threads…

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

Button" to click the result and delete the result. Data A when entering them shouldenter a non-zero number if entering 0 it will say "Or enter another 0"

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

Application" it will get an error as shown above.

To fix that error, I will Declare the library "using System.Windows.Forms;" as shown below.

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

<b>robust applications(M4)</b>

<small> </small><b>Debugging:</b>

Debugging is the process of finding out the error or the cause of the error (where thebug is) to have a direction to fix the error (fix the bug). Debugging is not only to removeerrors from the program, but more importantly, to help the programmer betterunderstand the execution of the program. A programmer without the ability to debugeffectively is like being blind

It is normal for any programmer to have an error in thousands of lines of code. Theprogram may not run according to the programmer's intention, or run the wrongfunction it is prescribed, causing the program to be rated shoddy. So when there is anerror, the programmer must debug to fix the error to help the program run well.

<b>IDE debugger:</b>

IDEs allow programmers to write code to develop applications. In addition, it alsointegrates a lot of different software development tools such as: code search support, compiler and interpreter creation, code organization and sorting

In addition, the IDE helps to optimize the coding process. It provides a suitable interface for code generation and helps to automate the programming steps. In simpler terms, an IDE is an environment that integrates the functions of many processes together. It allows users to use popular programming languages such as Java, Python, etc. Besides, the IDE environment also supports programmers to install plugins to make the coding process simpler.

What makes IDEs superior is the ability to chain pre-assigned groups of code from one or more people. Users simply build hierarchies and systems together incodes. The IDE also comes with both an intuitive debugger and checker, which greatly saves time re-testing the program.

Software is difficult to install and consumes memory space of the computer.Sometimes the IDE can't find the error and fix it

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

<small>and debugging IDE debugging found error</small>

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

Figure3-25 The program is out of error.

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

<b>the individual(D4).</b>

<small> </small><b>Define:</b>

<b>Coding conventions: A coding convention is a set of guidelines for a </b>

language-engineering language that recommends setting styles, practices, and methods for eachaspect of programs written in that language. These conventions typically include file organization, margining, comments, declarations, statements, spaces, naming conventions, set implementations, setup rules, setup rules, methods best in architecture, etc. This is a guide to quality structural software. Software developers should follow guidelines to help improve the readability of their source code and make it easier to maintain. Coding conventions are applicable only to human maintainers andpeer reviewers of a project software. Conventions can be formalized in a well-documented rule that the entire team or company follows, or can be as informal as information that lowers an individual's code. Coding conventions are not enforced by the compiler

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

Increase quality

It is common to find that software developers spend most of their time solving code quality problems that could have been prevented. Implementing programming standards and best practices will help the team detect problems early or even prevent them altogether. This will increase efficiency throughout thesoftware process.

The risk of project failure is minimized

Many times it happens that IT projects fail due to problems while developing software. Implementing code quality standards reduces many problems and the risk of project failure.

Minimum complexity

If a code is complex, then the chances of it being error-prone are higher. Coding standards make it possible to develop less complex software programs and thus reduce errors.

Easy to maintain

If programming standards in software engineering are followed, the code will be consistent and easily maintainable. This is because anyone can understand it and can modify it at any time.

<small> </small><b>The benefit of coding standard for a team or personal:</b>

Implementing code quality standards reduces many problems and the risk of project failure. If a piece of code is complex, the chances of it being error-prone are higher. Coding standards make it possible to develop less complex software

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

the same way, it would be easier for everyone to predict and be more organizedRead more codes. Declare variables in the usual place, in the usual order, declared in the same and usual way.

For example, my current employer has a very specific standard for how digital identities should be declared. We have to capitalizeLikeThis. I hate it. Terrible. But everyone does it the same way, allOfTheTime. It becomes completely 100% predictable. And that's better

<b>5.1 Outline the coding standard you have used in your code(P5).</b>

<small> </small><b>Variable:</b>

Avoid using multiple variables as a whole to avoid influence use only when necessary• I will put captions for each section

• We need names that are memorable and meaningful

<small> </small><b>Some notes in naming:</b>

• Do not reuse the same names or change only a few characters such as capital letters. In many cases it will lead to confusion

• Do not set up two namespaces with the same name, but only change it with uppercase letters, so there are more numbers

• Don't build a method with the same parameters and only different cases.• Abbreviations should not be used in IDs or parameter names.

• When naming abbreviations, you can use Pascal case or Camel case for naming.

<b>Naming rules:</b>

<b>Common capitalization styles:</b>

<b>Pascal Case: The first letter of the identifier and the first letter of each subsequent word must be capitalized. For names of three or more characters, use Pascal Case.</b>

<b>Camel Case: The first letter in the identifier is a lowercase letter and the first letter of the followinghyphen must be capitalized.</b>

All characters in the identifier must be capitalized. Use this rule for identifiers with 2 characters or less.

<b>Named Assembly and DLL: Use a name to collectively describe the internal functions of the </b>

Assembly.

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

Use Pascal syntax to name the namespace.

Use the prefix of company and organization names to limit the conflict of namespaces with the same name.

<b>For example:</b>

<b>Name the class, struct, and interface:</b>

Use nouns or noun phrases to name classes, struct. Use Pascal's case.Name the interface an adjective phrase, or you can use a noun or a noun phrase.Do not use the prefix "C" for class names.

Should end the name of the inheriting class with the name of the base class.Use the "I" prefix for the interface name.

<b>For example: Name the class</b>

Name the interface:

Name the method, property, and field of a type:Name the method:

Use verb or verb phrase for method names.Name properties

Use nouns, noun phrases or adjectives.

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

Use Pascal case to name the field.Use nouns, noun phrases or adjectives.Do not use prefixes for field names.

it makes the source code easier to learn, easier to understand it makes the source code easier to learn, easier to understand.

Every substatement inside a block must be indented.

The opening braces must be in a straight column with the closing brace.

we need to avoid confusing using verbose encodings, length of functions we shouldkeep to a minimum and easy to understand.

<b>For example: Solve equations of degree 1:</b>

</div>

×