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

assignment 2 front sheet qualification btec level 5 hnd diploma in computing

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 (3.32 MB, 120 trang )

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

<b>ASSIGNMENT 2 FRONT SHEET</b>

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

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

<b>submission</b>

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

<b>❒Summative Feedback:</b>

<b>❒ </b>

<b>Resubmission Feedback:</b>

<b>Lecturer Signature:</b>

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

Table of Contents

I. Introduction to the program ... 6

1. Scenario and Requirement Analysis. ... 6

2. Common features of IDE. ... 35

2.1. User Start Window. ... 36

2.2. Windows Form Design ... 37

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

4.2. Not using an IDE (text editor) ... 51

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

IV. Coding standards. ... 52

1. Definition ... 52

2. Coding standards in my code ... 52

3. Coding standard is necessary in a team as well as for the individual. ... 57

References ... 60

<b>Table Of Figures</b>

Figure 1. List ... 7

Figure 2. Class Book ... 9

Figure 3. Class Book ... 10

Figure 4. Class Borrow ... 11

Figure 5. Flowchart Login ... 12

Figure 6. Flowchart Add ... 13

Figure 7. Flowchart Edit ... 14

Figure 8. Flowchart Delete ... 15

Figure 9. Flowchart of Borrow Book ... 16

Figure 10. Flowchart Return Book ... 17

Figure 11. Main Winform ... 18

Figure 12. Search in Book List ... 19

Figure 13. Login ... 20

Figure 14. Functions ... 21

Figure 15. Adding or Editing error message ... 22

Figure 16. Warning of deleting ... 22

Figure 17. Warning of deleting ... 23

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

Figure 18. Wrong Day Need To Return ... 24

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

Figure 19. Borrow List ... 25

Figure 20. Unavailable to Borrow ... 26

Figure 21. Search in List of book borrowers ... 27

Figure 22. Fee ... 28

Figure 23. Visual studio interface (Article, 2021). ... 35

Figure 24. Start Window of Microsoft Visual Studio ... 36

Figure 25. Windows Forms ... 37

Figure 26. Toolbox ... 38

Figure 27. Proposal completed ... 39

Figure 28. Constructor automatically ... 39

Figure 29. Constructor automatically ... 40

Figure 30. Start with and without Debugging ... 40

Figure 31. Logical error ... 41

Figure 32. Breakpoint ... 42

Figure 33. Step Over ... 43

Figure 34. Result of Step Over in Visual Studio tip ... 44

Figure 35. Run To Cursor ... 45

Figure 36. Run To Cursor ... 45

Figure 37. Run To Click ... 46

Figure 38. Locals ... 46

Figure 39. The Watch ... 47

Figure 40. Using visual studio to code ... 49

Figure 41. Curly Brackets ... 53

Figure 42. Inter-term ... 53

Figure 43. Comments ... 54

Figure 44. Make lines at the samee level ... 55

Figure 45. Var ... 55

Figure 46. Blank line ... 56

Figure 47. Keyword in C (Dotnet Concepts, 2011) ... 57

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

<b>I.Introduction to the program.</b>

I was given a challenge to design a library application that was produced using the IDE and was subject to Coding standards for a comprehensive business problem after passing the presentation to exhibit my problem solving and fundamental programming abilities. As a result, I'll create a WinForm application utilizing Microsoft Visual Studio's C# programming language. The software will include the following features: Add, Edit, Delete, and Search. In addition, I'veincluded several additional functions to improve the program's functionality. And now for my report.

<b>1. Scenario and Requirement Analysis.</b>

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

<b>2. Design Phase.2.1. Data structure:</b>

In this article, I use List as a list of objects. It can be accessed by index. It is located in the System.Collections.Genericnamespace. Where this list can be used to create a set of different variables like: Integer, string,... And I use List with 2 objects. It is used for the list of books in the library (aList) and the list of students borrowing books (bList).

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

String availability

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

String status

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

- Borrow: This feature includes a list that stores the loan list's text; each individual added will have the same data type andproperties.

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

String people

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

String booknameString datebString dater

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

Functions:Login:

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

Add Book:

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

Edit Book:

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

Delete Book:

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

Borrow Book:

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

Return Book:

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

Key Features of Procedural Programming: (Sagar Bhatia, 2021).

<b>+ Predefined functions: A preset function is usually an instruction with a name attached to it. Predefined functions are</b>

usually included in higher-level programming languages, however they are drawn from a library or registry rather thana program. 'charAt()' is an example of a pre-defined function that looks for a character location in a string.

