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

Huỳnh trần anh khoa GCS200252 programming ASM 02

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 (1.28 MB, 26 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

HUYNH TRAN ANH KHOA

Student ID

GCS200283

Class

GES0904_NX

Assessor name



THAI THI THANH THAO

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

P2
X

Grading grid
P3
X

P4
X

P5
X

M2

M3

M4

D2

D3


D4

KELBIN


 Summative Feedback:

Grade:
Lecturer Signature:

 Resubmission Feedback:

Assessor Signature:

Date:


Table of Contents
P2. Give explanations of what procedural, object-oriented and event-driven paradigms are; their characteristics and the relationship between them. ................................................... 4
1) Procedural Programming ................................................................................................................................................................................................................................................... 4
a. .......................................................................................................................................................................................................................................................................... Definitions
............................................................................................................................................................................................................................................................................................ 4
b. ................................................................................................................................................................................................................................................................... Characteristics
............................................................................................................................................................................................................................................................................................ 4
2) Object-oriented Programming ........................................................................................................................................................................................................................................... 5
a. .......................................................................................................................................................................................................................................................................... Definitions
............................................................................................................................................................................................................................................................................................ 5
3) Event-driven paradigms ..................................................................................................................................................................................................................................................... 6
a. .......................................................................................................................................................................................................................................................................... Definitions

............................................................................................................................................................................................................................................................................................ 6
b. ................................................................................................................................................................................................................................................................... Characteristics
............................................................................................................................................................................................................................................................................................ 6
4) Relationship........................................................................................................................................................................................................................................................................ 7
P3. Write a program that implements an algorithm using an IDE. ............................................................................................................................................................................................ 7
1) Analysis Problem: ............................................................................................................................................................................................................................................................... 7
3) Designed ............................................................................................................................................................................................................................................................................. 8
4) Code ................................................................................................................................................................................................................................................................................... 8
5) Flowchart.......................................................................................................................................................................................................................................................................... 14
P4. Explain the debugging process and explain the debugging facilities available in the IDE. ............................................................................................................................................... 15
1) What is Debugging? ......................................................................................................................................................................................................................................................... 16
2) Process ............................................................................................................................................................................................................................................................................. 16
3) Facilities available in the IDE ............................................................................................................................................................................................................................................ 16
Code Highlighting: is a possibility of text editors used in programming languages. When an IDE detects a syntax error, it will frequently assist you by highlighting the section of
code where the error was detected. It is important to keep in mind that the IDE may not always highlight the actual error. .................................................................................... 17
Breakpoints: Breakpoints are most popular used to stop a running program immediately before executing an incorrect instruction by specified programmer. Breakpoints usually
add to the code editor by clicking the line number on the left. They usually have a red area on the line number. ...................................................................................................... 17
Debugging facilities: ......................................................................................................................................................................................................................................................... 18
P5 Outline the coding standard you have used in your code. ................................................................................................................................................................................................. 19
Conclusion ................................................................................................................................................................................................................................................................................ 20
The IDE is of great help to programmers, it help you solve a lot of difficult problems in human life. Programmers can rely on the IDE to solve some complex algorithms quickly
because there are many similar relationships between them. If I didn’t have an IDE, I couldn’t finish my task. .................................................................................................................. 20
References ................................................................................................................................................................................................................................................................................ 20


P2. Give explanations of what procedural, object-oriented and event-driven
paradigms are; their characteristics and the relationship between them.
1) Procedural Programming
a. Definitions
Procedural Programming is a programming clay model that uses a linear or top-down approach. It depends on procedures or

syllabus to perform maths. Procedural Programming is also known as instruction programming.
The main purpose of Procedural Programming is the division of programming duties into a set of variables, data structures,
and subroutines. In object-oriented programming, it breaks down a programming task into objects that expose behaviors and
data using interfaces

b. Characteristics
There are 5 popular characteristics of procedural programming:
• A large program is broken down into small manageable procedures or functions. This reduces code repetition,
which improves code capabilities.
• Different functions can share data via global variables. Functions are all free and independent, so if we want to share
data for computers to understand, we need to declare it scoped on.
• Functions can change global data. Since global data are transferred from function to function; during the course of the
transformation, the global data may be altered in function chains.
• Top-down methodology. Procedural programming follows the top-down rule, the workflow must go from the top to
the bottom


Figure 1: Procedural Programming

2) Object-oriented Programming
a. Definitions
Object-oriented Programming ( OOP ) is programming that helps to approach and see our human life as a collection of
objects. They work in tandem to solve a particular problem at hand.

