Uploaded by nidhardesigns

1150-1619622396900-unit-01-programming-assignment-reworded-2021 compress

advertisement
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Programme title
HND in Computing
Assessor
Unit(s)
Internal Verifier
Unit 01 : Programming
Assignment title
Student’s name
List which assessment criteria
the Assessor has awarded.
Pass
Merit
Distinction
INTERNAL VERIFIER CHECKLIST
Do the assessment criteria awarded match
those shown in the assignment brief?
Y/N
Is the Pass/Merit/Distinction grade awarded
justified by the assessor’s comments on the
student work?
Y/N
Has the work been assessed
accurately?
Y/N
Is the feedback to the student:
Give details:
• Constructive?
• Linked to relevant assessment criteria?
• Identifying opportunities for
improved performance?
• Agreeing actions?
Y/N
Y/N
Y/N
Y/N
Does the assessment decision need
amending?
Y/N
Assessor signature
Date
Internal Verifier signature
Date
Programme Leader signature (if required)
Date
P.G.Sumesh Maduranga Malpana
Programming Assignment No : 01
1|Page
0
0
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
2|Page
0
0
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
Unit 01 : Programming
Unit Title
Assignment Number
Assessor
Submission Date
Date Received 1st
submission
Re-submission Date
Date Received 2nd
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 analysi
Integrated Development Environment (IDE).
Pass, Merit & Distinction Descripts
P2
M2
D2
M3
D3
LO3. Implement basic algorithms in code using an IDE.
Pass, Merit & Distinction Descripts
P3
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts
Grade:
P4
P5
M4
Assessor Signature:
Date:
Assessor Signature:
Date:
D4
Resubmission Feedback:
Grade:
Internal Verifier’s Comments:
Signature & Date:
* 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.
3|Page
0
0
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Feedback: Student to Assessor
Assessor
signature
Date
Student
signature
Date
4|Page
0
0
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
5|Page
0
0
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.
Word Processing Rules
The font size should be 12 point, and should be in the style of Time New Roman.
Use 1.5 line spacing. Left justify all paragraphs.
Ensure that all the headings are consistent in terms of the font size and font style.
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.
1.
2.
3.
4.
Important Points:
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
6|Page
0
0
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.
1. I know that plagiarism is a punishable offence because it constitutes theft.
2. I understand the plagiarism and copying policy of the Edexcel UK.
3. I know what the consequences will be if I plagiaries or copy another’s work in any of the
assignments for this program.
4. I declare therefore that all work presented by me for every aspects of my program, will
be my own, and where I have made use of another’s work, I will attribute the source in
the correct way.
5. I acknowledge that the attachment of this document signed or not, constitutes a binding
agreement between myself and Edexcel UK.
6. I understand that my assignment will not be considered as submitted if this document is
not attached to the attached.
Date:
(Provide Submission Date)
Student’s Signature:
(Provide E-mail ID)
7|Page
0
0
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
Unit Number and Title
Unit 01: Programming
Academic Year
2020/21
2019/20
Unit Tutor
Assignment Title
Design &Implement a GUI based system using a suitable
Integrated Development Environment
Issue Date
Submission Date
IV Name & Date
Submission Format
This submission will have 3 components
1. Written Report
This submission is in the form of an individual written report. This should be written in a concise, formal
business style using single spacing and font size 12. You are required to make use of headings, paragraphs
and subsections as appropriate, and all work must be supported with research and referenced using the
Harvard referencing system. Please also provide a bibliography using the Harvard referencing system. (The
recommended word count is 2,00–25,00 words for the report excluding annexures)
2. Implemented System (Software)
The student should submit a GUI based system developed using an IDE. The system should connect with a
backend database and should have at least 5 different forms and suitable functionality including insert, edit
and delete of main entities and transaction processing.
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.
Unit Learning Outcomes:
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
8|Page
0
0
LO2. Explain the characteristics of procedural, object-orientated and event-driven
programming, conduct an analysis of a suitable Integrated Development
Environment (IDE).
LO3. Implement basic algorithms in code using an IDE.
LO4. Determine the debugging process and explain the importance of a coding
standard
9|Page
0
0
Assignment Brief and Guidance:
Activity 1
Searching on an array/list is to find a given element on the array, return whether it is
found or not and return its position if found. Linear search and binary search are two
popular searching algorithms on arrays.
1.1 Define what an algorithm is and outline the characteristics of a good algorithm.
Develop algorithms for linear search and binary search using Pseudo code.
1.2 Convert the algorithms developed in 1.1 to executable programmes using Python and
implement a dry run to evident above the execution of two codes. Show the outputs
at the end of each iteration and the final output. Critically evaluate the efficiencies in
implemented codes using Big-O notation .
Activity 2
2.1 Define what is meant by a Programming Paradigm. Explain the main characteristics of
Procedural, Object oriented and Event-driven paradigms and the relationships among
them.
2.2 Write small snippets of code as example for the above three programming paradigms
using a suitable programming language(s) and critically evaluate the code samples that
you have above in relation to their structure and the unique characteristics
Activity 3 and Activity 4 are based on the following Scenario.
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.
Vehicle rent and hire options are described below.
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:
10 | P a g e
0
0
Total rent = weeklyRent x 1 + dailyRent x 3 + dailyDriverCost x 10
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
3.1 Design suitable algorithms for vehicle tariff calculation for rents and hires.
Ideally 3 functions should be developed for this purpose as follows:
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.
Function 2: Day tour - hire calculation.
Calculate total hire_value when vehicle_no, package_type, start_time, end_time,
start_km_reading, end_km_reading parameters are sent in. Should return
base_hire_charge, waiting_charge and extra_km_charge as output parameters.
Function 3: Long tour - hire calculation.
Calculate total hire_value when vehicle_no, package_type, start_date, end_date,
start_km_reading, end_km_reading parameters are sent in. Should return
base_hire_charge, overnight_stay_charge and extra_km_charge as output parameters.
3.2 Implement the above algorithms using visual studio IDE (using C#.net) 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.
3.3 Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual Studio
IDE for your application development contrasted with not using an IDE.
Activity 4
11 | P a g e
0
0
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. 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 What is debugging an application? Explain 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 Explain 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.
12 | P a g e
0
0
Acknowledgement
In preparation of my assignment, I had to take the help and guidance of some respected
persons, who deserve my deepest gratitude. As the completion of this assignment gave
me much pleasure, I would like to show my gratitude Module lecturer, on ESOFT Metro
Campus for giving me a good guidelines for assignment throughout numerous
consultations. I would also like to expand my gratitude to all those who have directly and
indirectly guided me in writing this assignment.
Thank You.
13 | P a g e
0
0
Contents
Acknowledgement ............................................................................................................. 13
List of Tables ..................................................................................................................... 15
List of Figures .................................................................................................................... 15
Activity 01.......................................................................................................................... 17
What is Algorithm .............................................................................................................. 17
Characteristics of an Algorithm ......................................................................................... 17
The Programming Process ................................................................................................. 18
Linear Search ..................................................................................................................... 19
Pseudocode for Linear Search........................................................................................ 20
Dry run for Linear Search .............................................................................................. 20
Python code for Linear Search (Data Found) ................................................................ 21
Binary Search ..................................................................................................................... 21
Pseudocode for Binary Search ....................................................................................... 21
Dry run for Binary Search .............................................................................................. 22
Python code for Binary Search ...................................................................................... 23
Algorithm Efficiency and Big3O Notation ........................................................................ 24
Big-O Notation ............................................................................................................... 24
Efficiency of an algorithm ............................................................................................. 24
Method for determining Efficiency................................................................................ 25
Space-Time tradeoff ....................................................................................................... 25
Asymptotic Notations .................................................................................................... 26
Best, Worst, and Average case Efficiency ..................................................................... 26
Provide Above Algorithms Critically Evaluate Their Efficiencies Using Big-O Notation
............................................................................................................................................ 27
Linear Search ................................................................................................................. 28
Binary Search ................................................................................................................. 28
Activity 02.......................................................................................................................... 29
Programming Paradigm ..................................................................................................... 29
Procedural Programming Paradigm ................................................................................... 30
Characteristics of Procedural Programming .................................................................. 30
Object-Oriented Programming (OOP) ............................................................................... 30
Characteristics of object-oriented programming............................................................ 31
Event Driven Programming ............................................................................................... 32
Characteristics of Event-Driven Programming .............................................................. 32
The relationship between procedural, object-oriented and event-driven paradigm ........... 33
Procedural Code Example .............................................................................................. 34
Object-Oriented Code Example ..................................................................................... 35
Event Driven Code Example.......................................................................................... 36
Activity 03.......................................................................................................................... 39
Ayubo Leisure Welcome Form ...................................................................................... 39
Vehicle Type Registration Form.................................................................................... 39
Vehicle Registration Form ............................................................................................. 40
Package Registration Form ............................................................................................ 40
Rent Calculation Form ................................................................................................... 41
Day Tour Calculation Form ........................................................................................... 41
14 | P a g e
0
0
Long Tour Calculation Form ......................................................................................... 42
Ayubo Database in SQL .................................................................................................... 42
Vehicle Database............................................................................................................ 44
Vehicle Type Database .................................................................................................. 44
Packagers Database ........................................................................................................ 45
Implementation of the Ayubo System ............................................................................... 46
Implementation and Output case 1................................................................................. 46
Implementation and Output case 2................................................................................. 47
Implementation and Output case 3................................................................................ 48
Implementation and Output case 4................................................................................. 49
Implementation and Output case 5................................................................................. 50
Integrated Development Environment (IDE) ..................................................................... 51
Benefits Of Visual Studio IDE....................................................................................... 51
Visual programming .......................................................................................................... 53
How this futures helpful for Ayubo Drive creation. .......................................................... 53
Activity 04.......................................................................................................................... 54
Ayubo Data Added Forms in IDE...................................................................................... 54
What is Debugging an Application .................................................................................... 60
Visual Studio Debugging Features .................................................................................... 61
Example for debugging the Ayubo drive program ........................................................ 63
Evaluate the debugging process be used to help develop more secure, robust
applications. ................................................................................................................... 66
Coding Standards ............................................................................................................... 66
Why coding standard is necessary for the team. ............................................................ 67
Why coding standard is necessary for individual. ......................................................... 68
Conclusion .........................................................................................................................70
Gantt chart .......................................................................................................................... 71
References .......................................................................................................................... 72
List of Tables
Table 1:Dry run for Linear Search (Data Found) .............................................................. 20
Table 2:Dry run for Linear Search (Data not found) ......................................................... 21
Table 3:Dry run for Binary Search (Data found) ............................................................... 23
Table 4:Dry run for Binary Search (Data not found) ......................................................... 23
Table 5:Gantt Chart ............................................................................................................ 71
List of Figures
Figure 1:Procedural Code Example ................................................................................... 35
Figure 2:Object Oriented code ........................................................................................... 36
Figure 3:Event Driven Code Example ............................................................................... 38
Figure 4:Welcome Form .................................................................................................... 39
15 | P a g e
0
0
Figure 5:Vehicle Type Registration Form ......................................................................... 39
Figure 6:Vehicle Registration Form .................................................................................. 40
Figure 7:Package Registration Form.................................................................................. 40
Figure 8:Rent Calculation Form ........................................................................................41
Figure 9:Day Tour Calculation Form................................................................................. 41
Figure 10:Long Tour Calculation Form ............................................................................. 42
Figure 11:Ayubo Database in SQL .................................................................................... 43
Figure 12:User Design in sql ............................................................................................. 43
Figure 13:Vehicle Table in sql ........................................................................................... 44
Figure 14:Vehicle Design in sql......................................................................................... 44
Figure 15:Vehicle Type Table in sql.................................................................................. 44
Figure 16:Vehicle Type Design in sql ............................................................................... 45
Figure 17:Packagers Table in sql ....................................................................................... 45
Figure 18:Packagers Design in sql ..................................................................................... 45
Figure 19: Implementation and Output case 1 ................................................................... 46
Figure 20:Implementation and Output case 1 .................................................................... 46
Figure 21:Implementation and Output case 2 .................................................................... 47
Figure 22:Implementation and Output case 3 .................................................................... 48
Figure 23:Implementation and Output case 4 .................................................................... 49
Figure 24:Implementation and Output case 5 .................................................................... 50
Figure 25:Login Form ........................................................................................................ 54
Figure 26:Vehicle Type Registration Form ....................................................................... 55
Figure 27:Vehicle Registration Form ................................................................................ 55
Figure 28:Package Registration Form................................................................................ 56
Figure 29:Rent Calculation Form ......................................................................................57
Figure 30:Day Tour Calculation Form............................................................................... 58
Figure 31:Long Tour Calculation Form ............................................................................. 59
Figure 32:Ayubo IDE Case 01 ........................................................................................... 61
Figure 33:Ayubo IDE Case 02 ........................................................................................... 63
Figure 34: Error Movement ............................................................................................... 63
Figure 35:Correct Movement ............................................................................................. 64
Figure 36:Error Movement ................................................................................................ 64
Figure 37:Correct Movement ............................................................................................. 65
Figure 38:Error Movement ................................................................................................ 65
Figure 39:Correct Movement ............................................................................................. 66
Figure 40:Use of proper data type...................................................................................... 68
Figure 41:Use of proper variable ....................................................................................... 68
Figure 42:Indentation ......................................................................................................... 69
Figure 43:Use Commenting ............................................................................................... 69
Figure 44:Use of proper control name ............................................................................... 69
Figure 45:Use of proper file name ..................................................................................... 70
16 | P a g e
0
0
Activity 01
What is Algorithm
An algorithm is a set of instructions designed to perform a specific task. This can be a
simple process, such as multiplying two numbers, or a complex operation, such as playing
a compressed video file. Search engines use proprietary algorithms to display the most
relevant results from their search index for specific queries. (TechTerms, 2013)
In computer programming, algorithms are often created as functions. These functions serve
as small programs that can be referenced by a larger program. For example, an image
viewing application may include a library of functions that each use a custom algorithm to
render different image file formats. An image editing program may contain algorithms
designed to process image data. Examples of image processing algorithms include
cropping, resizing, sharpening, blurring, red-eye reduction, and color enhancement.
(TechTerms, 2013)
In many cases, there are multiple ways to perform a specific operation within a software
program. Therefore, programmers usually seek to create the most efficient algorithms
possible. By using highly-efficient algorithms, developers can ensure their programs run as
fast as possible and use minimal system resources. Of course, not all algorithms are created
perfectly the first time. Therefore, developers often improve existing algorithms and
include them in future software updates. When you see a new version of a software program
that has been "optimized" or has "faster performance," it most means the new version
includes more efficient algorithms. (TechTerms, 2013)
Characteristics of an Algorithm
1. Finiteness: An algorithm should have finite number of steps and it should end
after a finite time.
2. Input: An algorithm may have many inputs or no inputs at all.
3. Output: It should result at least one output.
4. Definiteness: Each step must be clear, well-defined and precise. There should be
no any ambiguity.
5. Effectiveness: Each step must be simple and should take a finite amount of time.
17 | P a g e
0
0
The Programming Process
Developing a program involves steps just like any problem solving task. There are main
five steps within the programming process:

Defining the problem

Design the program

Code the program

Testing the program

Document and Maintain
Defining the problem
Knowing the objective is the first consideration. Is it a payroll or editing program? Knowing
who the top user are is additionally necessary. Determining the inputs and outputs is next.
How can the program operate and what knowledge is required to form it happen? After this
has been set practicability is that the next thought. How many programmers can it take, is
that the project at intervals budget, will the project have a sensible define. Finally, if the
project is a go, then one should take measures to make sure the project is correctly
documented and analyzed.
Design the Program
Programs use algorithms that are like equations that tell the pc what task to perform. The
aim of the coder is to make algorithms that are clear and easy. Algorithms are expressed
first in logical hierarchical form known as modularization. Using modules or (a complete
thought) the coder creates a logical thought method for the pc to follow. After that the
program is attenuated in greater detail exploitation pseudocode. Pseudocode uses terms like
if, else, and, then to relate the programs rules to the pc.
Code the program
After the program has been designed it should be coded or written. Using the
pseudocode associate degreed logic needs from step two an appropriate programing
language should be selected. As expressed within the introduction, writing languages
disagree in specifications and usefulness. Once the suitable code language has been
chosen, it's imperative that the coder follow the syntax rules with as very little deviation
as potential so as for the program to have high accuracy.
Testing the program
After the program is written it then enters the programming debugging and testing part of
the Program Development Life Cycle. During this point the coder are going to be trying to
18 | P a g e
0
0
find errors in each logic and syntax, yet as exploring different areas that will cause the
program to either not work properly or to not run at all. This process is a lengthy
and tedious one, oftentimes consisting of up to 50% of a program9s time in
development. However, with a careful eye paid to program style and coding the quantity
of your time spent debugging can be cut significantly. As stated, debugging can uncover
errors in each logic and syntax. Syntax errors will prevent the program from executing.
They will be such easy things as misspelled words or can involve breaking the syntax
rules of the programming language used. On the opposite hand, logic errors can enable the
program to run however can offer incorrect results. Errors of this type could include simply
mistreatment the incorrect relative operator or larger, mistakes in writing formulas. Once
the coder locates the errors they're then fastened and therefore the program is run once
more. This will happen multiple times, usually known as <execute, check, and correct=, till
the program runs cleanly. The program will then enter the testing phase.
Document and Maintain
Documentation should be current from the terribly starting as a result of it's required for
those committed program currently and future. Upon completion User Documentation for
industrial use, Operator Documentation for those that run computer systems, and coder
Documentation for programmers charged with maintenance. Every program desires
positive amount and memory to process the instructions and data. As the process power
and memory area unit the foremost precious resources of a pc, a program ought to be
ordered go into such a fashion that it utilizes the smallest amount of memory and processing
time.
Linear Search
In Linear Search the list is searched sequentially and the position is returned if the key
element to be searched is available in the list, otherwise -1 is returned. The search in Linear
Search starts at the beginning of an array and move to the end, testing for a match at each
item.
All the elements preceding the search element are traversed before the search element is
traversed. i.e. if the element to be searched is in position 10, all elements form 1-9 are
checked before 10.
19 | P a g e
0
0
Pseudocode for Linear Search
Linear search (list, data)
Begin
Found=false
For I=0 to length of list-1
If list [I] =data then
found=TRUE
Break
End if
Next
If found=TRUE then
Print <data found=
Else
Print <data not found=
End if
End
Dry run for Linear Search
Data found
Example:
List [20,15,30,27,47,89,90,67,16,7,56]
Search data [89]
Results = data found
Place
1
2
3
4
5
6
l
0
1
2
3
4
5
Search Data
Found
89
False
89
False
89
False
89
False
89
False
89
True
Table 1:Dry run for Linear Search (Data Found)
Output
Data Found
20 | P a g e
0
0
Data not found
Results = data not found
Place
1
2
3
4
5
6
7
8
9
10
11
l
Search data
Found
0
57
False
1
57
False
2
57
False
3
57
False
4
57
False
5
57
False
6
57
False
7
57
False
8
57
False
9
57
False
10
57
False
Table 2:Dry run for Linear Search (Data not found)
Output
Data not found
Python code for Linear Search (Data Found)
def linear search (list, search):
position=-1:
for I in range (0, Len(list)-1):
if list[I]==search:
positioni+1
break
if position=! =-1:
print (<data found=)
print (<position, position=)
else:
print (<data not found=)
k= [10,20,58,45,32,6,54,95,68,7,5,36,21]
search data=45
linear search (k, search data)
Binary Search
Pseudocode for Binary Search
21 | P a g e
0
0
Function binary_search (sorted list, search data)
Begin
Position = -1
Low=0
High (length of sorted list -1)
While(low<=high) DO
Mid = (low+ high)/2
If (sorted list[mid]=search data)
Position = mid+1
Break
Else if (search data>sorted list[mid])
Low =mid+1
Else
High=mid-1
End if
End do
Return Position
End
Start
List = input list of data
Sdata = input search data
Pos = binary_search (sorted List, Sdata)
If Pos! = -1 Then
Output <Data Found at=, Pos
Else
Output <Data Not Found=
Stop
Dry run for Binary Search
Data found
List 1[10,5,25,32,65,41,120,56,77,78,80]
Sorted the list 1[5,10,25,32,41,56,77,78,80]
22 | P a g e
0
0
Search data=25
Search
Steps Sorted List
Law high Mid Found
Output
data
1
5,10,25,32,41,56,77,78,80 25
0
9
-
False
-
2
5,10,25,32,41,56,77,78,80 25
0
9
-
False
-
3
5,10,25,32,41,56,77,78,80 25
0
3
4
False
-
4
5,10,25,32,41,56,77,78,80 25
2
3
1
False
-
5
5,10,25,32,41,56,77,78,80 25
2
3
2
True
Data is found
Table 3:Dry run for Binary Search (Data found)
Data not found
Steps List
Search data Law
high Mid Found
Output
1
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
2
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
3
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
4
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
5
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
6
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
7
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
8
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
9
5,10,25,32,41,56,77,78,80
28
0
-
-
False
-
10
5,10,25,32,41,56,77,78,80
28
0
-
-
False
Data not found
Table 4:Dry run for Binary Search (Data not found)
Python code for Binary Search
def binary_search (item_list, item):
first = 0
last = Len(item_list)-1
found = False
while (first<=last and not found):
mid = (first + last)//2
if item_list[mid] == item:
23 | P a g e
0
0
found = True
else:
if item < item_list[mid]:
last = mid - 1
else:
first = mid + 1
return found
print (binary_search ([1,2,3,5,8], 8))
Algorithm Efficiency and Big–O Notation
Big-O Notation
Big-O notation is the language we use for talking about how long an algorithm takes to run
(time complexity) or how much memory is used by an algorithm (space complexity). BigO notation can express the best, worst, and average-case running time of an algorithm. For
our purposes here, we are going to focus primarily on Big-O as it relates to time complexity.
(Lovett, 2020)
As a software engineer, you9ll find that most discussions of Big-O focus on the <upperbound= running time of an algorithm, which is often termed the worst-case. An important
piece to note is the <running time= when using Big-O notation does not directly equate to
time as we know it (e.g., seconds, milliseconds, microseconds, etc.). Analysis of running
times does not take certain things into account, such as the processor, the language, or the
run time environment. Instead, we can think of time as the number of operations or steps it
takes to complete a problem of size n. In other words, Big-O notation is a way to track how
quickly the runtime grows relative to the size of the input. (Lovett, 2020)
Efficiency of an algorithm
Computer resources are limited that should be utilized efficiently. The efficiency of an
algorithm is defined as the number of computational resources used by the algorithm. An
algorithm must be analyzed to determine its resource usage. The efficiency of an algorithm
can be measured based on the usage of different resources.
24 | P a g e
0
0
For maximum efficiency of algorithm we wish to minimize resource usage. The important
resources such as time and space complexity cannot be compared directly, so time and
space complexity could be considered for an algorithmic efficiency. (info, 2018-2023)
Method for determining Efficiency
The efficiency of an algorithm depends on how efficiently it uses time and memory space.
The time efficiency of an algorithm is measured by different factors. For example, write a
program for a defined algorithm, execute it by using any programming language, and
measure the total time it takes to run. The execution time that you measure in this case
would depend on a number of factors such as:

Speed of the machine

Compiler and other system Software tools

Operating System

Programming language used

Volume of data required
However, to determine how efficiently an algorithm solves a given problem, you would
like to determine how the execution time is affected by the nature of the algorithm.
Therefore, we need to develop fundamental laws that determine the efficiency of a program
in terms of the nature of the underlying algorithm. (info, 2018-2023)
Space-Time tradeoff
A space-time or time-memory tradeoff is a way of solving in less time by using more
storage space or by solving a given algorithm in very little space by spending more time.
To solve a given programming problem, many different algorithms may be used. Some of
these algorithms may be extremely time-efficient and others extremely space-efficient.
Time/space trade off refers to a situation where you can reduce the use of memory at the
cost of slower program execution, or reduce the running time at the cost of increased
memory usage. (info, 2018-2023)
25 | P a g e
0
0
Asymptotic Notations
Asymptotic Notations are languages that uses meaningful statements about time and space
complexity. The following three asymptotic notations are mostly used to represent time
complexity of algorithms:
(i) Big O
Big O is often used to describe the worst-case of an algorithm.
(ii) Big Ω
Big Omega is the reverse Big O, if Bi O is used to describe the upper bound (worst - case)
of a asymptotic function, Big Omega is used to describe the lower bound (best-case).
(iii) Big Θ
When an algorithm has a complexity with lower bound = upper bound, say that an
algorithm has a complexity O (n log n) and (n log n), it9s actually has the complexity Θ (n
log n), which means the running time of that algorithm always falls in n log n in the bestcase and worst-case. (info, 2018-2023)
Best, Worst, and Average case Efficiency
Let us assume a list of n number of values stored in an array. Suppose if we want to search
a particular element in this list, the algorithm that search the key element in the list among
n elements, by comparing the key element with each element in the list sequentially.
The best case would be if the first element in the list matches with the key element to be
searched in a list of elements. The efficiency in that case would be expressed as O(1)
because only one comparison is enough.
Similarly, the worst case in this scenario would be if the complete list is searched and the
element is found only at the end of the list or is not found in the list. The efficiency of an
algorithm in that case would be expressed as O(n) because n comparisons required to
complete the search.
26 | P a g e
0
0
The average case efficiency of an algorithm can be obtained by finding the average
number of comparisons as given below:
Minimum number of comparisons = 1 Maximum number of comparisons = n
If the element not found then maximum
number of comparison = n
Therefore, average number of comparisons = (n + 1)/2
Hence the average case efficiency will be expressed as O (n). (info, 2018-2023)
Provide Above Algorithms Critically Evaluate Their Efficiencies Using Big-O
Notation
Big O Notation is the language we use to describe the complexity of an algorithm. In other
words, Big O Notation is the language we use for talking about how long an algorithm takes
to run. It is how we compare the efficiency of different approaches to a problem. With Big
O Notation we express the runtime in terms of 4 how quickly it grows relative to the input,
as the input gets larger.
There9s a little linear search function for a small, fixed-size array, with the comment <do a
binary search or lookup table later=. One of our Google Summer of Code students took this
to heart and implemented a binary search that was unfortunately not only incorrect but also
slower than the linear search. This is not too surprising, because implementing a binary
search is anything but trivial, despite the seeming simplicity of the algorithm. Also,
common wisdom says that for small array sizes, linear search beats binary search. I took
this as the starting point for a little project, to find out about the respective virtues of linear
and binary search on modern CPUs.
To limit the scope of this project, I concerned myself only with searching in small to
medium sized sorted arrays of integers, producing the index of the first element that is equal
to or greater than the search key. My results will not necessarily apply to other applications.
27 | P a g e
0
0
Although I will briefly explore the usage of SIMD instructions to speed up linear search
this is not the primary purpose of this project, so I haven9t benchmarked those
implementations as extensively, but I will present a few results.
Linear Search
def linear search (list, search):
position=-1:
for I in range (0, Len(list)-1):
if list[I]==search:
positioni+1
break
if position=! =-1:
print (<data found=)
print (<position, position=)
else:
print (<data not found=)
k= [10,20,58,45,32,6,54,95,68,7,5,36,21]
search data=45
linear search (k, search data)
Every loop iteration here does two conditional branches: One to check whether we9re
already at the element we9re looking for and the other to check whether we9re at the end of
the array. Fortunately, both are easy to predict: By predicting that we9re not at the end of
the array and that we haven9t found the element yet, we get exactly one branch
misprediction per search, which is hard to improve upon. We can, however, reduce the total
number of branches.
Binary Search
def binary_search (item_list, item):
first = 0
last = Len(item_list)-1
found = False
while (first<=last and not found):
mid = (first + last)//2
28 | P a g e
0
0
if item_list[mid] == item:
found = True
else:
if item < item_list[mid]:
last = mid - 1
else:
first = mid + 1
return found
print (binary_search ([1,2,3,5,8], 8))
This will work for n < MAX_INT/2. For larger n, middle must be calculated as min + ((max
- min) >> 1), which is one subtraction per iteration more.
Each iteration here also does two unconditional branches, one of which is essentially
unpredictable. There9s no way for the CPU to know in which of the two halves of the search
space the element you9re looking for will be, which means that we9ll get on average one
branch misprediction per two iterations.
There is a way around this unconditional branch, however: It can be turned into two
conditional move instructions. I haven9t found a way to tell GCC to do this, so I had to do
it using inline assembly (for x86 and AMD64).
Activity 02
Programming Paradigm
Since the release of the first high-level programming language, Plankalkül, and the
resulting release of languages like FORTRAN and Common Lisp, programming languages
have been pushing the envelope of what programming can be and what types can mean to
a computer programmer. Often this is done through what is called a programming
paradigm.
A programming paradigm is the concept by which the methodology of a programming
language adheres to. Paradigms are important because they define a programming language
and how it works. A great way to think about a paradigm is as a set of ideas that a
programming language can use to perform tasks in terms of machine-code at a much higher
level. These different approaches can be better in some cases, and worse in others. A great
29 | P a g e
0
0
rule of thumb when exploring paradigms is to understand what they are good at. While it
is true that most modern programming languages are general-purpose and can do just about
anything, it might be more difficult to develop a game, for example, in a functional
language than an object-oriented language. (Boudreau, 2020)
Procedural Programming Paradigm
Procedural Programming may be the first programming paradigm that a new developer will
learn. Fundamentally, the procedural code is the one that directly instructs a device on how
to finish a task in logical steps. This paradigm uses a linear top-down approach and treats
data and procedures as two different entities. Based on the concept of a procedure call,
Procedural Programming divides the program into procedures, which are also known as
routines or functions, simply containing a series of steps to be carried out.
Simply put, Procedural Programming involves writing down a list of instructions to tell the
computer what it should do step-by-step to finish the task at hand. (Bhatia, 2021)
Characteristics of Procedural Programming
The characteristics of procedural programming are:
1. Procedural programming follows a top-down approach.
2. The program is divided into blocks of codes called functions, where each function
performs a specific task.
3. Procedural programs model real-world processes as 'procedures' operating on 'data'.
4. The data and functions are detached from each other.
5. The data moves freely in a program.
6. It is easy to follow the logic of a program.
7. A function can access other function's data by calling that function.
Object-Oriented Programming (OOP)
Object-oriented programming (OOP) is a computer programming model that organizes
software design around data, or objects, rather than functions and logic. An object can be
defined as a data field that has unique attributes and behavior.
30 | P a g e
0
0
OOP focuses on the objects that developers want to manipulate rather than the logic
required to manipulate them. This approach to programming is well-suited for programs
that are large, complex and actively updated or maintained. This includes programs for
manufacturing and design, as well as mobile applications; for example, OOP can be used
for manufacturing system simulation software.
The organization of an object-oriented program also makes the method beneficial to
collaborative development, where projects are divided into groups. Additional benefits of
OOP include code reusability, scalability and efficiency.
The first step in OOP is to collect all of the objects a programmer wants to manipulate and
identify how they relate to each other -- an exercise known as data modeling.
Examples of an object can range from physical entities, such as a human being who is
described by properties like name and address, to small computer programs, such as
widgets.
Once an object is known, it is labeled with a class of objects that defines the kind of data it
contains and any logic sequences that can manipulate it. Each distinct logic sequence is
known as a method. Objects can communicate with well-defined interfaces called
messages. (Gillis, 2021)
Characteristics of object-oriented programming
Encapsulation
This principle states that all important information is contained inside an object and only
select information is exposed. The implementation and state of each object are privately
held inside a defined class. Other objects do not have access to this class or the authority to
make changes. They are only able to call a list of public functions or methods. This
characteristic of data hiding provides greater program security and avoids unintended data
corruption.
Abstraction
Objects only reveal internal mechanisms that are relevant for the use of other objects, hiding
any unnecessary implementation code. The derived class can have its functionality
31 | P a g e
0
0
extended. This concept can help developers more easily make additional changes or
additions over time.
Inheritance
Classes can reuse code from other classes. Relationships and subclasses between objects
can be assigned, enabling developers to reuse common logic while still maintaining a
unique hierarchy. This property of OOP forces a more thorough data analysis, reduces
development time and ensures a higher level of accuracy.
Polymorphism
Objects are designed to share behaviors and they can take on more than one form. The
program will determine which meaning or usage is necessary for each execution of that
object from a parent class, reducing the need to duplicate code. A child class is then created,
which extends the functionality of the parent class. Polymorphism allows different types of
objects to pass through the same interface. (Gillis, 2021)
Event Driven Programming
Event-driven programming known as a computer programming paradigm that used the
occurrence of events to determine the control flow of the program. This type of application
is designed to detect events as they occur, and use an appropriate event-handling procedure
to deal with it, which normally use a callback function or method.
Theoretically, event-driven style of programming is supported in all programming
languages, but they may different in the way of implement it, for example, it9s easier to
implement in languages that provide high-level abstractions, such as closures. Besides, for
other programming environments such as Adobe Flash, they are specifically tailored for
triggering program code by events.
Generally, there is a main loop in an event-driven application that used to listen for events
and triggers a callback function when there are events is detected. (Science, 2021)
Characteristics of Event-Driven Programming
Service Oriented
32 | P a g e
0
0
Service oriented is a key features in event-driven programming that used to write programs
that are made for services and it takes does not slow down the computer as service oriented
only consume little of the computer processing power and usually services run in the
background of OS. (Science, 2021)
Time Driven
In event driven programming, time driven is a paradigm, it9s 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 it9s a pre-set to do task. For example,
windows update is the example of time driven, which user can set when to update or when
to check and download the update. (Science, 2021)
Event Handlers
Event handlers is a type of function or method that run a specific action when a specific
event is triggered. For example, it could be a button that when user click it, it will display
a message, and it will close the message when user click the button again, this is an event
handler. (Science, 2021)
Trigger Functions
Trigger functions in event-driven programming are a functions that decide what code to
run when there are a specific event occurs, which are used to select which event handler to
use for the event when there is specific event occurred. (Science, 2021)
Events
Events include mouse, keyboard and user interface, which events need to be triggered in
the program in order to happen, that mean user have to interacts with an object in the
program, for example, click a button by a mouse, use keyboard to select a button and etc.
(Science, 2021)
The relationship between procedural, object-oriented and event-driven paradigm
Procedural programming means that as a series of steps, you describe a program and its sub
programs. On the other hand, declarative programs attempt to define the result irrespective
33 | P a g e
0
0
of the steps taken to calculate it but rather some description or denotation of the desired
result.
Object-oriented programming is a way to organize code around the concepts of
encapsulation, inheritance,replacement, programming to interfaces, etc.
Event based programming is about writing event handling procedures and having the core
event loopprovided by the underlying system. In this way you can save the trouble of
writing your own event loop and benefit from various libraries that already work with the
system provided event loop. Event based programsare very often writing using object
oriented style, but not always.
These three categories are thus not related strictly hierarchically, but in common usage they
are mostlynested within one another.
Procedural Code Example
def showMenu():
print('Main Menu')
print('1.Play game')
print('2. View high scores')
print('3. Quit')
showMenu()
34 | P a g e
0
0
Figure 1:Procedural Code Example
Object-Oriented Code Example
class Parrot:
# class attribute
species = "bird"
# instance attribute
def __init__(self, name, age):
self.name = name
self.age = age
# instantiate the Parrot class
blu = Parrot("Blu", 10)
woo = Parrot("Woo", 15)
# access the class attributes
35 | P a g e
0
0
print("Blu is a {}".format(blu.__class__.species))
print("Woo is also a {}".format(woo.__class__.species))
# access the instance attributes
print("{} is {} years old".format( blu.name, blu.age))
print("{} is {} years old".format( woo.name, woo.age))
Figure 2:Object Oriented code
Event Driven Code Example
36 | P a g e
0
0
import turtle
turtle.setup(400,500)
# Determine the window size
wn = turtle.Screen()
# Get a reference to the window
wn.title("Handling keypresses!")
wn.bgcolor("lightgreen")
tess = turtle.Turtle()
# Change the window title
# Set the background color
# Create our favorite turtle
# The next four functions are our "event handlers".
def h1():
tess.forward(30)
def h2():
tess.left(45)
def h3():
tess.right(45)
def h4():
wn.bye()
# Close down the turtle window
# These lines "wire up" keypresses to the handlers we've defined.
wn.onkey(h1, "Up")
wn.onkey(h2, "Left")
wn.onkey(h3, "Right")
wn.onkey(h4, "q")
# Now we need to tell the window to start listening for events,
# If any of the keys that we're monitoring is pressed, its
# handler will be called.
wn.listen()
wn.mainloop()
37 | P a g e
0
0
Figure 3:Event Driven Code Example
38 | P a g e
0
0
Activity 03
Ayubo Leisure Welcome Form
Figure 4:Welcome Form
Vehicle Type Registration Form
Figure 5:Vehicle Type Registration Form
39 | P a g e
0
0
Vehicle Registration Form
Figure 6:Vehicle Registration Form
Package Registration Form
Figure 7:Package Registration Form
40 | P a g e
0
0
Rent Calculation Form
Figure 8:Rent Calculation Form
Day Tour Calculation Form
Figure 9:Day Tour Calculation Form
41 | P a g e
0
0
Long Tour Calculation Form
Figure 10:Long Tour Calculation Form
Ayubo Database in SQL
42 | P a g e
0
0
Figure 11:Ayubo Database in SQL
Figure 12:User Design in sql
43 | P a g e
0
0
Vehicle Database
Figure 13:Vehicle Table in sql
Figure 14:Vehicle Design in sql
Vehicle Type Database
Figure 15:Vehicle Type Table in sql
44 | P a g e
0
0
Figure 16:Vehicle Type Design in sql
Packagers Database
Figure 17:Packagers Table in sql
Figure 18:Packagers Design in sql
45 | P a g e
0
0
Implementation of the Ayubo System
Implementation and Output case 1
1
Figure 20:Implementation and Output case 1
46 | P a g e
0
0
Implementation and Output case 2
Figure 21:Implementation and Output case 2
47 | P a g e
0
0
Implementation and Output case 3
Figure 22:Implementation and Output case 3
48 | P a g e
0
0
Implementation and Output case 4
Figure 23:Implementation and Output case 4
49 | P a g e
0
0
Implementation and Output case 5
Figure 24:Implementation and Output case 5
50 | P a g e
0
0
Integrated Development Environment (IDE)
An integrated development environment (IDE) is a software suite that consolidates basic
tools required to write and test software.
Developers use numerous tools throughout software code creation, building and testing.
Development tools often include text editors, code libraries, compilers and test platforms.
Without an IDE, a developer must select, deploy, integrate and manage all of these tools
separately. An IDE brings many of those development-related tools together as a single
framework, application or service. The integrated toolset is designed to simplify software
development and can identify and minimize coding mistakes and typos.
Some IDEs are open source, while others are commercial offerings. An IDE can be a
standalone application or it can be part of a larger package. (Gillis, 2018)
Benefits Of Visual Studio IDE
Squiggles and Quick Actions
Squiggles are wavy underlines that alert you to errors or potential problems in your code
as you type. These visual clues help you fix problems immediately, without waiting to
discover errors during build or runtime. If you hover over a squiggle, you see more
information about the error. A lightbulb might also appear in the left margin showing Quick
Actions you can take to fix the error. (Microsoft, 2021)
Code Cleanup
With the click of a button, you can format your code and apply any code fixes suggested
by your code style settings, .editorconfig conventions, and Roslyn analyzers. Code
Cleanup, currently available for C# code only, helps you resolve issues in your code before
it goes to code review. (Microsoft, 2021)
Refactoring
Refactoring includes operations such as intelligent renaming of variables, extracting one or
more lines of code into a new method, and changing the order of method parameters.
(Microsoft, 2021)
IntelliSense
51 | P a g e
0
0
IntelliSense is a set of features that display information about your code directly in the
editor and, in some cases, write small bits of code for you. It's like having basic
documentation inline in the editor, so you don't have to look up type information elsewhere.
(Microsoft, 2021)
Visual Studio search
Visual Studio menus, options, and properties can seem overwhelming at times. Visual
Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.
(Microsoft, 2021)
Live Share
Collaboratively edit and debug with others in real time, regardless of your app type or
programming language. You can instantly and securely share your project. You can also
share debugging sessions, terminal instances, localhost web apps, voice calls, and more.
(Microsoft, 2021)
Call Hierarchy
The Call Hierarchy window shows the methods that call a selected method. This
information can be useful when you're thinking about changing or removing the method,
or when you're trying to track down a bug. (Microsoft, 2021)
CodeLens
CodeLens helps you find code references, code changes, linked bugs, work items, code
reviews, and unit tests, without leaving the editor. (Microsoft, 2021)
Go To Definition
The Go To Definition feature takes you directly to the location of a function or type
definition. (Microsoft, 2021)
Peek Definition
The Peek Definition window shows a method or type definition without opening a separate
file. (Microsoft, 2021)
52 | P a g e
0
0
Visual programming
Visual programming can be a usage scenario that generally requires a dedicated IDE.
Visual Basic enables users to create new applications by moving programming, building
blocks, or nodes of code to create flowcharts or structure diagrams that are squared and
then compiled or applied. Square Measure supported the uniform modeling language. This
interface has become popular with Lego Mind's Storm system and is actively pursued by a
variety of companies who wish to take full advantage of custom browser features such as
those offered by Mozilla. KTechlab supports flow code and can be a modern open-source
IDE and package development machine for microcontrollers. Visual programming is also
responsible for the simplicity of distributed programming (see LabVIEW and EICASLAB
software). One of the earliest visual programming systems, Max, was statuesque when it
comes to the analog synthesizer style and has been used to create vintage music
performance packages since the 1980s. The first example was Paragraph, a stream-based
system originally developed for the Macintosh. The graphic programming environment
"Grape" is used to program qfix gear units.This approach is also used in specialized
packages like Open Lab, where suggestion users want the flexibility of a full artificial
language, but not the normal learning curve that comes with it.
How this futures helpful for Ayubo Drive creation.
The Live Share service allows you to share the code context and debugging process and
access live access to Visual Studio, such as Google Docs services.
Using live sharing, I was able to read, edit, debug, and navigate the project that was
developing in a natural way.
Redesigning any IDE was very helpful to me.
These redesigns showed the suggestions in the light bulb icon, and I'll greatly benefit from
actions such as moving the base class and interface, and changing namespaces to fit folder
structures.
A useful feature is the updated search box. In the previous version, it was called Instant
Launch. The new search experience here was fast and important to me to get the best
results.
Debugging made it possible to identify bugs in the software and remove those bugs. It was
very helpful for me to find objects and appropriate values in the debugging process.
53 | P a g e
0
0
When I right-click on Table Designer and select Properties, I wanted to create my properties
in the Properties window. If not, I could edit these properties in the Properties window
when selecting the table.
Activity 04
Ayubo Data Added Forms in IDE
Figure 25:Login Form
54 | P a g e
0
0
Figure 26:Vehicle Type Registration Form
Figure 27:Vehicle Registration Form
55 | P a g e
0
0
Figure 28:Package Registration Form
56 | P a g e
0
0
Figure 29:Rent Calculation Form
Rent Calculation Code
//create connection
SqlConnection CalculateCon = new SqlConnection(cs);
CalculateCon.Open();
//create command
String sql = "SELECT VehicleType.dailyDriverCost,
VehicleType.perDayCost, VehicleType.perWeekCost, VehicleType.perMonthCost FROM
VehicleType INNER JOIN Vehicles ON VehicleType.vehicleTypeID =
Vehicles.vehicleTypeID WHERE Vehicles.vehicleNo='" + this.txtVehicleNo.Text + "'";
SqlCommand CalculateCom= new SqlCommand(sql, CalculateCon);
//access Data
SqlDataReader sdr = CalculateCom.ExecuteReader();
//Bind data
if (sdr.Read())
{
dailyDriverCost = Convert.ToInt32(sdr.GetValue(0));
perDayCost = Convert.ToInt32(sdr.GetValue(1));
perWeekCost = Convert.ToInt32(sdr.GetValue(2));
perMonthCost = Convert.ToInt32(sdr.GetValue(3));
}
else
{
MessageBox.Show("No record found..!!!", "Error" ,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
CalculateCon.Close();
57 | P a g e
0
0
Figure 30:Day Tour Calculation Form
Day Tour Calculation Code
//create connection
SqlConnection CalculateCon = new SqlConnection(cs);
CalculateCon.Open();
//create command
String sql = "SELECT
Packages.packageTypeName,Packages.perkmCost,Packages.perHourCost,Packages.extrakmC
ost," +
" Packages.extraHourCost, Packages.driverOvernightRate,
Packages.maximumkmLimit, Packages.maximumHourLimit," +
" Packages.vehicleNightParkRate, Packages.packageType" +
" FROM Packages where packageType='DayTour' ";
SqlCommand CalculateCom = new SqlCommand(sql, CalculateCon);
//access Data
SqlDataReader sdr = CalculateCom.ExecuteReader();
//Bind data
while (sdr.Read())
{
Package package = new Package();
package.packageTypeName = Convert.ToString(sdr.GetValue(0));
58 | P a g e
0
0
package.perkmCost = Convert.ToInt32(sdr.GetValue(1));
package.perHourCost = Convert.ToInt32(sdr.GetValue(2));
package.extrakmCost = Convert.ToInt32(sdr.GetValue(3));
package.extraHourCost = Convert.ToInt32(sdr.GetValue(4));
package.driverOvernightRate = Convert.ToInt32(sdr.GetValue(5));
package.maximumkmLimit = Convert.ToInt32(sdr.GetValue(6));
package.maximumHourLimit = Convert.ToInt32(sdr.GetValue(7));
package.vehicleNightParkRate = Convert.ToInt32(sdr.GetValue(8));
package.packageType = Convert.ToString(sdr.GetValue(9));
packagesList.Add(package);
this.cmbVType.Items.Add(package.packageTypeName);
}
CalculateCon.Close();
}
Figure 31:Long Tour Calculation Form
Long Tour Calculation Code
//create connection
SqlConnection CalculateCon = new SqlConnection(cs);
CalculateCon.Open();
//create command
59 | P a g e
0
0
String sql = "SELECT
Packages.packageTypeName,Packages.perkmCost,Packages.perHourCost,Packages.extrakmC
ost," +
" Packages.extraHourCost, Packages.driverOvernightRate,
Packages.maximumkmLimit, Packages.maximumHourLimit," +
" Packages.vehicleNightParkRate, Packages.packageType" +
" FROM Packages where packageType='LongTour' ";
SqlCommand CalculateCom = new SqlCommand(sql, CalculateCon);
//access Data
SqlDataReader sdr = CalculateCom.ExecuteReader();
//Bind data
while (sdr.Read())
{
Package package = new Package();
package.packageTypeName = Convert.ToString(sdr.GetValue(0));
package.perkmCost = Convert.ToInt32(sdr.GetValue(1));
package.perHourCost = Convert.ToInt32(sdr.GetValue(2));
package.extrakmCost = Convert.ToInt32(sdr.GetValue(3));
package.extraHourCost = Convert.ToInt32(sdr.GetValue(4));
package.driverOvernightRate = Convert.ToInt32(sdr.GetValue(5));
package.maximumkmLimit = Convert.ToInt32(sdr.GetValue(6));
package.maximumHourLimit = Convert.ToInt32(sdr.GetValue(7));
package.vehicleNightParkRate = Convert.ToInt32(sdr.GetValue(8));
package.packageType = Convert.ToString(sdr.GetValue(9));
packagesList.Add(package);
this.cmbVType.Items.Add(package.packageTypeName);
}
CalculateCon.Close();
}
What is Debugging an Application
Debugging is the process of detecting and removing of existing and potential errors (also
called as 8bugs9) in a software code that can cause it to behave unexpectedly or crash. To
prevent incorrect operation of a software or system, debugging is used to find and resolve
bugs or defects. When various subsystems or modules are tightly coupled, debugging
becomes harder as any change in one module may cause more bugs to appear in another.
Sometimes it takes more time to debug a program than to code it.
To debug a program, user has to start with a problem, isolate the source code of the problem,
and then fix it. A user of a program must know how to fix the problem as knowledge about
problem analysis is expected. When the bug is fixed, then the software is ready to use.
Debugging tools (called debuggers) are used to identify coding errors at various
development stages. They are used to reproduce the conditions in which error has occurred,
then examine the program state at that time and locate the cause. Programmers can trace
the program execution step-by-step by evaluating the value of variables and stop the
60 | P a g e
0
0
execution wherever required to get the value of variables or reset the program variables.
Some programming language packages provide a debugger for checking the code for errors
while it is being written at run time. (Times, 2021)
Here's the debugging process:

Reproduce the problem.

Describe the bug. Try to get as much input from the user to get the exact reason.

Capture the program snapshot when the bug appears.

Analyse the snapshot based on the state and action.

Fix the existing bug, but also check that any new bug does not occur.
Visual Studio Debugging Features
Set a breakpoint and start the debugger
Figure 32:Ayubo IDE Case 01
Breakpoints are a useful feature when I know the line of code or the section of code that I
want to examine in detail at runtime.
To debug, I need to start our app with the debugger attached to the app process. F5 (Debug
> Start Debugging) is the most common way to do that. However, right now I may not have
set any breakpoints to examine my app code, so I will do that first and then start debugging.
Breakpoints are the most basic and essential feature of reliable debugging. A breakpoint
indicates where Visual Studio should suspend my running code so I can take a look at the
values of variables, or the behavior of memory, or whether or not a branch of code is getting
run.
If I have a file open in the code editor, I can set a breakpoint by clicking in the margin to
the left of a line of code.
Navigate code in the debugger using step commands
61 | P a g e
0
0
I provide the keyboard shortcuts for most commands because they make navigation of my
app code quicker. (Equivalent commands such as menu commands are shown in
parentheses.)
To start my app with the debugger attached, press F11 (Debug > Step Into). F11 is the Step
Into command and advances the app execution one statement at a time. When I start the
app with F11, the debugger breaks on the first statement that gets executed.
Step over code to skip functions
When I was on a line of code that is a function or method call, I can press F10 (Debug >
Step Over) instead of F11.
F10 advances the debugger without stepping into functions or methods in my app code (the
code still executes). By pressing F10, I can skip over code that you're not interested in. This
way, I can quickly get to code that you are more interested in.
Run to a point in your code quickly using the mouse
Using the Run to Click button is similar to setting a temporary breakpoint. This command
is also handy for getting around quickly within a visible region of app code. I can use Run
to Click in any open file.
Advance the debugger out of the current function
Sometimes, I was might want to continue my debugging session but advance the debugger
all the way through the current function.
Press Shift + F11 (or Debug > Step Out).
This command resumes app execution (and advances the debugger) until the current
function returns.
Run to cursor
62 | P a g e
0
0
Figure 33:Ayubo IDE Case 02
When I was editing code (rather than paused in the debugger), right-click a line of code in
my app and choose Run to Cursor (or press Ctrl to F10). This command starts debugging
and sets a temporary breakpoint on the current line of code.
Restart your app quickly
Click the Restart Restart App button in the Debug Toolbar (or press Ctrl + Shift + F5).
When I was press Restart, it saves time versus stopping the app and restarting the debugger.
The debugger pauses at the first breakpoint that is hit by executing code.
If I do want to stop the debugger and get back into the code editor, I can press the red stop
Stop Debugging button instead of Restart.
Example for debugging the Ayubo drive program
Find the red and green squiggles!
Figure 34: Error Movement
63 | P a g e
0
0
Figure 35:Correct Movement
Check the light bulb!
Figure 36:Error Movement
64 | P a g e
0
0
Figure 37:Correct Movement
Figure 38:Error Movement
65 | P a g e
0
0
Figure 39:Correct Movement
Evaluate the debugging process be used to help develop more secure, robust
applications.
While taking about security, we know our application tends to become more secure if there
is lesser number of bugs in application. Mainly debugging helps to find out where the
problems occurred, what type of problems occurred and why it is being encountered. It
provides the detailed description of the errors and bugs so we can easily sort out with the
help of the feedback provided by the debugger. It also shows the probable errors and bugs
during the writing of the code. So, if the bugs are removed then our application will be able
to solve problems very efficiently and the security will be maximized which directly leads
in making application more robust and secure.
Coding Standards
They are a series of procedures that can be defined for a particular programming language
specifying a programming style, the methods, & different procedures. These procedures
can be for various aspects of the program written in that language. They can be considered
essential attributes of software development.
66 | P a g e
0
0
A coding standard makes sure that all the developers working on the project are following
certain specified guidelines. The code can be easily understood and proper consistency is
maintained.
Consistency has a positive impact on the quality of the program and one should maintain it
while coding. Also, it should be taken care that coding rules are homogeneously followed
across different levels of the system and they do not contradict each other. The finished
program code should look like that it has been written by a single developer, in a single
session. (Guides, 2020)
Why coding standard is necessary for the team.
Enhanced Efficiency
It is often seen that the software developers spend a larger part of their time resolving code
quality issues that could have been prevented. Implementing programming standards and
best practices would help the team to detect the problems early or even prevent them
completely. This will increase efficiency throughout the software process.
Risk of project failure is reduced
Many times it happens that IT projects fail due to problems while developing software.
Implementing the code quality standards reduces many problems and the risk of project
failures.
Minimal Complexity
If a code is complex, there are higher chances of it being vulnerable to errors. Coding
standards help in the development of software programs that are less complex and thereby
reduce the errors.
Easy to Maintain
If programming standards in software engineering are followed, the code is consistent and
can be easily maintained. This is because anyone can understand it and can modify it at
any point in time
Bug Rectification
67 | P a g e
0
0
It becomes really easy to locate and correct bugs in the software if the source code is written
in a consistent manner.
A Comprehensive Look
If the source code maintains consistency, a clear view of how code fits in the larger
application or fits into the company as a whole.
Cost-Efficient
A clear code gives the developers an opportunity to reuse the code whenever required. This
can radically reduce the cost along with the efforts put in the development.
In a nut shell, coding conventions in software engineering play a vital role in project
success.
Why coding standard is necessary for individual.
Use of proper data type
Figure 40:Use of proper data type
Use of proper variable
Figure 41:Use of proper variable
68 | P a g e
0
0
Indentation
Figure 42:Indentation
Use Commenting
Figure 43:Use Commenting
Use of proper control name
Figure 44:Use of proper control name
69 | P a g e
0
0
Use of proper file name
Figure 45:Use of proper file name
The best applications are coded properly. This sounds like an obvious statement, but by
8properly9, I mean that the code not only does its job well, but is also easy to add to,
maintain and debug.
There9s nothing worse than inheriting an application or needing to make changes to code
that requires a lot of energy to decipher â€< you end up trawling through lines and lines of
code that doesn9t make its purpose or intentions clear. Looking through unfamiliar code is
much easier if it is laid out well and everything is neatly commented with details that
explain any complicated constructs and the reasoning behind them.
Conclusion
This unit introduces students to the core concepts of programming with an introduction to
algorithms and the characteristics of programming paradigms.
Among the topics included in this unit are : introduction to algorithms, procedural, objectorientated and event-driven programming, security considerations, the integrated
development environment and the debugging process.
On successful completion of this unit student will be able to design and implement
algorithms in a chosen language within a suitable integrated development environment.
This IDE will be used to develop and help track any issues with the code.
70 | P a g e
0
0
As a result, they will develop skills such as communication literacy, critical thinking,
analysis, reasoning and interpretation which are crucial for gaining employment and
developing academic competence.
Gantt chart
No Task Name
Start
Finish
Year 2021
Month
November
December
1W 2W 3W 4W 1W 2W 3W 4W
01
27/11/2021
02
Identifying
25/11/2021
Requirement
Task 01
28/11/2021
03
Task 02
06/12/2021
10/12/2021
04
05
Task 03
Task 04
11/12/2021
17/12/2021
16/12/2021
20/12/2021
06
Modifying
Assignment
21/12/2021
22/12/2021
07
Finalizing
Assignment
23/12/2021
23/12/2021
08
Submitting
Assignment
24/12/2021
24/12/2021
05/12/2021
Table 5:Gantt Chart
71 | P a g e
0
0
References
Bhatia, S., 2021. Procedural Programming [Definition]. [Online]
Available at: https://hackr.io/blog/procedural-programming
[Accessed 29 December 2021].
Boudreau, E., 2020. What Is A Programming Paradigm?. [Online]
Available at: https://towardsdatascience.com/what-is-a-programming-paradigm1259362673c2
[Accessed 29 December 2021].
Gillis, A. S., 2018. integrated development environment (IDE). [Online]
Available at: https://searchsoftwarequality.techtarget.com/definition/integrateddevelopment-environment
[Accessed 29 December 2021].
Gillis, A. S., 2021. object-oriented programming (OOP). [Online]
Available at: https://searchapparchitecture.techtarget.com/definition/object-orientedprogramming-OOP
[Accessed 29 December 2021].
Guides, 2020. Importance of Coding Standard and Code Quality in Software
Development. [Online]
Available at: https://www.multidots.com/importance-of-code-quality-and-codingstandard-in-software-development/
[Accessed 29 December 2021].
info, T., 2018-2023. Efficiency of an algorithm. [Online]
Available at: https://www.brainkart.com/article/Efficiency-of-an-algorithm_37217/
[Accessed 28 December 2021].
Lovett, P., 2020. Big-O Notation: A simple explanation with examples. [Online]
Available at: https://www.linkedin.com/pulse/big-o-notation-simple-explanationexamples-pamela-lovett
[Accessed 28 December 2021].
Microsoft, 2021. Welcome to the Visual Studio IDE. [Online]
Available at: https://docs.microsoft.com/en-us/visualstudio/get-started/visual-studioide?view=vs-2022
[Accessed 29 December 2021].
Science, C., 2021. Event-Driven Programming Features. [Online]
Available at: https://www.ukessays.com/essays/computer-science/eventdrivenprogramming-features-6167.php
[Accessed 29 December 2021].
TechTerms, 2013. Algorithm. [Online]
Available at: https://techterms.com/definition/algorithm
[Accessed 28 December 2021].
Times, T. E., 2021. Definition of 'Debugging'. [Online]
Available at: https://economictimes.indiatimes.com/definition/debugging
[Accessed 29 December 2021].
72 | P a g e
0
0
Grading Rubric
Grading Criteria
Achieved
Feedback
LO1 Define basic algorithms to carry out an operation
and outline the process of programming an
application.
P1Provide a definition of what an algorithm is and outline
the process in building an application.
M1Determine the steps taken from writing code to
execution.
D1 Evaluate the implementation of an algorithm in a suitable
language. Evaluate the relationship between the written
algorithm and the code variant
LO2 Explain the characteristics of procedural,
objectorientated and event-driven programming,
conduct an analysis of a suitable Integrated
Development Environment (IDE)
73 | P a g e
0
0
P2Give explanations of what procedural, objectorientated,
and eventdriven paradigms are; their characteristics and the
relationship between them.
M2 Compare and contrast the procedural, object
orientated and event driven paradigms used in given
source code of an application
D2Critically evaluate the source code of an application which
implements the programming paradigms, in terms of the
code structure and characteristics.
LO3Implement basic algorithms in code using an IDE.
P3Write a program that implements an algorithm using an
IDE.
M3Use the IDE to manage the development process of the
program.
D3Evaluate the use of an IDE for development of
applications contrasted with not using an IDE.
74 | P a g e
0
0
LO4 Determine the debugging process and explain
the importance of a coding standard
P4Explain the debugging process and explain the debugging
facilities available in the IDE.
P5Outline the coding standard you have used in your code.
M4Evaluate how the debugging process can be used to
help develop more secure, robust applications.
D4 Critically evaluate why a coding standard is necessary in
a team as well as for the individual.
75 | P a g e
0
0
Download
Study collections