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

Assignment 2 1618 Programming (Merit) Greenwich

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.84 MB, 67 trang )

ASSIGNMENT 2 FRONT SHEET
Qualification

BTEC Level 5 HND Diploma in Computing

Unit number and title

Unit 1: Programming

Submission date

23/12/2022

Date Received 1st submission

Re-submission Date

24/12/2022

Date Received 2nd submission

Student Name

Tran Duc Long

Student ID

GCH210562

Class


GCH1106

Assessor name

Pham Danh Tuyen

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
Grading grid
P2

P3

P4

P5

M2

M3

Page 1 of 66

M4

D2

D3


D4


 Summative Feedback:

 Resubmission Feedback:

2.1

2.2

2.4

Grade:
Lecturer Signature:

Assessor Signature:

Page 2 of 66

2.3

Date:


Table of Contents
A. Task 1: Introduction to your program (P3) ............................................................................................. 7
1.1.


Introduce the Overview/ Context of the problem .......................................................................... 7

1.2.

List out the application’s requirements........................................................................................... 7

1.3.

How can my program solve the problem: ....................................................................................... 7

A. Task 2: Explain programming paradigms(P2).......................................................................................... 7
2.1 Explain what is Procedural Programming with source code and illustrations ..................................... 7
2.2 Explain what is Object-Oriented Programming with source code and illustrations ............................ 9
2.3 Explain what is Event-Driven Programming with source code and illustrations ................................ 11
2.4 The relationship between them ......................................................................................................... 13
2.5 Conclude which paradigms will be used to develop the application with explanation. .................... 13
B.

Task 3: IDE features(P4-M2-M3-M4) .................................................................................................... 16
3.1 Introduce what is IDE .......................................................................................................................... 16
3.2 Introduce features of IDE with illustrations ....................................................................................... 17
a) Code editor:....................................................................................................................................... 17
b) Other IDE tools: ................................................................................................................................. 17
3.3 An explanation and evaluation of the debugging process in the IDE used and how it helped with
development. ............................................................................................................................................ 18
Definition:.............................................................................................................................................. 18
Procedure: ............................................................................................................................................. 19
Evaluation:............................................................................................................................................. 19
3.4 Evidences that you have used debugging during the implementation .............................................. 19
3.5 An evaluation of developing applications using an IDE versus developing an application without

using an IDE............................................................................................................................................... 22

C.

Task 4: Design and Implementation(P3-P5) .......................................................................................... 23
4.1 Flowchart of the application ............................................................................................................... 23
4.1.1 User case: ..................................................................................................................................... 23
4.1.2 Flow Chart: ................................................................................................................................... 24

Page 3 of 66


4.1.3 Class diagrams: ............................................................................................................................. 29
4.2 Source code and screenshots of the final application with explanation ........................................... 29
4.2.1. Screenshots of the program:....................................................................................................... 29
4.2.2. Source code of the program: ...................................................................................................... 37
4.3 Explain and evaluate coding standards used in the program ............................................................ 58
a)

Layout: ........................................................................................................................................... 59

b)

White space: .................................................................................................................................. 59

c)

Indentation: ................................................................................................................................... 60

d)


Naming rules: ................................................................................................................................. 60

e)

Note: .............................................................................................................................................. 61

4.4 Explain the benefits of using coding standards .................................................................................. 62
4.5 Evaluate my entire program: .............................................................................................................. 62
D. Conclusion: ............................................................................................................................................ 63
E.

Reference: ............................................................................................................................................. 64

Table of figures
Figure 1: Procedural paradigm (Vats.R,2022) ................................................................................................ 8
Figure 2: Foreach in POP ................................................................................................................................ 8
Figure 3:OOP paradigm (Vats, 2022) .............................................................................................................. 9
Figure 4:Object-oriented paradigm characteristics (Doherty, 2020). .......................................................... 10
Figure 5: Interface in OOP ............................................................................................................................ 10
Figure 6: Event-driven paradigm (Anon., 2021.) .......................................................................................... 11
Figure 7: Event-driven paradigm characteristics (Baral, 2012) .................................................................... 12
Figure 8: Event button in Event-driven ........................................................................................................ 12
Figure 9: Loop for in my program ................................................................................................................. 13
Figure 10: Loop foreach in my program ....................................................................................................... 13
Figure 11: if-else in my program .................................................................................................................. 14
Page 4 of 66


Figure 12: Switch in my program.................................................................................................................. 14