b. Characteristics
There are 4 popular characteristics of Object-oriented Programming:
• Encapsulation – Encapsulation is the most secure collection and collection of data and privacy from external interfaces
• Inheritance- This is the process by which a class can be derived from a base class with all features of the base class and
some of its own. This increases code reusability.
• Polymorphism- This is a feature that can exist in many different forms. For example, a problem can be stacked to add

two integers and two reals.
• Abstraction- This is basic level data feature without any details.


Figure 2: Object-Oriented Programming

3) Event-driven paradigms
a. Definitions
An event-driven paradigm is a type of programming pattern used in important events, programs are identified by events such
as user actions, outputs, or messages passed from various programs. Event-driven programming is the dominant paradigm
used in graphical user interfaces and other applications that are centered on performing certain actions in response to user
input. This is also true of programming for device drivers.

b. Characteristics
There are 8 Characteristics of Event-driven Paradigms:








Service Oriented.
Time Driven.
Event Handlers.
Trigger Functions.
Events.
Simplicity of Programming and Ease of Development.
Compare Event Driven Programming with Object-oriented Programming (OOP)



• References.

Figure 3: Event-driven Paradigms

4) Relationship
In the procedural programming model, many people define a program and its subprograms as a set of steps. In
the event programming model, one executes an event to determine what happens.
Procedural programming uses a very detailed list of instructions to tell the computer what to do step-by-step. In
object-oriented programming, you organize your code by creating objects, and then you can give those objects
properties and you can make them do certain things.

P3. Write a program that implements an algorithm using an IDE.
Example: You own a showroom of Mercedes Benz car. More and more customers come to buy cars, so the management
becomes much more difficult. So you need an application software to help you manage your showroom


1) Analysis Problem:






Proceed to import more new cars
Determine the quantity of all products of cars
Count the number of customers ordering products
Calculate total revenue
Search products


2) Analysis Object








Name of car: string
Versions: string
Category: string
Quantity: int
Price: double
Amount: double
List: save and manage list of books

3) Designed
Manage products

Products
-

Name: string
Versions: string
Category: string
Color: string
Quantity: int
Price: double

Amount: double
Products ()
Products (string, int, double)
Set, get

List: List<Products>

-

Import (): void
View (): void
Search (): void
Synthetic (): void


4) Code







5) Flowchart


P4. Explain the debugging process and explain the debugging facilities
available in the IDE.
1) What is Debugging?
Debugging is a process of checking and uncovering existing, potential bugs in software code that can cause it to behave

unexpectedly or crash. Debugging is the process of removing the above errors to help prevent the incorrect operation of a
software or system. The main purpose of debugging is to find and solve errors or defects in the process of programming or
writing code
Almost all IDEs, such as Eclipse, Visual Studio, Android Studio, Net Beans, and others, include debugging tools. The steps to
debugging are frequently determined by the type of error that you are attempting to debug. I will explain two types of
debugging processes.
They are quite as same as together
• Run-time Error: This is a basic error that you will often encounter in programming. For example, if you are stuck in
DevideByZeroExceptions, you can add a breakpoint or more points to this function and run it in debug mode to see how
your code gets a variable with a value of zero.
• Logic Error: This is more advanced error in programming, it is more difficult than Run-time Error. Logic Errors cause
the program to run correctly but abnormally, for example, crashes or time errors. This error creates other errors that no
one wants or unusual behavior that you may not immediately notice.

2) Process
One of the most popular used tools in the debug cycle is the power supply debugger. Within the IDE, the strong tool is
provided with an intuitive debugging environment that is fully integrated with other workbench tools, giving you the
flexibility you need to best solve problems that arise.
To use, take full advantage of this debug perspective effectively, you must use complied executables for debugging. These
executables contain additional debugging information that allows the debuggers to create direct links between the source code
and binaries generated from that source. In the IDE, you will see dissimilar icons: arrowhead icon for executables that are not
compiled for debugging


3) Facilities available in the IDE
Code Highlighting: is a possibility of text editors used in programming languages. When an IDE detects a syntax error, it
will frequently assist you by highlighting the section of code where the error was detected. It is important to keep in mind that
the IDE may not always highlight the actual error.

Figure 4: Code Highlighting



Breakpoints: Breakpoints are most popular used to stop a running program immediately before executing an incorrect
instruction by specified programmer. Breakpoints usually add to the code editor by clicking the line number on the left. They
usually have a red area on the line number.

Figure 5: Breakpoints in Visual Studio

4) Debugging facilities:
Window

Hotkey

Breakpoints

CTRL+ALT+B

Exception Settings

