Programming Sithum
Programming Sithum
Shifani Moideen
Assessor Internal Verifier
Unit 1: Programming
Unit(s)
Design &Implement a GUI based system using a suitable Integrated
Assignment title Development Environment
Watte Gedara Pavithra Sithum Sameera Deshapriya
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.
Give details:
Programme Leader
signature (if required) Date
1|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID KAN 90945
Unit Title Unit 1 Programming
Assignment Number 1 Assessor
2022.04.13 Date Received 1st
Submission Date submission
Date Received 2nd
Re-submission Date submission
Assessor Feedback:
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.
Pass, Merit & Distinction Descripts P1 M1 D1
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a suita
Integrated Development Environment (IDE).
Pass, Merit & Distinction Descripts P2 M2 D2
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4
* Please note that grade decisions are provisional. They are only confirmed once internal and external moderation has taken place and
grades decisions have been agreed at the assessment board.
Assignment Feedback
2|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Assessor Date
signature
Sithum Deshapriya 2022.04.12
Student Date
signature
3|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
General Guidelines
1. A Cover page or title page – You should always attach a title page to your assignment. Use
previous page as your cover sheet and make sure all the details are accurately filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject, Assignment No, and
Page Number on each page. This is useful if individual sheets become detached for any
reason.
5. Use word processing application spell check and grammar check function to help editing your
assignment.
Important Points:
4|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in the body
except for the before mentioned compulsory information will result in rejection of your work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
5. You must take responsibility for managing your own time effectively.
6. If you are unable to hand in your assignment on time and have valid reasons such as illness,
you may apply (in writing) for an extension.
7. Failure to achieve at least PASS criteria will result in a REFERRAL grade .
8. Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You will
then be asked to complete an alternative assignment.
9. If you use other people’s work or ideas in your assignment, reference them properly using
HARVARD referencing system to avoid plagiarism. You have to provide both in-text citation
and a reference list.
10. If you are proven to be guilty of plagiarism or any academic misconduct, your grade could be
reduced to A REFERRAL or at worst you could be expelled from the course
Student Declaration
I hereby, declare that I know what plagiarism entails, namely to use another’s work and to present
it as my own without attributing the sources in the correct way. I further understand what it means
to copy another’s work.
Unit Tutor 1
Submission Format
3. Presentation
With the submitted system student should do a presentation to demonstrate the system that was
developed. Time allocated is 10 to 15 min. Student may use 5 to 10 PowerPoint slides while doing the
presentation, but live demonstration of the system is required. Evaluator will also check the ability to modify
and debug the system using the IDE.
6|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
LO4. Determine the debugging process and explain the importance of a coding
standard
7|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Assignment Brief and Guidance:
8|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Activity 1
A. The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence
relation.
Fn = F n-1 + F n-2
Define what an algorithm is and outline the characteristics of a good algorithm. Write the
algorithms to display the Fibonacci series and the factorial value for a given number using
Pseudo code. Determine the steps involved in the process of writing and executing a
program.
Take a sample number and dry run the above two algorithms. Show the outputs at the end
of each iteration and the final output. Examine what Big-O notation is and explain its role in
evaluating efficiencies of algorithms. Write the Python program code for the above two
algorithms and critically evaluate their efficiencies using Big-O notation.
Activity 2
2.1 Explain what is meant by a Programming Paradigm and the main characteristics
of Procedural, Object oriented and Event-driven paradigms and the relationships
among them. Write small snippets of code as example for the above three
programming paradigms using a suitable programming language(s). you also need to
critically evaluate the code samples that you have given above in relation to their
structure and the unique characteristics.
9|Page
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Ayubo Drive is the transport arm of Ayubo Leisure (Pvt) Ltd, an emerging travel & tour
company in Sri Lanka. It owns a fleet of vehicles ranging from cars, SUVs to vans.
The vehicles that it owns are hired or rented with or without a driver. The tariffs are based on
the vehicle type. Some of the vehicle types that it operates are, small car, sedan car, SVUs, Jeep
(WD), 7-seater van and Commuter van. New vehicle types are to be added in the future.
1. Rent (With or without driver) – For each type of vehicle rates are given per day, per week
and per month. Rate for a driver also given per day. Depending on the rent period the total
rent amount needs to be calculated. For example: if a vehicle is rented for 10 days with a
driver, total amount to be calculated as follows:
2. Hire (with driver only) – These are based on packages such as airport drop, airport pickup,
100km per day package, 200km per day package etc. Standard rates are defined for a
package type of a vehicle typeif that is applicable for that type of vehicle.For each package
maximum km limit and maximum number of hours arealso defined. Extra km rate is also
defined which is applicable if they run beyond the allocated km limit for the tour. For day
tours if they exceed max hour limit,a waiting charge is applicable for extra hours. Driver
overnight rate and vehicle night park rate also defined which is applicable for each night
when the vehicle is hired for 2 or more days
Activity 3
Function 1: Rent calculation.
Return the total rent_value when vehicle_no, rented_date, return_date, with_driver
parameters are sent in. with_driver parameter is set to true or false depending whether the
vehicle is rented with or without driver.
10 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Write suable algorithms for vehicle tariff calculation for rents and hires. Ideally 3
functions should be developed for this purpose as above. Use the visual studio IDE
(using C#.net) to Implement the above algorithms and design the suitable database
structure for keeping the tariffs for vehicle types and different packages which must be
used for implementing the above functions.
Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual
StudioIDE for your application development contrasted with not using an IDE.
Activity 4
4.1 Design and build a small system to calculate vehicle hire amounts and record them in a
database for customer billing and management reporting forAyubo drive. This includes the
completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions. It essentially requires an
interface for hire calculation and recording function described above. Generating customer
reports and customer invoices are not required for this course work.
4.2 Explain debugging process and the features available in Visual studio IDE for debugging
your code more easily. Evaluate how you used the debugging process to develop more
secure, robust application with examples.
4.3 Outline the coding standards you have used in your application development. Critically
evaluate why a coding standard is necessary for the team as well as for the individual.
11 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
12 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
• ACKNOWLEDGEMENT
I've put in more time and effort on this project. It would not, however, have been possible
without the generous support and assistance of many individuals and organizations. I'd like to
express my heartfelt gratitude to each one of them.
I'd like to thank everyone who has helped me the most throughout this project. I am grateful to
my teachers for their unwavering support for the project. Their assistance and insightful
comments, as well as their willingness to share their expertise with me.
A special thanks goes to my colleagues who assisted me in completing the project, where they
all exchanged their own interesting ideas and thoughts, making it possible for me to complete
my project with all accurate information.
I'd like to thank the members of BTEC batch 72 for their kind cooperation and encouragement,
which helped me finish this project. I'd like to express my heartfelt gratitude and appreciation
to those in the industry who have given me their undivided attention and time.
Finally, my heartfelt gratitude goes to my family members who provided moral support for me
to successfully complete the project. This assignment would not be possible without their
constant encouragement.
W.G.P.S.S Deshapriya
[email protected]
[email protected]
[email protected]
Contents
Task 1: ...................................................................................................................................... 18
13 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.1 Describe What an Algorithm ......................................................................................... 18
1.1.1 Definition of Algorithms ......................................................................................... 18
1.1.2 Flowchart ................................................................................................................ 19
1.1.3 Pseudo-Code ........................................................................................................... 20
1.1.4 Characters of Algorithm.......................................................................................... 21
1.2.1 Programming Process ........................................................................................... 22
1.2.3 Fibonacci ................................................................................................................. 24
1.2.4 Factorial .................................................................................................................. 25
1.2.5 Fibonacci Pseudo code and Dry run ....................................................................... 26
1.2.6 Factorial Pseudo code and Dry run ......................................................................... 27
1.3 Big O Notation ............................................................................................................... 29
1.4 What is Big-O NOTATION? ......................................................................................... 31
1.4.1 Using Big-O notation to explain the Fibonacci sequence. ................................. 31
1.4.2 Big O Notation in Factorial .................................................................................... 33
Task 2 ....................................................................................................................................... 37
2.1 Programming Paradigm ................................................................................................ 37
2.1.1 Procedural programming......................................................................................... 38
2.1.2 Object-Orientated .................................................................................................... 38
2.1.3 Event-Driven ........................................................................................................... 39
2.2 Procedural, Object-Oriented, and Even-Driven Paradigms are Compared ................... 41
2.3 Small snippets of code as example for the above three programming paradigms. ........ 43
2.3.1 Procedural programming......................................... Error! Bookmark not defined.
2.3.2 Object oriented programming ................................. Error! Bookmark not defined.
2.3.3 Event-Driven Programming .................................... Error! Bookmark not defined.
2.4 Evaluate my Programmed .............................................................................................. 46
Task 3: Implement Basic Algorithms in Code Using an IDE (LO3) ....................................... 52
3.1 Pseudocode for Rent Calculation ................................................................................... 52
3.1.1 Algorithm of Rent Car (Rent_Calculation) ............................................................. 52
3.1.2 Pseudocode for Day Tour-Hire Calculation............................................................ 53
3.1.3 Pseudocode for Long Tour-Hire Calculation .......................................................... 54
3.1.4 SQL Database in Ayubo Drive ............................................................................... 55
3.1.5 Tables ...................................................................................................................... 55
3.1.6 Table Designs .......................................................................................................... 56
3.2 Implement the Above Algorithms Using Visual Studio IDE ........................................ 57
3.2.1 Rent Calculation ...................................................................................................... 57
3.2.2 Day Tour Calculation .............................................................................................. 58
3.2.3 Long Tour Calculation ............................................................................................ 60
3.3 Analyze the features of an Integrated Development Environment (IDE) and explain
how those features help in application development. .......................................................... 61
14 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.3.1 Integrated Development Environment .................................................................... 61
3.3.2 Benefits Of IDE ...................................................................................................... 63
3.3.2 What Is the Use of an IDE in Application Development? ...................................... 67
3.4. Visual Studio IDE for application development to not using an IDE. .......................... 70
3.4.1 Visual Studio IDE ................................................................................................... 70
3.3.2 Evaluate the Use of The Visual Studio IDE ........................................................... 72
Task 4 Determine the Debugging Process and Explain the Importance of a Coding Standard
(LO4)........................................................................................................................................ 78
4.1 Design and build a small system to calculate vehicle hire amounts and record them in a
database for customer billing and management reporting for Ayubo drive. This includes
the completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions .............................................. 78
4.2 What is debugging an application? Explain the features available in Visual studio IDE
for debugging your code more easily................................................................................... 84
4.2.1 Debugging ............................................................................................................... 84
4.2.2 Evaluate How You Used the Debugging Process to Develop More Secure, Robust
Application with Examples .............................................................................................. 88
4.2.2.1 Debugger Security................................................................................................ 88
4.2.2.2 The Debugging Processes .................................................................................... 90
4.2.2.3 Common Debugging Tools .................................................................................. 90
4.2.2.5 Example of A Robust Application ....................................................................... 93
4.3 Outline the coding standards you have used in your application development ............. 96
4.3.1 Definition of Coding Stranded ................................................................................ 96
References ........................................................................ Error! Bookmark not defined.
Table Of content
15 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure Content
Figure 1 Flowchart ................................................................................................................... 19
Figure 2 Pseudocode ................................................................................................................ 20
Figure 3 Fibonacci ................................................................................................................... 24
Figure 4 Fibonacci output ........................................................................................................ 25
Figure 5 Factorial ..................................................................................................................... 25
Figure 6 Factorial output .......................................................................................................... 26
Figure 7 Fibonacci Big O notation........................................................................................ 31
Figure 8 Big o notation Factorial ............................................................................................. 35
Figure 9 Small snippets ............................................................................................................ 43
Figure 10 Output ...................................................................................................................... 44
Figure 11 Four functions .......................................................................................................... 44
Figure 12 import turtle ............................................................................................................. 45
Figure 13 key press handlers .................................................................................................... 45
Figure 14 OOP Python code .................................................................................................... 47
Figure 15 output oop ................................................................................................................ 47
Figure 16 class ......................................................................................................................... 47
Figure 17 identify the attribute................................................................................................. 48
Figure 18 access the class ........................................................................................................ 48
Figure 19 access the attribute ................................................................................................... 48
Figure 20 Procedural code ....................................................................................................... 49
Figure 21 output ....................................................................................................................... 50
Figure 22get a list ..................................................................................................................... 50
Figure 23 Function Approaching ............................................................................................. 50
Figure 24 Printing command.................................................................................................... 51
Figure 25 Database................................................................................................................... 55
Figure 26 Tables....................................................................................................................... 55
Figure 27 vehicle table ............................................................................................................. 56
Figure 28 Package Table .......................................................................................................... 56
Figure 29 Login Table.............................................................................................................. 57
Figure 30 Rent Calculation ...................................................................................................... 57
Figure 31 coding rent calculation............................................................................................. 58
Figure 32 Day Tour .................................................................................................................. 58
Figure 33 Day Tour .................................................................................................................. 59
Figure 34 Long Tour ................................................................................................................ 60
Figure 35 Long Tour part 1 ...................................................................................................... 60
Figure 36 Long Tour part 2 ...................................................................................................... 61
16 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 37 Visual Studio IDE ...................................................................................................... 70
Figure 38 IDE Editor................................................................................................................ 72
Figure 39 Solution Explorer ..................................................................................................... 73
Figure 40 Team Explorer ......................................................................................................... 73
Figure 41 Tool Bar ................................................................................................................... 74
Figure 42 Bookmark ................................................................................................................ 75
Figure 43 Server Explorer ........................................................................................................ 76
Figure 44 Testing code ............................................................................................................. 76
Figure 45 Debug....................................................................................................................... 77
Figure 46 Vehicle ..................................................................................................................... 78
Figure 47 Vehicle Table ........................................................................................................... 78
Figure 48 Search Button .......................................................................................................... 79
Figure 49 Save Button.............................................................................................................. 79
Figure 50 Update Button .......................................................................................................... 80
Figure 51 Delete Button ........................................................................................................... 80
Figure 52 Clear Button ............................................................................................................. 80
Figure 53 Package .................................................................................................................... 81
Figure 54 Table ........................................................................................................................ 81
Figure 55 Search Button .......................................................................................................... 81
Figure 56 Save Button.............................................................................................................. 82
Figure 57 Delete Button ........................................................................................................... 82
Figure 58 Clear Button ............................................................................................................. 82
Figure 59 Login form ............................................................................................................... 83
Figure 60 Login button and exit button ................................................................................... 84
Figure 61 debugging monitoring.............................................................................................. 89
Figure 62 bug ........................................................................................................................... 95
Figure 63 string ........................................................................................................................ 98
Figure 64 string2 ...................................................................................................................... 98
Figure 65 local variables .......................................................................................................... 99
Figure 66 try and catch............................................................................................................. 99
Figure 67 && ........................................................................................................................ 100
17 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Task 1:
Searching on an array/list means looking for a specific element in the array and returning
whether it was found or not, as well as its position if it was found. Linear search and binary
search are two popular array searching algorithms.
18 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.1.2 Flowchart
A flow chart is a type of traffic diagram that represents a process by using various symbols to
represent steps or a sequence of events. Each of these symbols is linked by arrows to show the
flow directions of the process. The structured program mainly consists of three types of
elements
• Sequence
It's extremely boring. Simply follow one instruction, then the next, and so on. Just do them in
the order they are listed or in the sequence, they are listed in. This is true for most lines of code.
• Selection
This is the point at which you select or choose between two or more flows. The option is
determined by posing a question. The path (or which lines of code) will be executed based on
the answer.
• Iteration
It also allows some code (one to many lines) to be executed (or repeated) several times. The
code may not be executed at all (repeat it zero times), it may be executed a fixed number of
times, or it may be executed indefinitely until a condition is met. Also known as looping
because the flowchart depicts the flow looping back on itself.
Figure 1 Flowchart
19 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.1.3 Pseudo-Code
Figure 2 Pseudocode
20 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.1.4 Characters of Algorithm
1) Input specified.
The input is the data that will be modified to produce the output during the computation. There
should be 0 or more well-defined inputs in an algorithm. Input precision needs knowing what
type of data, how much of it there should be, and in what format it should be.
2) Output specified.
The output is the data obtained because of the computation. One or more outputs should match
the output signal in a well-defined technique. Precision in output also demands knowing what
type of data output should be, how much of it should be output, and in what format it should
be output
3) Definiteness.
Algorithms must specify each step in the process, as well as the sequence in which the steps
must be completed. Definiteness refers to the order in which operations are performed to
convert input into output. The algorithm should be simple and straightforward. Each step's
specifics must also be specified. It should contain only quantitative information, not qualitative
information.
4) Effectiveness.
All the steps required to get to the output must be achievable with the given resources for an
algorithm to be effective. It should not include any extra or redundant steps that could render
the algorithm useless.
5) Finiteness.
The algorithm will finally come to a halt. Stopping could mean you get the intended result or
a response stating that no solution is possible. Algorithms must come to a halt after a certain
number of steps. An algorithm should never be endless and should always end after a set
number of steps.
6) Independent.
21 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Step-by-step instructions should be included in an algorithm, and they should be independent
of any programming code. It should be written in such a way that it may be used with any
programming language.
(Definition., n.d.)
1.2.1 Programming Process
Developing a program involves steps like any problem-solving task. There are six main
ingredients in the programming process:
1) Defining the problem
2) Designing the solution
3) Coding the program
4) Testing the program
5) Deployment of the Product
6) Maintenance and Operations
23 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
• Maintenance and Operations
After each of the preceding steps has been successfully completed and the software item has
been fully released into the market, the item must be kept running, and support is required. This
involves resolving faults and remaining current with the most recent functioning structure fixes
or updates of third-party software. If the product's customer base continues to grow,
development such as additional processing power, memory, and database limit should be
implemented to maintain the software functioning smoothly.
(Definition, n.d.)
1.2.3 Fibonacci
In this program, I'll learn how to print the Fibonacci sequence using a while loop.
You should be aware of the following to comprehend this example. Python programming topics
Figure 3 Fibonacci
24 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Output
1.2.4 Factorial
A number's factorial is the product of all integers from 1 to that number. The factorial of 6 is,
for example, 1*2*3*4*5 = 120. Factorial does not have a definition for negative numbers, and
the factorial of zero is one, 0!
(GeeksforGeeks., n.d.)
I used For loop to calculate Factorial.
Figure 5 Factorial
25 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Output
26 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Dry Run of Fibonacci Code
5 0 1 0
0 1 1 0 0 0+1 1
1 1 2 0 1 0+1 1
1 2 3 1 1 1+1 2
2 3 4 1 2 1+2 3
27 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Dry Run of Factorial Code
Table 2 factorial dry run
5 1
4 5 5 5,4,3,2,1 5=1*5
3 20 4 4,3,2,1 20=5*4
2 60 3 3,2,1 60=20*3
120 1 1 120=120*1
120
28 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.3 Big O Notation
Big O notation is a convenient way to express how quickly a function grows. It is rarely useful,
or even possible, to compute an exact result when studying an algorithm's time complexity
T(n). Typically, we are only concerned with how quickly T(n) grows as a function of the input
size n.
• a measure of complexity o ()
• concrete
• concrete
• unambiguous
There should be a limited number of them.
Best, worst, and average case :
Best performance: the item we are looking for is in the first position; examines one position
Worst performance: item not in the array or in the last position; examines all positions Average
performance (given that the item is in the array): examines half of the array
29 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Improved algorithm
Which is more practical?
The worst-case scenario for real-time programming
To get a general idea of running time: average case; however, this is frequently difficult to
establish • To choose between several available algorithms: helps to know what the best case
is (maybe your data are in the best-case format, for example random).
Independence of Machines
The efficiency evaluation should be as machine independent as possible. For an algorithm's
time complexity, we count the number of basic operations performed by the algorithm and
calculate how this number varies with the size of the input.
Space complexity: the amount of extra space required in relation to the space used to represent
the input.
Basic operations
The term "basic operations" refers to operations that take a fixed amount of time (at most time
C for some constant C). In other words, the time required to perform the operation does not
scale with the size of the operands and is not limited by a constant.
Basic operations continuation
If we don't know how operations are implemented, we must use our best judgment: can
something be implemented as a constant time operation in principle?
For example, adding two 32-bit integers is possible, but adding a list of 32-bit integers is not:
a longer list will take longer.
(GeeksforGeeks., n.d.)
(definition, n.d.)
30 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.4 What is Big-O NOTATION?
Big O notation is a convenient way to express how quickly a function grows. When studying
an algorithm's time complexity T (n), it is rarely useful, if not impossible, to compute an exact
result. Typically, we are only concerned with how quickly T (n) grows as a function of the
input size n.
Python Code:
31 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Model the time function for calculating Fib(n) as the sum of the time required to calculate
Fib(n-1) plus the time required to add the two (O(1)). This assumes that subsequent
evaluations of the same Fib (n) take the same amount of time, implying that no memorizing
occurs.
T (n<=1) = O (1)
The solution will be obtained by solving this recurrence relation (for example, using
generating functions). Draw the recursion tree with depth n and intuitively determine that this
function is asymptotically O. (2n). Induction can be used to prove the hypothesis.
Base: n = 1 is obvious
An interesting fact about this function is that the value of T (n) is asymptotically the same as
the value of Fib (n) because they are both defined as
The recursion tree's leaves will always return one. Fib (n) is the sum of all values returned by
the recursive tree's leaves that are equal to the number of leaves. T (n) equals Fib (n) x O
because each leaf will take O (1) to the computer (1). As a result, the Fibonacci sequence (
(1.6n)) is the tight bound for this function. You can discover this tight bond by employing the
generating functions I mentioned earlier.
(codistwa, n.d.)
32 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
1.4.2 Big O Notation in Factorial
Finally, factorial complexity is the increase in execution time as a function of the factorial of
the input parameter. The factorial complexity is the slowest. In mathematics, the factorial
corresponds to a recursive multiplication. The execution time is proportional to the factorial
of the input parameter, which quickly equates to very large numbers. For example, the result
(720) of 6! = 6 * 5 * 4 * 3 * 2 corresponds to the total number of executions.
720 is a large number; one can imagine how long it will take. So, if we multiply 12 by the
double, we get hundreds of millions (479 001 600 to be exact). This is enormous! As a result,
it is prudent to use a function with lower complexity.
To demonstrate this complexity, we write a factorial function and use it in the for loop
(condition part).
This is the problem of the traveling salesman. The character chooses three paths because, first
and foremost, we know that we can depart from any city, so we subtract it from the calculation
(4 - 1 = 3). Then he discusses possible paths, implying that it is about probability, which is
calculated using the factorial (3! -> 3 x 2). Finally, he computes the average because we can
travel through the cities in both directions, so it is the same, knowing it is the same length.
(codistwa, n.d.)
33 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Python Code :
def factorial(num):
if num == 1:
return 1
return num * factorial(num - 1)
def exponential(num):
for x in range(factorial(num)+1):
print(x)
print(exponential(6)) # 720
# ============== #
x = np.linspace(-6,6, 100)
g = factorial(x)
plt.plot(x, g, label='$O(n!)$')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.grid()
plt.title('factorial',fontsize=12)
plt.savefig('factorial.png', bbox_inches='tight')
plt.show()
34 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 8 Big o notation Factorial
Formula
O(n!)
35 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
It is determined by how they are computed. Because the value of n! quickly grows out of hand,
it may be possible to calculate it ahead of time for all values of n for which n! can be expressed
in the type of use. If you use this method, the value of n! is O. (1).
It's O (n) if you calculate them on the fly by multiplying n by n-1, n-2, and so on, and using a
built-in type, because calculating n! necessitates O (n) multiplications.
When using a large implementation, where there is no limit to how large your numbers can get,
a single multiplication is no longer O. (1). Instead, it approaches O (n log n) because n!
According to Sterling's formula, for high n, goes to (n/e) n, and thus has approximately n log n
bits. n is being calculated! In that case, the letter O (n2 log n).
Your performance will suffer significantly if you use a particularly inefficient method of
calculation, such as performing multiplication as repeated addition and adding by incrementing
your output by 1 repeatedly.
36 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Task 2
37 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
2.1.1 Procedural programming
The most serious criticism leveled at procedural programming is that it is one of the oldest
methods of programming. As a result, it is regarded as outdated and generally uncool. But those
are minor gripes. More specific complaints that I believe are appropriate:
It is frequently difficult to think clearly about the overarching program. Naming procedures
with functions can help to simplify the machine-like nature of procedural code, but the ways
humans and computers think aren't all that similar, so code that hews too closely to what
machines like frequently confuses humans.
Abstractions do not exist. Simple things are abstracted from more complex underlying realities
by good programs. They place a premium on human comprehension over machine efficiency.
There are times when this is not possible due to performance constraints, and in those cases,
procedural code can be faster and thus better.
2.1.2 Object-Orientated
38 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Characteristics of an object-oriented program
• Abstraction is the ability to represent data at a high level of abstraction, without relying
on specifics.
• Inheritance- This is the process by which a class can be derived from a base class,
retaining all the base class's features as well as some of its own. This improves the
reusability of code.
2.1.3 Event-Driven
It responds to specific types of user input, such as a click on a command button, a selection
from a drop-down list, an entry into a text box, or other types of user events.
Other programming languages may include user events that are primarily delivered via a
command-line interface or another type of user interface. The inverse of event-driven
programming is programming that is written to act regardless of user input.
Display apps, for example, that provide weather updates or sports scores, may contain less
event-driven programming than other types of programs. However, nearly all software relies
on user events for functionality, and it's easy to argue that event-driven programming should
be the default for almost all types of projects. This is because, in general, applications and code
modules are written to respond to human actions, which is part of the core concept of how
humans interact with machines. Identifying event-driven aspects of programs, on the other
hand, can be useful in design analysis.
39 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Characteristics of event-driven programming
• Data structures are created in such a way that they characterize objects.
• When new data and functions are required, they can be easily added.
Service oriented
Service oriented is a key feature in event-driven programming that is used to write programs
for services, and it does not slow down the computer because service oriented only consumes
a small portion of the computer processing power and usually services run in the background
of the OS.
Time Driven
Time driven is a paradigm in event driven programming; 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 a time-driven application in which the user can specify when to update or when to
check for and download updates.
Because it is very visual, event-driven programming is simpler and easier to program than
other types of programming. For example, you can place a button by simply selecting it,
placing it on a form, and writing a code for it. Because it allows the user to pause the code
40 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
while it is running, event-driven programming makes it simple to insert pre-written code
scripts into an existing application. As a result, developing with event-driven programming
is simple.
(WPShout, n.d.)
41 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
What are the relationships between programming procedural, object-oriented and
even-driven paradigms?
Table 3 relationship in pp, oop,evp
Thus, these three categories are not strictly hierarchically related, but in common usage, they
are mostly nested within one another.
(WPShout, n.d.)
42 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
2.3 Small snippets of code as example for the above three programming paradigms.
• Event Driven
43 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Output
Figure 10 Output
44 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 12 import turtle
45 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
2.4 Evaluate my Event Driven Program me.
• Line 2nd I design the window size and line 3rd get a reference to the window. Line 4th
5th and 6th I design the windows title, set background color, and create our favorite
turtle.
• I need the call to the window’s ‘listen’ method at line 31, otherwise it won’t notice
my keypresses.
• I named my handler functions ‘h1, h2’ and so on, but we can choose better names.
The handlers can be arbitrarily complex functions that call other functions, etc.
• Pressing the ‘q’ key on the keyboard call’s function ‘h4’ (because we bound the ‘q’
key to ‘h4’ on line 26). While executing ‘h4’, the window’s bye method (line 24)
closes the turtle window, which causes the window’s main loop call (line 31) to end
its execution. Since we did not write any more statements after line 32, this means that
our program has completed everything, so it too will terminate.
• Pressing the ‘w ‘on the keyboard call’s ‘h5’ that for loop then execute and Turtle
rotate itself.
• We can refer to keys on the keyboard by their character code (as we did in line 26), or
by their symbolic names. Some of the symbolic names to try are Cancel (the Break
key), BackSpace, Tab, Return(the Enter key), Shift_L (any Shift key), Control_L (any
Control key), Alt_L (any Alt key), Pause, Caps_Lock, Escape, Prior (Page Up), Next
(Page Down), End, Home, Left, Up, Right, Down, Print, Insert, Delete, F1, F2, F3,
F4, F5, F6, F7, F8, F9, F10, F11, F12, Num_Lock, and Scroll_Lock.
46 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
• Object Orient Program me
Figure 16 class
47 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 17 identify the attribute
48 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
2.4 Evaluate the Object Orient My programmed
• In the program, I defined a class called Rajapaksha. After that, I define attributes. An
object's attributes are its distinguishing features.
• When I use attributes called species. species = int to ‘Airoplane’
• These attributes are defined in the class's __init__ method. As soon as the object is
created, the initializer method is called.
• The Rajapaksha class is then instantiated. In this case, ’ kaputa’ and ‘basil’ serve as
references (value) to our new objects.
• __class .species gives us access to the class attribute. All instances of a class have the
same class attributes. Similarly, kaputa.name and kaputa.age are used to access the
instance attributes. Instance attributes, on the other hand, differ for each instance of a
class.
• procedural program me
49 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Code Output
Figure 21 output
50 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 24 Printing command
51 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Task 3: Implement Basic Algorithms in Code Using an IDE (LO3)
52 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.1.2 Pseudocode for Day Tour-Hire Calculation
53 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.1.3 Pseudocode for Long Tour-Hire Calculation
Calculate Km
TOThrs = endKm – startKm
If TOThrs > maxHrs
extraKM = TOTkm – maxKm
extraKmCost = extraKm * extraKmRate
else
extraKmCost = 0
end if
else
Display (‘Invalid details’)
End if
End function
54 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.1.4 SQL Database in Ayubo Drive
Figure 25 Database
3.1.5 Tables
Figure 26 Tables
55 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.1.6 Table Designs
• Vehicle Table
• Package Table
56 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
• Login Table
57 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 31 coding rent calculation
58 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Day Tour coding
Console Application
59 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.2.3 Long Tour Calculation
3.3 Analyze the features of an Integrated Development Environment (IDE) and explain
how those features help in application development.
62 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.3.2 Benefits Of IDE
Improved developer productivity is the overall goal and primary benefit of an integrated
development environment. IDEs increase productivity by reducing setup time, speeding up
development tasks, keeping developers up to date, and standardizing the development
process.
Setup time is reduced: Without an IDE interface, developers would have to spend time
configuring multiple development tools. With an IDE application integration, developers
have the same set of capabilities in one place, eliminating the need to switch tools frequently.
Faster development tasks: Improved developer productivity is achieved through tighter
integration of all development tasks. Code, for example, can be parsed and syntax checked
while being edited, providing immediate feedback when syntax errors occur. To complete
tasks, developers do not need to switch between applications. Furthermore, the IDE's tools
and features assist developers in organizing resources, avoiding mistakes, and taking
shortcuts. Furthermore, IDEs help to speed up development by encouraging holistic thinking.
They force developers to consider their actions in the context of the entire development
lifecycle, rather than as a series of discrete tasks.
Another advantage is the ability to stay current and educated. For example, the IDE's help
topics are constantly updated, as are new samples, project templates, and so on. Programmers
who are constantly learning and staying up to date on best practices are more likely to add
value to the team and the enterprise, as well as boost productivity.
Examine the following SAP Web IDE features to fully comprehend how they can benefit your
application development.
63 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Using wizards, templates, and WYSIWYG editors, create SAPUI5 applications that adhere
to SAP Fiori UX guidelines.
Use a collection of dynamic interactive features, such as code completion and API reference
support, to speed up coding and testing. You can instantly preview your applications for any
screen size, including desktop, tablet, and smartphone.
Mock data can be used to build and preview your entire application's user interface without
connecting to any system.
Using Business Server Pages, deploy on SAP HANA Cloud Platform (HCP) and SAP ABAP
(BSP).
Using the extensible framework of SAP Web IDE, you can easily extend SAP delivered
applications with plugins and templates.
In your SAP Web IDE project, use source control to manage your code and improve your
workflow.
Some ide and their features
(IDE, n.d.)
Microsoft Visual Studio is a premium IDE with prices ranging from $699 to $2,900 depending
on edition and licensing. This IDE's various editions can produce a wide range of programs,
from web applications to mobile apps to video games. This software suite includes a plethora
of tools for compatibility testing, allowing you to see how your apps perform on over 300
different devices and browsers. Visual Studio is an excellent tool for both students and
professionals due to its versatility.
ASP.NET, DHTML, JavaScript, JScript, Visual Basic, Visual C#, Visual C++, Visual F#,
XAML, and other languages are supported.
64 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Notable features include:
• IntelliSense
• Error list for debugging while developing Approval checks when deploying apps via
Click Once, Windows Installer, or Publish Wizard
Drawbacks: Because Visual Studio is a large IDE, it requires a lot of resources to open and
run, so making simple changes may take a long time on some devices. It may be easier to use
a lightweight editor for simpler tasks.
(IDE, n.d.)
2. PyCharm
PyCharm was created by Jet Brains and offers a free Community Edition, a 30-day free trial
of the Professional Edition, and an annual subscription ranging from $213 to $690. PyCharm
is the best IDE for Python programmers of all skill levels because it provides comprehensive
code assistance and analysis. PyCharm also supports other languages and runs on multiple
platforms, allowing it to be used by almost anyone.
65 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
AngularJS, Coffee Script, CSS, Python, HTML, JavaScript, Node.js, Python, TypeScript, and
template languages are supported.
3. NetBeans
C, C++, C++11, Fortan, HTML 5, Java, PHP, and other languages are supported.
Editor
Typically, at least one programming language editor with syntax highlighting, with support
for more, especially in the case of web development.
67 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Profiling
A good IDE should also enable you to profile the performance of your application. Another
feature that will help with debugging and testing.
More
An IDE should also be a test environment, not just for debugging but also for tests, primarily
component and unit tests. Allowing for the verification of functionality with specified test
calls and results, as well as the testing of components using mockups and stubs to simplify
dependencies.
One disadvantage of IDEs I've discovered (or at least popular ones like Visual Studio.NET
and Eclipse, which are both excellent by the way) is the extra garbage they generate. I mean
all the extra files and folders when I say garbage. A simple hello world c++ program written
in Visual Studio.NET, for example, would be a few megabytes, with the.cpp file being 1kb.
I use a command window and the history (2 commands—cc, /filename) at school, as well as
a GUI text editor. We have eclipse installed on our Unix terminals at school, but due to the
high load on the servers, it frequently freezes, so it's best to compile with a simple editor and
command window. If you find that using command line-based tools works well and efficiently
for you, I don't see why you should use an IDE.
68 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
"IDE" is such a broad term. You're using an IDE if you use some of Vim's external-integration
features, such as the: make command and:cn and:cl to step through compiler errors. As a
result, I consider the distinction between a sufficiently advanced editor (Vim, Emacs, edit,
but not Notepad or the like) and an IDE to be completely irrelevant and a matter of personal
preference.
However, I consider the software that most people consider IDEs (Eclipse, JBuilder, and
Visual Studio) to be bloatware. They consume resources, generate useless extraneous files
and features, and complicate the already difficult task of programming. You'd be better off
understanding your code, how it's interconnected, and how to build it manually rather than
relying on a magical tool. Of course, in my opinion. My numerous professors who have
insisted on JBuilder and Eclipse for everything would undoubtedly disagree.
So, my advice is to use the integrating features of your favorite editor, whether it's Vim,
Emacs, or whatever, to interact with the standard CLI tools you'll need, such as make, gdb,
or ant. That way, you'll understand what's going on "under the hood" with your project, have
full access to the underlying tools, and still be able to work quickly from within a single
environment. Of course, I prefer Emacs, but Vim works just as well right out of the box; you
just need to learn how to use the editor's features.
An IDE's purpose is to connect various programming tools with GUI widgets to make it easier
for some people to use those tools.
If you're comfortable with command line tools (editor, debugger, code structure browser), an
IDE won't be of any use to you.
Start with an editor (I recommend GNU Emacs), then learn the command line tools as you
need them, and finally, if you want, try an IDE.
Using an IDE on day one may not be the best choice in the long run.
69 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.4. Visual Studio IDE for application development to not using an IDE.
Simply put, Visual Studio is a coding tool. As others have mentioned, it allows you to write
code in any language, including non-Microsoft languages.
Of course, you can also use notepad, notepad++, or sublime text to write code (my favorite
one). Text editors are what these are. Text editors are lightweight and fast, but they provide
little assistance when writing code. (However, sublime text does support some extensions that
can help a little bit.) Visual Studio Code is a relatively new lightweight, open-source editor
that is multi-platform (runs on Windows, Mac, and Linux), extensible, and offers a lot of help
(intelligence, debugging, basic refactoring, etc.) but does not do as much for you as full Visual
Studio. It's like a powerful text editor.
Full Visual Studio is at the other end of the spectrum. This type of editor is known as an
Integrated Development Environment (IDE). Even though they share the same name, Visual
Studio and Visual Studio Code are COMPLETELY DIFFERENT PRODUCTS. It is only
70 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
available for Windows and comes in a variety of SKUs. One of the SKUs (Community
Edition...CE) is free but still very powerful. The others are not free (in fact, they are quite
expensive), but they provide you with increasingly powerful features.
ALL SKUs (including CE) support the use of Xamarin, a powerful tool for creating cross-
platform mobile applications with code-sharing, even when targeting iOS and Android.
Microsoft also recently released a new IDE, Visual Studio for Mac, but I know very little
about it aside from the fact that it is an excellent choice for cross-platform Xamarin
development. (Using Xamarin to compile iOS apps necessitates the use of a Mac.) You can
also continue to develop for Android on your Mac).
IDEs provide a plethora of features to aid in software development, but they are NOT
lightweight. The IDE loads slowly, and opening projects is also slow. However, once loaded,
you get a slew of features to help you with your development (Intelligence, Code Completion,
Refactoring, Snippets, Project Templates, Solution Templates, Database integration, builds,
deployments, and extensibility to make it even more powerful with third-party plug-ins
known as extensions).
(IDE, n.d.)
71 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3.3.2 Evaluate the Use of The Visual Studio IDE
IDE Basics
The image below depicts the Visual Studio IDE with an open project, as well as the Solution
Explorer window for navigating project files and the Team Explorer window for navigating
source control and work item tracking. The highlighted features in the title bar are explained
in greater detail below.
Solution Explorer
I use Solution Explorer to view, navigate, and manage your code files. Solution Explorer can
help you organize your code by categorizing it into solutions and projects. The editor window,
where you'll probably spend most of your time, displays your code and allows you to edit
source code and design a user interface. Visual Studio's notifications, such as debugging and
error messages, compiler warnings, publishing status messages, and more, are sent to the
Output window. Each message source is represented by its own tab.
72 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 39 Solution Explorer
Team Explorer
Using version control technologies such as Git and Team Foundation Version Control, Team
Explorer (VSTS) allows you to track work items and share code with others (TFVC).
A designer is a simple tool that allows you to create a user interface without having to write
code. Drag UI controls from the Toolbox window, such as list boxes, calendars, and buttons,
onto a design surface that represents the window or dialog box. Without writing any code,
you can resize and rearrange the elements. Designers are included in any project that includes
73 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
a user interface. Blend for Visual Studio, a sophisticated graphics tool that works seamlessly
with Visual Studio, is the default designer if your project has a XAML-based user interface.
If you're a developer, you'll probably spend most of your time in the editor window. Visual
Studio includes editors for C#, C++, Visual Basic, JavaScript, XML, HTML, CSS, and F#,
and many other languages are supported by third-party plug-in editors (and compilers).
Individual files can be edited in the text editor by selecting File | Open | File. Click on the file
name in Solution Explorer to edit files in an open project. The code is colorized, and you can
change the color scheme in Quick Launch by typing "Colors." You can have multiple text
editor tabbed windows open at the same time. Each window can be split independently. The
text editor can also be used in full-screen mode.
Figure 32 Tool Bar
Bookmarks
74 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Bookmarks enable you to navigate quickly to specific lines in files that you are actively
working on.
Figure 42 Bookmark
Like SQL Server Management Studio, the SQL Server Object Explorer in Visual Studio
provides a view of your database objects. SQL Server Object Explorer enables you to perform
light-duty database administration and design tasks such as editing table data, comparing
schemas, and executing queries directly from the SQL Server Object Explorer by using
contextual menus. SSDT also includes project types and tools for creating SQL Server 2012
Analysis Services, Reporting Services, and Integration Services Business Intelligence (BI)
solutions (formerly known as Business Intelligence Development Studio).
75 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 43 Server Explorer
Visual Studio includes both a managed code (.NET) and a native C++ unit test framework.
Simply add a Test Project to your solution, write your tests, and then run them from the Test
Explorer window to create unit tests. See Unit Test Your Code for more information.
76 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Debugging your program
The cutting-edge debugger in Visual Studio allows you to debug code running in your local
project, on a remote device, or on an emulator such as those for Android or Windows Phone.
You can step through code one statement at a time, inspecting variables as you go, step
through multi-threaded applications, and set breakpoints that are only hit when a specified
condition is true. All of this can be configured within the code editor, eliminating the need to
leave the context of your code.
Figure 45 Debug
Multiple windows in the debugger allow you to view and manipulate local variables, the call
stack, and other aspects of the runtime environment. These windows can be found in the
Debug menu. The Immediate Window allows you to type an expression and immediately see
the result. The IntelliTrace window records each method call and other event in a
running.NET program and can assist you in quickly locating the source of a problem. See
Debugging in Visual Studio for more information.
77 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Task 4 Determine the Debugging Process and Explain the Importance of a Coding
Standard (LO4).
4.1 Design and build a small system to calculate vehicle hire amounts and record them
in a database for customer billing and management reporting for Ayubo drive. This
includes the completing the database design started in 3.2 and implementing one or
more GUIs for vehicle, vehicle type, and package add/edit/delete functions
Figure 46 Vehicle
• Vehicle Table
78 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Cording Vehicle Form
79 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 50 Update Button
80 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
2. Package Output
Figure 53 Package
• Package Table
Figure 54 Table
81 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 56 Save Button
82 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
3. Login Form
83 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 60 Login button and exit button
4.2 What is debugging an application? Explain the features available in Visual studio
IDE for debugging your code more easily.
4.2.1 Debugging
Software programs that are being developed are subjected to extensive testing, updating,
troubleshooting, and maintenance. Normally, software contains errors and bugs that are
removed on a regular basis. To identify and correct problems, complete software programs
are compiled and executed on a regular basis during the debugging process. Large software
programs with millions of source code lines are broken down into smaller components. To
maximize efficiency, each component is debugged separately first, then the program.
84 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Debuggers can assist me in performing ad hoc inspection or modification of variables, code,
or any other aspect of the runtime environment, whereas manual debugging necessitates
stopping, editing, and re-executing the application (possibly requiring recompilation).
Debuggers can attach to a running process or use a crash dump, whereas manual debugging
requires "steps to reproduce" a defect.
Debuggers can easily and readable display complex data structures, multi-threaded
environments, or full runtime stacks.
Debuggers provide numerous ways to reduce the time and repetitive work required to
complete almost any debugging task.
Both visual debuggers and console debuggers are useful and share many features.
A visual debugger integrated into an IDE also provides easy access to smart editing and all
the IDE's other features in a single integrated development environment (hence the name).
One of the most important aspects of Visual Studio Code is its excellent debugging support.
The built-in debugger in VS Code speeds up the edit, compile, and debug loop.
In addition to debugging, VS Code allows you to run the program. Ctrl+F5 invokes the
Debug: Start Without Debugging action, which uses the currently selected launch
configuration. In 'Run' mode, many of the launch configuration attributes are supported.
While the program is running, VS Code maintains a debug session, and pressing the Stop
button terminates it.
Tip: Although the Run action is always available, not all debugger extensions support it. 'Run'
will be the same as 'Debug' in this case.
Toggle breakpoints by clicking on the editor margin. In the Debug view's BREAKPOINTS
section, you can fine-tune breakpoint control (enable/disable/reapply).
85 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Breakpoints in the editor margin are typically represented by red filled circles.
When a debugging session begins, breakpoints that cannot be registered with the debugger
turn gray. The same thing could happen if the source is edited while a debug session is running
without live-edit support.
The command Reapply All Breakpoints returns all breakpoints to their original location. This
is useful if your debug environment is "lazy" and "misplaces" breakpoints in unexecuted
source code.
Log points
A log point is a type of breakpoint that instead of "breaking" into the debugger, logs a message
to the console. Log points are particularly useful for injecting logging while debugging
production servers that cannot be shut down.
A "diamond" shaped icon represents a Log point. Log messages are plain text with the option
of including expressions to be evaluated within curly braces (").
Debuggers can attach to a running process or use a crash dump, whereas manual debugging
requires "steps to reproduce" a defect.
Debuggers can easily and clearly display complex data structures, multi-threaded
environments, or full runtime stacks.
Debuggers provide numerous options for reducing the time and repetitive work required to
complete almost any debugging task.
86 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Visual debuggers and console debuggers are both useful and share many features.
A visual debugger integrated into an IDE also provides easy access to smart editing and all
other IDE features in a single integrated development environment (hence the name).
The Visual Studio debugger allows you to observe and troubleshoot your program's run-time
behavior. The debugger is compatible with all Visual Studio programming languages and
libraries. You can use the debugger to examine your code, examine and edit variables, view
registers, see the instructions generated from your source code, and view the memory space
used by your application.
See Debug, Profile, and Diagnose for an overview of debugging and diagnostics in Visual
Studio.
What's New in Visual Studio 2015's Debugger? Describes new features in Visual Studio 2015.
Debugger Fundamentals The fundamentals of using the Visual Studio debugger are covered.
Debugging fundamentals, execution control, attaching to a running program, Just-In-Time
debugging, automatically launching the debugger, dumps, breakpoints, inspecting your
program, handling exceptions, Edit and Continue, and using expressions in the debugger are
all covered.
(SearchSoftwareQuality., n.d.)
(Security, n.d.)
4.2.2 Evaluate How You Used the Debugging Process to Develop More Secure, Robust
Application with Examples
The ability to debug another process grants you extremely broad powers that you would not
have otherwise, particularly when debugging remotely. A malicious debugger could cause
extensive damage to the machine being debugged. Many developers, however, are unaware
that the security threat can also flow in the opposite direction. Malicious code in the debugged
process has the potential to jeopardize the security of the debugging machine: there are several
security exploits that must be avoided.
The code you're debugging and the debugger have an implicit trust relationship. You should
be willing to run something if you are willing to debug it. The bottom line is that you must
have confidence in what you are debugging. If you can't trust it, you shouldn't debug it, or
you should debug it on a machine you can afford to risk and in an isolated environment.
Debugging should be disabled on production machines to reduce the potential attack surface.
Debugging should never be enabled indefinitely for the same reason.
88 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
In general, local debugging is safer than remote debugging. The total surface area that can be
probed increases with remote debugging.
In remote debugging, the Visual Studio Remote Debugging Monitor (msvsmon.exe) is used,
and there are several security recommendations for configuring it. Because No Authentication
mode is insecure, Windows Authentication is the preferred way to configure the
authentication mode.
(Security, n.d.)
When using Windows Authentication mode, keep in mind that granting an untrusted user
permission to connect to msvsmon is risky because the user gains access to all your
computer's resources.
Debug an unknown process on a remote machine: there are potential exploits that could affect
the machine running the debugger or compromise the Visual Studio Remote Debugging
89 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Monitor, msvsmon.exe. If you must debug an unknown process, try doing so locally and using
a firewall to keep any potential threats contained.
Debugging in software development entails locating and correcting code errors in a computer
program. Debugging is an essential part of the testing process and the entire software
development lifecycle. Debugging begins as soon as code is written and continues in stages
as code is combined with other programming units to form a software product. Debugging a
large program with thousands of lines of code can be simplified by employing strategies such
as unit tests, code reviews, and pair programming.
Once an error has been identified, the error must be in the code. At this point, reviewing the
code's logging and employing a standalone debugger tool or the debugging component of an
integrated development environment can be beneficial (IDE). Invariably, the bugs in the most
frequently used functions are discovered and fixed first. In some cases, the module causing
the issue is obvious, but the line of code itself is not. Unit tests, such as JUnit and unit, which
allow the programmer to run a specific function with specific inputs, can be useful in
debugging in this case.
The standard procedure is to create a "breakpoint" and run the program until that breakpoint
is reached, at which point program execution terminates. An IDE's debugging component
typically allows the programmer to view memory and variables, run the program to the next
breakpoint, execute only the next line of code, and, in some cases, change the value of
variables or even the contents of the line of code about to be executed.
Debugging can also benefit from source code analyzers such as security, common code errors,
and complexity analyzers. A complexity analyzer can identify modules that are so complex
that they are difficult to understand and test. Some tools can analyze a test run to see which
90 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
lines of code were not executed, which can help with debugging. Other debugging tools
include advanced logging and simulators, which allow the programmer to simulate how an
app will appear and behave on a mobile device.
Some tools, particularly open-source tools and scripting languages do not run in an IDE and
must be debugged manually. Dropping values into a log, extensive "print" statements added
during code execution, or hard-coded "wait" commands that simulate a breakpoint by waiting
for keyboard input at specific times are examples of such techniques.
The term "bug" was coined as a synonym for "error" in engineering. Admiral Grace Hopper,
a pioneer in computer programming who was also known for her dry sense of humour, is
credited with the term's application to computing and the inspiration for using the word
debugging as a synonym for troubleshooting. Admiral Hopper and her team "debugged" the
computer and saved the moth after an actual bug (a moth) got caught between electrical relays
and caused a problem in the United States Navy's first computer. It is now housed in the
Smithsonian Institution.
When it comes to computer software, the term robust refers to an operating system or other
program that performs well not only under normal conditions, but also under unusual
conditions that put its designers' assumptions to the test.
Software is typically buggy (i.e., contains errors) and fragile, making it ineffective. This is
due, in large part, to the fact that programs are typically too large and complex for a single
human mind to comprehend in their entirety, making it difficult for programmers to discover
and eliminate all errors, or even to be certain of the extent of errors that exist. This is
especially true for subtle errors that only manifest themselves in unusual circumstances. The
robustness of Unix-like operating systems is a key feature. That is, they can run for long
91 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
periods of time (sometimes years) without crashing (i.e., stopping working) or requiring a
reboot (i.e., restarting). Individual application programs may crash from time to time, but they
almost always do so without affecting other programs or the operating system itself.
Robustness is something that should be built into software from the start; it is not something
that can be successfully added later. The lack of robustness planning in advance is a major
contributor to the numerous security and stability issues that plague some non-Unix-like
operating systems.
Another important strategy for developing robust software is to write general code that can
handle a wide range of situations, avoiding the need to add extra code to handle special cases.
This is because code added solely to accommodate special cases is frequently buggier than
other code, and stability issues can become especially frequent and/or severe because of
interactions between several such sections of code.
In terms of robustness, Linux, and other open-source software, i.e., software for which the
source code is freely available, have a significant advantage over closed source software, i.e.,
software for which the source code is secret (as is the case for most commercial, or
proprietary, software). It is that the source code can be reviewed at their leisure by many
highly diverse programmers via the Internet, making it easier to find and correct errors than
when the code is only reviewed by in-house programmers, who are frequently under deadline
pressure and may not have strong incentives to find and eliminate all bugs.
92 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Applying the Unix Philosophy's Rule of Composition (i.e., designing programs so that they
can be linked to other programs) also contributes to the creation of robust software. This is
because it results in smaller, modular programs that are easier to understand and correct than
larger ones that try to do a lot of things. It is also because input from other programs (as
opposed to human input) can be particularly effective for stress-testing software and thus for
assisting in the provision of tolerance for unusual and large inputs.
Several other deliberate design concepts contribute to the robustness of Unix-like operating
systems. One approach, which is increasingly being adopted by other operating systems, is to
provide each application program with its own area of memory, preventing it from interfering
with memory areas reserved for other applications or the kernel (i.e., the core of the operating
system).
Another is the permissions system, which is required for access to all objects (i.e., files and
directories) on the system. When properly administered, this system can make it difficult for
sloppy or malicious (e.g., viruses, worms, and trojans) code to affect critical parts of the
system. Robust programming, also known as bomb-proof programming, is a programming
style that prevents unexpected or abnormal termination. Essentially, it necessitates code that
can handle bad (invalid or absurd) inputs in a reasonable manner. If an internal error occurs,
the program or library gracefully terminates and provides enough information for the
programmer to debug the program or routine.
Because the queue structure will be inaccessible to the caller, we must define two items: the
structure itself and an interface to it. We start with the interface. The object used by the caller
to represent a queue is referred to as a token. Furthermore, we must avoid a "dangling
reference" problem (in which a program references queue A after that queue is deleted).
Assume a programmer employs the library to create queue A. Queue A is then deleted, and
queue B is created; queue B happens to occupy the same slot in the queue array as queue A
did. A subsequent token reference to queue A will result in a reference to queue B. To avoid
93 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
this problem, we associate a unique integer (called a nonce) with each queue and merge it
into the token. In the preceding example, queue A could have nonce 124 and queue B could
have nonce 3086. Queue A's token is f (7, 124), and Queue B's token is f (7, 3085). Queue
A's token is f (7, 124), and Queue B's token is f (7, 3085). The reference to queue A will be
detected and rejected if these values differ.
where << and | are the usual C operators. We emphasize, however, that any function invertible
in either argument is acceptable. In the above,
and
This greatly simplifies the interface, but at the expense of assuming a 32-bit value (or greater).
Fortunately, most systems support integers of this length as a datatype. So, we put the
following in the header file:
/* queue identifier; combines internal index and nonce */ typedef long int qticket;
Calling routines do not need to know anything about the internal structures if this token is
defined.
The second issue is how to deal with errors. We can print error messages (and potentially act,
such as terminating), return error results and allow the caller to handle the error, or set up
94 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
special error handlers (if the language supports these; they are typically written as trap or
exception handlers). Unfortunately, C does not support error exception handlers. Returning
error codes to the caller provides much more flexibility than handling the error in the routine
and is equally simple to implement. The complication is that a set of error codes must be used
to indicate the possible errors. So, as we go through our library, we'll keep track of errors and
define error codes.
(SearchSoftwareQuality., n.d.)
Examples:
Figure 62 bug
/* * error return values * all the queue manipulation functions return these; * you can interpret
them yourself, or print the error * message in qe_errbuf, which describes these codes
*/#define QE_NONE 0 /* no errors *//* * the error buffer; contains a message describing the
last queue * error (but is NUL if no error encountered); not cleared on success */extern char
qe_errbuf [256];
95 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
4.3 Outline the coding standards you have used in your application development
Coding standards, also known as programming styles or coding conventions, are a valuable
resource for programmers. Unfortunately, they are frequently overlooked by junior as well as
some program developers because many of the recommended coding standards have no effect
on the compilation of the code itself, a concept that we will discuss later. This report will
attempt to demonstrate the significance of coding standards and why they have already
become a common practice for both businesses and programming language developers.
I'll start by explaining what coding standards are. In general, they are a set of standards and
guidelines that are/should be followed when writing program source code. A standard is a set
of rules that a developer is expected to follow. However, these rules, such as "the compiled
file must have the extension’s," are frequently followed regardless. Guidelines, on the other
hand, are much less well followed. They are stylistic measures that have no direct impact on
the compilation of the guide and exist solely to make the source code more readable to
humans. They are optional, but strongly advised. One thing to keep in mind about coding
standards that many programmers seem to overlook is that they are not an abstract concept.
In fact, for many businesses and almost all programming languages, a coding standard is a
physical document that is essential for producing consistent code.
Coding standards vary in importance depending on the company and programming language.
Commenting code (an area of coding standards that will be explained later) would be
significantly less important for a COBOL programmer than it would be in other languages,
because COBOL can be made self-documenting. It may also be unimportant for a company
that will not be continuously producing software, and it may be more time consuming than
96 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
simply building the software without it. However, the importance of coding standards in
open-source software cannot be overstated.
Mozilla Firefox, the open-source internet browser that makes all its code freely available
online, is the most prominent example of this. This is done so that other developers can
examine the source code and potentially identify security flaws/bugs in the code as well as
extend it. If the program did not adhere to a specific style convention, it would be extremely
difficult for other developers to identify potential flaws. Furthermore, Firefox has a massive
database of extensions, some of which it created but many of which were created by third-
party developers. External extensions would be very difficult to understand and integrate into
Firefox if they did not adhere to a coding standard, and Firefox would not be as popular as it
is today.
Coding standards, when properly implemented, can provide significant benefits to both the
produced code and the companies implementing them. They can make a significant difference
when it comes to software maintenance. Maintenance is arguably the most important and
recurring step in the Software Development Life Cycle (SDLC). When the developers in
charge of maintaining the code are not the same as the ones who created it, it is up to them to
understand code written by another developer. This task would be extremely different in the
absence of a coding standard because most programmers have their own programming style,
which is often difficult to follow by anyone other than the original developer. Having a coding
standard, on the other hand, means that all software programmers will be able to easily read
and understand all the code for a program, if it conforms to the coding standard and the
developer who is maintaining the code is familiar with it, allowing it to be easily maintained
and modified if necessary.
There are two types of coding standards: those written for a company and those written for a
programming language. The company coding standard is what developers are expected to
follow within the company, whereas the programming language coding standard is what the
programming language developers recommend all programmers follow. Both frequently
97 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
contain many similar points, and for companies that only program in one language, they are
frequently nearly identical. Companies that develop software in multiple languages, on the
other hand, frequently develop their own coding standard. Mozilla Firefox, for example, is
written in C++, XUL, XBL, and JavaScript. Instead of inefficiently employing each
language's four separate coding standards, Mozilla has developed its own coding standards.
(Standards, n.d.)
Use string interpolation to concatenate short strings, as shown in the following code. To
append strings in loops, especially when you are working with large amounts of text, use a
String Builder object.
Figure 63 string
Figure 64 string2
Use implicit typing for local variables when the type of the variable is obvious from the right
side of the assignment, or when the precise type is not important. The following example uses
implicit typing in a fog statement
98 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Figure 65 local variables
Simplify your code by using the C# using statement. If you have a try-finally statement in
which the only code in the final block is a call to the Dispose method, use a using statement
instead.
99 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
&& and // Operators
To avoid exceptions and increase performance by skipping unnecessary comparisons, use &&
instead of &and | instead of | when you perform comparisons, as shown in the following
example.
Figure 67 &&
References
Algorithms, S., n.d. Sorting Algorithms. [Online]
Available at: https://betterexplained.com/articles/sorting-algorithms
[Accessed 8 2 2022].
Algorithms, S., n.d. Sorting Algorithms. [Online]
Available at: https://betterexplained.com/articles/sorting-algorithms
[Accessed 7 2 2022].
Blog, P., n.d. Top 48 Integrated Developer Environments (IDEs) & Code Editors. [Online]
Available at: https://blog.profitbricks.com/top-integrated-developer-environments-ides/
[Accessed 26 2 2022].
codistwa, n.d. codistwa. [Online]
Available at: https://codistwa.com/guides/big-o-notation-and-complexity-time#$$o(n!)$$-:-
factorial-complexity
[Accessed 15 3 2022].
codistwa, n.d. codistwa Febonacci. [Online]
Available at: Available at: https://codistwa.com/guides/big-o-notation-and-complexity-
time#$$o(n!)$$-:-time in febonscci-complexity
[Accessed 15 3 2022].
Definition., A., n.d. Algorithm Definition.. [Online]
Available at: Algorithm Definition. 2022. Algorithm Definition. [ONLINE] Available at:
https://techterms.com/definition/algorithm. [Accessed 10 February 2022].
[Accessed 7 2 2022].
100 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Definition, A., n.d. Algorithm Definition. [Online]
Available at: https://techterms.com/definition/algorithm
[Accessed 7 2 2022].
definition, B. O. n., n.d. Big O notation: definition and examples. [Online]
Available at: https://yourbasic.org/algorithms/big-o-notation-explained
[Accessed 17 2 2022].
GeeksforGeeks., n.d. GeeksforGeeks. Factorial. [Online]
Available at: https://www.geeksforgeeks.org
[Accessed 11 2 2022].
GeeksforGeeks., n.d. GeeksforGeeks. Fibonnacci. [Online]
Available at: https://www.geeksforgeeks.org
[Accessed 10 2 2022].
IDE, V. S., n.d. Visual Studio IDE. [Online]
Available at: https://msdn.microsoft.com/en-us/library/dn762121.aspx.
[Accessed 3 3 2022].
Process., T. P., n.d. The Programming Process.. [Online]
Available at: http://www.cs.bham.ac.uk/~rxb/java/intro/2programming.html
[Accessed 15 2 2022].
SearchSoftwareQuality., n.d. What is debugging? - Definition. [Online]
Available at: https://searchsoftwarequality.techtarget.com/definition/debugging.
[Accessed 11 3 2022].
SearchSoftwareQuality, n.d. What is integrated development environment (IDE)? -
Definition. [Online]
Available at: SearchSoftwareQuality. 2018.
Whahttps://searchsoftwarequality.techtarget.com/definition/integrated-development-
environment
[Accessed 22 2 2022].
Security, D., n.d. Debugger Security. [Online]
Available at: https://msdn.microsoft.com/en-us/library/ms242231.aspx
[Accessed 18 3 2022].
Standards, B. o. C., n.d. Benefits of Coding Standards. [Online]
Available at: https://www.valid-computing.com/benefits-of-coding-standards.html
[Accessed 5 4 2022].
WPShout, n.d. Three Development Paradigms: Procedural, Object-Oriented, and
Functional. [Online]
Available at: https://wpshout.com
[Accessed 20 2 2022].
yourbasic.org, n.d. Big O notation: definition. [Online]
Available at: https://yourbasic.org/algorithms
[Accessed 18 2 2022].
101 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Appendix
Weeks 1st 2nd 3rd 4th 1st 2nd 3rd 4th 1st 2nd 3rd 4th
Task 1
Task 2
Task 3
Task 4
102 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
103 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
Grading Rubric
104 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
LO2 Explain the characteristics of procedural,
objectorientated and event-driven programming,
conduct an analysis of a suitable Integrated
Development Environment (IDE)
105 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
P3Write a program that implements an algorithm using an
IDE.
106 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
M4Evaluate how the debugging process can be used to
help develop more secure, robust applications.
107 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming
108 | P a g e
KAN90945 W.G.P.S.S. Deshapriya Unit 01 Programming