Uploaded by Samadhi Sandanayaka

e163365-programming-assignment

advertisement
lOMoAR cPSD| 25952889
E163365 Programming Assignment
HND in Computing (ESOFT Metro Campus)
Studocu is not sponsored or endorsed by any college or university
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Higher National Diploma in Computing
Programme title
Lasitha Ranawaka
Assessor
Internal Verifier
Unit(s)
Assignment title
M.G.Dineru Sahan Hiruwinda
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?
Y/N
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)
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Date
lOMoAR cPSD| 25952889
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
M.G.Dineru Sahan Hiruwinda/KUR00133075
Unit Title
Assignment Number
Submission Date
Lasitha Ranawaka
Assessor
20/08/2022
Date Received 1st
submission
Date Received 2nd
submission
Re-submission Date
Assessor Feedback:
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.
Pass, Merit & Distinction Descripts
P1
M1
D1
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a suita
Integrated Development Environment (IDE).
Pass, Merit & Distinction Descripts
P2
M2
D2
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.
Assignment Feedback
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Feedback: Student to Assessor
Assessor
signature
Date
Student signature
Date
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject, Assignment No,
and Page Number on each page. This is useful if individual sheets become detached for any
reason.
5. Use word processing application spell check and grammar check function to help editing
your assignment.
Important Points:
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
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
except for the before mentioned compulsory information will result in rejection of your
work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
5. You must take responsibility for managing your own time effectively.
6. If you are unable to hand in your assignment on time and have valid reasons such as illness,
you may apply (in writing) for an extension.
7. Failure to achieve at least PASS criteria will result in a REFERRAL grade .
8. Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You will
then be asked to complete an alternative assignment.
9. If you use other people’s work or ideas in your assignment, reference them properly using
HARVARD referencing system to avoid plagiarism. You have to provide both in-text citation
and a reference list.
10. If you are proven to be guilty of plagiarism or any academic misconduct, your grade could be
reduced to A REFERRAL or at worst you could be expelled from the course
Student Declaration
I hereby, declare that I know what plagiarism entails, namely to use another’s work and to present it
as my own without attributing the sources in the correct way. I further understand what it means to
copy another’s work.
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.
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Student’s Signature:
(Provide E-mail ID)
Date:
(Provide Submission Date)
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
M.G.Dineru Sahan Hiruwinda/KUR00133075
Unit Number and Title
Unit 01: Programming
Academic Year
2021/22
Unit Tutor
Assignment Title
Design &Implement a GUI based system using a suitable Integrated
Development Environment
Issue Date
Submission Date
20/08/2022
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.
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
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
(IDE).
LO3. Implement basic algorithms in code using an IDE.
LO4. Determine the debugging process and explain the importance of a coding standard
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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.
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), 7seater van and Commuter van. New vehicle types are to be added in the future.
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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.
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
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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.
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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)
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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.
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
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.
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
Table of Contents
1.0
Task 01 ................................................................................................................................. 1
1.1
Algorithm ............................................................................................................................. 1
1.1.1
Characteristics of Good Algorithm ............................................................................ 1
1.1.2
What is Fibonacci series ........................................................................................... 4
1.1.3
Pseudo code for Fibonacci series.............................................................................. 4
1.1.4
What is Factorial value ............................................................................................. 5
1.1.5
Pseudo code for Factorial Value ............................................................................... 6
1.1.6
Programming Process ............................................................................................... 7
1.2
What is Big – O Notation ............................................................................................... 10
1.3
Algorithms with Big – O Notation..............................................................................11
2.0Task 02 ...................................................................................................................................... 11
2.1
Programming Paradigm ..............................................................................................11
2.1.1
Procedural Programming .........................................................................................11
2.1.2
Characteristics of Procedural Programming ........................................................... 12
2.1.3
Object-Oriented Programming ............................................................................... 13
2.1.4
Characteristics of Object Oriented Programming ................................................... 14
2.1.5
Event-driven Programming .................................................................................... 15
Event – driven programming ..................................................................................... 16
2.2
2.2.1
Characteristic of Event – driven programming....................................................... 16
2.1.2 Procedural programming and Object – orientate programming ........................................ 18
2.1.3 object-oriented programming and Event driven programming ......................................... 19
2.3
procedural programming ........................................................................................... 19
2.3.1
2.4
object-oriented programming .................................................................................... 20
2.4.1
2.5
C# code for procedural programming..................................................................... 19
Python cod for object-oriented programming......................................................... 20
event driven programming.......................................................................................... 20
i
M.G.Dineru Sahan Hiruwinda
E163365
Programming
2.5.1
Python cod for even Event –driven programming ...................................................... 20
3.0 Task 03 ..................................................................................................................................... 21
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
lOMoAR cPSD| 25952889
3.1 Rent calculation .................................................................................................................... 21
3.1.1 Day Tour ............................................................................................................................ 22
3.1.2 Long Tour .......................................................................................................................... 24
3.2 Cording Part ......................................................................................................................... 26
4.0 Task 04 ..................................................................................................................................... 34
4.1 Data Base Structures............................................................................................................. 34
4.2 debugging process ................................................................................................................ 38
4.2.1 Available features in visual studio IDE for debugging code more easily .......................... 41
4.3 Debugging tools ................................................................................................................... 41
4.4 What are coding standards? .................................................................................................. 42
M.G.Dineru Sahan Hiruwinda
ii
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 1: PROGRAMMING PARADIGM ........................................................................................... 11
Figure 2: Object oriented programming ......................................................................................... 20
Figure 3: Python cod for even Event –driven programming .......................................................... 20
Figure 4: Rent Calculation form ..................................................................................................... 21
Figure 5: Day tour form .................................................................................................................. 22
Figure 6: Day tour cod.................................................................................................................... 23
Figure 7: Long tour form ................................................................................................................ 24
Figure 8: Long tour......................................................................................................................... 25
Figure 9: Database connection ....................................................................................................... 26
Figure 10: Customer insert ............................................................................................................. 27
Figure 11: customer........................................................................................................................ 29
Figure 12: vehicle ........................................................................................................................... 30
Figure 13: Rent package ................................................................................................................. 31
Figure 14: Long tour ....................................................................................................................... 31
Figure 15: Rent ............................................................................................................................... 34
Figure 16: Package .......................................................................................................................... 34
Figure 17: vehicle............................................................................................................................ 36
Figure 18: Long tour ....................................................................................................................... 36
Figure 19: Day tour ........................................................................................................................ 37
Figure 20: Customer ....................................................................................................................... 37
M.G.Dineru Sahan Hiruwinda
iii
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
M.G.Dineru Sahan Hiruwinda
iv
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.0 Task 01
1.1 Algorithm
What is Algorithm
A collection of instructions for solving a problem or completing a task is known as
an algorithm. Recipes, like arithmetic formulae, are algorithms. Algorithmic code is a
type of computer code. Algorithms are a type of computer method that works similarly to
a recipe and informs your computer exactly what steps to take to solve a problem or
achieve a goal. Algorithms are used to manage the internet, and they are used to conduct
all online searches. Apps on smartphones are nothing more than algorithms. Algorithms
are required for online book recommendations and vacation websites to work. Artificial
intelligence is nothing more than a set of algorithms. Algorithms are responsible for
everything users view and do on the internet. Algorithms are used every time someone
sorts a column in a spreadsheet, and algorithms now handle the majority of financial
transactions. Algorithms assist devices in responding to voice instructions, recognizing
faces, sorting photographs, and building and driving automobiles. Algorithms for selflearning and self-programming are currently becoming more common. Algorithms are
frequently beautiful and quite effective instruments for completing tasks.
[CITATION RAI21 \l 1033 ]
1.1.1 Characteristics of Good Algorithm
-
Input specified
The data that must be altered in order to generate the output are the input. An algorithm
should contain 0 or more inputs that are well described. For input to be precise, you must
be aware of the kind, quantity, and format of the data.
M.G.Dineru Sahan Hiruwinda
1
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
- Output Specified
The results of the computation are the data (your intended result). An algorithm should
provide at least one output that is clearly specified and matches the desired outcome.
Additionally, knowing the type of data, the quantity, and the format of the output—or
even if there will be any output at all—is necessary for output accuracy.
M.G.Dineru Sahan Hiruwinda
2
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
-
Definiteness
Every step and the sequence in which those actions must be performed must be specified
in algorithms. Defining the process flow for converting input to output is the definition of
definitiveness. The algorithm should be explicit and clear. Each step's specifics must be
described in detail (including how to handle errors). Everything in it should be
quantifiable, not qualitative.
-
Effectiveness
An algorithm must be able to complete all of its essential stages and reach its desired
result in order for it to be effective. It shouldn't include any extraneous or redundant
stages that might render the algorithm useless.
-
Finiteness
At some point, the algorithm must stop. Stopping might result in either getting the desired
result or a response indicating no solution is conceivable. An algorithm must end after a
predetermined number of steps. An algorithm shouldn't run forever and should always
end after a set amount of steps.
-
Independent
An algorithm should include detailed instructions that are unrelated to any programming
code. It should be designed such that it may be used with any programming language.
M.G.Dineru Sahan Hiruwinda
3
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.1.2 What is Fibonacci series
According to the principle that each number in the Fibonacci sequence (known as a
Fibonacci number) is sufficient for the sum of the two numbers before it, the Fibonacci
sequence could be an assortment of numbers that starts with a 1 or a zero and ends with a
1. The following equation is derived for n = 0 if the Fibonacci sequence is chosen F (n),
where n is that term's first term, and the primary two terms are, by convention, zero and
one. [CITATION Vel17 \l 1033 ]
F (0) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34...
In some texts, it is customary to use n = 1. In that case, the first two terms are defined as 1
and 1 by default, and therefore:
F (1) = 1, 1, 2, 3, 5, 8, 13, 21, 34...
1.1.3 Pseudo code for Fibonacci series
Step 1: Start
Step 2: Declare variable c, d, e, f
Step 3: Initialize variable c = 0, y = 1 and f = 2
Step 4: Read n from user
Step 5: Print c and d
Step 6: Repeat until f <= n:
Step 6.1: e = c + d
Step 6.2: print e
Step 6.3: c = y, d = e
Step 6.4: f=f+1
Step 7: Stop
M.G.Dineru Sahan Hiruwinda
4
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
If a user Enters 5, then n=5,
Variables x and y are initialized to 0 and 1 respectively. In Step 5, we directly print x and
y, so the Output till Step 5 is - 0 1
In Step 6, value of "f" is 2 as the first two numbers (0, 1) are already printed. Now for
every iteration of "f", we add c and d, so variable "e" now becomes 1 (0+1). Then the
value of "e" is printed. So Output now becomes - 0 1 1
In Step 6.3, we move 2nd last value (which is stored in variable "d") to variable "c" and
last value (which is stored in variable "e") to y.
Then Now,
c = 1, d =1
In Step 6.4, Value of "f" is incremented by 1(f = f+1) and iteration again continues until
value of "f” is less than user entered number "n".
So, for i = 3, Again following steps 6.1 to 6.4, Output will be - 0 1 1 2
So, for i=4, Again following steps 6.1 to 6.4, Output will be - 0 1 1 2 3
So, for i=5, Again following steps 6.1 to 6.4, Output will be - 0 1 1 2 3 5
For i=6, condition f less than n becomes false as (6<=5) is false. Hence the Final Output
will be - 0 1 1 2 3 5
1.1.4 What is Factorial value
The sum of all positive whole numbers is less than or equal to a particular positive
integer, denoted in mathematics by the use of an exclamation point for that whole
number. Factorial seven is therefore written as 7! This indicates that 1 x 2 x 3 x 4 x 5 x 6
x 7 is true. Factorial zero is a suitable value.
M.G.Dineru Sahan Hiruwinda
5
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.1.5 Pseudo code for Factorial Value
Step 1: Start
Step 2: Declare Variable N, fact, d
Step 3: Initialize Variable fact
Step 4: Read number from User
Step 5: Repeat Until c <= number
5.1 Fact = fact * d
5.2 d = d+1
Step 6: Print fact
Step 7: Stop
We first take input from user and store that value in variable named “n”. Now we
initialize a variable “Fact” with value 1 (Fact=1) and variable i with value 1(c=1). Repeat
next two steps until d is less than n.
Multiply Fact with current value of d
Increment i with 1
At last, print the value of Fact.
Now let’s take an example,
Let the input be 6.
The equation that gets created by our algorithm is 6x5x4x3x2x1.
The Factorial of 6 is 720(6x5x4x3x2x1)
M.G.Dineru Sahan Hiruwinda
6
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.1.6 Programming
Process
Steps of Programming Process
-
Defining the problem
-
Planning the solution
-
Coding the program
-
Testing the program
-
Defining the problem
Assume you are approached because someone needs a programmer's services. To
examine the issue, you meet with users from the client company, or you meet with a
systems analyst who presents the project. Determining what you already know (the data
provided as input) and what you hope to learn is the challenge of defining the problem
(output-the result). Eventually, you create a written contract that details the necessary
input, processing, and output types among other things. This method is not
straightforward.
M.G.Dineru Sahan Hiruwinda
7
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Planning the Solution
The creation of a flowchart and the writing of pseudocode, or perhaps even both, are two
popular methods of problem-solving planning. A flowchart is essentially a visual
depiction of a problem-solving process in steps. It comprises boxes and other symbols
that indicate activities together with arrows that show the program's direction. It is a road
plan for what and how your program will accomplish its goals. A common set of
flowchart symbols has been created by the American National Standards Institute (ANSI).
Figure 1 depicts the symbols and possible uses for them in a straightforward flowchart of
a typical daily act—preparing a letter for sending.
Pseudocode is a nonstandard language that resembles English and allows you to express
your answer with greater accuracy than you can in plain English, but with less precision,
than is necessary when using a formal programming language. Pseudocode enables you to
concentrate on the logic of the program without having to worry about the specific syntax
of a particular programming language just yet. Pseudocode, however, cannot be run on a
computer. When we concentrate on language examples later in this chapter, we shall show
these.
M.G.Dineru Sahan Hiruwinda
8
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
-
Coding the program
The next stage for a programmer is to write the program, which entails expressing their
answer in a programming language. From the flowchart, pseudocode, or another tool, you
will transform the logic into a programming language. As we've already mentioned, a
programming language is a collection of rules that gives the computer a method to be told
what actions to do. There are several programming languages; some examples are
BASIC, COBOL, Pascal, FORTRAN, and C. Working with one or more of these may
come up. Later on in this chapter, we will go into further depth about the various
languages. Programming languages are far more exact even though they function
somewhat grammatically like the English language. You must strictly adhere to the
language's rules—its syntax—for your program to function. Of course, speaking the
language fluently does not ensure that your software will function, just as speaking
English well does not automatically imply that you are knowledgeable in the subject
matter. The crucial thing to remember is that using the language correctly comes first.
Then, using a terminal or personal computer, you must enter your coded program in a
way that the machine can comprehend.
-
Testing the program
Well-designed software can supposedly be written right the first time, according to some
experts. In fact, they claim that there are mathematical techniques to demonstrate the
accuracy of a program. The majority of programmers, however, are accustomed to the
thought that their freshly built programs will undoubtedly have a few defects because the
world's flaws still exist. This initially seems disheartening because programmers are often
precise, cautious, detail-oriented, and proud of their work. Nevertheless, there are several
possibilities to incorporate errors into programs, and you will likely find lots of them, just
like those who came before you.
M.G.Dineru Sahan Hiruwinda
9
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.2 What is Big – O Notation
The big-O notation may be useful for determining a formula's quality. The Big-O notation
basically indicates the relationship between the algorithm's input and, consequently, the
steps required to run it. A space, closing parenthesis, and a large "O" are used to indicate
it. The relationship between the input and the steps taken by the formula is displayed
using "n" inside of the parenthesis. As an illustration, the Big-O notation is utilized when
the input and the step the formula takes to finish its execution are both linear (n). In a
similar vein, the Big-O notation for quadratic functions is O (n2).
Some of the most often used Big-O functions are as follows:
Linear Complexity (O (n))
If the number of steps needed to complete the execution of an algorithm increases or
decreases linearly with the number of inputs, the complexity of the algorithm is said to be
linear. The symbol for linear complexity is O. (n).
Constant Complexity (O(C))
If, regardless of the quantity of inputs, the steps necessary to finish the execution of an
algorithm stay constant, then the complexity of the algorithm is said to be constant. O (c),
where c can be any constant number, stands for constant complexity.
Quadratic Complexity (O (n^2))
When the steps needed to run an algorithm are a quadratic function of the quantity of
input, the algorithm is said to be quadratic in complexity. The symbol for quadratic
complexity is O (n2).
M.G.Dineru Sahan Hiruwinda
10
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
1.3 Algorithms with Big – O Notation
An indicator of an algorithm's complexity is the Big-O notation. The Big-O notation, in a
nutshell, indicates the relationship between the input to the algorithm and the steps
required to execute it. It is denoted by a capital "O" with an opening and closing
parenthesis. Using "n" in the parenthesis, the relationship between the input and the
algorithm's stages is displayed. For instance, the Big-O notation will be utilized if the
input and the step the algorithm takes to complete its execution are both linear (n).
Likewise, the Big-O notation for quadratic functions is O (n2).
2.0 Task 02
2.1 Programming Paradigm
Figure 1: PROGRAMMING PARADIGM
2.1.1 Procedural Programming
The idea of invoking procedures serves as the foundation for procedural programming, an
evolution of structured programming. Procedures are just a collection of instructions that
must be followed. They are often referred to as routines, subroutines, or functions. Any
procedure in a program can be invoked by another procedure or by itself at any point
while it is being executed.
M.G.Dineru Sahan Hiruwinda
11
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
2.1.2 Characteristics of Procedural Programming
-
Local Variable
A local variable is a variable that is defined in the method's primary structure and has a
local scope. If the local variable is used outside the method it is declared in, the code will
stop working.
-
Global Variable
Programming language concepts known as "global variables" enable the declaration of a
variable type outside of any function and make it accessible to all other functions inside
the program. A set of global variables that, when combined, affect various aspects of a
program or the setting in which it runs is known as a global state or global environment.
-
Parameter Passing
Parameter passing is a method for supplying parameters to functions, subroutines, and
procedures. There are several ways to pass parameters, including "pass by value," "pass
by reference," "pass by result," "pass by value-result," and "pass by name."
- Predefined functions
Typically, a predefined function is an instruction with a name. Higher-level programming
languages typically include predefined functions, but they come from a library or registry
rather than a program.
Advantages of procedural programming
- An easier to way to keep track of program flow.
-
The ability to be strongly modular or structured
-
It will increase the reusability of the code.
-
Many general programming languages supporting it.
-
Needs only less memory
M.G.Dineru Sahan Hiruwinda
12
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Disadvantages of Procedural Programming
-
Difficult to create new data types reduces extensibility
-
Importance for given to the operation on data rather than the idea.
-
It isn't terribly sensible with a real-world downside.
-
It solves real-world issues will kind a posh program.
2.1.3 Object-Oriented Programming
Classes and objects are used in the programming paradigm known as object-oriented
programming (OOP). It is used to decompose software into reusable code blueprints, or
classes, that may be used to create particular instances of objects. A few examples of
object-oriented programming languages are JavaScript, C++, Java, and Python. A class is
a generic template that may be used to make more specialized, concrete things. Classes
are commonly used to indicate large groupings with similar characteristics, such as Car or
Dog. These classes specify which properties, such as color, an instance of this type will
have, but not the value of those attributes for a given object.[CITATION Eri20 \l 1033 ]
M.G.Dineru Sahan Hiruwinda
13
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
2.1.4 Characteristics of Object Oriented Programming
Objects
In object-oriented programming, a developer develops an abstract data type known as an
object. In addition to several attributes and methods, it might also include additional
objects. Classes are how most computer languages refer to objects.
Classes
A class is a blueprint for creating objects (a specific data structure), providing initial
values for state (member variables or attributes), and implementing behavior in objectoriented programming (member functions or methods).
Data abstraction
Abstraction is the process of expressing key characteristics without providing context or
justification. Classes are defined utilizing the concept of abstraction as a collection of
attributes like size, weight, and cost as well as methods to operate on these attributes.
They include all of the essential characteristics of the object. The operations that operate
on the data are known as member functions, and the attributes are known as data
members because they hold data.
Inheritance
Inheritance is the process by which a class acquires the properties and functions of
another class. The class whose attributes and methods are inherited is called the "parent
class." The properties from the parent class are passed down to the child class.
Polymorphism
The terms "polymorphism" and "morphism," which are Greek, are the origin of
polymorphism. Polymorphism is the combination of the words "morphism" and
"morphism," which together indicate "many forms." The capacity for a person to assume
multiple identities is referred to as polymorphism. An operation, for instance, can act
differently depending on the circumstances. The behavior is determined on the type of
data used in the operation.
M.G.Dineru Sahan Hiruwinda
14
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Advantages of Object Oriented Programming
- “Write once and use it multiple times” you can achieve this by using class.
-
Flexibility through polymorphism.
-
Effective downside resolution.
-
Only relevant data will be presented via data hiding and abstraction, ensuring data
security.
-
OOP systems are often simply upgraded from little to massive systems.
Disadvantages of Object Oriented Programming
- The creation of Object-Oriented Programs necessitates a significant amount of
effort.
-
Object Oriented Programs need tons of labor to form.
-
Object Oriented Programs need a great amount of work to create.[CITATION
Adv212 \l 1033 ]
2.1.5 Event-driven Programming
An event, such as a user action like a click or keypress, or a message from the software or
another program, can validate the flow of program execution in event-driven
programming. An application that is event-driven recognizes events as they occur and
reacts with the appropriate event-handling technique. Although event-driven programs
can be written in any programming language, some languages were their program, can
validate the flow of program execution in event-driven programming. An application that
is event-driven recognizes events as they occur and reacts with the appropriate eventhandling technique. Although event-driven programs can be written in any programming
language, some languages were specifically designed to support them. These languages
offer an integrated development environment (IDE) that partially automates the assembly
of code and offers a wide range of integral objects and controls, each of which can
respond to a variety of events. [CITATION gee21 \l 1033 ]
M.G.Dineru Sahan Hiruwinda
15
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
2.2 Event – driven programming
Event-driven programming is a programming paradigm in which events, such as a user
action such as a mouse click or key press, or a message from the operating system or
another program, govern the flow of program execution. An event-driven application is
one that detects events as they happen and responds with an appropriate event-handling
technique. The concept is based on interrupt-driven programming, which was popular in
early command-line environments like DOS and embedded computers (where the
application is implemented as firmware). [CITATION Eve21 \l 1033 ]
2.2.1 Characteristic of Event – driven programming
-
Service oriented
-
Time driven
-
Event handlers
-
Trigger function
-
Event
-
Simplicity of programming and ease of development
M.G.Dineru Sahan Hiruwinda
16
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Service Oriented
Event-driven programming, which is used to create programs for services, must include
EvService-oriented programming. Since service-oriented programming takes very little
processing power and typically runs in the background of the operating system, it does
not cause the computer to slow down.
Time driven
The paradigm of time-driven programming involves timing the execution of code. This
could be a piece of code that does a predefined operation at a predetermined interval, such
as once every hour, once a week, or once a month. A good example of this is Mac OS X
Mavericks, which at a certain time each day checks for updates and notifies you whether
to install them immediately or at a later time.
Event Handlers
Event handlers are a type of function or method that performs a certain action when a
particular event is triggered. A button that opens a message when the user presses it and
hides it when the user clicks the button once again is an example of an event handler.
Trigger Functions
Trigger functions decide what code is ran when a specific event occurs, they are used to
choose when event handlers are ran for the event that occurs, most applications have a
trigger function for each event that is likely to occur.
M.G.Dineru Sahan Hiruwinda
17
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Events
Mouse, keyboard, and user interface events must be triggered in the program for them to
occur, which means the user must interact with an item in the program, such as clicking a
button with a mouse, selecting a button with the keyboard, and so on.
Simplicity of programming and ease of development
Event-driven programming is simpler and easier to develop than other styles of
programming since it is so visibly evident. For instance, installing a button is as simple as
choosing it, adding it to a form, and adding code to it. Event-driven programming is
simpler and easier to develop than other styles of programming since it is so visibly
evident. For instance, adding a button is as simple as choosing it, adding it to a form, and
adding code to it.
2.1.2 Procedural programming and Object – orientate programming
The program is broken down into little
chunks called functions in procedural
programming.
In procedural programming, the program
is divided down into little parts called
functions.
In procedural programming, there is no
access specifier.
Access specifies such as private, public,
and protected are used in object-oriented
programming.
It's simple to add additional data and
functions.
Data is hidden in object-oriented
programming, making it safer.
It's not straightforward to add new data
and functions.
Because procedural programming lacks a
good method for concealing data, it is
insecure.
Overloading is not feasible with
procedural programming.
[CITATION pp_19 \l 1033 ]
Overloading is not feasible with
procedural programming.
2.1.3 object-oriented programming and Event driven programming
M.G.Dineru Sahan Hiruwinda
18
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
The programming paradigm known as "Object-Oriented Programming" (OOP) makes use
of objects to address issues. A programming paradigm known as object-oriented
programming (OOP) is based on the idea of "objects," which are data structures that
contain code in the form of procedures and data in the form of fields, which are referred
to as methods and attributes, respectively. Events-based or event-driven programming
When it comes to computer programming, in event-driven programming, the program's
flow is determined by things like user actions (mouse clicks, key presses), sensor outputs,
or messages from other programs or threads. [CITATION FAI14 \l 1033 ]
Object-oriented programming focuses on executing actions and manipulating data
enclosed in objects in a sequential sequence of steps, whereas event-driven programming
is more dynamic and relies on event triggering and event handling to define program
sequencing. Threads in event-driven programming can conduct activities based on
triggers/events in the program.[CITATION SUJ15 \l 1033 ]
2.3 procedural programming
2.3.1 C# code for procedural programming
2.4 object-oriented programming
2.4.1 Python cod for object-oriented programming
M.G.Dineru Sahan Hiruwinda
19
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Figure 2: Object oriented programming
Programming
lOMoAR cPSD| 25952889
2.5 event driven programming
2.5.1 Python cod for even Event –driven programming
Figure 3: Python cod for even Event –driven programming
M.G.Dineru Sahan Hiruwinda
20
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
3.0 Task 03
3.1 Rent calculation
Figure 4: Rent Calculation form
M.G.Dineru Sahan Hiruwinda
21
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
3.1.1 Day Tour
Figure 5: Day tour form
M.G.Dineru Sahan Hiruwinda
22
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 6: Day tour cod
M.G.Dineru Sahan Hiruwinda
23
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
3.1.2 Long Tour
Figure 7: Long tour form
M.G.Dineru Sahan Hiruwinda
24
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
M.G.Dineru Sahan Hiruwinda
Figure 8: Long tour
25
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
3.2 Cording Part
Customer Data Base Connection
Figure 9: Database connection
M.G.Dineru Sahan Hiruwinda
26
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Customer data load
Customer Insert
Figure 10: Customer insert
M.G.Dineru Sahan Hiruwinda
27
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Customer update
Customer Delete
M.G.Dineru Sahan Hiruwinda
28
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Customer search
Figure 11: customer
3.3 interface
M.G.Dineru Sahan Hiruwinda
29
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 12: vehicle
M.G.Dineru Sahan Hiruwinda
30
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 13: Rent package
Figure 14: Long tour
M.G.Dineru Sahan Hiruwinda
31
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
M.G.Dineru Sahan Hiruwinda
32
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
4.0 Task 04
4.1 Data Base Structures
Figure 15: Rent
Figure 16: Package
M.G.Dineru Sahan Hiruwinda
33
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 17: vehicle
Figure 18: Long tour
M.G.Dineru Sahan Hiruwinda
34
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Figure 19: Day tour
Figure 20: Customer
M.G.Dineru Sahan Hiruwinda
35
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
4.2 debugging process
Finding and correcting existing and potential bugs—often referred to as "bugs"—in
software code that can make it behave strangely or crash is the process of debugging. In
order to stop software or systems from malfunctioning, defects or problems must be
found and fixed. This process is known as "debugging." When numerous subsystems or
modules are closely coupled together, debugging becomes more challenging because each
alteration to one module may result in the emergence of additional flaws in the others.
Programming a program can take more time than debugging it.
To debug a software, the user must first identify the problem, isolate the source code, and
then correct it. Because knowledge of problem analysis is anticipated, a user of a software
must know how to resolve the problem. The program will be available to use after the bug
has been repaired. Debugging tools (sometimes known as debuggers) are used to detect
coding mistakes at various stages of development. They're used to recreate the error
conditions, then look at the program state at the moment to figure out what went wrong.
Programmers can follow the execution of a program step by step by assessing the value of
variables and stopping it if necessary to obtain the value of variables or reset program
variables. Some programming language packages include a debugger that may be used to
check for flaws in the code as it is being created at run time.[CITATION Def211 \l 1033 ]
M.G.Dineru Sahan Hiruwinda
36
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Steps of debugging process
- Identify the error
This is an obvious step but a tricky one, sometimes a bad identification of an error can
cause lots of wasted developing time, is usual that production errors reported by users are
hard to be interpreted and sometimes the information we are getting from them is
misleading.
A few tips to make sure you identify correctly the bug are.
See the error. This is easy if you spot the error, but not if it comes from a user, in that case
see if you can get the user to send you a few screen captures or even use remote
connection to see the error by yourself.
Reproduce the error. You never should say that an error has been fixed if you were not
able to reproduce it.
Understand what the expected behavior should be. In complex applications could be hard
to tell what should be the expected behavior of an error, but that knowledge is basic to be
able to fix the problem, so we will have to talk with the product owner, check
documentation… to find this information
Validate the identification. Confirm with the responsible of the application that the error is
actually an error and that the expected behavior is correct. The validation can also lead to
situations where is not necessary or not worth it to fix the error.
- Find the error
Once we have an error correctly identified, is time to go through the code to find the exact
spot where the error is located, at this stage we are not interested in understanding the big
picture for the error, we are just focused on
finding it. A few techniques that may help to find an error are:
Logging. It can be to the console, file… It should help you to trace the error in the code.
Debugging. Debugging in the most technical sense of the word, meaning turning on
whatever the debugger you are using and stepping through the code.
M.G.Dineru Sahan Hiruwinda
37
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Removing code. I discovered this method a year ago when we were trying to fix a very
challenging bug. We had an application which a few seconds after performing an action
was causing the system to crash but only on some computers and not always but only
from time to time, when debugging, everything seemed to work as expected, and when
the machine was crashing it happened with many different patterns, we were completely
lost, and then it occurred to us the removing code approach. It worked more or less like
this: We took out half of the code from the action causing the machine to crash, and we
executed it hundreds of times, and the application crashed, we did the same with the other
half of the code and the application didn’t crash, so we knew the error was on the first
half, we kept splitting the code until we found that the error was on a third party function
we were using, so we just decided to rewrite it by ourselves.
- Analyze the error
This is a critical step, use a bottom-up approach from the place the error was found and
analyze the code so you can see the big picture of the error, analyzing a bug has two main
goals: to check that around that error there aren’t any other errors to be found (the iceberg
metaphor), and to make sure what are the risks of entering any collateral damage in the
fix.
- Prove your analysis
This is a straight forward step, after analyzing the original bug you may have come with a
few more errors that may appear on the application, this step it’s all about writing
automated tests for these areas (is better to use a test framework as any from the xUnit
family).
Once you have your tests, you can run them and you should see all them failing, that
proves that your analysis is right.
- Cover lateral damage
At this stage you are almost ready to start coding the fix, but you have to cover your ass
before you change the code, so you create or gather (if already created) all the unit tests
for the code which is around where you will do the changes so that you will be sure after
completing the modification that you won’t have break anything else. If you run this unit
tests, they all should pass.
M.G.Dineru Sahan Hiruwinda
38
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
-
Fix the error
That’s it, finally you can fix the error!
- Validate the solution
Run all the test scripts and check that they all pass.[ CITATION Sol22 \l 1033 ]
4.2.1 Available features in visual studio IDE for debugging code more easily
-
Starting a Debugging
-
Set a breakpoint
-
Navigate code in the debugger using step commands
-
Step over code to skip functions
-
Step into a property
-
Run to a point in your code quickly using the mouse
-
Advance the debugger out of the current function
-
Run to cursor
4.3 Debugging tools
Debugging tools created exclusively for embedded applications have been around for
more than 30 years and have gotten quite complex as a result. When compared to a
desktop software, the most distinguishing feature of an embedded application is that each
embedded system is unique (but one PC looks very much like every other). The key to a
successful embedded debugger is that it is versatile and configurable enough to handle
such wide ranges of needs from one user to the next. A debugger's customizability can
take several forms, although most of them include scripting capabilities.
It's vital to remember that a debugger is usually a collection of tools rather than a single
software. A debugger can operate in a variety of ways, including assisting with code
development on a simulated target or with real target hardware.[CITATION Usi21 \l 1033
]
M.G.Dineru Sahan Hiruwinda
39
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
4.4 What are coding standards?
The strand of coding (plus strand; sense strand) DNA is the strand of duplex DNA that, by
convention, has the same base sequence as messenger RNA (mRNA), which is
synthesized from the DNA (except that the RNA has uracil substituting for thymine). The
other anticoding strand, which serves as a template for mRNA assembly during
transcription, is complementary to this one.
Purpose of Having Coding standard
In the Coding phase, different modules mentioned in the design document are coded
according to the module specification. The major purpose of the coding phase is to use a
high-level language to code from the design document created during the design phase,
and then to unit test this code.
Code standards are a well-defined and standard style of coding that good software
development companies expect their programmers to follow. They frequently create their
own coding standards and rules based on what works best for their company and the sorts
of software they create. Maintaining coding standards is critical for programmers; else,
code will be rejected during code review.[CITATION Cod19 \l 1033 ]
Advantages of using coding standards
-
Enhancement of the efficiency of the software development process
-
Reduction in the code complexity and the number of bugs
-
Improvement of the bug fixing process
-
Improvement of the code maintenance process
-
Reduction of development cost and time by enabling reusability
-
Better team integration[CITATION COD22 \l 1033 ]
M.G.Dineru Sahan Hiruwinda
40
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Why are coding standards necessary?
- They reduce security concerns and performance issues that might have resulted
from poor coding practices;
-
They help guarantee code quality, making your code easier to read, analyze, and
work through. The code also becomes easier to maintain and extend, even by new
developers;
-
They lead to lower code complexity and more elegant design solutions;
-
Any developer can examine any part of the code, understand it, and change it
independently of when and who wrote it. [CITATION COD22 \l 1033 ]
M.G.Dineru Sahan Hiruwinda
41
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
References
Anon., n.d. CODACY. [Online]
Available at: https://blog.codacy.com/coding-standards-what-are-they-and-why-do-youneed-them/
[Accessed 6 august 2022].
Anon., n.d. Solved assignment. [Online]
Available at: https://sites.google.com/site/assignmentssolved/mca/semester5/mc0084/6
[Accessed 6 August 2022].
debugger, U. a., n.d. sciencedirect. [Online]
Available at: https://www.sciencedirect.com/topics/engineering/debugging-tool
[Accessed 6 august 2022].
'Debugging', D. o., 2021. indiatimes. [Online]
Available at: https://economictimes.indiatimes.com/definition/debugging
[Accessed 6 August 2022].
doherty, E., 2020. What is Object Oriented Programming? OOP Explained in Depth.
[Online]
Available at: https://www.educative.io/blog/object-oriented-programming
[Accessed 3 august 2022].
GeeksforGeeks, 2018. GeeksforGeeks. [Online]
Available at: https://www.geeksforgeeks.org/introduction-of-programming-paradigms/
[Accessed 3 august 2022].
Guidelines, C. S. a., 2019. geeksforgeeks. [Online]
Available at: https://www.geeksforgeeks.org/coding-standards-andguidelines/#:~:text=Purpose%20of%20Having%20Coding%20Standards,helps%20to
%20detect%20error%20easily.
[Accessed 6 august 2022].
OOP, A. a. D. o., n.d. brainkart. [Online]
Available at: https://www.brainkart.com/article/Advantages-and-Disadvantages-of-
M.G.Dineru Sahan Hiruwinda
42
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
OOP_36649/
[Accessed 3 july 2022].
pp_pankaj, 2019. geeks for geeks. [Online]
Available at: https://www.geeksforgeeks.org/differences-between-procedural-and-objectoriented-programming/
[Accessed 3 july 2022].
Programming, E.-d., n.d. technologyk. [Online]
Available at: https://www.technologyuk.net/computing/software-development/softwaredesign/event-driven-programming.shtml
[Accessed 3 august 2022].
RAINIE, L. & ANDERSON, J., 2021. Pew Reserch Center. [Online]
Available at: https://www.pewresearch.org/internet/2017/02/08/code-dependent-pros-andcons-of-the-algorithm-age/
[Accessed 6 july 2022].
SAHER, F., 2014. c-charpcorner. [Online]
Available at: https://www.c-sharpcorner.com/interview-question/what-is-the-differencebetween-object-oriented-programming-and-event-baseddrivenprogramming#:~:text=Object%20oriented%20programming%20focuses%20on,the
%20sequencing%20of%20the%20program
[Accessed 3 july 2022].
SUMAN, S., 2015. c-charpcorner. [Online]
Available at: https://www.c-sharpcorner.com/interview-question/what-is-the-differencebetween-object-oriented-programming-and-event-baseddrivenprogramming#:~:text=Object%20oriented%20programming%20focuses%20on,the
%20sequencing%20of%20the%20program
[Accessed 3 august 2022].
Velasquez, R., 2017. eLearning Industry. [Online]
Available at: https://elearningindustry.com/fibonacci-sequence-what-is-and-how-appliesagile-development
[Accessed 8 july 2022].
M.G.Dineru Sahan Hiruwinda
43
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
lOMoAR cPSD| 25952889
Whatis.com, 2021. Whatis.com. [Online]
Available at: https://www.techtarget.com/whatis/definition/factorial
[Accessed 8 july 2022].
M.G.Dineru Sahan Hiruwinda
44
E163365
Downloaded by Samadhi Sandanayaka (sandanayakasamadhi@gmail.com)
Programming
Download