Figure 13:Class book in my program ............................................................................................................ 15
Figure 14: An event listener in my program................................................................................................. 16
Figure 15: Event button Cancel in my program ........................................................................................... 16
Figure 16: Screenshot of an IDE ................................................................................................................... 18
Figure 17: Debugging section ....................................................................................................................... 20
Figure 18: Break point .................................................................................................................................. 20
Figure 19: Start debugging ........................................................................................................................... 21
Figure 20: Expected result ............................................................................................................................ 22
Figure 21: Algorithm linear search with IDE ................................................................................................. 22
Figure 22: User case in my program ............................................................................................................. 24
Figure 23: Flowchart my program ................................................................................................................ 25
Figure 24: Algorithm linear search to find book's location .......................................................................... 25
Figure 25: Flowchart of methods searching in my program ........................................................................ 26
Figure 26:Flowchart of methods sorting in my program ............................................................................. 27
Figure 27: method form Login in my program ............................................................................................. 28
Figure 28:Event update and remove books in my program ........................................................................ 28
Figure 29: Class diagram of my program ...................................................................................................... 29
Figure 30: form Loading in my program ....................................................................................................... 30
Figure 31: Form Login ................................................................................................................................... 30
Figure 32: Form Program.............................................................................................................................. 31
Figure 33: Form to add and update Book..................................................................................................... 31
Figure 34: Message box to exception handling ............................................................................................ 32
Figure 35: List book ...................................................................................................................................... 32
Figure 36: Book already exists ...................................................................................................................... 33
Figure 37: Save book's information .............................................................................................................. 33
Figure 38: Example: sorting book by date added ......................................................................................... 34
Figure 39: Example: searching by book's name in my program .................................................................. 34
Figure 40: Click button Edit .......................................................................................................................... 35
Figure 41: Click button delete ...................................................................................................................... 36
Figure 42: Edit color...................................................................................................................................... 36

Figure 43: Click button refresh ..................................................................................................................... 37
Figure 44:View code of form frmRunning .................................................................................................... 38
Figure 45: View code of form Login.............................................................................................................. 39
Figure 46: Class Book .................................................................................................................................... 40
Figure 47: interface IChecker in my program ............................................................................................... 41

Page 5 of 66


Figure 48: Class CheckerImp to exception handling .................................................................................... 41
Figure 49: interface IController in my program ........................................................................................... 42
Figure 50:Methods searching in my program .............................................................................................. 45
Figure 51: Methods sorting in my program ................................................................................................. 48
Figure 52: Interface IViewController in my program ................................................................................... 48
Figure 53: View code frmProgram................................................................................................................ 55
Figure 54: View code of AddUpdateForm .................................................................................................... 58
Figure 55: Layout in my program ................................................................................................................. 59
Figure 56: White space in my program ........................................................................................................ 60
Figure 57: Indentation in my program ......................................................................................................... 60
Figure 58:Naming rules: ............................................................................................................................... 61
Figure 59:Types note in my program ........................................................................................................... 61

Page 6 of 66


A. Task 1: Introduction to your program (P3)
1.1.

Introduce the Overview/ Context of the problem


Everything in our current civilization is modern and inventive. Every day, there is a great
deal of innovation, particularly in technology. We must acknowledge that technology has
invaded every part of our life, from basic gadgets like phones and computers to complicated
programming programs.
In this assignment, I will talk about library management, or called librarian software,
precisely how I can use it, as well as extensive explanations of its features and characteristics,
and ultimately an evaluation of the functions and the overall program. In addition, I included
many alternatives in my application for users to choose from, each with its own purpose and
information to allow them to develop a range of programs. These capabilities will aid the
archivist in entering the book's information such as type book..., as well as finding which
author.

1.2.

List out the application’s requirements

This system will give the archivist power and flexibility to manage the entire book from a
single online portal. Librarians can do:
+ Create a new book including id, name, type book, adding date , and author.
+ Edit/delete/save the book's information.
+ Sorting books by name/type book/added date/author/id.
+ Searching for books by name/type book/id/date of adding/author.

1.3.

How can my program solve the problem:
+ After the user logs into the program, there will be a total screen including the
functions.
+ When user press new/add books button, program will show a form where they can
enter book’s information then book's information will show on main screen.

+ Users can edit/delete/save/refresh the information books have just entered according
to the corresponding messageBoxes.
+ Users can view sorted book’s information as well as search for books through menu 2
combobox sort and search on the main screen.

A.

Task 2: Explain programming paradigms(P2)

2.1 Explain what is Procedural Programming with source code and illustrations

Page 7 of 66