<b>+ Local Variable: A local variable is a variable that is defined in the method's main structure and is only valid inside the</b>

scope of the method. The local variable can only be used in the method in which it is defined; if it is used outside of thatfunction, the code will fail.

<b>+ Global Variable: A global variable is one that is declared outside of every other function in the program. As a result, </b>

unlike local variables, global variables can be utilized in any function.

<b>+ Modularity: When two distinct systems are given two separate tasks to complete, they are grouped together to </b>

complete a bigger job first. The tasks of each set of systems would subsequently be completed one by one until all tasks were completed.

<b>+ Parameter Passing: A system for passing parameters to functions, subroutines, and procedures is known as </b>

parameter passing. 'Pass by value', 'pass by reference', 'pass by result', 'pass by value-result', and 'pass by the name' areall methods for passing parameters.

Therefore, in my program, there are 7 main procedural paradigms used, which are:+ Adding new book.

+ Editing existing books in DataGridView of library.

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

+ Deleting a book in DataGridView of library.

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

+ Search book in DataGridView of library (Following Name, Author or Category).+ Borrow book in DataGridView of library.

+ Return book in DataGridView of book borrowers.

+ Search book in DataGridView of book borrowers (Following Name or Book).

<b>2. OOP paradigm.</b>

Object-oriented programming (OOP) is a programming paradigm that organizes software design around data, ratherthan functions and logic. An object is a data field with its own set of properties and behavior. (Alexander S. Gillis, 2021).

Structure: (Alexander S. Gillis, 2021).

<b>+ Classes: are data types that are created by the user and serve as the blueprint for individual objects, properties, and </b>

<b>+ Objects: are instances of a class that have been constructed with specified data. Real-world items or abstract entities</b>

can be represented by objects. The description is the sole object defined when a class is created for the first time.

<b>+ Methods: are functions that describe an object's behavior and are specified within a class. In class declarations, each </b>

method begins with a reference to an instance object. In addition, instance methods refer to the subroutines that make up an object. Methods are used by programmers to ensure reusability and to keep functionality contained to a single object at

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

a time.

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

<b>+ Attributes: describe the status of an object and are defined in the class template. Data will be saved in the attributes </b>

field of objects. The class's characteristics are the class's own.Object programming characteristics: (Alexander S. Gillis, 2021).

<b>+ Encapsulation: This concept asserts that an object contains all relevant information and only selective information is </b>

revealed. Each object's implementation and state are kept private within a specified class. This class is not accessible to other objects, and they do not have the ability to modify it. Only a list of public functions or methods are available to them.This data masking feature improves application security and avoids data corruption that isn't intended.

<b>+ Polymorphism: Objects merely show the internal mechanisms that let them to interact with other objects, concealing </b>

any extraneous implementation code. The functionality of the derived class can be expanded. Developers may find it easier to make adjustments or additions over time if they use this notion.

<b>+ Abstraction: Code from other classes can be reused by classes. Developers may establish relationships and </b>

subclasses between items, allowing them to reuse similar logic while preserving a distinct hierarchy. OOP's virtue of forcing more extensive data analysis reduces development time and ensures greater correctness.

<b>+ Inheritance: Objects are created to communicate behaviors and come in a variety of shapes and sizes. The program</b>

determines what meaning or usage is required for each execution of a superclass object, avoiding the requirement for duplication of code. Then a subclass is developed that extends the parent class's functionality. Different sorts of objectscan flow via the same interface thanks to polymorphism.

Popular pure OOP languages include:+ Ruby

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

+ Scala

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

+ JADE+ Emerald

Programming languages designed primarily for OOP include:+ Java

+ Python+ C++

Other programming languages that pair with OOP include:+ Visual Basic .NET

+ PHP+ JavaScript

<b>3. Event-Driven paradigm</b>

Event-driven programming is a programming paradigm in which the control flow of a program is determined by the occurrence of events. This sort of software is made to detect events as they happen and respond with an appropriateevent-handling technique, which is usually a callback function or method. (ukessays, 2021).

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

Key features and characteristics of event-driven programming: (ukessays, 2021).

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

<b>+ Service Oriented: Service oriented programming is a crucial component of event-driven programming that is used to</b>

develop programs for services. It does not slow down the computer since service oriented programming uses very little

<b>processing power and normally runs in the background of the operating system.</b>

<b>+ Time Driven: Time driven programming is a paradigm in event driven programming; it's code that runs on a time trigger. </b>

