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

Assignment 2 Programming (1618 Distinction)

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.14 MB, 42 trang )

ASSIGNMENT 2 FRONT SHEET
Qualification

BTEC Level 5 HND Diploma in Computing

Unit number and title

Unit 1: Programming

Submission date

Date Received 1st submission

Re-submission Date

Date Received 2nd submission

Student Name

Bui Quang Minh

Student ID

GCD210325

Class

GCD1104

Assessor name


Ly Quynh Tran

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

M4

D2

D3

D4

Minh



 Summative Feedback:

Grade:
Lecturer Signature:

Assessor Signature:

 Resubmission Feedback:

Date:


Table of Contents
CHAPTER 1: INTRODUCTION TO YOUR PROGRAM (P3) .............................................................................. 5
I. CONTEXT OF THE PROBLEM ..................................................................................................................... 5
II. APPLICATION’S REQUIREMENTS ............................................................................................................. 5
CHAPTER 2: EXPLAIN PROGRAMMING PARADIGMS (P2) ........................................................................... 7
I. PROCEDURAL PROGRAMMING ................................................................................................................ 7
1. Definition ............................................................................................................................................. 7
2. Key Features ........................................................................................................................................ 7
2.1 Predefined functions ...................................................................................................................... 7
2.2 Local variable ................................................................................................................................. 8
2.3 Global variable ............................................................................................................................... 8
2.4 Modularity ..................................................................................................................................... 8
2.5 Parameter passing ......................................................................................................................... 9
II. OBJECT-ORIENTED PROGRAMMING ..................................................................................................... 10
1. Definition ........................................................................................................................................... 10
2. Concept .............................................................................................................................................. 10
III. EVENT-DRIVEN PROGRAMMING .......................................................................................................... 13
1. Definition ........................................................................................................................................... 14

2. Key Features ...................................................................................................................................... 14
2.1 Service oriented ........................................................................................................................... 14
2.2 Time driven .................................................................................................................................. 14
2.3 Event handlers ............................................................................................................................. 14
2.3 Trigger functions .......................................................................................................................... 14
2.3 Event ............................................................................................................................................ 15
3. Event-driven programming applications …........................................................................................ 15
IV. CONCLUSION ....................................................................................................................................... 15
V. EVALUATE THE SOURCE CODE (CODE STRUCTURE AND CHARACTERISTICS) (D2) ............................... 19
CHAPTER 3: IDE FEATURES (P4-M2-M3-M4) ............................................................................................ 20
I. DEFINITION (P4) ………………………............................................................................................................ 20
II. IDE FEATURES (M2) ............................................................................................................................... 20
1. Syntax Highlighting ............................................................................................................................ 20
2. Autocomplete .................................................................................................................................... 21
3. Debugging .......................................................................................................................................... 22
4. Refactoring ........................................................................................................................................ 22
5. Code Search ....................................................................................................................................... 23
III. USING IDE TO MANAGE THE DEVELOPMENT PROCESS (M3) .............................................................. 23


IV. EXPLAINATION AND EVALUATION OF DEBUGGING PROCESS (P4-M4) ............................................... 25
1. Explaination of Debugging Process in the IDE used ........................................................................... 25
2. Evaluate how Debugging Process can be used to increase more secure .......................................... 26
2.1 Debugging process ....................................................................................................................... 26
2.2 Evaluation about debugging process ............................................................................................ 27
V. DEVELOPING APPLICATION USED IDE and ONE WITHOUT IDE (D3) ..................................................... 27
1. Evaluation of Developing Application using IDE ................................................................................ 27
2 Evaluation of Developing Application without using IDE .................................................................... 28
CHAPTER 4: DESIGN AND IMPLEMENTATION (P3-P5-D4) ......................................................................... 29
I. WRITE A PROGRAM ................................................................................................................................ 29

1. Flowchart ........................................................................................................................................... 29
1.1 Flowchart of application ............................................................................................................... 29
1.2 Flowchart of removing book ......................................................................................................... 31
1.2 Flowchart of removing client ........................................................................................................ 32
2. Source Code ....................................................................................................................................... 33
2.1 Removing book ............................................................................................................................. 33
2.2 Removing clinet ............................................................................................................................ 33
3. Screenshots ........................................................................................................................................ 34
3.1 Removing book ............................................................................................................................. 34
2.2 Removing client ............................................................................................................................ 35
II. EXPLAINATION and EVALUATION CODING STANDARD (P5) ................................................................. 36
1. Definition ........................................................................................................................................... 36
2. C# Coding Standard and Naming Convetions .................................................................................... 36
2.1 Pascal casing ................................................................................................................................. 36
2.2 Abbreviations ............................................................................................................................... 37
2.3 Vertically align .............................................................................................................................. 37
2.4 Comments .................................................................................................................................... 38
2.5 Set name for variables ................................................................................................................. 38
3. Coding Standard’s Advantages .......................................................................................................... 38
III. WHY CODING STANDARD IS NEEDED FOR TEAM AND INDIVIDUAL (D4) ............................................ 39
Reference list ……………………………………………………………………………………………………………………………………… 41