CTRL+ALT+E

Output

CTRL+ALT+O

Watch

CTRL+ALT+W, (1, 2, 3, 4)

Quick Watch


SHIFT+F9

Autos

CTRL+ALT+V, A

Locals

CTRL+ALT+V, L

Call Stacks

CTRL+ALT+C

Immediate

CTRL+ALT+I


Parallel Stacks

CTR: +SHIFT+D, S

Parallel Watch

CTR: +SHIFT+D, (1, 2, 3, 4)

Threads


CTRL+ALT+H

Modules

CTRL+ALT+U

GPU Threads

-

Tasks

CTR: +SHIFT+D, K

Python Debug Interactive

SHIFT+ALT+I

JavaScript Console

CTRL+ALT+V, C

DOM Explorer

CTRL+ALT+V, D

Live Visual Tree

-


Live Property Explorer

-

Processes

CTRL+ALT+Z

Memory

CTRL+ALT+M, (1, 2, 3, 4)

Disassembly

CTRL+ALT+D

5) Debugging in Visual Studio
In the process of using Visual Studio, you will often encounter application errors in programming.
That means you will run the program with debug feature attached with debug mode. When you do
this, debugging provides many ways to check what your code is doing at runtime.
Here are some debuggers that you often encounter in Visual Studio:
a. Set a breakpoint and start the debugger
- To Debug you need to open your visual studio app with debugging attached to the application process. Press F5 to start
the process Debug, press F5 is the most common and simplest way. However, you don’t currently have any breakpoints
installed to test the Visual Studio application code, so we will do the first thing before we start debugging. Breakpoints
are the most basic and essential part of reliable debugging. A breakpoint indicates where Visual Studio will pause the
program with your error code so it can review variable values or memory operations, or a branch of code that is not
suitable for running.
- Besides pressing F5, you can use the Start Debugging
on the top of Button Start Debugging in the Debug Toolbar,

and run to the first breakpoint when it encounters an errors. You can also select the line and press F9, select Debug >


Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the
left margin.

b. Navigate code in the debugger using step commands
- We provide command data shortcuts because they make navigating your application code faster. If you don’t know the
buttons, you can use the default features above Button.
- To start your application with the debugger attached, press the F11 key. F11 is the Step Into command key and more
efficient execution of the application one statement at a time. When you activate the F11 key with the application, the
debug feature will interrupt the first statement to be executed.

- This yellow arrow will represent the statement that debugger broke, which also pause the execution of the application at
the same time.
- Pressing F11 is the best way to examine the execution in detail. By default the debugger ignores non-user code.


c. Step into a property
- By default Visual Studio, debugging will ignore managed fields, but the Step Into Specific command allows you to
override this behavior.
- Right click on forte and select Step Into Specific then choose one of the predefined options.

d. Run to a point in your code quickly using the mouse
- When debugging, move your mouse over a line of code until the Run to Click button


- Using this button is similar to setting a temporary breakpoint. This command is also useful during debuggin, helping to
move quickly in the visible area of the application code.


P5 Outline the coding standard you have used in your code.
Visual Studio is a modern, goal-oriented programming software, especially easy to use and manipulate. It was created by
Microsoft under the leadership of Anders Hejlsberg and his team as part of the NET initiative and has been approved by the
European computer technology association and international organizations. It includes familiar, modern and easy to use
programming languages, C, C++, Java, Python,…
1. The names of classes and methods should always be in Pascal Case.


2. Camel Case should always be used for method arguments and local variables.

3. Avoid the use of underscore “_” while naming identifiers


4. Avoid the use of System data types and prefer using the Predefined data types.

Conclusion
The IDE is of great help to programmers, it help you solve a lot of difficult problems in human life.
Programmers can rely on the IDE to solve some complex algorithms quickly because there are many
similar relationships between them. If I didn’t have an IDE, I couldn’t finish my task.


References
[1] Object-Oriented Programming, 07/2021, Available at: />[2] Characteristics of Object-Oriented programming language, 07/2021, Available at:
/>[3] Characteristics of procedural programming, 07/2021, Available at:
h/2019/05/programming-paradigms-what-is-procedural-programming/
[4] Debugging, 07/2021, Available at: />[5] Debugging in the IDE, 07/2021, Available at:
/>_Base_.html
[6] Syntax highlighting, 07/2021, Available at: />[7] Breakpoint, 07/2021, Available at: />[8] Procedural Programming, 07/2021, Available at: />[9] Event-Driven Programming Features, 07/2021, Available at: />[10] Visual Studio Debugger, 07/2021, Available at: />


×