Unit-01 Programming Assignment
Unit-01 Programming Assignment
Unit(s)
Assignment title
M.A.M.AFRI
Student’s name
M.A.M.AFRI 1
improved performance? Y/N
• Agreeing actions? Y/N
M.A.M.AFRI 2
Confirm action completed
Remedial action
taken
Give details:
Internal
Verifier Date
signature
Program Leader
signature (if Date
required)
Date Received
Submission Date 1st submission
LO1. Define basic algorithms to carry out an operation and outline the process of programming an applicati
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, con
analysis of a suitable Integrated Development Environment (IDE).
M.A.M.AFRI 3
LO3. Implement basic algorithms in code using an IDE.
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4
Resubmission Feedback:
* 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
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
M.A.M.AFRI 4
Feedback: Student to Assessor
Assessor Date
signature
Student Date
signature
M.A.M.AFRI 5
4. All the assignments should print in A4 sized paper, and make sure to only use one
side printing.
5. Allow 1” margin on each side of the paper. But on the left side you will need to leave
room for binging.
Important Points:
1. Check carefully the hand in date and the instructions given with the assignment. Late
submissions will not be accepted.
2. Ensure that you give yourself enough time to complete the assignment by the due
date.
3. Do not leave things such as printing to the last minute – excuses of this nature will not
be accepted for failure to hand in the work on time.
4. You must take responsibility for managing your own time effectively.
5. 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.
6. Failure to achieve at least a PASS grade will result in a REFERRAL grade being
given.
7. Non-submission of work without valid reasons will lead to an automatic REFERRAL.
You will then be asked to complete an alternative assignment.
8. Take great care that if you use other people’s work or ideas in your assignment, you
properly reference them, using the HARVARD referencing system, in you text and
any bibliography, otherwise you may be guilty of plagiarism.
9. If you are caught, plagiarizing you could have your grade reduced to A REFERRAL
or at worst you could be excluded from the course.
M.A.M.AFRI 6
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.
M.A.M.AFRI 7
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number M.A.M.AFRI/00083957
Unit Tutor
Assignment Title Design & Implement a GUI based system using a suitable
Integrated Development Environment
Issue Date
Submission Date
Submission Format
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)
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
M.A.M.AFRI 8
ability to modify and debug the system using the IDE.
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
LO4. Determine the debugging process and explain the importance of a coding
standard
M.A.M.AFRI 9
Assignment Brief and Guidance:
Activity 1
Searching on an array/list is to find a given element on the array and return whether it is found or
not and return its position if found. Linear search and binary search are two popular searching
algorithms on arrays.
1.1 Define what an algorithm is and outline the characteristics of a good algorithm. Develop
algorithms for linear search and binary search using Pseudo code.
1.2 Describe the steps involved in the process of writing and executing a program. Take an array
of 10 or more elements and dry run the above two algorithms. Show the outputs at the end of
each iteration and the final output.
1.3 Define 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 Define what a Programming Paradigm means. Explain the main characteristics of Procedural,
Object oriented and Event-driven paradigms and the relationships among them.
2.2 Write small snippets of code as example for the above three programming paradigms using a
suitable programming language(s).
2.3 Critically evaluate the code samples that you have above in relation to their structure and the
unique characteristics.
M.A.M.AFRI 10
Activity 3 and Activity 4 are based on the following Scenario.
Ayubo Drive is the transport arm of Ayubo Leisure (Pvt) Ltd, an emerging travel & tour
company in Sri Lanka. It owns a fleet of vehicles ranging from cars, SUVs to vans.
The vehicles that it owns are hired or rented with or without a driver. The tariffs are based on the
vehicle type. Some of the vehicle types that it operates are, small car, sedan car, SVUs, Jeep
(WD), 7-seater van and Commuter van. New vehicle types are to be added in the future.
1. Rent (With or without driver) – For each type of vehicle, rates are given per day, per week
and per month. Rate for a driver also given per day. Depending on the rent period, the total
rent amount needs to be calculated. For example: if a vehicle is rented for 10 days with a
driver, total amount to be calculated as follows:
2. Hire (with driver only) – These are based on packages such as airport drop, airport pickup,
100km per day package, 200km per day package etc. Standard rates are defined for a
package type of a vehicle type if that is applicable for that type of vehicle. For each package,
maximum km limit and maximum number of hours are also 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 two or more days.
Activity 3
3
3.1 Design suable algorithms for vehicle tariff calculation for rents and hires.
Ideally 3 functions should be developed for this purpose as follows:
M.A.M.AFRI 11
sent in. with driver parameter is set to true or false depending whether the vehicle is rented with
or without driver.
3.2 Implement the above algorithms using visual studio IDE (using C#.net) and design the
suitable database structure for keeping the tariffs for vehicle types and different packages
which must be used for implementing the above functions.
3.3 Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual Studio IDE for
your application development contrasted with not using an IDE.
Activity 4
2
3
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 for Ayubo drive. This includes the
completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions. It essentially requires an
interface for hire calculation and recording function described above. Generating customer
reports and customer invoices are not required for this course work.
4.2 What is debugging an application? Explain the features available in Visual studio IDE for
debugging your code more easily. Evaluate how you used the debugging process to develop
M.A.M.AFRI 12
more secure, robust application with examples.
4.3 Explain the coding standards you have used in your application development. Critically
evaluate why a coding standard is necessary for the team as well as for the individual.
M.A.M.AFRI 13
Grading Rubric
M.A.M.AFRI 14
LO2 Explain the characteristics of procedural, object
orientated and event-driven programming, conduct an
analysis of a suitable Integrated Development
Environment (IDE)
P2 Give explanations of what procedural, object
orientated, and event driven paradigms are; their
characteristics and the relationship between them.
M.A.M.AFRI 15
P3 Write a program that implements an algorithm using
an IDE.
M.A.M.AFRI 16
D4 Critically evaluate why a coding standard is necessary
in a team as well as for the individual.
M.A.M.AFRI 17
Table of Contents
1.1 Algorithm..........................................................................................................................22
What is algorithm?...............................................................................................................22
Characteristics of a good algorithm are,..........................................................................22
Linear Search....................................................................................................................22
Binary Search....................................................................................................................23
1.2Linear Search in Python Programming..........................................................................24
1.3 Define What Big-O Notation...........................................................................................27
Efficiency Analysis............................................................................................................27
Binary Search in python programming................................................................................28
2.1 Programming Paradigms................................................................................................31
What is a programming paradigm?......................................................................................31
Imperative Programming Paradigm (Procedural)............................................................32
Structured Programming Paradigm.....................................................................................33
Functional Programming Paradigm......................................................................................33
• A huge program is broken down into small convenient procedures or functions.......33
• Different functions can share data through global variables........................................33
• Functions can change global data.................................................................................33
Top-down methodology...................................................................................................33
Advantages of procedural programming.........................................................................34
Restrictions or disadvantages of procedural programming.............................................34
The characteristics of Object Oriented programming are as follows,.............................35
A comparison between Procedural and Object Oriented Programming.............................36
The Characteristics of Event-driven Programming are as follows,......................................38
1.Events (Mouse, keyboard and user interface)..............................................................38
3.Local variables...............................................................................................................39
2.2. Using the Procedural and Imperative Programming Paradigms in Python
Language.................................................................................................................................41
Using the Object Oriented Programming Paradigms in Python Language. Object Oriented
Programming Characteristics...............................................................................................42
M.A.M.AFRI 18
Polymorphism in Python Programming
Language...................................................................................49
M.A.M.AFRI 19
Package details interface......................................................77
Vehicle Details Interface.......................................................78
M.A.M.AFRI 20
Task 01
1.1 Algorithm
What is algorithm?
In computer programming, algorithms are often formed as functions. These functions serve
as small programs that can be referenced by a larger program. In many cases, there
are several ways to perform a specific operation within a software program. In general
term, An algorithm is defined as a set of instructions designed to perform a specific
task. Algorithms work via input and output. They take the input and apply each step of the
algorithm to that information to produce an output.
Linear Search
In Linear Search Algorithm method, we compare the elements of the array one By one with
the main element we are looking for in sequential order. The pseudo code for linear search
would be like as given below:
BEGIN
Index = 1
i=0
Found = False
M.A.M.AFRI 21
WHILE i < length(numlist) AND NOT found
IF numlist[i] == numSought then
Index = i
Found = True Endif
i=i+1
Endwhile
Return Index
END
Binary Search
The Binary Search Algorithm can only be applied on sorted data and works by finding the
middle element in a list of information, sometime recently choosing which side of the
information the required element is to be found within. The undesirable half of the data is at
that point rejected and the process is repeated until the required element is found or until it
is known that the required element does not exist within the data. The Time complexity of
linear search is “O (n)” The Pseudo code for Binary Search would like as given below ,
BEGIN
Low = 0
High = a.length -1
WHILE Low <= High:
Mid = (Low + High) / 2 IF
a[Mid] == b:
Return Mid
Else if a[Mid] > b:
High = Mid -1
Else:
Low = Mid + 1
Endif
M.A.M.AFRI 22
Endwhile
Return “Not found”
END
Figure 1.1
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Begins from the leftmost element of given array [] and one by one compare element
”a” with each element of array []
M.A.M.AFRI 23
Iteration 2
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
It continues either searching until the element “25” is found or all the elements are searched.
Iteration 3
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Iteration 4
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Iteration 5
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Once”a” equals with any of the element, returns the index value
M.A.M.AFRI 24
Figure 1.2
M.A.M.AFRI 25
1.3 Define What Big-O Notation
Efficiency Analysis
M.A.M.AFRI 26
Binary Search in python programming
Figure 1.3
M.A.M.AFRI 27
Searching for Number “30” in the “array”
Iteration Low High Mid Found
1 0 9 4 No
2 5 9 7 No
3 5 6 5 Yes
Iteration 1
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Iteration 2
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Iteration 3
5 10 15 20 25 30 35 40 45 50
0 1 2 3 4 5 6 7 8 9
Once”a” equals with any of the element, returns the index value
M.A.M.AFRI 28
Figur
e 1.4
Efficiency Analysis
Best Case 1 comparison Item found in the 1st middle
element
Activity 2
M.A.M.AFRI 29
2.1 Programming Paradigms
Figure 2.1.1
M.A.M.AFRI 30
Imperative Programming Paradigm (Procedural)
Figure 2.1.2
M.A.M.AFRI 31
Structured Programming Paradigm
Structured Programming means that the code will implement the instruction-by-
instruction one after the other. It does not support the possibility of skipping from one
instruction to some other with the assistance of any statement like GOTO and variables.
This decreases code repetition, which improves read ability and maintainability of the code.
Functions are completely isolated; therefore, if we want to share data, we need to declare it
in the upper scope.
In the mean-time global data are transferred from function to function; during the
progression of the transformation, the global data may be improved in function chains.
Top-down methodology.
Procedural programming follows the top-down approach; workflow is going from top to
bottom.
Below is an example of the main subroutine of a program coded using the procedural
paradigm.
M.A.M.AFRI 32
Advantages of procedural programming
1. The coding is easy and simple.
2. The codes have the capability to be reused in numerous parts of the program.
3. The programming paradigm consumes less memory on the computer.
4. It is easier for tracking the flow of the codes in the program written in the procedural
programming paradigm.
5. The programming paradigm is considered as the best for general programming to
learn and implement.
Object-Oriented Paradigm is where we focus on real life objects while programming any
solution. The objective of an object-oriented program is to represent the real world in code.
In the object-oriented paradigm, the problem is divided into smaller parts called objects, and
systems are built around objects. Objects are depictions of things that exist in the real world
that we wish to model in a computer system.
M.A.M.AFRI 33
The characteristics of Object Oriented programming are as follows,
Figure 2.1.3
Encapsulation
Encapsulation is taking data and keeping it securely from outside interfaces. These user
defined data types are called "classes," and one occasion of a class is an "object."
Abstraction
The capability to represent data at a very theoretical level without any details.
Abstraction facilitates the easy conceptualization of real world objects, by excluding
the pointless details of the object.
M.A.M.AFRI 34
Inheritance
The process by which a class can be derived from a base class with all features of base class
and some of its own. This escalates code reusability, Classes are created in hierarchies,
and inheritance allows the assembly and methods in one class to be distributed down
the hierarchy. That means less programming is necessary when adding functions to complex
systems.
Polymorphism
This is the capability to exist in numerous methods, allows procedures about objects to be
formed whose precise type is not known until runtime.
Uses recursion concept to iterate collective Uses loop concept to iterate collective data
data
No side effects of its functions The method can have side effects
The focus in procedural programming is The focus in object oriented programming
“What are you doing” is “How are you doing it
M.A.M.AFRI 35
Event-driven Programming Paradigms
Event-driven Programming is when a program is designed to respond to user
involvement in various forms. It is known as a programming paradigm in which the
flow of program implementation is determined by “Events”. Events are any user
interaction, such as a click or key press, in response to prompt from the system. Events are
checked by a code (function) known as an “Event listener”. If the event listener detects that
an allocated event has happened, it will prompt a callback function, known as an event
handler. As shown below is an example,
Figure 2.1.4
M.A.M.AFRI 36
The Characteristics of Event-driven Programming are as follows,
Time driven
Time driven in event driven programming is a paradigm, it is the code that runs on a time
prompt, this could be a part of the code that runs at a particular time, which could be once a
week or whenever a program is launched, and this means it is a pre-set task.
Event handlers
Event handler is a function that takes place when a certain event occurs, they are
implemented in response to a certain event that takes place, this can be on a
button, when a button is clicked the code is executed, if the button is clicked again after that
it will execute again, this is an event handler.
Trigger functions
Trigger functions choose what code is executed when a particular event takes place,
they are used to choose when event handlers are executed for the event that took place, most
applications have a trigger function for each event that is probable to occur.
For the events inside a program to occur, they need to be generated, this is when the user
interacts with an object, which may be a button getting clicked by a mouse, events can be
generated in many different ways, it can be with your mouse, due to movement, left
clicking, right clicking or scrolling, the keyboard can also be used to begin events, this can
be from pressing certain keys, holding down certain keys or from being typed onto the
keyboard. The events occur due to code being assigned to something, for example
code might be assigned to a button, so when that particular button is clicked the code is
executed.
M.A.M.AFRI 37
•Pre-defined functions
A pre-defined function is a function that is built into the programming language. This can be
used as procedural so this code will run as soon as the program is ongoing, or you can
assign the code to a button, so that it can be triggered through an event.
3. Local variables
A local variable is a variable that is stated within a method, that variable will only be used
by the method where it is stated, other methods will not use it.
Parameter passing
Event-driven allows the user to choose different tools from the toolbar to directly create
what they need such as buttons, radio buttons, etc.
This also let us to put objects wherever they want them to be and can directly edit. Some
find it easier to directly click on the object that they want to edit.
M.A.M.AFRI 38
Effortlessness of Programming
Can make the programming easier is that when using an event driven language such as
visual basic it generally has predictive coding so when the user is coding it will suggest
what you want to do from what you are typing.
It allows for more interactive programs. Nearly all modern GUI programs use event driven
programming.
It can be executed using hardware interrupts, which will decrease the power used by the
computer.
It allows sensors and other hardware to effortlessly interact with the software.
M.A.M.AFRI 39
Slower
Programs with complex GUIs (Graphical User Interface) may be slower to load and run
than simpler program particularly if the RAM (Random Access Memory) is insufficient.
Confusing
Programs with too many forms can be very confusing for the user.
Figure 2.2.1
I have reused the function “calculate total()” to calculate the “number_list1” and
“number_list2” total. The procedural style depends on procedure calls to create modularized
code. Which means you can use functions to group the parallel type of work and
makes the overall code simpler. And get the Output as shown below
M.A.M.AFRI 40
Figure 2.2.2
Figure 2.2.3
M.A.M.AFRI 41
In the above
There is a Class named Student.
Constructors have the default name” __init__”. They are functions that are indirectly
labelled when an object of the class is formed.
All instance methods as well as the constructor have their first parameter as self.
Self refers to instance that is being referenced while calling the method.
“Name” and “age” are the instance variables.
M.A.M.AFRI 42
Figure 2.2.4
In the above:
“S” is the name of the object that I’m creating based on Student class
Even though the class has three parameters (self, name, age), I will still pass
only name and age while creating an object, as we don’t need to refer self here. It is
implicit.
Once an object is formed, you can refer to the attributes of the object using a dot. For
example, s.name refers to the name attribute of that individual object.
M.A.M.AFRI 43
Encapsulation in python programming language
Figure 2.2.5
This the concept of wrapping data such that the outside world has access only to
unprotected properties. Some properties can be hidden to reduce exposure. This is an
execution of data hiding.
In Python, this is implemented by creating private, protected and public instance variables
and methods.
Private properties have double underscore (__) in the start, while protected properties have
single underscore (_). By default, all other variable and methods are public. Private
properties are available from within the class only and are not available for child class (if
inherited). Protected properties are accessible from within the class but are available to child
class too. All these constraints are removed for public properties. Given below is he Output,
M.A.M.AFRI 44
Figure 2.2.5
M.A.M.AFRI 45
Inheritance in python programming language
Figure 2.2.6
M.A.M.AFRI 46
In inheritance, another class (called subclass) inherits a “class”. The subclass adds some
attributes to superclass.
Figure 2.2.7
M.A.M.AFRI 47
Polymorphism in Python Programming Language
Figure
2.2.8
Can produce function that can take any object allowing for polymorphism
Figure 2.2.9
M.A.M.AFRI 48
Event driven in Python Programming Language
Figure 2.2.9
The turtle module in Python has a timer that can effect an event when its time is up. When
the event does happen, the handler is called, and shown below is the event when executed,
M.A.M.AFRI 49
Figure 2.2.10
Key-press Events
M.A.M.AFRI 50
Figure 2.2.11
It is needed to call the window’s listen method, or else it won’t respond to the key
presses.
The handlers can be randomly complex functions that call other functions.
M.A.M.AFRI 51
Pressing the “space” key on the keyboard calls function a4 (because it has been bounded to
a4). While executing a4, the window’s bye method closes the turtle window, which causes
the window’s “main loop” call to terminate its execution.
The keys can be referred on the keyboard by their character code. When the turtle window
opens, It enables “t” to move by pressing the arrow keys.
M.A.M.AFRI 52
Mouse Events
Figure 2.2.12
A mouse event is a bit different from a key press event because it’s handler needs two
parameters to receive a,b coordinate information telling where the mouse was when the
event happened.
This enables to move the turtle to an accurate coordinate position. So what this program
does is move the turtle (and draw a line) to anywhere the mouse is clicked on.
M.A.M.AFRI 53
Activity 3
Function
RentCalculation(RegNo,RentedDate,ReturnDate,WithDriver)
DateDiff=ReturnDate -RentedDate
/*calculate months,weeks,days
Months=DateDiff / 30
Remainder = DateDiff % 30
Weeks = Remainder / 7
Days = Remainder % 7
(found)
Show VehicleType,MonthlyRate,WeeklyRate,DayRate,DriverRate
Total_Amount= Amount+Date_Diff*DriverRate
Else
M.A.M.AFRI 54
Total_Amount=Amount
End if
Print("Total amount",total_amount")
Else
End if
End function
If found()
Noofhours end_time-start_time If
ex_hours-no_hours-max_hours
ex_hour_charge-ex_hours*ex_hour_rate
ex_hours 0 endif
M.A.M.AFRI 55
else ex_hour_charge-
ex_hours*ex_hour_rate:
no_of km end_km-start_km.
max km
else
ex_km=0
endif
ex_km_charge-ex_km*ex_km_rate
end if
end function
M.A.M.AFRI 56
Function 3: Long tour.
if(NoofKM permitted_KM)then
Ex KM-NoofKM-permitted_KM
else
Ex KM-0
Endif
ExKMCharge Ex KM * ExKMRate
Print("Extra KM Charge",EXKMCharge)
M.A.M.AFRI 57
/"calculate Night Charge/
NightCharge(VehiNightRate + DrNightCharge) (NoofDays -1).
Print("Owner Night Charge",NightCharge)
Else
Print("Record Not Found")
Endif
End function
3.2 Database structure for keeping the tariffs for vehicle types and different packages
and Console Applications.
M.A.M.AFRI 58
Packages Design
Figure 3.2.1
M.A.M.AFRI 59
Pacckages Data
Figure 3.2.2
M.A.M.AFRI 60
The Database structure for Vehicles is displayed below,
Vehicle Design
Figure 3.2.3
M.A.M.AFRI 61
Vehicle Data
Figure 3.2.3
M.A.M.AFRI 62
Console Application
Figure 3.2.4
M.A.M.AFRI 63
Rent Calculation
Figure 3.2.5
Figure 3.2.6
M.A.M.AFRI 64
Day Tour
Figure 3.2.7
Figure 3.2.8
M.A.M.AFRI 65
Figure 3.2.9
Figu
re 3.2.10
M.A.M.AFRI 66
Long Tour
Figure 3.2.11
Figure 3.2.12
M.A.M.AFRI 67
Figure 3.2.13
M.A.M.AFRI 68
3.3 Integrated Development Environment (IDE)
An integrated development environment (IDE) is a software suite that combines basic tools
necessary to write and test software. IDEs provide interfaces for users to write code,
organize text groups, and automate programming redundancies. IDE Common Features
are,
Text editor
Virtually every IDE will have a text editor designed to write and manipulate source
code. Some tools may have visual components to drag and drop front-end components, but
most have a simple interface with language specific syntax highlighting.
Debugger
Debugging tools support users in identifying and resolving errors within source code.
They often simulate real world scenarios to test functionality and performance.
Programmers and software engineers can usually test the various sections of code and
Identify errors before the application is released.
Compiler
Compilers are components that translate programming language into a form that
Machines can process, such as binary code. The machine code is analyzed to confirm
Its accuracy. The compiler then parses and optimizes the code to optimize performance.
M.A.M.AFRI 69
Code completion
Code complete features assist programmers by intelligently identifying and inserting
Common code components. These features save developers time writing code and
Reduce the possibilities of errors and bugs.
M.A.M.AFRI 70
Activity 04
Database record for customer billing and management reporting for Ayubo.
Login Interface
Figure 4.1.1
M.A.M.AFRI 71
Main Menu Interface
Figure 4.1.2
M.A.M.AFRI 72
Package details interface
Figure 4.1.3
M.A.M.AFRI 73
Vehicle Details Interface
Figure 4.1.4
Figure
4.1.5
M.A.M.AFRI 74
Day Tour Interface
Figure 4.1.5
Figure 4.1.6
M.A.M.AFRI 75
Backend Code for Rent Calculation
Figure 4.1.7
Figure 4.1.8
M.A.M.AFRI 76
4.2 What is debugging an application?
Debugging is the process of identifying and eliminating of existing and potential errors (Also
called as ‘bugs’) in a software code that can cause it to behave unexpectedly or crash. To
prevent incorrect operation of a software or system, debugging is used to find and resolve
bugs or defects. When various subsystems or components are firmly coupled, debugging
becomes harder as any change in one component may cause more Bugs to appear in another.
Sometimes it takes more time to debug a program than to Code it.
When running the app in Visual Studio for the first time, we may start it by pressing the
Green arrow button Start Debugging in the toolbar (or F5). By default, the Debug value
Appears in the drop down to the left. If you are new to Visual Studio, this can leave the
impression that the debugging the app has something to do with running the app, which it
does, but three are two very different tasks.
Select a debug build
Figure 4.2.1
M.A.M.AFRI 77
A Debug value indicates a debug configuration. When we start the app (press the green arrow
or F5) in a debug configuration, we start the app in debug mode, which means we are running
the app with a debugger attached. This enables a full set of debugging features that can be
used to help find bugs in the app. If we have a project open, choose the drop-down
selector where it says Debug and choose Release instead. Select a Release build.
Figure 4.2.2
When we switch this setting, we change our project from a debug configuration to a
release configuration. Visual Studio projects have separate release and debug
configurations for our program. We build the debug version for debugging and the
release version for the final release distribution. A release build is optimized for
performance, but a debug build is better for debugging.
Fix an exception
When I have fixed all the red squiggles and resolved or at least investigated all the green
squiggles, I am ready to start the debugger and run the app. Press F5 (Debug > Start
Debugging) or the Start Debugging button Start Debugging in the Debug toolbar. At this
point, the sample app throws a Serialization Exception (a runtime error). That is, the app
blocks on the data that it is trying to serialize. Because I started the app in debug mode
(debugger attached), the debugger's Exception Helper takes you right to the code that threw
the exception and gives a helpful error message.
M.A.M.AFRI 78
Figure 4.2.3
Break points
I set breakpoints wherever you want to pause debugger execution. I can break execution
when a function is called. When i debug, execution pauses at the breakpoint, before the Code
on that line is executed. This is useful, for example, when you know the function Name but
not its location. It is also useful if you have functions with the same name and you want to
break on them all (such as overloaded functions or functions in different projects).
M.A.M.AFRI 79
Figure 4.2.4
M.A.M.AFRI 80
4.3 Coding standards
They are a series of measures that can be defined for a particular programming language
Specifying a programming style, the methods, & different procedures. These procedures Can
be for various characteristics of the program written in that language. They can be considered
as essential attributes of software development.a coding standard makes sure that all the
developers working on the project are following certain specified guidelines. The code
can be easily understood and proper consistency is maintained. Consistency has a positive
impact on the quality of the program and one should maintain it while coding. Also, it
should be taken care that the guidelines are consistently followed across different levels
of the system and they do not oppose each other. The finished program code should look like
that it has been written by a single developer, in a single session.
It is a good practice to comment while writing code. It helps other developers to understand
your code. With the use of the Integrated Development Environment and other tools,
commenting can be utilized in many different ways. It is advisable to start every method or
routine with the comment specifying what a routine, method or a function does, about
its various parameters, its return values, errors and exceptions (if any). In addition, the role of
each file and class, their contents and even the steps of complex Codes should be summarized
in the comments.
Figure 4.2.5
M.A.M.AFRI 81
Use of Indentation
It is advisable to make use of indentation while writing the code. There is no particular style
defined, but any style can be chosen for writing code. However, a consistent
indentation style should be followed throughout the code. For Instance,
F
igure 4.2.6
Using Variables
Variables are the names I gave to computer memory locations, which are used to store values
in a computer program. In most or all software programming languages, variables work
like containers to hold numbers, phrases, or other important stuff used in numerous places in
my code.
M.A.M.AFRI 82
Figure 4.2.7
Why a coding standard is necessary for the team as well as for the individual. Coding
standards are a set of guidelines, best practices, programming styles and Conventions
that developers follow to when writing source code for a project. All big software companies
have them. A coding standards document tells developers how they must write their code.
Instead of each developer coding in their own preferred style, they will write all code to the
standards outlined in the document. This makes sure that a large project is coded in a reliable
style parts are not written differently by different programmers. Not only does this solution
make the code easier to understand, it also ensures that any developer who looks at the code
will know what to expect throughout the entire application.
Working Independently. In this case, programmer has to follow those coding standards
because the programmer needs to state an efficient well working computer application.
Because of that the inner logic of the program should be clearly stated, that means the code.
If the programmer works according to the coding standards, the code will be not only simpler
but also will be efficient too. When proper coding standards are used, there will be no
errors in the specific program. In that case, the testing stage will be easier. Because of that
the deployment process of the program will be efficient so the programmer can develop the
program within the given time period.
M.A.M.AFRI 83
When you start sharing code or start reading code shared by others, you begin to realize that
not everybody writes their code they way you do. You see that other, ugly coding style, and
think, “Everybody needs to write in the same style that I do so that things are easier to
understand.” Therefore, it is natural that everybody wants their own ways turned into the
standard, so they do not have to change their habits. If the entire team work according to a
specific coding standard, the combining process will be easier and the wastage of the time
will be decreased because of that. So if the programmers use same standards it will make
things much easier for the team. Likewise, the coding standards is not only important in
working as a team but also it benefits in working as individual as well.
M.A.M.AFRI 84
References
Available at:
https://medium.com/@bhattshlok12/characteristics-of-an-algorithm-49cf4d7bcd9
Accessed by (2022/01/23)
Available at:
http://neonbrand.com/procedural-programming-vs-object-oriented-programming-areview/
Accessed by (2022/01/23)
Available at:
https://www.edrawsoft.com/flowchart/program-flowchart-definition.html
Accessed by (2022/01/23)
Available at:
http://www.cs.cornell.edu/courses/cs482/2003su/handouts/pseudocode.pdfJacobson,
Accessed by (2022/01/23)
Available at:
https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide-29956242698
Accessed by (2022/01/23)
Available at:
https://medium.com/karuna-sehgal/a-simplified-explanation-of-the-big-o-notation-
82523585e835
Accessed by (2022/01/23)
Available at:
https://towardsdatascience.com/demystifying-binary-search-bed0274e27e7
Accessed by (2022/01/23)
M.A.M.AFRI 85
Available at:
https://searchsoftwarequality.techtarget.com/definition/integrated-developmentenvironment
Accessed by (2022/01/23)
M.A.M.AFRI 86
Acknowledgment
In preparation of my assignment, I had to take the help and guidance of some respected
persons, who deserve my deepest gratitude. As the completion of this assignment gave me
much pleasure, I would like to show my gratitude Mr.Safran, Course Instructor. Whatever I
have done is only due to such guidance and assistance and I would not forget to thank him. I
respect and thank all my colleagues at the ESOFT METRO CAMPUS, for providing me all
support and guidance, which made me complete the assignment on time. I am extremely
grateful to be a part of this amazing team. Thanking you.
M.A.M.AFRI
M.A.M.AFRI 87
M.A.M.AFRI 88
M.A.M.AFRI 89