Time driven programming can be a specific code that runs on a specified time, such as once an hour, once a week, or once a month; it's a pre-set to do activity. Windows Update, for example, is a time-driven system in which the user may specify when to update or when to look for and download updates.

<b>+ Event Handlers: When a certain event is triggered, event handlers are a sort of function or method that performs a</b>

specified action. For example, an event handler may be a button that displays a message when the user clicks it andcloses the message when the user clicks the button again.

<b>+ Trigger Functions: In event-driven programming, trigger functions are functions that determine what code to execute </b>

when a given event happens. They are also used to determine which event handler to use when a specific event occurs.

<b>+ Events: Mouse, keyboard, and user interface events must be triggered in the program for them to occur, which means</b>

the user must interact with an item in the program, such as clicking a button with a mouse, selecting a button with the keyboard, and so on.

Here are some examples of possible events:+ Click the button on the screen.

+ Press the key on the keyboard.

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

+ Hover.

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

+ Timeout.

+ Receive the output signal of the sensor.

+ Receive messages from other programs or threads.

<b>1. Definition.</b>

Integrated development environments (IDEs) are programs that make it easier to create other programs. One of the key advantages of an IDE, which is designed to integrate all programming jobs in one application, is that it provides a central interface with all the tools a developer requires, including: (Veracode, 2019).

<b>+ Code editor: These editors differ from text editors in that they seek to either simplify or enhance the process of creating </b>

and modifying code for developers.

<b>+ Compiler: Compilers convert source code written in a human-readable/writable language into a computer-executable</b>

<b>+ Debugger: During testing, debuggers are used to assist developers in debugging their application applications.</b>

<b>+ Build automation tools: These may be used to automate typical development processes in order to save time.</b>

This is how the Source Editor and Debugger look like in Microsoft Visual Studio 2021

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

<b>2. Common features of IDE.</b>

I use Visual Studio 2021 with C# Winform for this design, so I'll go over some of its main features.

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

g , g

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

<b>2.1. User Start Window.</b>

When we open Visual Studio, we will see the window screen of Microsoft Visual Studio. Here, we can easily choosedifferent functions such as: Open a project or folder or can create a new project. Besides, we can also easily trackback old projects in Open Recent.

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

<b>2.2. Windows Form Design.</b>

We will select Create a new project, then find Windows Forms App (.Net Framework) for C#. Then fill in the information and we will have a Windows forms as shown below.

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

In it, Visual Studio has supported us with the toolbox. It has all the necessary features for us to use for example:Button, Check Box, Label, etc. Thanks to that, form design will be easier and more efficient for programmers.

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

With the proposal completed, it saves your time a lot. It will suggest you the passages that you use the most. And in some cases when you forget the name of the properties or method of an object, it can help you easily.

<small>Figure 27. Proposal completed</small>

<b>2.2.3.Generate getter/setter, constructor automatically.</b>

To shorten the time, when creating a class for an object, we need to build a getter/setter for each part of it. With theshortcut "propfull" we can quickly create a function, then we just need to press "Tap".

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

<b>2.2.4.Integrate compiler.</b>

After we have finished the code, we will run the program. Visoul Studio gives us 2 options: with and without debugging.

<small>Figure 30. Start with and without Debugging</small>

<b>3. Debugging process.3.1. Definition:</b>

Debugging is the process of using debugging tools to assist developers find and fix flaws, problems, and anomalies in computer programs that impact how they function and what they produce. Debugging allows the software to function properly and effectively by checking, detecting, and correcting flaws or defects (ee, n.d.)

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

Almost all IDEs, such as Eclipse, Visual Studio, Android Studio, Net Beans, and others, have debugging facilities. The stages to debugging are usually determined by the sort of fault you're seeking to solve. I'll go through two different sorts ofdebugging procedures.

They're comparable in certain ways:- Run-time error.

- Logical error.

<b>3.1.1.Run-time error.</b>

If you're stuck with DevideByZeroException, for example, you may set a breakpoint in this method and run it in debug mode to observe it execute step by step and investigate how your code acquires a variable with a value of zero. Run-timeError is the name for this sort of error. DevideByZeroExceptions are discovered during the execution of the program.

<b>3.1.2.Logical error.</b>

Logical errors are difficult to detect since they are not always obvious. A logical mistake is a flaw in a software that causes it to run regularly but not abnormally (or crash like Run-time error). This mistake causes an unexpected error orother behavior, which you may not notice right away. You build a C# function to calculate the sum of two integers, for example.

</div>

×