CHAPTER 1: INTRODUCTION TO YOUR PROGRAM (P3)
I. CONTEXT OF THE PROBLEM
I successfully passed the presentation so I could illustrate in the report my fundamental
programming and problem-solving abilities. The more challenging task is building a fully working
application. For a specific business problem, security has been built using an IDE and in accordance
with coding standards. This report provides a summary of the fundamentals of programming in
part 2. focuses on object-oriented programming and generalises how to create a thorough

application. Utilize the programming skills you've gained (procedural, object-oriented, event
programming, ...). Examine the IDE's app-writing capabilities. Compare the use of an IDE against
not using one when developing applications to learn advanced programming.
Summary the previous assignment
I provided the details needed to develop library management software in Assignment 1. I
created a simple flowchart of the software's platform for applications and ran various
algorithms to address its problems.
In assignment 2, I will focus on object-oriented programming and generalises how to create a
thorough application, and examine the IDE's app-writing capabilities.

II. APPLICATION’S REQUIREMENTS
The application must allow the user to input inputs and perform specific CRUD (Create / Read /
Update /Delete) actions:


Create: The CREATE operation does what the name implies. It means creating an entry.
This entry could be an account, user information, a post, or a task.



Read: The READ operation means getting access to the inputs or entries in the UI. That
is, seeing it. Again, the entry could be anything from user information to social media
posts, and others.



Update: UPDATE is the operation that allows you to modify existing data. That is, editing
the data.




Delete: DELETE is the operation that is used to remove existing data, data created from
CREATE.

In my report, I've decided to focus on developing a library management application with a user
interface that enables the creation, updating, deletion, and display of the book list through
input data.
A company's library management system supervises every aspect of its operations. This system handles
borrowed books, clients borrowing books, and other functions.
1. Manager can search for books for a specific DateTime or book information.
2. Manager can add books or remove books, and manage the client's information.


Figure 1. Function “Remove” helps to delete an item


CHAPTER 2: EXPLAIN PROGRAMMING PARADIGMS (P2)
I. PROCEDURAL PROGRAMMING
1. Definition
Procedural programming is a programming paradigm built around the idea that programs are
sequences of instructions to be executed. They focus heavily on splitting up programs into
named sets of instructions called procedures, analogous to functions. A procedure can store
local data that is not accessible from outside the procedure's scope and can also access and
modify global data variables.
Simply put, Procedural Programming involves writing down a list of instructions to tell the
computer what it should do step-by-step to finish the task at hand.

Figure 2. What is procedural programming

2. Key Features

2.1 Predefined functions
A predefined function is a function available in a procedural programming language from a
library of available functions. These functions allow a programmer to complete common tasks
without creating the required code themselves. This can help a developer save time during
production.


Figure 3. Function “Remove” helps to delete an item
2.2 Local variable
A local variable is a programming variable that has a local scope of use. This means the variable
only functions in the function in which the developer defines it. Local variables only work in this
capacity, so they can cause code to fail, leaving a task unfinished if a professional or user
attempts to use the variable in a method outside of its scope.

Figure 4. Choice is a local variable used in Main
2.3 Global variable
Global variables increase functionality when local variables are insufficient. Developers can use
global variables in nearly all functions. When defined globally, a variable makes itself available
to all methods and functions in the code, allowing the developer to access key data throughout
the program's many procedures.

Figure 5. Global variables used in many methods, functions


2.4 Modularity
Modularity is a structure in which a developer divides the functionality of its code into a series
of smaller blocks. The programmer can then call these blocks, often called methods or functions
in procedural programming languages, in their code to access them.

Figure 6. Function “setInfoBooks” used to add books’ information


Figure 7. Function above is called in Main
2.5 Parameter passing
Parameters are the data values that transfer from each function within a code sequence. When
using parameter passing, developers place input parameters into a module or device and
receive output parameters in return. Parameters allow a programmer to assign passed data to
variables, equations and commands within a function to complete computing actions on the
data.

Figure 8. List is passed into function in order to use