Procedural programming is a programming paradigm that teaches a computer to
execute a program logically. Fundamentally, procedural programming is the process of
writing a set of instructions that the computer may follow step by step. The
procedural programming paradigm divides codes into processes, with each block of
code performing a specific purpose. Procedures, often known as routines, subroutines,
or functions, are essentially a collection of computing processes that must be
performed in the sequence specified by developers. (isaaccomputerscience, n.d.)

Figure 1: Procedural paradigm (Vats.R,2022)


Procedural paradigm characteristics:
+ Procedural program models imitate real-world processes on data.
+ Data flows freely throughout a software.

+ The program's flow is simple and straightforward.
+ Big jobs are broken down into smaller ones (functions).
+ Uses a top-down approach to program design.
+ The majority of functions exchange global data. (Chakrabarty, 2013)



Example code:

Figure 2: Foreach in POP

Page 8 of 66


2.2 Explain what is Object-Oriented Programming with source code and illustrations


Object-oriented programming (OOP) is a fundamental programming paradigm that
almost all developers employ. The most common programming paradigm and the
conventional approach to code are OOP. It is a programming paradigm centered on
classes and objects rather than functions and logic. It is used to divide a software
program into basic, reusable classes that may then be utilized to produce individual
instances of things. Object-oriented programming languages include JavaScript, C#,
Java, and Python. A class is a type of object that is used to construct distinct, concrete
things. Classes, like functions in procedural programming, can contain methods, but
they are only available to objects of that kind. These functions, which are specified
within the class, carry out some operation. (Doherty, 2020).

Figure 3:OOP paradigm (Vats, 2022)



Object-oriented paradigm characteristics:
+ Encapsulation: data and information concealment

Page 9 of 66


+ Abstraction: displays just important qualities and conceals irrelevant
information.
+ Inheritance: the ability to derive a class for a hierarchy from another class.
+ Objects: an object is a class instance.
+ Class: a group of objects with similar properties (Doherty, 2020).

Figure 4:Object-oriented paradigm characteristics (Doherty, 2020).


Example code:

Figure 5: Interface in OOP

Page 10 of 66


2.3 Explain what is Event-Driven Programming with source code and illustrations


"Event-driven programming is a programming paradigm in computer programming in
which the flow of the program is governed by events such as user actions (mouse
clicks, key presses), sensor outputs, or message passing from other programs or
threads," according to Wikipedia. Event-driven programming is the prevalent

paradigm in graphical user interfaces and other programs (for example, JavaScript web
applications) that are focused on doing specific actions in response to user input. This
is also true for device driver programming (e.g., P in USB device driver stacks).
A main loop in an event-driven application normally listens for events and then calls a
callback function when one of those events is recognized. In embedded systems, this
can be accomplished by employing hardware interrupts rather than a continually
running main loop. Event-driven applications may be developed in any programming
language, however languages with high-level abstractions, such as await and closures,
make the work simpler." (Anon., n.d.)

Figure 6: Event-driven paradigm (Anon., 2021.)


Event-driven paradigm characteristics:
+ Service-Oriented: The service-oriented requires less computer resources and
typically runs in the background of the operating system.
+ Time-Driven: code that only executes at a given time.

Page 11 of 66


+ Trigger Functions: These are functions that run when a specified event occurs.
+ Events: The user must interact with a software object (click a button by a mouse,
use the computer keyboard to choose a button).
+ Programming Simplicity and Development Ease: Event-driven programming is
significantly simpler and easier to implement than other types of programming.
For example, you may place a button by choosing it, dragging it to a form, and
assigning it a listener. (Kolenikova, 2022).

Figure 7: Event-driven paradigm characteristics (Baral, 2012)



Example code:

Figure 8: Event button in Event-driven

Page 12 of 66


2.4 The relationship between them


Because of increased consumer demand, programs/applications are getting
increasingly complicated. Developers mix two or three programming paradigms in one
software to simplify them. Here's how they may be combined in a program:
+ The procedural paradigm represents the issue solution, defining procedures and
data flows.
+ Looking at models and developing objects to represent those models is what
object oriented is all about.
+ When events are triggered, the event programming paradigm generates actions
for both procedural programming and programming objects, which aid in the
development of human engagement with the program.

2.5 Conclude which paradigms will be used to develop the application with
explanation.
In my program, I have used procedural programming, object-oriented programming and eventdriven paradigms.
• Procedural programming:
Firstly, I used for and for each loops to conduct tasks like as looking for book information. I
also used if-else and switch statement to test the condition when the user entered data. This
simplifies and makes the code easier to understand.


Figure 9: Loop for in my program

