Uploaded by Udantha Wijeweera

Programing hnd pearson

advertisement
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Programme title
Higher National Diploma in Computing
Assessor
Internal Verifier
Unit(s)
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?
Is the Pass/Merit/Distinction grade awarded
justified by the assessor’s comments on the
student work?
Has the work been assessed
accurately?
Is the feedback to the student:
Give details:
• Constructive?
• Linked to relevant assessment criteria?
• Identifying opportunities for
improved performance?
• Agreeing actions?
Does the assessment decision need
amending?
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Y/N
Assessor signature
Date
Internal Verifier signature
Date
Programme Leader signature (if required)
Date
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
2|Page
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
Unit Title
UDANTHA MANODYA WIJEWEERA / COL-00081057
Design & Implement a GUI based system using a suitable Integrated
Development Environment
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 analysis of a suitab
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
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Feedback: Student to Assessor
Assessor
signature
Date
Student
signature
Date
4|Page
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
5|Page
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
1.
2.
3.
4.
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.
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
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 aspect 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.
Student’s Signature:
(E125472@esoft.academy)
Date:
(14/07/2022)
7|Page
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
UDANTHA MANODYA WIJEWEERA / COL-00081057
Unit Number and Title
Unit 01: Programming
Academic Year
2021/22
Unit Tutor
Mr. Tharaka Karunarathne
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 1,500–2,000 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.
8|Page
Unit Learning Outcomes:
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
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
Assignment Brief and Guidance:
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
B. Factorial of a non-negative integer, is multiplication of all integers smaller than or equal
to n. For example, factorial of 6 is 6*5*4*3*2*1 which is 720.
n! = n * (n - 1) * …….. 1
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.
Activity 3 and Activity 4 are based on the following Scenario.
10 | P a g e
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:
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
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.
11 | P a g e
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.
12 | P a g e
Grading Rubric
Grading Criteria
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
Achieved
Feedback
LO2 Explain the characteristics of procedural,
objectorientated and event-driven programming,
conduct an analysis of a suitable Integrated
Development Environment (IDE)
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.
14 | P a g e
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.
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.
15 | P a g e
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.
16 | P a g e
Table of Contents
1. Acknowledgement…………………………………………………………………………….….18
2. Introduction……………………………………………………………………………………….19
3. Activity 1 - Define basic algorithms to carry out an operation
and outline the process of programming an application……………………………..……….20
3.1. What is an Algorithm………………………………………………………………………...20
3.2. Characteristics of an Algorithm………………………………………………………...…….20
3.3. Pseudocode for Fibonacci numbers……………………………………………….………….20
3.4. Dry Run for Fibonacci numbers………………………………………………………..…….21
3.5. Pseudocode for factorial numbers…………………………………………………….…..….22
3.6. Dry run for factorial numbers……………………………………………………..…………22
3.7. Process of creating an application…………………………………………………….…..….23
3.8. What is Big O Notation………………………………………………………………....……23
3.9. Python code for Fibonacci numbers……………………………………………..……...……24
3.10. Python code for factorial numbers…………………………………………………..….….25
3.11. Critical evaluation of Big O notation and efficient programming………………………26
4. Activity 2 – Define programming paradigms and characteristics……………..………..…...27
4.1. What is programming paradigm………………………………………………..……………27
4.2. Procedural paradigm…………………………………………………..……………………..27
4.3. Characteristics of Procedural paradigm……………………………….……………………..27
4.4. Object oriented Paradigm……………………………………………………………………28
4.5. Characteristics of Object-Oriented paradigm…………………………..……………………28
4.6. Event driven paradigm……………………………………………………………………….28
4.7. Characteristics of Event driven paradigm……………………………………………………28
4.8. Relationships between programming paradigms…………….………………………………29
4.9. Code snippet for procedural………………………………………………………………….29
4.10. Code snippet for Object oriented…………………….…………………………………….30
4.11. Code snippet for Event driven……………………..……………………………………….31
5. Activity 3 – Implementing basic algorithms and coding using C#...........................................32
5.1. Rent calculation flowchart……………………………………….…………………………..32
5.2. Day tour hire calculation flowchart………………………………….……………….………33
5.3. Long tour hire calculation flowchart……………………………..…………………………..34
5.4. Rent calculation coding in C#..................................................................................................35
5.5. Day tour hire calculation coding in C#....................................................................................37
5.6. Long tour hire calculation C#..................................................................................................37
5.7. Database structure for Ayubo Travels……………………….………………………………41
5.8. Analysis on the features in an IDE…………………………….…………………………….43
5.9. Comparison of using an IDE for development and not
using an IDE for development……………………………………..………………………..44
6. Activity 4 – Determine the debugging process and importance
of coding standards……………………………………………………………………………..45
6.1. Login page and its code in C#.................................................................................................45
6.2. Main menu page and its code in C#........................................................................................49
6.3. Implementing Insert function in C#.........................................................................................51
6.4. Implementing Update function in C#......................................................................................53
17 | P a g e
Udantha Wijeweera I Programming I Assignment 01
6.5. Implementing Delete function in C#.....................................................................................55
6.6. Implementing View function in C#.......................................................................................56
6.7. Debugging process………………………………………………………………………….60
6.8. Debug features in visual studio…………………………………..…………………………61
6.9. Importance of debugging when developing robust application…………………….………64
6.10. Critical evaluation in coding standards………………………………………..…………66
7. Conclusion………………………………………………………………………………………69
8. Reference List………………………………………………………………………….………..70
18 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Acknowledgement
The success and final outcome of this assignment required a lot of guidance and
assistance from many people and I am extremely fortunate to having been able to work
with great minds specially during intensive practical sessions. My gratitude goes to
specially Mr. Tharaka Karunarathne for providing us with all his insights in regards to the
module and much more. It was because of his guidance and efforts collectively that we were able
to complete the assignment on time and submit our best work. I would also like to further
extend my gratitude to the Esoft academic staff for facilitating us in this journey.
19 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Introduction
Computer programming is the process of designing and writing computer programs. As a skill
set, it includes a wide variety of different tasks and techniques. Programming and computer
science are vast fields that encompass so very much. There are billions of dollars to be earned in
different ways. From selling software, to creating the next Facebook, or even building a
decentralized application with blockchain technology. This coursework will cover the basic
forefront to mid-level programming concepts in a descriptive way to enhance understanding.
20 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Activity 1 - Define basic algorithms to carry out an operation and outline the process of
programming an application.
Algorithm
According to (Bullinaria, 2019) an algorithm designed for a specific task can be described as a
finite series of instructions, each of which has a distinct meaning and can be completed in a finite
period of time with a finite amount of effort. As a result, an algorithm must be accurate enough
for humans to understand. Further (Gillis, 2022) suggests that algorithms can be classified into
various categories such as natural languages, programming languages, pseudocode, flowcharts
and control tables. Natural language expressions are rare, as they are more complex.
Programming languages are normally used for expressing algorithms executed by a computer.
Characteristics of an Algorithm
According to (Sondhi, 2021) a successful algorithm musty be Unambiguous which means an
algorithm is like a blueprint of an application therefore it should be clear and simple to
understand the input & output criteria must well outlined. The phases listed in an algorithm
should be countable, and it should end after a defined number of steps. Effectiveness should be
maintained in an algorithm to produce efficient results this can be achieved through Time
parameter and space parameter; Time parameter is none other than the duration for an algorithm
to process and the Space parameter refers to the storage space required by the algorithm with
reference to input criteria and lastly algorithms must be language independent which means the
deigned algorithm must work for all programming languages.
Pseudocode for Fibonacci number sequence
Start
i: integer
j: integer
k: integer
s: integer
n: integer
i=1, j=0, k=1, s=0, n=0
Input n
While i<=n
Print j
S=j + k
j=k
k=s
i=i+1
End while
Stop
21 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Dry run for Fibonacci numbers
Input Sample number ‘N’ as 5
-
While “i” is less than or equal to N
J will be printed as 0
S will be J plus K which is 1
Then J will be equal to K new J value will be 1
K will be equal to S value of K will be 1
The counter will increment i is equal to i plus one
Back to the beginning of the loop While “i” is less than or equal to N (i=2)
New J value will be 1 and it will be printed
-
S will be J plus K which is 2
Then J will be equal to K new J value will be 1
K will be equal to S value of K will be 2
The counter will increment i is equal to i plus one
Back to the beginning of the loop While “i” is less than or equal to N (i=3)
New J value will be 1 and it will be printed
-
S will be J plus K which is 3
Then J will be equal to K new J value will be 2
K will be equal to S value of K will be 3
The counter will increment; i is equal to i plus one
Back to the beginning of the loop While “i” is less than or equal to N (i=4)
New J value will be 2 and it will be printed
-
S will be J plus K which is 5
Then J will be equal to K new J value will be 3
K will be equal to S value of K will be 5
The counter will increment; i is equal to i plus one
Back to the beginning of the loop While “i” is less than or equal to N (i=5)
New J value will be 3 and it will be printed
-
S will be J plus K which is 8
Then J will be equal to K new J value will be 5
K will be equal to S value of K will be 8
The counter will increment; i is equal to i plus one
Back to the beginning of the loop While “i” is less than or equal to N (i=6)
Condition is False will exit the loop and end the program
Hence the output will be:
Output→ 0,1,1,2,3
22 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Pseudocode for Factorial value
Start
n: int
fact: int
n=0, fact=1
Input n
While n>0
Fact = fact*n
n=n-1
print fact
End while
Stop
Dry run for Factorial numbers
Input Sample number ‘N’ as 3
-
While “n” is greater than 0
fact is equal to fact multiplied by n current fact value is 1 multiplied by the current n value 3
gives the new fact equals 3
new n value equals previous n value minus 1 hence new n value is equal to 2
While “n” is greater than 0
fact is equal to fact multiplied by n; current fact value is 3 multiplied by the current n value 2
gives the new fact equals 6
new n value equals previous n value minus 1 hence new n 2 minus 1 which is 1
While “n” is greater than 0
fact is equal to fact multiplied by n; current fact value is 6 multiplied by the current n value 1
gives the new fact equals 6
Hence the output will be:
Output→ 6
As 3x2x1
Steps to create a successful program
Developing a software entails the same processes as any other problem-solving endeavor. In the
programming process, there are five main components:
1. Defining the problem
2. Planning the solution
3. Coding the program
4. Testing the program
5. Documenting the program
23 | P a g e
Udantha Wijeweera I Programming I Assignment 01
As the steps outlined above and to discuss those steps a bit in-depth is as follows.
According to (Valenzuela, 2018) the first step to in creating a successful program would be to
Identify the problem, Defining the problem is the most critical part as it is will need to
develop a concrete plan for what the program is intended to do. A crucial step in
Identifying the known inputs (or provided data) and the desired output is required for this
operation. Programming a working application is not an easy task, with time and constant
effort. In Order to provide the solution to the problem identified in the next step would be to
Find a solution, the help of flowchart and pseudocodes are useful. Experienced programmers
use either of these methods to convey program development to clients. The solution process
enables programmer to focus on the logical flow of the program without having to adhere to the
actual syntax used by the programming language for the project. Once the solution is identified
and a blue print is made the next step would be to Code it. This is where the algorithmic design
skills from computational thinking come into play. Testing is yet another critical aspect in the
workflow it will determine the quality of the program, will help to locate any bugs the testing
phase is achieved in different levels, once the testing is done the software should be ready to be
handed over to the user along with a fully documented user guide on how to use the for the first
time.
Big-O notation and its role in programing
The effectiveness of an algorithm as interpreted by (Jamieson, 2021) can be evaluated using Big
O Notation. As the input increases, it calculates how long it takes to run a function. Efficiency is
measured in terms of Time complexity and Space complexity. The length of the function's
execution in terms of its computational process is measured by its time complexity. Space
complexity is the required memory for a function to be executed. Big O is referred to as the
algorithm's upper bound, which denotes that it handles the worst-case scenario. The algorithm
will never perform worse than we anticipate thanks to our utilization of the worst-case scenario.
Furthermore (Mulonda, 2019) suggests that Big O notation is used by programmers as a kind of
measurement unit to assess or gauge the effectiveness of a piece of code(s), a script, or an
algorithm. The precise runtime of a script or algorithm is difficult to ascertain. It also depends on
other elements like the processor's speed and other technical details of the computer running the
script or algorithm. Big O notation is therefore used to assess how fast the runtime grows in
relation to the input data that will be processed by that algorithm rather than analyzing the
runtime itself directly.
24 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Python Code for Fibonacci numbers
nterms = int(input("How many terms? "))
n1, n2 = 0, 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
Fig1.1 Python code for Fibonacci numbers in python IDLE
25 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Python Code for factorial numbers
num = int(input("Enter a number: "))
fact = 1
if num < 0:
print(" Factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
fact = fact*i
print("The factorial of",num,"is",fact)
Fig1.2 Python code for factorial numbers in python IDLE
26 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Evaluating the program code with Big O notation for efficiency
According to (Spacey, 2016) The word "algorithm" has been used to describe highly optimized
codes, such as a widely complex problem in regards to arithmetic functions. The word implied as
a code has a strict design and resolves a complex problem. Codes frequently has little
complexity, is repetitious, or is not crucial. A Code that, for instance, shows a user interface,
verifies input, executes a transaction, or computes a value is typically simple to implement. Since
they are more sophisticated than other types of structures, algorithms can start out as extensive
research projects. Any code written by a developer on the spot that doesn't resolve a significant
issue is often not regarded as an algorithm. It is important to realize that businesses frequently
use the word algorithm. As a result, the phrase is starting to lose its original meaning and is
increasingly being used to refer to code. Comparing the pseudocode for Fibonacci numbers it
and considering the Big O notation feature the pseudocode does not store and display a lot of
unnecessary variable/data this is an efficient use of space complexity and when considering the
timing of execution for the python code for Fibonacci numbers is that comparatively its fast and
could run computers with less hardware features.
27 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Activity 2 – Define the characteristics of procedural object oriented and event driven
programming.
Programming paradigm
According to (Bartoníček, 2014) Paradigm is a set of patterns and procedures utilized to
accomplish a specific task. For a certain idea to become a paradigm, it should be picked up
globally in many independent organizations and societies. There are mainly 3 paradigms that will
be discussed here it is as follows
1. Procedural Paradigm
2. Object oriented paradigm
3. Event driven paradigm
Procedural paradigm
The method of programming that has been utilized since the invention of computers is known
as the procedural paradigm. In this paradigm, unless otherwise specified, the program consists
of a series of instructions that the computer is to carry out in the sequence that they were
written. It is a straightforward method that is usually simple to follow when the program is
brief. It may be exceedingly challenging to comprehend, manage, and debug larger programs
created with a procedural approach. The majority of procedural languages have IF, FOR &
WHILE statements control mechanisms. Below is an example of a piece of procedural
programing:
Characteristics of Procedural programming
•
•
•
•
•
Predefined functions: Included in higher-level programming languages and these
functions are recognized by name.
Local Variable: Defined in the method's primary structure and used inside the method's
local scope.
Global variable: Is one that is declared outside of every other function. As a result,
unlike a local variable, global variables can be utilized in all functions.
Modularity: is the process through which two distinct systems that are working on two
different tasks are combined to complete a bigger job first.
Parameter Passing: A mechanism used to pass parameters to functions, subroutines or
procedures. (Bhatia, 2022)
28 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Object oriented paradigm
Due to the modularity of objects, the object-oriented paradigm was created to simplify complex
projects and distribute the workload among team members. An object is the centerpiece of the
object-oriented paradigm. Data structures and operations that may be performed on the data,
known as methods, are grouped together as objects. The programmer can achieve a high level
of encapsulation by properly typing the data and procedures.
Characteristics of Object-oriented programming
•
•
•
•
Encapsulation - When each object inside a class retains a private state. Other objects
cannot directly access this state; instead, they must call a set of public functions. These
methods let the object to control its own state, and no other class may change it unless
specifically authorized.
Abstraction - Abstraction is an extension of encapsulation. It is the process of selecting
data from a larger pool to show only the relevant details to the object. Abstraction is the
method of obtaining, deleting, or choosing user data it enables to utilize the same data
you used for apps with little to no modification which is one of the benefits of
Abstraction.
Inheritance – Ability to acquire some/all properties of another object. For example, a
child inherits the genes/characteristics of his/her parents. Reusability is a major
advantage whereas the fields and methods of the existing class can be re-used. For
example, Apple is a fruit assuming that a class called Fruit is there and a subclass of it is
an Apple. Hence an Apple acquires the properties of the class Fruit.
Polymorphism – Polymorphism is the use of classes exactly like its parent class this
was there is less or no confusion with mixing types. This being said, each child subclass keeps its own functions/methods as they are. (Banda , 2020)
Event-driven paradigm
The main focus of event-driven programming is the classification of events, therefore the
Program flow ultimately on external events. The model containing the idea of event-driven
programming is known as an asynchronous model. Events are necessary for event-driven
programming to function. Events select what to do and in what order to perform it after they
have looped. The flowchart that follows will help you comprehend how this operates.
(tutorialspoint, n.d.)
Characteristics of Event-driven programming
• Service oriented – Often appears in the background and does not have any real interaction
with the user but at the same time these applications could be stopped from running with
users will.
• Time driven – These included such as antivirus scans, task scheduler and operating
system updates etc. These events follow real time settings and variables.
• Event Handlers – These are sections of code that are set out to denote the actions of
various events, such that when right or left clicking the mouse can have different results.
• Trigger functions – These specific pieces of code designed to take actions for an event
e.g., clicking a button to trigger the calculation on a calculator. (BURROWS, 2013)
29 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Relationships between programming paradigms
Procedural programming means that as a series of steps, you describe a program and its
subprograms. On the other hand, declarative programs attempt to define the result irrespective 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 loop provided 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 programs
are 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 mostly nested within one
another.
Sample code for Procedural programing:
def Sum(sample_list):
total = 0
for x in sample_list:
total += x
return total
list1 = [25, 50, 90]
list2 = [9, 45, 77, 20]
print(Sum(list1))
print(Sum(list2))
Output:
165
151
The function “Sum()” have been used to calculate the “list1” and “list2” total. The procedural
style depends on procedure calls to create modularized code. Which means the use of functions
to group the tasks parallelly makes the overall code simpler and easier to digest for programmers
when it comes to locating errors as well. According to (John, 2022) procedural programming Just
consists of a set of computational steps that teach the computer how to do a job in a logical
sequence. When addressing large projects, it is preferable to utilize another programming
paradigm rather than procedural programming, which is excellent for basic applications. Further
(Khatri, 2022) suggests that procedural paradigm focuses on enhancing the program's clarity,
quality, and development time, with its unique characteristics with higher level programming
language these functions recognized by name, the parameter passing mechanism used to
functions ex: list1 & list2.
30 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Sample code for Object oriented programing:
class Parrot:
species = "bird"
def __init__(self, name, age):
self.name = name
self.age = age
blu = Parrot("Blu", 10)
woo = Parrot("Woo", 15)
print("Blu is a {}".format(blu.__class__.species))
print("Woo is also a {}".format(woo.__class__.species))
print("{} is {} years old".format( blu.name, blu.age))
print("{} is {} years old".format( woo.name, woo.age))
Output:
Blu is a bird
Woo is also a bird
Blu is 10 years old
Woo is 15 years old
An object could represent an employee with attributes such as name, title, experience, etc., with
behaviors like working, on-leave, underperformed, etc as mentioned in the above code [species =
bird ] According to (Herrity, 2022) For example, an object could represent an employee with
attributes such as name, title, experience, etc., with behaviors like working, on-leave,
underperformed, etc., The four principles of object-oriented comparing the unique characteristic
methods of oop considering the encapsulation feature in the class parrot there is private data such
as the name and age these data may not be exposable. Abstraction is the feature when
considering the above code def init __(self, name, age).
31 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Sample code for Event driven programing:
import asyncio
async def main():
print('Hello ...')
await asyncio.sleep(1)
print('... World!')
asyncio.run(main())
The asyncio module in Python has a timer that can affect an event when its time is up first it will
print Hello then after sometime it will print World and the loop ends. When the event does
happen, the handler is called, and shown below is the event when executed, create and manage
event loops, which provide asynchronous APIs for networking, running subprocesses, handling
OS signals, etc.; implement efficient protocols using transports; bridge callback-based libraries
and code with async/await syntax.
32 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Activity 3 – Implementing basic Algorithms in code using an IDE.
3.1 Design suable algorithms for vehicle tariff calculation for rents and hires. Ideally 3 functions
should be developed for this purpose as follows:
Rent Calculation flow chart
Fig 3.1: Flow chart for calculation
33 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Day tour – hire calculation
Fig 3.2: Flow chart for day tour – hire calculation
34 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Long tour – hire calculation
Fig 3.3: Flow chart for long tour – hire calculation
35 | P a g e
Udantha Wijeweera I Programming I Assignment 01
3.2 Implement the above functions into workable applications using C#.net in Visual
studio IDE with suitable database structures to store the tariffs for vehicle types and
different packages which must be used for implementing the above functions.
Function 1: Rent Calculation
private void button2_Click(object sender, EventArgs e)
{
double drivercharge = 0;
int rates = 0;
DateTime date1 = dateTimePicker1.Value;
DateTime date2 = dateTimePicker2.Value;
int numberDays = (int)date2.Subtract(date1).TotalDays;
int month = numberDays / 30;
int week = (numberDays % 30) / 7;
if (numberDays < 7)
{
rates = numberDays * 3500; //3500 per day charges
}
if (numberDays >= 7 || numberDays < 30)
{
rates = week * 9000; //9000 per day charges
}
if (numberDays >= 30)
{
rates = month * 35000; //35000 per month
}
if (checkBox1.Checked)
{
drivercharge = 2500 * numberDays; //2500 per driver charge
}
if (checkBox2.Checked)
{
drivercharge = 0;
}
double TotalAmount = drivercharge + rates;
textBox2.Text = TotalAmount.ToString();
}
}
}
36 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 3.4: Output/GUI for Rent Calculation
37 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Function 2: Day Tour Calculation
int waitingcharge = 0;
int extrakm = 0;
DateTime Time1 = dateTimePicker1.Value;
DateTime Time2 = dateTimePicker2.Value;
int numberdays = (int)Time2.Subtract(Time1).TotalHours;
int start = int.Parse(textBox3.Text);
int end = int.Parse(textBox4.Text);
int distance = end - start;
int basecharge, packagekm, priceperkm, totalhirecharge;
packagekm = int.Parse(textBox9.Text);
priceperkm = int.Parse(textBox10.Text);
basecharge = packagekm * priceperkm;
textBox5.Text = basecharge.ToString();
if (distance > 100)
{
extrakm = (distance - 100) * 150; // 150 per extra km
}
if (numberdays > 4 || numberdays <= 12) // Maximum time allowed 4 hours
{
waitingcharge = (4 - numberdays) * 100;
}
totalhirecharge = basecharge + waitingcharge + extrakm;
textBox8.Text = totalhirecharge.ToString();
textBox7.Text = waitingcharge.ToString();
textBox6.Text = extrakm.ToString();
}
38 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 3.5: Output/GUI for Day Tour Calculation
39 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Function 3: Long Tour Calculation
private void button2_Click(object sender, EventArgs e)
{
int driverovernight;
int extrakm = 0;
int overnightcharge = 0;
int parkingcharge = 0;
DateTime Time1 = dateTimePicker1.Value;
DateTime Time2 = dateTimePicker2.Value;
int numberdays = (int)Time2.Subtract(Time1).TotalHours;
int start = int.Parse(textBox3.Text);
int end = int.Parse(textBox4.Text);
int distance = end - start;
int basecharge, packagekm, priceperkm, totalhirecharge;
packagekm = int.Parse(textBox9.Text);
priceperkm = int.Parse(textBox10.Text);
basecharge = packagekm * priceperkm;
textBox5.Text = basecharge.ToString();
if (distance > 100)
{
extrakm = (distance - 100) * 150; // 150 per extra km
}
driverovernight = int.Parse(textBox11.Text);
if (numberdays > 2)
{
overnightcharge = (numberdays - 2) * 350 + parkingcharge +
driverovernight;
}
totalhirecharge = basecharge + extrakm + overnightcharge;
textBox8.Text = totalhirecharge.ToString();
textBox6.Text = extrakm.ToString();
}
40 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 3.6: Output/GUI for Long Tour Calculation
41 | P a g e
Udantha Wijeweera I Programming I Assignment 01
3.3 Implementation of Database Structure for the scenario
This application is implemented with a database which includes about 6 table to save all the
data for Rentals, Day tour, long tour, package details, Vehicle registration and Driver
Registration. The option of amending details, inserting new details and deleting any existing is
also being made possible through certain functions implemented in the application itself fro
specific users only.
Fig 3.7: Designed Database structure
Fig 3.8: Tabular format view of Day Tour from database
42 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 3.9: Tabular format view of Vehicle registration from database
43 | P a g e
Udantha Wijeweera I Programming I Assignment 01
3.3. Analysis on the features of an integrated development environment (IDE)
The IDE that has been used to design and develop the system is Visual Studio Community
2022. Visual studio comes in with some useful features, according to (Kannan, 2022):
1. It is a 64bit IDE – Enables a considerable enhancement when loading projects and
executing which is also a factor in saving time. It allows to work on projects ranging from
different size capacities and complexities.
2. .NET6 – This is yet another unified framework that is available in visual studio IDE that
enables Web development, client and mobile apps in both Window and Mac.
3. Intellidcode – This yet another exciting functionality available in Visual studio 2022 IDE is
that this feature has the capability of predicting the next lines for you code using AI, this
helps developers save time and ease of work to complete the code based on the context, i.e.,
Variable names, functions etc.
4. Hot Reload – It helps the users to speed up the development process by simply reducing the
time to re-build and deploy the app for every change made in the code.
5. Find in files is faster – Helps to search for particular files within a project using. This new
version has a noticeably better performance. In comparison to earlier Visual Studio
versions, it is three times faster.
Fig 3.10: Detailed List of features seen in the visual studio IDE.
44 | P a g e
Udantha Wijeweera I Programming I Assignment 01
-
-
-
In Solution Explorer, at upper right, you can view, navigate, and manage your code files.
Solution Explorer can help organize your code by grouping the files into solutions and
projects.
The central editor window, where you'll probably spend most of your time, displays file
contents. In the editor window, you can edit code or design a user interface such as a
window with buttons and text boxes.
In Git Changes at lower right, you can track work items and share code with others by using
version control technologies like Git and GitHub.
Use of an IDE for development in contrast to not using an IDE
According to (Walker, 2021) Software developers use a range of tools to write, design, and test
their code. The most popular development tools include text editors, code libraries, bug tracking
programs, compilers, and test platforms but an IDE like Visual studio is much more advanced
and can yield an efficiency in time. Without an IDE, a developer must pick, utilize, integrate, and
monitor each tool separately. Several of these development-related technologies are combined
into one framework by an integrated development environment such as Visual Studio.
Developers don't have to spend hours learning how to use each utility separately when they are
all available on the same workbench. This is useful for new developers who might utilize an IDE
to familiarize themselves with a team's common tools and procedures. Furthermore by (Gillis,
n.d.), Visual Studio includes a code editor that supports syntax highlighting and code completion
using IntelliSense for variables, functions, methods, loops. IntelliSense is supported for the
included languages, as well as for XML, Cascading Style Sheets, and JavaScript when
developing web sites and web applications. Autocomplete suggestions appear in a modeless list
box over the code editor window, in proximity of the editing cursor, Visual Studio includes a
debugger that works both as a source-level debugger and as a machine-level debugger. In
addition, it can also attach to running processes, monitor, and debug those processes. The Visual
Studio debugger can also create memory dumps as well as load them later for debugging. Multithreaded programs are also supported. The debugger can be configured to be launched when an
application running outside the Visual Studio environment crashes, Visual studio also consists of
many designing features such as: Windows Forms Designer, WPF Designer, Web
designer/development, Class designer, Data designer and Mapping designer.
45 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Activity 4 – Determining the debugging process and explain the importance of a coding
standard.
4.1. Building a small system to record and view data for Hire calculation and vehicle types
and packages.
-
The Login Page for the System
The Username & password for Authorized users would be “admin” & admin123.
Once the correct logins are entered it will direct to the Main menu page.
If Incorrect login details are entered error message will be displayed.
Cancel Button will exit the page
private void button1_Click(object sender, EventArgs e)
{
string usrname = textBox1.Text;
string password = textBox2.Text;
if ((this.textBox1.Text == "admin") && (this.textBox2.Text == "admin.123"))
{
MessageBox.Show("Login Successful");
}
else
{
MessageBox.Show("Incorrect Login Details");
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
46 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 4.1: Login Page
47 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 4.2: Login details (Correct)
48 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 4.3: Login details (Incorrect)
49 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Main Menu page
Fig 4.4: Main Menu page
- If these Buttons are clicked it direct the user to the relevant form and below is coding that was used
to implement these functions.
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form5 frm5 = new Form5();
frm5.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Form6 frm6 = new Form6();
frm6.ShowDialog();
}
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
Form7 frm7 = new Form7();
frm7.ShowDialog();
}
}
private void button4_Click(object sender, EventArgs e)
{
this.Hide();
Form4 frm4 = new Form4();
frm4.ShowDialog();
}
}
50 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Vehicle Registration form
Fig 4.5: Vehicle registration page
51 | P a g e
Udantha Wijeweera I Programming I Assignment 01
1. Inserting Data into Vehicle Registration DB
Inserting Data and the data has been successfully added.
Fig 4.6: Vehicle registration page
Below shows the data that was input has been successfully inserted into the database
Fig 4.7: Data successfully inserted
52 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Code for Insert function in C#
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ADELAP029;Initial
Catalog=AyuboTravels;Integrated Security=True";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Insert into
VehicleRegistration(Vehicle_id,VehicleType,Seating,Numberplate) Values ('" +
textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" +
textBox4.Text + "')";
cmd.ExecuteReader();
con.Close();
MessageBox.Show("Successfuly inserted Details");
}
53 | P a g e
Udantha Wijeweera I Programming I Assignment 01
2. Updating the details
- Adding new data to update existing data, which has been updated successfully
Fig 4.8: New data inserted to update existing records
Fig 4.9: Newly updated records
54 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Code for Update function in C#
private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ADELAP029;Initial
Catalog=AyuboTravels;Integrated Security=True";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Update VehicleRegistration set Vehicle_id='" +
textBox1.Text + "', VehicleType='" + textBox2.Text + "',Seating='" + textBox3.Text +
"',Numberplate='" + textBox4.Text + "' where Vehicle_id='" + textBox1.Text + "';";
cmd.ExecuteReader();
con.Close();
MessageBox.Show("Successfuly updated Details");
}
55 | P a g e
Udantha Wijeweera I Programming I Assignment 01
3. Deleting a record
- Deleting a record from the database.
Fig 4.10: Before deleting any records
Fig 4.11: After deleting the desired record
56 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Code for Delete function in C#
private void button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ADELAP029;Initial
Catalog=AyuboTravels;Integrated Security=True";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Delete from VehicleRegistration where Vehicle_id='" +
textBox1.Text + "';";
cmd.ExecuteReader();
con.Close();
MessageBox.Show("Successfuly Deleted Details");
}
Code for View function in C#
private void button4_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ADELAP029;Initial
Catalog=AyuboTravels;Integrated Security=True";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
SqlDataAdapter sqlda = new SqlDataAdapter("SELECT * FROM
VehicleRegistration", con);
DataTable dtb1 = new DataTable();
sqlda.Fill(dtb1);
dataGridView1.DataSource = dtb1;
}
57 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Driver Registration Form
Fig 4.12: Inserting records/viewing records in Driver registration DB
58 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Package Registration Form
Fig 4.13: Inserting records/viewing records in Package Registration DB
59 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Hire Calculation
Fig 4.14: Inserting records/viewing records in Day tour Calculation DB
60 | P a g e
Udantha Wijeweera I Programming I Assignment 01
4.2. Debugging process and Visual studio IDE for debugging.
According to (Metwalli, 2020) In order to fix an error or to find workable solutions, a developer
or a programmer uses the process of debugging. When Grace Hopper was working on the Mark
II computer and noticed that it wasn't operating properly, the term "debug" first surfaced. The
relay of the computer malfunctioned as a result of a moth becoming lodged in it. So, a "bug" was
a very literal phrase used to identify the process. According to (Tawde, 2022) says that prior to
releasing a product as in a software in this context first and foremost it should be bug free. In the
modern tech industry firms strive hard to be at the top because of the intense market rivalry. If
the software doesn't have any bugs, then customer satisfaction is met because when a customer
uses software that has no errors, they are pleased. This is the rationale behind why debugging is a
necessary step before any organization releases a product to the market.
The process of debugging
1. Identify the error - A poor error identification can result in a waste of time which is
concern for time parameter. Users frequently report production mistakes that are difficult
to understand, and occasionally the information received is deceptive. It's important to
pinpoint the true error.
2. Find the error location - After accurately identifying the issue, it is important to search
the code to determine exactly where it is. Instead of trying to analyze the issue at this
point.
3. Analyze the error – This stage requires to start from the error location and evaluate the
code from the bottom. This aids in comprehending the error. There are two basic
objectives when analyzing a bug: to determine the likelihood of introducing any collateral
damage into the fix, and to search for more mistakes that may exist nearby.
4. Prove the analysis – Once the initial bug has been thoroughly examined, it required to
look for a few more faults that might occur in the application. This step involves creating
automated tests using a test framework for these regions.
5. Cover lateral damage – During this stage the unit tests for the code are gathered to make
changes and once these unit tests are run, they all should pass. (Sayantini, n.d.)
Fig 4.15: Flow of debugging process.
61 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Debugging features in Visual studio IDE.
Debugging can take many different forms, including using a debugger to step through the code,
examining logs, unit testing, profiling, and examining dumps. A primary method of debugging
developers is interactive debugging with Visual Studio. Interactive debugging entails joining a
running process with a debugger and examining the execution and state of the program.
1. Attaching the debugger – When pressing F5 to run from Visual studio or choose
Debug>Start debugging, visual studio immediately starts debugging.
Fig 4.16: Start debugging
Fig 4.17: Attach to process
62 | P a g e
Udantha Wijeweera I Programming I Assignment 01
2. The debugger break mode – This process is required for debugging, which indicates
that a certain line of code has caused the program to pause. More precisely, on a certain
line of code, all active threads are stopped. By pressing Ctrl+Alt+Break or setting
breakpoints, you can access the Debug | Break All menu item to enter break mode.
Fig 4.18: Debugging initiation
Fig 4.19: Break All
63 | P a g e
Udantha Wijeweera I Programming I Assignment 01
3. While in break mode navigate through code
3.1. Continue (F5) will quit break mode and continue the program’s execution until the next
breakpoint is hit, entering break-mode again.
3.2.Step Over (F10) will execute the current line and break on the next line of code.
3.3. Step Into (F11) is used when the next execution line is a method or a property. When
clicked, the debugger will step into the method’s code first line. By default, properties are
skipped. To enable stepping into property code go to Tools | Options | Debugging and
uncheck Step over properties and operators.
Fig 4.20: Step over properties
3.4. Run execution to here – This allows to continue execution, and break in a specified
location without a breakpoint. It’s like creating a breakpoint and removing it after first
break.
3.5. Run to closer location - This allows to forcefully set the next line of code to execute. The
current (yellow) line will not be executed. It can be a line that was executed before or
after, but it’s best for the new line of code to stay in the current scope.
64 | P a g e
Udantha Wijeweera I Programming I Assignment 01
4. Investigate variables - When in break mode, you can investigate the value of local
variables and class members. This is as easy as hovering over a variable. The hover
popup is called a Data Tip. You can get to the same popup by right-clicking the variable
and select QuickWatch (Shift+F9 or Ctrl+D, Q) in the context menu.
5. Data tip and quick watch notable features
Pinning DataTips – You can leave a DataTip pinned to the editor by clicking on the pin
icon. Useful when you hit the same breakpoint many times (maybe in a loop).
6. Break Point advanced features - The breakpoints have several very useful lesser-known
features. By right-clicking a break you will see a context menu:
Fig 4.21: Breakpoint advanced features
Using debugging process to develop robust applications
According to (Ghimire, 2021) When it comes to security, we are aware that fewer bugs mean
the program is more likely to be secure. Debugging primarily aids in determining the locations,
types, and causes of problems as well as their causes. It provides a thorough explanation of faults
and bugs that can be quickly fixed with the aid of the debugger's input. Additionally, it displays
any potential faults or problems that occurred during code authoring. Therefore, if the flaws are
fixed, our application will be able to address issues extremely effectively, and security will be
maximized, which immediately results in making the program more resilient and secure.
For an example when considering the code to debug the login page and by clicking the Login
button;
To start the first debugging session. As soon as the breakpoint is placed and by running the
application normally would - from the menu, the toolbar or by pressing F5. What happens now is
that the application is executed just like normal, but as soon as a line with a breakpoint is
reached, the execution is stopped right before that line would be executed. since it won't be set
before the line with the breakpoint has been evaluated. When hovering the mouse over the
different variables - the IDE will tell what they contain.
65 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Fig 4.22: Example of a debugging from scenario
When a program confronts the testers and gives erroneous results or fails to execute, one of the
processing duties is debugging. The debugging process improves the program's robustness and
completeness, and it requires it to handle any input or events it may face. - To stop hackers
clashing and plugging data or crashing systems, apps, powerful programs will build a restricted
detection of weaknesses.
66 | P a g e
Udantha Wijeweera I Programming I Assignment 01
4.3. Critical evaluation of Coding standards
According to (Bose, 2021) coding standards are a set of guidelines, methods, and best practices
used to create cleaner, easier-to-read, more effective codes with minimal errors. They provide a
standard structure that software engineers can utilize to create complex, highly functioning sets
of codes. Depending on the industry a particular product is being produced for, different best
practices and standards apply to coding. Software development standards for gaming software
will be different from those for luxury car software. For an example, the car sector
commissioned MISRA C and C++, which are now regarded as the de-facto standards for
developing programs that prioritize safety. They are currently recognized as the industry's best
standards for producing code. It is simpler to build precise code that meets product expectations
when you follow industry-specific standards. Writing code that satisfies end users and complies
with business criteria becomes simpler. Further more (Sengayire, 2019) suggests some of the
common aspects of coding standards are:
- Naming conventions such naming the classes, methods, objects, packages, variables etc.
- File and folder naming.
- Formatting and indentation which should followed and written to a standard format.
- Commenting and documenting makes it easier to review work specially when locating bugs
in scripts.
- Specific ways how classes and functions should behave.
- When it comes to testing; specifying what tools and methods that should be used.
Further importance of coding standards for teams and individuals
A further factor to take into account is the uniformity of variable names used throughout the
coding process. The benefits of incorporating coding standards into your development project are
as follows: When it comes to efficiency coding standards aids in the early detection of errors
which is a benefit for the entire team specially QA teams when testing certain aspects in the
code. There will also be a greater likelihood that these next issues will be entirely be avoided.
Implementing code standards will prevent problems and errors caused by improper coding. In
order to minimize complexities coding standards, aid in reducing the complexity of the
development process this is a crucial point for individual developers to easy understand what is
happening in the program. Error rates are higher with complicated coding specially human
errors. Utilizing coding standards reduces the likelihood of errors and problems in your
development project, and in fixing bugs, Smooth maintenance and last but not least Cost
saving aspects this could greatly weigh in for teams levels/organizational levels as a whole
where better coding standards are implemented because A Clean code also makes it possible to
reuse it whenever necessary, cutting down on the time required for the project, Coding
requirements adhere to industry norms set by organizations like the International Organization
for Standardization (ISO). It establishes a standard for code quality and, most importantly, it
guarantees the safety of your development project. (Office Partners 360, n.d.)
67 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Coding Standards applied in the above scenario
In the path of developing this application for Ayubo tours, I have implemented the and used
several coding standards and best practices they such as a good file structure, use of comments,
indentation patterns and variable declaration, while following the standards it has helped and
eased my work specially when locating certain errors and misinterpretations in calculations other
functions.
The user of comments – These Comments are text notes added to the program to provide
explanatory information about the source code.
Fig 4.23: Commenting used in scenario
Proper implementation of names used for database tables – This helps to identify the tables
in main database individually so that the proper table is used for the specific form.
Fig 4.24: Naming conventions for DB tables
68 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Declaring variables - To indicate the type of data that can be entered into a given field,
variables are declared at the beginning of each line of code. The entire names of all the variables
were utilized in their declarations in an easy and in a comprehending manner.
Fig 4.25: Variable declaration
69 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Conclusion
This course work pretty well covers all most all of the aspects of mid-level advanced
programming concepts from basic theories of what programming is and introduction to
Algorithms and designing a few with pseudocodes implementing codes for simple and complex
programs using C# and Python, defining the main programming paradigms such as objectoriented programming and gradually moving into designing and developing a functional
computer application with a complete database and evaluating on the use of IDE’s, testing, and
coding standards.
70 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Reference List
Banda , F. (2020, March 20). Key Lime. Retrieved from https://info.keylimeinteractive.com/thefour-pillars-of-object-orientedprogramming#:~:text=Object%2DOriented%2DPrograming%20allows%20programmers,
and%20can%2Ddo%20various%20methods.
Bartoníček, J. (2014). Programming Language Paradigms & The Main Principles of ObjectOriented Programming. CRIS - Bulletin of the Centre for Research and Interdisciplinary
Study, 95-98. Retrieved from
https://www.researchgate.net/publication/272577347_Programming_Language_Paradi
gms_The_Main_Principles_of_Object-Oriented_Programming
Bhatia, S. (2022, June 07). Retrieved from https://hackr.io/blog/procedural-programming
Bose, S. (2021, February 2). Brower Stack. Retrieved from
https://www.browserstack.com/guide/coding-standards-best-practices
BURROWS, R. (2013, November 10). Retrieved from http://reece-burrowsmedia.blogspot.com/2013/11/key-features-of-event-driven-programming.html
Ghimire, L. (2021). Retrieved from https://www.quora.com/How-can-the-debugging-processbe-used-to-help-develop-more-secure-robust-applications
Gillis, A. S. (n.d.). TechTarget. Retrieved from
https://www.techtarget.com/searchsoftwarequality/definition/integrateddevelopment-environment
Herrity, K. (2022, May 18). indeed. Retrieved from https://www.indeed.com/careeradvice/career-development/what-is-object-oriented-programming
Jamieson, A. (2021, March 22). Towards Data Science. Retrieved from
https://towardsdatascience.com/introduction-to-big-o-notation820d2e25d3fd#:~:text=Big%20O%20Notation%20is%20a,time%20complexity%20and%2
0space%20complexity.
John, P. (2022). CODESPEEDY. Retrieved from https://www.codespeedy.com/programmingparadigms-in-python/
Kannan, N. (2022, January 10). Retrieved from https://www.syncfusion.com/blogs/post/top-5features-in-visual-studio-2022.aspx
Khatri, V. (2022, June 10). TechGeekBuzz. Retrieved from
https://www.techgeekbuzz.com/blog/procedural-programming/
Metwalli, S. A. (2020, July 24). Retrieved from https://betterprogramming.pub/all-aboutdebugging-an-introduction-b9eeb0b24681
Mulonda, Y. (2019, July 17). Retrieved from https://blog.bitsrc.io/algorithms-efficiency-big-o-insimple-englishadbaedbcdfcf#:~:text=Complexity%20%7C%20Runtime%20Analysis%20%7C%20Big%20
O,going%20to%20take%20to%20run%3F
Office Partners 360. (n.d.). Retrieved from https://www.op360.com/coding-standards/
71 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Sayantini. (n.d.). Retrieved from https://www.edureka.co/blog/what-is-debugging/
Sengayire, P. (2019, November 26). Retrieved from https://medium.com/@psengayire/theimportance-of-coding-standards-and-conventions-in-the-software-development-teamhow-they-can-5d252556a05
Spacey, J. (2016, August 08). Retrieved from https://simplicable.com/new/algorithm-vscode#:~:text=An%20algorithm%20is%20a%20series,steps%20that%20machines%20can
%20execute.
Tawde, S. (2022). EDUCBA. Retrieved from https://www.educba.com/what-is-debugging/
tutorialspoint. (n.d.). Retrieved from
https://www.tutorialspoint.com/concurrency_in_python/concurrency_in_python_event
driven_programming.htm#
Valenzuela, J. (2018, March 20). Retrieved from https://www.iste.org/explore/ComputerScience/Computer-programming-in-4-steps
Walker, A. (2021, December 03). Retrieved from https://www.g2.com/articles/ide
72 | P a g e
Udantha Wijeweera I Programming I Assignment 01
Download