II. OBJECT-ORIENTED PROGRAMMING
1. Definition
Object-oriented programming (OOP) is a computer programming model that organizes
software design around data, or objects, rather than functions and logic. An object can be
defined as a data field that has unique attributes and behavior.
OOP focuses on the objects that developers want to manipulate rather than the logic required
to manipulate them. This approach to programming is well-suited for programs that are large,
complex and actively updated or maintained. This includes programs for manufacturing and
design, as well as mobile applications; for example, OOP can be used for manufacturing system
simulation software.

Figure 9. OOP Illustration

2. Concept
Object – An object is an instance of a class. Anything that we see are nothing but objects. Objects can be
anything like pen, car, computer, bike, mobiles, etc. If there are objects then they will have properties
and behaviours which will differentiate one object from other.


Figure 10. Example of object (book) in application


Class – Classes are something which defines an object. You can say Class is a blueprint of an
Object. The class describes all properties and behaviours of an Object. Classes define attributes
and methods of the objects of their kind.

Figure 11. Example of class in application
Inheritance: The ability to create new class from an existing class is called inheritance. Let us
understand deeply about inheritance by an example.

Figure 12. Example of Inheritance in application
Encapsulation: It means hiding data or implementation details of one module from other modules. It
can also be defined as restricting access to certain properties. Encapsulation is a technique which is used
for data hiding. It is helpful in reducing system’s complexity.


Figure 13. Illustration of encapsulation
Abstraction: It is a process of showing essential feature of the entity by hiding certain important details.
It reduces code complexity. It is another good feature of oops and used to show the necessary details to
the client of the object.

Figure 14. Example of abstraction
Polymorphism: Polymorphism is derived by the combination of two words POLY and MORPHISM. Poly
means many and Morph means slight change. Thus, Polymorphism means having one name with many
forms. Here we can have methods with the same name but slight change in its functionality.


III. EVENT-DRIVEN PROGRAMMING
1. Definition

An event-driven program is one that largely responds to user events or other similar input. The concept
of event-driven programming is an important one in application development and other kinds of
programming, and has spawned the emergence of event handlers and other resources.
An event-driven program is also known as an event-driven application.

Figure 15 Flowchart of even-driven program
Advantages








Simplicity: When compared to other types of programming languages, event-driven
programming is easier to use. Once there is a business requirement, the development of
the program is hassle-free.
Convenience: Predictive coding is another feature of event-driven programming. With
the help of languages like visual basic, predictive coding is made possible. When the
developer is typing the code, relevant suggestions are given.
Flexibility: In event-driven programming, there is no specific order from start to finish.
This order can make it easy to carry out the code. In addition to that, this is a type of
code that can be altered when necessary. If there is a requirement or errors in coding,
the code is flexible to be changed.
GUI Support: A pre-programmed toolbar in the form of a Graphical User Interface (GUI)
is available in event-driven programming. From this toolbar, it is able to create more
interactive programs. For example, tools such as radio buttons are already included.
Power Consumption: Implementation of event-driven programming is from hardware
interrupts. As a result, there is considerably less power consumption.



Disadvantages









Speed: Event-driven programming is based on GUIs. the programs overall execute the
reduced performance. Especially, if the installed memory is insufficient.
Complexity: Event-driven programming is too complex for simple programs. The flow of
the program and stack management are all that make EDP more complex. If it is a small
program, it is worth considering other options like batch programming.
Resource Utilization: Event-driven programming uses the main loop which is well known
to drain system resources. Because the main loop is constantly functioning in the
background. Moreover, due to the usage of GUI, EDP cannot provide an interface unless
the required specifications are met.
Language Translation: Once a program is written using the EDP language, you cannot
translate it to a different language. Because some functionalities like buttons are
programmed to work only with event-driven programming.
Platform Support: Generally, event-driven programming is platform-dependent. When a
particular program uses EDP, it cannot function on other platforms. For example, the
program visual basic works using windows library files. If the program is moved to a
different OS, these files cannot be found.

2. Key features

2.1 Service oriented
Service oriented is a key feature in event-driven programming that used to write programs that
are made for services and it takes does not slow down the computer as service oriented only
consume little of the computer processing power and usually services run in the background of
OS.

2.2 Time driven
In event driven programming, time driven is a paradigm, it’s a code that runs on a time trigger,
time driven can be a specific code that runs on a specific time, which could be once an hour,
once a week or once a month, this means it’s a pre-set to do task. For example, windows
update is the example of time driven, which user can set when to update or when to check and
download the update.

2.3 Event handlers
Event handlers is a type of function or method that run a specific action when a specific event is
triggered. For example, it could be a button that when user click it, it will display a message,
and it will close the message when user click the button again, this is an event handler.