Figure 10: Loop foreach in my program

Page 13 of 66


Figure 11: if-else in my program

Figure 12: Switch in my program


Object-Oriented Programming:
Secondly, I mostly user Object-Oriented Programming Paradigm because it suitable for the
scenario. I can create class of books in OOP.

Page 14 of 66


Figure 13:Class book in my program


Event-Driven Programming:
Secondly, I use Event-Driven programming paradigm to build event listener for buttons,
objects,… Have them perform specific tasks when pressed.

Page 15 of 66



Figure 14: An event listener in my program

Figure 15: Event button Cancel in my program

B.Task 3: IDE features(P4-M2-M3-M4)
3.1 Introduce what is IDE
An integrated development environment (IDE) is application development software that
integrates common developer tools into a single graphical user interface (GUI). An IDE is
often made up of the following components:
+ Source code editor: A text editor that can help you write software code by
highlighting syntax with visual clues, giving language-specific auto-completion, and
checking for flaws as you type.

Page 16 of 66


+ Local build automation: Tools for automating simple, recurring operations
associated with making a local build of software for usage by developers, such as
converting computer source code into binary code, packaging binary code, and
performing automated tests.
+ Debugger: A software that can graphically indicate the location of a defect in the
original code and is used to test other applications.
Because different tools do not need to be manually installed and integrated as part of the
setup process, an IDE allows developers to start writing new apps fast. When every utility
is represented on the same workbench, developers no longer need to spend hours
separately learning how to utilize different tools. This is also valuable for onboarding new
engineers, who may use an IDE to learn about a team's standard tools and procedures. In
reality, most IDE capabilities, such as intelligent code completion and automatic code
creation, are designed to save time by eliminating the need to write out whole character
sequences. (redhat.com, 2019)


3.2 Introduce features of IDE with illustrations
a) Code editor:
The shell is the environment in which the user may write code. The code editor is a text
editing area where developers may write, modify, and save code documents. It has
capabilities that aid in the authoring and modification of code. These are some examples:
+ Auto-completion (or code completion)
+ Bracket matching
+ Syntax checks
b) Other IDE tools:





Translator. This compiles or interprets the code.
Documentation for automobiles. This defines the function and purpose of the code, for
example, by identifying the modules and variables used, as well as its anticipated
behavior, and compiles this information into a text file that other developers may use to
understand how and why the code was generated.
Libraries. These provide functions that are not included in the programming language's
core. These functions can be imported and utilized in the program code at the beginning.
In Python, for example, the Turtle Graphics module gives access to some basic drawing
and graphics capabilities.

Page 17 of 66







Create automation. These tools save time by automating operations that would otherwise
be performed by hand. These may involve testing and compilation. When a software
contains thousands of lines of code, these tools come in handy. They increase software
quality by reducing faulty software builds and saving time and money.
Debugger. This is an IDE application that is used to identify mistakes. If the debugger finds
an error, it may indicate what sort of error it is and what line it is on. n.d. (bbc.co.uk, n.d.)

Figure 16: Screenshot of an IDE

3.3 An explanation and evaluation of the debugging process in the IDE used and
how it helped with development.
Definition:
Debugging is the act of finding and eliminating current and prospective problems (often
known as "bugs") in software code that might cause it to behave abnormally or crash.
Debugging is the act of finding and eliminating current and prospective problems (often
known as "bugs") in software code that might cause it to behave abnormally or crash.
When many subsystems or modules are tightly coupled, debugging becomes more
challenging since each change in one module may cause more flaws to appear in
another.(Anon, 2022)

Page 18 of 66


Procedure:
I used Microsoft Visual Studio Community 2022 to implement the solution to this
situation.
• The debugging procedure:
+ Recognizing a mistake.

+ Locate the error (at line...).
+ Correct the mistake.
+ Rerun the application to see if any errors remain.
• The debugging procedure will assist us in locating and correcting program errors,
making the application usable and bug-free.
Evaluation:
Evaluation: A debugger is a software tool that can help with software development by
finding code mistakes at various phases of operating systems or application
development. Some debuggers will evaluate the test run and establish break points to
see which lines of code are not executed. This tool allows coders or rookie IT students
like me to waste less time looking for issues and more time solving them. This feature
also makes it easy for coders or programmers to keep their applications updated.

3.4 Evidences that you have used debugging during the implementation


I will debug this code section:

Page 19 of 66


Figure 17: Debugging section


I will put a break point at the line I need to debug.

Figure 18: Break point




Next, I will start debugging, the program will run until the breakpoint.

Page 20 of 66



×