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

ASM 1 C programming 1619 FPT Greenwich (Distinction Super Sale)

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.47 MB, 49 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

Nguyen Huy Hoang

Student ID

GCH200739

Class

GCH0908

Assessor name


Lai Manh Dung

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

HOANG`

Grading grid
P2

P3

P4

P5

M2

M3

M4

D2

D3

D4



 Summative Feedback:

Grade:
Lecturer Signature:

 Resubmission Feedback:

Assessor Signature:

Date:


Table of Contents
Table of Contents .............................................................................................................................................................................................. 3
1.

2.

3.

Introduction to MY program ........................................................................................................................................... 6
1.1.

Introduction ..................................................................................................................................................................... 6

1.2.

List of user requirements of my application ....................................................................................... 6


1.3.

Overview / Explaination ........................................................................................................................................... 7

programming paradigms .................................................................................................................................................... 10
2.1.

Procedural Programming PARADIGM ......................................................................................................... 10

2.2.

Oject-Orient Programming Paradigm ........................................................................................................ 11

2.3.

Event-Drivent Programming .............................................................................................................................. 14

2.4.

The relationship Between three programming paradigms ABOVE ..................................... 15

2.5.

Explaination How PARADIGMS APPLIED IN MY SOFTWARE................................................................ 15

IDE features................................................................................................................................................................................... 16
3.1.

Introduce to IDE: .......................................................................................................................................................... 16


3.2.

Features of IDE and how it manage code: .............................................................................................. 17

o

Using IDE to implement analgorithm in a program: .......................................................................................................... 18

3.3.

Using IDE and Without Using IDE To Write Code ................................................................................. 19

3.3.1.

Using IDE: .............................................................................................................................................................................. 19

3.3.2.

Without Using IDE: ............................................................................................................................................................... 21

3.4.
3.4.1.

DEBUGGING .......................................................................................................................................................................... 21
DEFINITION .......................................................................................................................................................................... 21


4.

3.4.2.


Debugging in IDE: .............................................................................................................................................................. 23

3.4.3.

Conclusion ........................................................................................................................................................................... 27

Design and Implementation................................................................................................................................................ 28
4.1.

Flowchart of the application ........................................................................................................................ 28

4.2.

Source code and screenshots of the final application .......................................................... 29

4.3.

CODING STANDARD ......................................................................................................................................................... 45

References ....................................................................................................................................................................................................... 48

Figure 1: List user requirements........................................................................................................................................................................ 6
Figure 2: Flowchart describe program .............................................................................................................................................................. 7
Figure 3: Main interface of software tab 1........................................................................................................................................................ 8
Figure 4: Main interface of application tab 2 .................................................................................................................................................... 9
Figure 5: Main interface of software tab 2........................................................................................................................................................ 9
Figure 6: Short source code procedural programming in C# .......................................................................................................................... 10
Figure 7: Short source code describe OOP in C# ............................................................................................................................................. 12
Figure 8: Short source code EDP in C# ............................................................................................................................................................ 14

Figure 9: Interface of VISUAL STUDIO 2019 IDE .............................................................................................................................................. 17
Figure 10: Short source code implement algorithm ....................................................................................................................................... 18
Figure 11: Using IDE to write code .................................................................................................................................................................. 19
Figure 12: Imane debug ................................................................................................................................................................................... 23
Figure 13: DEbugging image 2 STEP OVER ...................................................................................................................................................... 24
Figure 14: Watch in Autos ............................................................................................................................................................................... 25
Figure 15: IDE warning when program has error. ........................................................................................................................................... 26
Figure 16:Debuging QUICKWATCH .................................................................................................................................................................. 27
Figure 17: Flowchart of My APPlication .......................................................................................................................................................... 28
Figure 18: Screen Shot event of tab employment when start loading ........................................................................................................... 30
Figure 19: Event of click BUTTON Fill info ....................................................................................................................................................... 31
Figure 20: Applicant info Table........................................................................................................................................................................ 31


Figure 21: Screen Shot Event of click CHECK BUTTON .................................................................................................................................... 32
Figure 22: Check Button .................................................................................................................................................................................. 33
Figure 23: When Phone number is in appropriate .......................................................................................................................................... 33
Figure 24: When Date of Birth is empty .......................................................................................................................................................... 34
Figure 25: When Lastname Textbox still empty. ............................................................................................................................................. 34
Figure 26: Soure code EVENT of CLick Print button ........................................................................................................................................ 35
Figure 27: Click the print button ..................................................................................................................................................................... 36
Figure 28: Edit button ...................................................................................................................................................................................... 37
Figure 29: SOURCE CODE EVENT OF CLICK RESET BUTTON ............................................................................................................................ 38
Figure 30: Reset Button ................................................................................................................................................................................... 38
Figure 31: RESET BUTTON ............................................................................................................................................................................... 39
Figure 32: SOURCE CODE EVENT OF CLICK LIGHT/Dark mode ........................................................................................................................ 39
Figure 33: Light mode. ..................................................................................................................................................................................... 40
Figure 34: Dark mode ...................................................................................................................................................................................... 40
Figure 35: Source code event of click ADD button .......................................................................................................................................... 41
Figure 36: Add info1 ........................................................................................................................................................................................ 42

Figure 37: Add button2 ................................................................................................................................................................................... 43
Figure 38: Event when click Search buttn ....................................................................................................................................................... 44
Figure 39: Screenshot when the Search button click ...................................................................................................................................... 44
Figure 40: Coding standard Example ............................................................................................................................................................... 45
Figure 41: Coding standard example ............................................................................................................................................................... 46


1. Introduction to MY program
1.1.

Introduction

About my application: RSS - also stand for Recuitment Support Software, which is typical software built
and developed for support company(virtual illustration) in handle and analyze basic tasks which is commonly
existed in recuitment field.
1.2.

List of user requirements of my application

Figure 1: List user requirements


1.3.

Overview / Explaination

Recruitment Support Software(RSS) is my application which wil be used by intervewers particularly
employer’s secretary and employee manager(employer) with the need of entering and storing informations
that they just get. The problem In there is how to enter and store data (formatted as string) in the form of a
program and user can handle these data.

To meet this problem, this application operate as a digital text program which can record, enter, check
and print primary information of applicant include: Name, Date of birth, Gender, Phone number, Degree, Skills
and Desired field. Not only that, this application also have some useful function to support interviewers to
check and edit this infor if it be wrong, reset infor input if it is no longer required and the employer can search
infor and contract with applicant.
To explain how the software can solve this problem, there is a flowchart below:

Figure 2: Flowchart describe program

Particularly, the information of applicant will be got input first. After the data(information) is put in, The
program is able to print out first without having to go through the check process, besides if it is not necessary
to print the program can go straight to the next process of checking information of applicant. When checking


the input data, if there have any wrong or inappropriate input informations, the program will back to entering
the input information for employer’s secretary can examine and re-type. In other case, once the input is invalid
or nothing wrong, the infor will be put into suitable list immediately for other task can be executed.
There are two image of main interface of this software:

Figure 3: Main interface of software tab 1


Figure 5: Main interface of software tab 2

Figure 4: Main interface of application tab 2


2. programming paradigms
2.1.


Procedural Programming PARADIGM

Procedural programming is also known as a instructor who give a list to tell computer, step-by-step, what need
to do, in an arrangement of how to execute from the first code to the second,etc... which may contain loops. It
depends on the how programmer to contribute a solution to handle a problem or to contribute an answer. Procedural
programming languages can be told consist C, C++, Fortran, Pascal and some others (Maurizio.G, Simone.M, 2010).

Figure 6: Short source code procedural programming in C#

Explain source code: In this screen shot, the source code is built as Procedural programming in C#.
Particularly, the souce code will be executed from the first line of code. In this source code, program will implement
from assigning the string datatypes with variables and print it out to Console. This is just a short code, in other case,
even when the total line of code is up thousands line, the program always implement in an order from the top line to
the down line.




2.2.

Characteristics of Procedural Programming:
 In procedural programming all line of code must be executed in an order. For instance, first line of
code is carried out, then the second, then the third and so on, it is impossible to jump from the 1st to
the 7th, it must first complete 1-6 in order to get to the 7th line (Moo, 2017).
 Programming language which apply the Procedural Programming commomly are very detailed and
spends a tons of time to write and build (Moo, 2017).
 Procedural programming utilize variables to get the state of the software and store procedures to
switch that state. Any part of code can access any variable. That maybe take it gets hard in debugging
because a error situation might have originated anywhere. It also causes it difficult to test it since the
act of a procedure might be vary reli on the variables (Maurizio.G, Simone.M, 2010).

 Procedural programming also make a concentrate on the intent that all algorithms are carried out with
functions and data that the programmer has access to and is able to change and edit (Maurizio.G,
Simone.M, 2010).

Oject-Orient Programming Paradigm

OOP(Object-oriented programming) Paradigm is hugely popular, It widely used in various diverse in
many programming languages to develop software applications and games. It can be understood is computer
programming model which organizes software pattern rotates around data, or objects, rather than functions and
logic. Each object could be defined as a data field that has unique attributes and behavior (Maurizio.G, Simone.M,
2010).


Figure 7: Short source code describe OOP in C#

Explain source code: In the source code above, it is a template which represent for a program which built as
OOP. This sorce code is an abstract class(present the Abstraction feature of OOP) which make the program can reuse it multiple time and not necessary to re-write this code times. In this source code there are some property of a
job-seeker, the properties of this class also should be designed to make it private to ensure security of these
informations. This access modifier also represent for Encapsulation feature of OOP.


Key Features of OOP:
o

Abstraction:
 Allows for simple things to represent complexity.
 Such as there are objects, classes, and variables representing more complex basic code or data.





For example, in my code i could create a Phone object then ask it to turn on. I needn't to concern
about how the Phone object operates as long as i know it has a on method within (S.Gillis, 2017).
 This is pretty vital because it helps avoid repeating the same work multiple times.
o Inheritance:
 Every classes are able to reuse code from other classes.
 With using inheritance the data is made manageable in a hierarchical order (S.Gillis, 2017).
 Relationships and subclasses between objects can be assigned, allow programmers to reuse
generall logical wheares still maintaining a unique hierarchy. This property of OOP forces a more
thorough data analysis, decreases development time and ensures a higher level of accuracy.
o Encapsulation:
 Encapsulation is known as a mechanism of wrapping the data variables and code behavior on the
data methods together as a single unit.
 The implementation of each object are privately held inside a specific class.
 The variables of a class will be hidden from other classes in program, and can be accessed only
through the methods of their current class, therefore it is also known as data hiding.
 Being able to re-utilize objects like code components or variables without permitting access to the
data system-wide (S.Gillis, 2017).
o Polymorphism:
 Objects are designed to share behaviors and they can get more than one form, enable programmer
to utilize the same word to mean vary things in vary contexts.
 A subclass is then spawned, which extends the functionality from superlass. Polymorphism enable
different types of objects to go through the same interface.
 In other words, polymorphism permits programmer desiges one interface (or class) and have
multiple implementations (S.Gillis, 2017).



Characteristics of OOP
 object orientated programming intent to the making up of reusable software object methods and

classes which can be effectively developed and not difficult incorporated into multiple programs.
 Commonly, the programmer use OOP to handle the problem in an old fashioned way. It doesn’t use
much algorithm but instead breaks down the problem of elements into vary classes.




2.3.

Unlike the Procedural programming which is a top down approach to execute the code , OOP
execute in a bottom up approach (Maurizio.G, Simone.M, 2010).

Event-Drivent Programming

Event-Driven Programming(EDP) is a widely well-known paradigm which relies on either external or internal
events which determined actions such as clicking on a mouse or change text in text box so that decide the program
flow (Maurizio.G, Simone.M, 2010). can interact with any hardware that is attached to a computer and is not a
complex program to use(Nørmark, 2011).

Figure 8: Short source code EDP in C#

Explain source code: This source code is one of events in an application. Particularly, the code will wait for an
event which is either a check in check box detail, it is executed whenever Checkbox Detail is checked. The program
will implement this code in scope of this code, when check box is checked, this text box located in this if statement
will be executed based on this assign that read only will turn off when this check box is checked. Besides when this
check box is not yet checked, the text box in this else if statement also is turn on(true). This source code is so short,
but this partly represent the feature of Event-Drivent programming, explain for how the EDP is executed.


Characteristics of Event-Driven Programming

 EDP just only can be used by using a graphical user interface which is one of its main features.








2.4.






2.5.

A feature generall in EDP is the existence of a main loop within the code. The main loop constantly
executes during program execution and identifies the valid events after which a function triggers
based on the event (Farell, 2011).
EDP can make program easily be developed and all properties used in the program are all
independent. Therefore, they can save altogether part the programmer time and effort saving them
separately (Farell, 2011).
Event-Driven Programming shares a few features with OOP which consist the utilize of variables,
procedures, classes and objects. In addition, EDP has two other special features, a main loop and
an event handler (Maurizio.G, Simone.M, 2010).

The relationship Between three programming paradigms ABOVE
Event driven programming simply utilizes event-driven handlers to keep a lots of code handy and

available for execute if and when requested. If there is no longer needed for this code, then it just rests
on the sidelines without interfering with or cluttering the other code. At this moment the program is a
cluster of subprograms. The controlling program simply gets track of diverse events and fires the code
inside the event-driven handler set aside for that specific event (Maurizio.G, Simone.M, 2010).
Object oriented programming merges the programming abilities of Procedural and Event-driven
programming and goes on to handle other tasks (Purdum, 2013). The functions and variables of a module
are kept in an object (Farell, 2011). Objects is not able to be made up randomly. Each object combines
from a class. A class is a blueprint, a design or an architecture for creating objects. A class do
encapsulate a tons of functions. Variables can appear in a class or inside its functions. A function is able
to encapsulate vary functions and variables and some others (Purdum, 2013).
With Event driven, programmer can supply event handlers to both Procedural and Object Oriented
Paradigms. Therefore, as a stand alone, it’s not a complete paradigm. For instance your procedural
report writer could have an event to handle out of paper. Or the object oriented program could have an
event to handle when lightning hits a person standing line for the move (Schach, 2006).

Explaination How PARADIGMS APPLIED IN MY SOFTWARE


Apply Programming Paradigms in my app: The program of my application used all three
programming paradigms to build it, especially OOP and EDP have been used mainly in this program to built
the system program inside the application. Particularly, my application mainly intent to the object info, which
focus on get these info of applicants and there are enough classes which inherit from super class which is
abstract class and interface(using inheritance and Abstraction features of OOP).
Not only that, the program also intent to these functions which used multiple times to get information
and some overloading methods are also used for functions of this app. And the application obviously have
main interface to interact with user, this evidently must be set many events to help the program can
communnicate and interact with user, such as whenever the user click on a button or change the text the text
box, the system code will be implemented to handle this tasks to meet the user requirements.

3. IDE features

3.1.

Introduce to IDE:

Definition: IDE is stand for Integrated Development Environment - a software application for programmer
develops program base on programming language, which contributes a toolbox that include all the facilities required
to computer programmers forsoftware development. Using IDE for designing code make it more effortless for a
programmer to build an application using its comprehension facilities (redhat, n.d.).
Because main function is helping programmer in coding, each moderm IDE commonly consists source editor,
debugger, coding automation. Almost modern IDE has intelligent avaiable code completion. This property help boost
speed the process of coding by limit typos, auto-complete code and other generall errors, the process of development
will be accelerated in result (Blokdyk, 2019). IDE’s have the capability of using the functionality of multiple
programming processes in a single process. Some IDE’s will work on a specific programming language, and also
they contain cross-language capabilities.
When building my application, to make the coding more convenient and easier to make an interface of my
application, I decide to select VISUAL STUDIO 2019 IDE to build this application because these features of it are
well-suitable.


There is image illustration of VISUAL STUDIO 2019 IDE below:

Figure 9: Interface of VISUAL STUDIO 2019 IDE

3.2.
Features of IDE and how it manage code:
 Source code editor: A text coding editor which can support in writing software code with convenient features
such as syntax highlighting with visual signals, given language(Particularly C#) can be specific autocompletion for example: when i write a line code such as Console.WriteLine, i just neet to write two letter Co
and the program will automatically present the avaiable matching code with this code from there if i click enter
button on keyboard this code will auto-complete based on my desired code. In addition, VSI parse code as it











is written, so bugs caused by programmer error are identified in real-time. VSI can check for bugs as code is
being written (redhat, n.d.). Whenever user write a wrong code in Visual Studio IDE, the program will notify a
warning to user via red underline of piece of wrong code and constantly notify to user to re-edit this code line.
Local build automation: Utilities which automatic handle simple, repeatable tasks as a part of creating a
local build of the software to be used, like compiling computer source code file into binary code for telling
computer what to do, packaging code, and running automated tests (redhat, n.d.).
When creating applications, VISUAL CODE IDE be in charge of provide resources available for me to easily
code such as library files, header files, etc., at specific positions. For example, if i want to use the linQ library,
the program will list available for using and the name variables or name file also list available for me to call.
Because utilities are describeed by a single GUI, programmers can perform behaviors without switching
between applications.
Evidence of how IDE manage Code:
o Using IDE to implement an algorithm in a program:
To illustrated how code is managed in IDE, I decide to use C# and complie in VISUAL STUDIO 2019
IDE to write a short code program which apply a comparing algorithm in this.

Figure 10: Short source code implement algorithm

Explaination: Firstly, IDE help program to compare whether there are numbers which greater than the
number be assign to variable in this source code. Secondly, assign the first number in the set numbers is the
largest. Compare the current largest number for next number in the set. If this number is larger than current

highest number, then set this number to be the largest number. The program Keep doing step three until there


is no number in the set, we can consider that current largest number is the largest number in the set and print
it to console.
In this screen shot, Visual Studio IDE manages all lines of code in source code, IDE ensure that all
code have not had any mistake in writing code process and if any error happens, IDE will notify and give a
warning for me immediately to ensure code can be implemented properly. From these features, it partly
manage the development of collaboration by utilities available in VSIDE.
3.3.
Using IDE and Without Using IDE To Write Code
3.3.1. Using IDE:

Figure 11: Using IDE to write code

Using IDE to write code is viewed as nice tool for not only new-in-field programmer but also for highqualify programmer, it contributes for programmer some features and useful-tools to develop a software. It
supports to rise their productivity, decreasing time to debug and figure out solution to handle problem.
On details, advantages of IDE:


IDEs save programmer time and effort – the entire intence of the use an IDE is to help coding a
software get faster and easier. IDEs do this by giving programmer helpful resources, shortcuts,
and error recognition (Nyakundi, 2021);














Having high-speed navigation to type and no necessary to concern about header or namespace,
class, project, etc;
Generating code automatically;
Each IDE also has nice Auto-completion, which help you avoid getting fear of forgetting the name
of methods, structures, classes and functions,etc..(Commonly With keyboard: Tab);
Ablity to refactor;
An IDE brings vary capabilities together in one location, and therefore decreases the struggle of
constantly switching among tools (Blokdyk, 2019);
Warning-as-you-type. Every mistakes and wrong syntaxs always are warning when programmer
code;
Hovering over syntax to get the tip or instruction of using library;
Integrated debugging and Integrated source control;
Support in collaboration – IDEs help groups working together and therefore can help boost
production (Codeacademy, 2019);
Keeping a perspective of files, errors, warnings, console, unit tests and source code on the screen
at the same time in a functional advantage way (Blokdyk, 2019).

These are many useful features(advantages) for programmer when using IDE to write code to develop
software. On the contrary, inspite of nice advantages, IDE also bring about some drawbacks to
programmer(particularly coding habit):
Disadvantages of using IDE:






New-in-field programmers or students like me will be in state of dependence to much in IDE when
writing code. Specfically, Forgetting or evade remember how to write fully code syntax or methods
happens much;
Dependence even when debug code. Although the truth is IDEs can't fix errors automatically –
programmer still need knowledge to write clear code;
A few IDES are pretty complex for learn to understand, especially for beginners (Codeacademy,
2019).


3.3.2. Without Using IDE:
Advantages of writing code without IDE:






Getting no more distractions from warning mistakes function of IDE.
Although no longer have Auto-completion of IDE, Writing code without IDE will urge programmers to
learn carefully each piece of syntax (Blokdyk, 2019), methods, structures in programming language
and taught yourself what to write on next line of the code. From there, programmer can fluent writing
code and not longer be necessary to concern about forgetting code when develop software.
Having no debug support, programmer will use logical thinking more when writing code without using
IDE (Blokdyk, 2019). This partly maybe enhance logic ability and ebugging skill.
Writing code in the Text Editor and implement it from command prompt. It will bring a true sense of
programming and execution flow.

Disvantages of writing code without IDE:




Having to spend much times to write code self-debug, analyze code, add style and design.
It just about not for beginners in field.

3.4.
DEBUGGING
3.4.1. DEFINITION
Typically, debug is understood is examining and removing process to do this tasks in errors or abnormalities
that do influent program’s working and its result from a program's source code. To illustrate, a programer may debug
a program to figure out where in the code an error occurs so that it could be handled or bypassed. Debugging checks,
detect and corrects errors or bugs enable the program executes properly and effectively (educba, n.d.).
Most moderm present IDEs supply tools to debug such as Eclipse, Visual Studio, Android Studio, Net Beans
etc. Debugging generally based on the kind of error that programmers are meeting. There are two debugging kinds:


i.

Run-time error: To illustrate this one, in case I just complete my code and am about to try running it.
Suddenly, i am getting stuck in ArgumentOutOfRangeException, meanwhile i am able to add a breakpoint
to this line of syntax and execute it in debug mode, i am able to figure out how it is implemented step by
step and find out the process of how my code execute getting value to variables and handle these. This
is called by Run-time Error. ArgumentOutOfRangeException are detected at run-time when the program
executed.

ii.

Logical-error: In my any code, i can also have other types of logical errors. Logical errors are just only
caught when program execution. One kind of logical error can be seen in this srceenshot code in C# is


DevideByZeroException. The operation of dividing by zero is an inappropriate operation and as a result,
program throws an exception. Program attempted to divide by zero. this math is invalid, the only way to
avoid this error is to not divide by zero. But, we can capture this error and handle it in a different way with
C sharp's exception handling features. These features help you deal with unexpected or exceptional
situations that occur when a program is running. Exception handling uses the try, catch, and finally key
words.


3.4.2. Debugging in IDE:
 Way debugging: In IDE, programmer can add one or more breakpoints to debug. Breakpoints are a
few steps in your code where code execution stop when it reaches that place (particularly line or piece
of code). Meanwhile Programmer can examine application’s data variables, consumption. At this time,
programmer can see what is the state of application and how it should operate. Programmer can also
check what type of the variables and how they are being used. This would help you in fixing the
problem.


Debugging facilities available in IDE used in my application:
To illustrate them, there are some screen shot I debug when I design my application RSS as C#
Programming language in VISUAL STUDIO 2019 IDE:
o Firstly, I add a break point in first line of source code where I want to debug:

Figure 12: Imane debug

o in line number 71, I add a breakpoint via key F9 in there to confirm location where I want to trigger
debug. To start debugging, I press key F5 and the process will be executed, program is about to
implement my source code from the break point.



To go on the next step, I press the F10(this is like Step Over (F10), if the current yellow highlighted
section is a method calls, the debugger will go inside the method ) to jump to the next lines and
implemet them.

Figure 13: DEbugging image 2 STEP OVER

When implement each line of code, IDE also examine that whether there are any wrong variable
appears.


Figure 14: Watch in Autos

Each line code will be implemented in an order and data variables and data value can be seen in the
Autos tab located in the bottom of inteface of VS IDE. I can also use the Watch (Debug/ Windows/
Watch/ Watch (1,2,3,4)) to inspect the variables.
Whenever I hover through each syntax, program tip will be displayed for me to examine. If I want to
jump in other section(Class, method, inteface) I can use key F11(STEP INTO: within the current
method, and the method will be executed and complete, then it will pause at the line where it called.).

When click key F10 to jump step over, each line is also both implemeted debug and implemented
nomarlly, Variables also run and programer also need to interact with these tasks available set in inside
system code as the way normal execution code. And if there are any errors or mistakes appear in my
source code, the Debugging Utilities of VISUAL STUDIO 2019 IDE will give a warning for me
immediately for I can examine this exception and find the solution to handle this.


×