2.4 Trigger functions
Trigger functions in event-driven programming are a function that decide what code to run
when there are a specific event occurs, which are used to select which event handler to use for
the event when there is specific event occurred.


* Although, I haven’t learned about Windown Form yet, so I will just give a simple example to
illustrate for “trigger functions”.

Figure 16 Trigger functions

2.5 Events

Events include mouse, keyboard and user interface, which events need to be triggered in the
program in order to happen, that mean user have to interacts with an object in the program,
for example, click a button by a mouse, use keyboard to select a button and etc.

3. Event-Driven programming applications
Event-driven programming is generally used in three cases:




When programming games in which a set of objects carries out control flow.
When creating server applications, it is undesirable to spawn service processes if, for one reason
or another.
When building user interfaces, including graphical ones.

IV. CONCLUSION
This section will provide an example of a C# library management software that was developed
utilizing the OOP approach.
OOP in my program:




Classes: A class is a user-defined data type that can be accessed and used by creating an
instance of that class. It has its own data members and member functions. A class is
comparable to an object’s blueprint. Both member functions and data members are
found in classes. The data members inside the class are manipulated using these
member functions.
For example, I also used one of my classes named “Client” including may properties such
as NameOfClient or PhoneNumber.






Figure 17. Example of class
Encapsulation: Encapsulation is the process of grouping functions and data into a single
entity. To access these data members, the member function’s scope must be set to
“public,” while the data members’ scope must be set to “private.” According to this
theory, an item contains all important information; only a small subset is made available
to the outside world. Each object has a private class that contains its implementation
and state.

Figure 18. Example of encapsulation
Inheritance: In its broadest sense, inheritance refers to the process of gaining
properties. One object in OOP inherits the properties of another. Developers can reuse
common functionality while retaining a distinct hierarchy by assigning relationships and
subclasses between items. This characteristic of OOP speeds up development and


provides more accuracy by requiring a more in-depth investigation of the data. The
parent-child relationship is symbolized via inheritance.

Figure 19. Example of Inheritance

V. EVALUATE THE SOURCE CODE IN TERMS OF CODE STRUCTURE AND
CHARACTERISTICS (D2)
The object-oriented programming paradigm must be used logically while comprehending the
key benefits and capabilities offered by the model. Classes, objects, functions, methods,
properties, interfaces, etc. are some of these. The protagonists who try to resolve disputed

issues are the topics. The relationship between features must be established by factors like
inheritance, encapsulation, abstraction, etc.
The human ability to provide the computer instructions, such as program structure, variable
declaration, loop constructions, statements, and functions, is made possible by the C#
programming language. The attributes and features of the source code produced in the C#
programming language also serve as a highly clear and understandable expression of the
object-oriented programming approach.
A computer program typically has the following elements:
1. Program Structure
Overall, type of program, there is always a structure or format in which the programmer develops
programs. A well-organized program uses suitable information structures and formats.
2. Variable Declaration
A variable is used to store values at run time or time of execution. Some programming languages give
flexibility to the programmer to avoid variable declaration, but a good programming language must have
a proper variable declaration method.
3. Looping structures
Looping in computer programming is used to repeat statements, under a given condition. There are
many types of loops with minor differences in different computer programming languages. Loops will
keep executing until the exit condition is met.


4. Control structures
A control structure is a slab in computer programming that examines variables and chooses the
execution direction in which to go, based on given parameters or conditions.
5. Sentence structure
In computer programming, when a programmer writes a program they use programming notation in an
expository. Thus, it is important that the notation has a sentence structure that can be easily expressed.


CHAPTER 3: IDE (P4–M2–M3–M4)

I. Definition (P4)
An integrated development environment (IDE) is software used to build applications. One of
the key benefits of an IDE is that it consolidates the most common developer tools in a single
graphical user interface. The software typically consists of a source-code editor, a compiler, and
a debugger, plus a range of build automation tools.
Without an IDE, software developers would need to pick, deploy, integrate, and independently
manage the aforementioned tools, which perform a variety of tasks. By using either an opensource or commercial IDE, developers have instant access to set of integrated tools that
streamline software development and eliminate coding mistakes and typos. Developers can
access an IDE either as a standalone application or as part of a larger package offering.

Figure 20. Interface of visual studio when having no errors


Figure 21. Interface of visual studio when having error or bug

II. IDE Features (M2)

Figure 22. Features of IDE

1. Syntax Highlighting
Syntax Highlighting is a very common feature in IDEs. It highlights code in different colors or
fonts, depending on a specific category of terms. This feature makes code much easier to read
and work with. Syntax Highlighting also makes the implementation of code easier, as
highlighting is done in real-time, which means errors can be detected much more easily.



×